https://bugs.llvm.org/show_bug.cgi?id=40681
Bug ID: 40681
Summary: [X86] LLVM 7.0.x optimises out variable init at -O1
Product: libraries
Version: 7.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedb...@nondot.org
Reporter: vit9...@avp.su
CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
llvm-...@redking.me.uk, spatel+l...@rotateright.com
Created attachment 21463
--> https://bugs.llvm.org/attachment.cgi?id=21463&action=edit
Test C file
LLVM 7.0 generates invalid code optimises out variable zeroing for 32-bit X86
at -O1 or higher when sanitizers are enabled. I was able to reproduce the issue
with AddressSanitizer or UndefinedBehaviorSanitizer enabled, yet I believe they
are just the trigger point. The IR looks fine, so most likely the issue lies in
LLVM itself.
The bug is not reproducible on LLVM 8.0 or trunk. If LLVM 7.1 release is
abandoned, it should be closed, otherwise I believe it is to be release
blocker.
Test example is provided in the attachment. Both C file and generated .S file.
clang -S -c -target i386-gnu-linux -march=pentium2 -pipe -nostdinc
-fno-asynchronous-unwind-tables -O1 -fno-builtin -I. -fno-omit-frame-pointer
-m32 -fno-stack-protector -fsanitize=address -c d.c -o d.S
Relevant comments for generated asm:
pushl %esi
...
# implicit-def: $esi ; allocates r temporary in %esi, which is filled with
random data
...
movl %esi, -16(%ebp)
...
calll func1
testl %eax, %eax
movl -16(%ebp), %ecx ; writes random data to %ecx
cmovsl %eax, %ecx ; if (%eax < 0) %ecx = %eax
movl %ecx, -16(%ebp) ; %ecx is returned back to stack
...
jns .LBB0_11 → if (%eax < 0) goto 11
jmp .LBB0_19
...
.LBB0_19:
...
movl -16(%ebp), %eax ; function returns random data when func1 returns >= 0
...
ret
--
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