Laurent Sansonetti
2009-Aug-31 23:37 UTC
[LLVMdev] problems with the 2.6 branch under x86_64
Hi all, I am currently porting my project to branches/release_26 and I noticed the JIT doesn't seem to work anymore when used in 64-bit. Every the very simple HowToUseJIT example crashes at runtime. $ gdb --arg ./Release/examples/HowToUseJIT GNU gdb 6.3.50-20050815 (Apple version gdb-1339) (Sat May 23 05:39:07 UTC 2009) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .... done (gdb) r Starting program: /Users/lrz/src/llvm-26/Release/examples/HowToUseJIT Reading symbols for shared libraries +++. done We just constructed this LLVM module: ; ModuleID = 'test' define i32 @add1(i32 %AnArg) { EntryBlock: %addresult = add i32 1, %AnArg ; <i32> [#uses=1] ret i32 %addresult } define i32 @foo() { EntryBlock: %add1 = tail call i32 @add1(i32 10) ; <i32> [#uses=1] ret i32 %add1 } Running foo: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x000000005fbff4bc 0x0000000100c00013 in ?? () (gdb) bt #0 0x0000000100c00013 in ?? () #1 0x000000010000d8b5 in main () It seems that we crashed inside the JIT'ed code. This sample program works fine if I force it to run in 32-bit (using arch -i386 ...). I investigated a little bit to see if the generated code was really targeting x86_64 and not i386, but it seems to be the case (though I may be mistaken). I suspect the problem might be related to the way I build LLVM. I am on Mac OS X and need a 2-way fat Intel Universal binary, so I build it like the following: $ ./configure $ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make $ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install Any help will be greatly appreciated :) Laurent