https://llvm.org/bugs/show_bug.cgi?id=26477
Bug ID: 26477 Summary: interrupt handler calls functions with misaligned stack Product: new-bugs Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: new bugs Assignee: unassignedb...@nondot.org Reporter: hjl.to...@gmail.com CC: amjad.ab...@intel.com, david.l.kreit...@intel.com, kevin.b.sm...@intel.com, llvm-bugs@lists.llvm.org Classification: Unclassified Incoming stack of x86 interrupt handler is aligned at 4 bytes (8 bytes for 64-bit). When it calls extern functions, it needs to realign the stack to 16-byte aligned if it is required: [hjl@gnu-6 interrupt-1]$ cat xx.i extern void bar (void); extern int i; void __attribute__ ((interrupt)) foo (void *frame) { bar (); i = 0; } [hjl@gnu-6 interrupt-1]$ /export/build/gnu/gcc-5/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-5/build-x86_64-linux/gcc/ -O2 xx.i -m32 -mno-sse -S [hjl@gnu-6 interrupt-1]$ cat xx.s .file "xx.i" .section .text.unlikely,"ax",@progbits .LCOLDB0: .text .LHOTB0: .p2align 4,,15 .globl foo .type foo, @function foo: .LFB0: .cfi_startproc pushl %ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 movl %esp, %ebp .cfi_def_cfa_register 5 pushl %ecx pushl %edx pushl %eax andl $-16, %esp <<<<<<<<<<<< Align stack cld .cfi_offset 1, -12 .cfi_offset 2, -16 .cfi_offset 0, -20 call bar movl $0, i leal -12(%ebp), %esp popl %eax .cfi_restore 0 popl %edx .cfi_restore 2 popl %ecx .cfi_restore 1 popl %ebp .cfi_restore 5 .cfi_def_cfa 4, 4 iret .cfi_endproc .LFE0: .size foo, .-foo .section .text.unlikely .LCOLDE0: .text .LHOTE0: .ident "GCC: (GNU) 5.3.1 20160201" .section .note.GNU-stack,"",@progbits [hjl@gnu-6 interrupt-1]$ But clang doesn't align stack: [hjl@gnu-6 interrupt-1]$ /net/gnu-mic-2//export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang -O2 xx.i -m32 -mno-sse -S [hjl@gnu-6 interrupt-1]$ cat xx.s .text .file "xx.i" .globl foo .p2align 4, 0x90 .type foo,@function foo: # @foo # BB#0: pushl %esp pushl %edx pushl %ecx pushl %eax subl $12, %esp calll bar movl $0, i addl $12, %esp popl %eax popl %ecx popl %edx popl %esp iretl .Lfunc_end0: .size foo, .Lfunc_end0-foo .ident "clang version 3.9.0 (http://llvm.org/git/clang.git bf1d31e84aa2722174da56b8aff311ae04f4d9e1) (http://llvm.org/git/llvm.git 6cced9c3cd18f529420a03b100970d97512bb9a4)" .section ".note.GNU-stack","",@progbits [hjl@gnu-6 interrupt-1]$ -- 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