Closed
Description
This is another discovery in my work on #58475 / rust-lang/rfcs#2635 -- trying to see if it's practical to enable overflow checks by default in release builds.
This fails with:
stderr:
------------------------------------------
/home/alex/p/rust/src/test/codegen/repeat-trusted-len.rs:11:11: error: CHECK: expected string not found in input
// CHECK: call void @llvm.memset.p0i8.i{{[0-9]+}}(i8* {{(nonnull )?}}align 1{{.*}} %{{[0-9]+}}, i8 42, i{{[0-9]+}} 100000, i1 false)
^
/home/alex/p/rust/build/x86_64-unknown-linux-gnu/test/codegen/repeat-trusted-len/repeat-trusted-len.ll:51:33: note: scanning from here
define void @repeat_take_collect(%"alloc::vec::Vec<u8>"* noalias nocapture sret dereferenceable(24) %0) unnamed_addr #2 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality {
The issue seems to be that the LLVM loop-idiom recognizer runs before the optimizations that remove the overflow checks, therefor you get a loop in assembly, instead of a call to memset. I've filed a bug against LLVM with this: https://bugs.llvm.org/show_bug.cgi?id=46057 , but I'm also filing a bug here so there's a way to track the rust side impact of it