[llvm-bugs] [Bug 26023] New: LLVM -0z push/pop optimization clobbers the red zone
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jan 4 18:22:07 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26023
Bug ID: 26023
Summary: LLVM -0z push/pop optimization clobbers the red zone
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: david.majnemer at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
consider:
$ cat t.c
#include <stdio.h>
int f() {
volatile char x[120] __attribute__((aligned(1)));
asm volatile("" : : "g"(x) : "memory");
x[119] = -2;
asm volatile("" : : "r"(-1));
return x[119];
}
int main() {
int x = f();
printf("%d\n", x);
}
compile with:
$ ~/llvm/Debug+Asserts/bin/clang -Oz t.c -o t
run it:
$ ./t
-1
the correct result is -2 but we push/pop'd -1 on to the stack, clobbering the
end of 'x' which exists on the red zone.
Reverting r255656, the commit which introduced the optimization, fixes this.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160105/b89a0e85/attachment.html>
More information about the llvm-bugs
mailing list