[LLVMbugs] [Bug 11468] Clang incorrectly handles exceptions in presence of stack aligned variables
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Dec 2 13:14:08 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=11468
Alexey Samsonov <samsonov at google.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
--- Comment #4 from Alexey Samsonov <samsonov at google.com> 2011-12-02 15:14:08 CST ---
Ouch, sorry for that. I tried to make another reproducer, please take a look:
$ cat exception_test.cc
#include <stdio.h>
__attribute__((noinline))
void TouchR15AndThrow(const char& arg) {
volatile int n __attribute__((aligned(32))) = 0;
asm volatile ("nop" : : : "%r15"); // force to save r15 on stack
throw arg;
}
int main() {
// Set r15 value
int a = 42;
asm ("movq %0, %%r15;\n\t" : : "g"(a) : "%r15");
// Output value of r15
int b;
asm ("movq %%r15, %0;\n\t" : "=g" (b) : : "%r15");
fprintf(stderr, "before = %d\n", b);
try {
TouchR15AndThrow('c');
} catch (const char&) { }
// Output value of r15 again
asm ("movq %%r15, %0;\n\t" : "=g" (b) : : "%r15");
fprintf(stderr, "after = %d\n", b);
return 0;
}
$ ../build/Release+Asserts/bin/clang++ -O2 exception_test.cc
$ ./a.out
before = 42
after = 0
there is no instruction that changes value in %r15, but it is incorrectly
restored after exception is caught.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list