Yuri
2011-Feb-21 05:16 UTC
[LLVMdev] How to force stack alignment for particular target triple in JIT?
I get SEGV in gcc-compiled procedure in Solaris10-i386. This procedure is called from llvm JIT code. Exact instruction that crashes is this: movdqa %xmm0, 0x10(%esp) %esp is 8-aligned, and by definition of movdqa it expects 16-aligned stack. This leads me to believe that llvm uses wrong ABI when calling external procedures and doesn't align stack properly. llvm module executing in JIT has this target triple: i386-pc-solaris2.10 Isn't target triple supposed to set correct ABI including stack alignment? How to set the correct alignment for this triple? Yuri
Duncan Sands
2011-Feb-21 07:50 UTC
[LLVMdev] How to force stack alignment for particular target triple in JIT?
Hi Yuri,> I get SEGV in gcc-compiled procedure in Solaris10-i386. This procedure > is called from llvm JIT code. > Exact instruction that crashes is this: movdqa %xmm0, 0x10(%esp) > %esp is 8-aligned, and by definition of movdqa it expects 16-aligned stack. > This leads me to believe that llvm uses wrong ABI when calling external > procedures and doesn't align stack properly. > > llvm module executing in JIT has this target triple: i386-pc-solaris2.10 > > Isn't target triple supposed to set correct ABI including stack > alignment? How to set the correct alignment for this triple?it is, however as far as I can see nowhere in LLVM makes any important decisions based on the triple containing "solaris". I suggest you try to work out how the stack alignment is set for other operating systems and send in a patch fixing the solaris case. Ciao, Duncan.
Yuri
2011-Feb-21 09:32 UTC
[LLVMdev] How to force stack alignment for particular target triple in JIT?
On 02/20/2011 23:50, Duncan Sands wrote:> Hi Yuri, > > >> I get SEGV in gcc-compiled procedure in Solaris10-i386. This procedure >> is called from llvm JIT code. >> Exact instruction that crashes is this: movdqa %xmm0, 0x10(%esp) >> %esp is 8-aligned, and by definition of movdqa it expects 16-aligned stack. >> This leads me to believe that llvm uses wrong ABI when calling external >> procedures and doesn't align stack properly. >> >> llvm module executing in JIT has this target triple: i386-pc-solaris2.10 >> >> Isn't target triple supposed to set correct ABI including stack >> alignment? How to set the correct alignment for this triple? >> > it is, however as far as I can see nowhere in LLVM makes any important > decisions based on the triple containing "solaris". I suggest you try > to work out how the stack alignment is set for other operating systems > and send in a patch fixing the solaris case. > > Ciao, DuncanThe attached patch fixes the problem for me. Though further changes will likely be needed for full Solaris ABI compatibility. Yuri -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch.txt URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110221/ef99d6c5/attachment.txt>
Joerg Sonnenberger
2011-Feb-21 13:25 UTC
[LLVMdev] How to force stack alignment for particular target triple in JIT?
On Sun, Feb 20, 2011 at 09:16:56PM -0800, Yuri wrote:> Isn't target triple supposed to set correct ABI including stack > alignment? How to set the correct alignment for this triple?OSX uses 16 Byte. Linux silently changed the SYSV ABI to 16 Byte alignment as well. The most likely candidate is that all other ELF platforms simply inherited this change. Joerg
Yuri
2011-Feb-22 00:03 UTC
[LLVMdev] How to force stack alignment for particular target triple in JIT?
On 02/21/2011 05:25, Joerg Sonnenberger wrote:> OSX uses 16 Byte. Linux silently changed the SYSV ABI to 16 Byte > alignment as well. The most likely candidate is that all other ELF > platforms simply inherited this change. >It turns out that Solaris (and FreeBSD) is supposed to be SYSV compliant and should have word stack alignment. gcc probably made a sweeping change once linux decided to change stack alignment. I filed gcc PR asking gcc to revert their behavior back to prescribed by documentation: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47842 So my previous patch is more for gcc compatibility, rather than a permanent correction. Yuri
Apparently Analagous Threads
- [LLVMdev] How to force stack alignment for particular target triple in JIT?
- [LLVMdev] How to force stack alignment for particular target triple in JIT?
- [LLVMdev] How to force stack alignment for particular target triple in JIT?
- [LLVMdev] llvm-gcc (pre-release and svn sources) fails to compile on Solaris10/SPARC
- [PATCH] fix alignment exceptions