Issue 133059
Summary [InstCombine][FuncAttrs] InstCombine breaks `initializes` attribute
Labels miscompilation, llvm:instcombine, miscompilation:undef, generated by fuzzer
Assignees
Reporter dtcxzyw
    Reproducer: https://alive2.llvm.org/ce/z/rx6rJk
```
; bin/opt -passes=instcombine test.ll -S

define fastcc void @src(ptr initializes((0, 48)) %0) {
  %2 = alloca [24 x i8], align 8
  store i8 0, ptr %0, align 16
  %3 = getelementptr i8, ptr %0, i64 1
  store i8 0, ptr %3, align 1
  %4 = getelementptr i8, ptr %0, i64 2
  store i16 0, ptr %4, align 2
  %5 = getelementptr i8, ptr %0, i64 4
  store i32 0, ptr %5, align 4
  %6 = getelementptr i8, ptr %0, i64 8
  store i16 0, ptr %6, align 8
  %7 = getelementptr i8, ptr %0, i64 10
  store i16 0, ptr %7, align 2
  %8 = getelementptr i8, ptr %0, i64 12
  store i32 0, ptr %8, align 4
  %9 = getelementptr i8, ptr %0, i64 16
  store double 0.000000e+00, ptr %9, align 16
  %10 = getelementptr i8, ptr %0, i64 24
  call void @llvm.memcpy.p0.p0.i64(ptr %10, ptr %2, i64 24, i1 false)
  ret void
}
```
After InstCombine, the last memcpy is dropped as the source buffer is uninitialized (filled with undef (in llvm)/poison (in alive2)).

Should we adjust `initializes` to only account for writing with well-defined values?
Generated with rustlantis + llubi.
Original rust mir program: https://gist.github.com/dtcxzyw/78250ce921833ea20c5cb040d29f1a3f

cc @haopliu @nikic
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to