https://llvm.org/bugs/show_bug.cgi?id=27183
Bug ID: 27183 Summary: __attribute__((force_align_arg_pointer)) with __asm__ causes segfault Product: clang Version: 3.8 Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: LLVM Codegen Assignee: unassignedclangb...@nondot.org Reporter: cjhop...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 16149 --> https://llvm.org/bugs/attachment.cgi?id=16149&action=edit Repro code. This code: __attribute__((noinline)) int use_sa(int* sa) { return *sa; } __attribute__((force_align_arg_pointer)) int doit() { int sa; long res; __asm__ __volatile__( "nop" : "=a" (res) : "S" (sizeof(sa)) : "esp"); sa = 1; return use_sa(&sa); } int main() { return doit(); } compiled with 'clang++ -m32 -O3' generates incorrect code that will segfault. The offending machine code looks something like: 00000010 <doit()>: 10: 55 push %ebp 11: 89 e5 mov %esp,%ebp 13: 56 push %esi 14: 83 e4 f0 and $0xfffffff0,%esp 17: 83 ec 20 sub $0x20,%esp 1a: 89 e6 mov %esp,%esi 1c: be 04 00 00 00 mov $0x4,%esi 21: 90 nop 22: c7 46 10 01 00 00 00 movl $0x1,0x10(%esi) 29: 8d 46 10 lea 0x10(%esi),%eax 2c: 89 04 24 mov %eax,(%esp) 2f: e8 cc ff ff ff call 0 <use_sa(int*)> 34: 8d 65 fc lea -0x4(%ebp),%esp 37: 5e pop %esi 38: 5d pop %ebp 39: c3 ret 3a: 66 0f 1f 44 00 00 nopw 0x0(%eax,%eax,1) Note the write to %esi @ 1c and then the dereference @ 29. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs