https://bugs.llvm.org/show_bug.cgi?id=49208

            Bug ID: 49208
           Summary: Wrong optimization around memset
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: bogdan.gur...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

Created attachment 24539
  --> https://bugs.llvm.org/attachment.cgi?id=24539&action=edit
The input llvm code

The attached example should be run with the O2 optimization level. The 'memset'
memory pointer argument is replaced by the 'undef' which causes unexpected
behavior at runtime. I don't see any reason to replace it with 'undef' since
there are writers and external function calls that are related to this memory
pointer.

Command line:
"C:\Program Files\LLVM\bin\clang.exe" -S -emit-llvm d:\work\test.bc -o
d:\work\test_out.bc -O2

I compared the input and output and the only replacement is:

from:
```
  %15 = load i8*, i8** %4, align 8, !tbaa !6
  %16 = shl nsw i64 %14, 1
  call void @llvm.memset.p0i8.i64(i8* align 2 %15, i8 0, i64 %16, i1 false) #0
```

to:
```
  %15 = shl nsw i64 %14, 1
  call void @llvm.memset.p0i8.i64(i8* align 2 undef, i8 0, i64 %15, i1 false)
#0
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to