Simon Burton <simon at arrowtheory.com> writes:>> There are several possibilities here: either add1 is assigned a NULL >> pointer, or LLVM was unable to use the JIT and generates bytecode >> instead of native code, or invalid native code was generated >> (unlikely). > > Well, it's not NULL: > > (gdb) print add1 > $1 = (int (*)(int)) 0x83e43b8 > (gdb) print ((char*)add1) > $2 = 0x83e43b8 "h\2245\b\002"Dissamsembling that address would reveal if llvm really created binary code for your function.>> >> What happens when you execute your function the same way the Fibonacci >> example does? (See examples/Fibonacci/fibonacci.cpp line 112). > > That works OK.This indicates that the JIT is not working and your code is being interpreted. I don't know about "llvm-config --libs jit" you are using but I would try adding LLVMJIT.o to your link command the same way you do with LLVMInterpreter.o Oh, and renaming your llvmjit.cpp to something else, just in case. (Is the linker case-sensitive?) -- Oscar
On Fri, 14 Apr 2006 03:25:39 +0200 Oscar Fuentes <oscarfv at telefonica.net> wrote: ...> Simon, > > With a fresh CVS checkout, I've tried your test case on Windows/VC++ > and it works ok. Too bad that I have not access to a Linux machine > right now. I'll like to see what's wrong with your test case. > > What you get from running the test case under gdb and inspecting the > value of add1 just before the function invocation? > > There are several possibilities here: either add1 is assigned a NULL > pointer, or LLVM was unable to use the JIT and generates bytecode > instead of native code, or invalid native code was generated > (unlikely).Well, it's not NULL: (gdb) print add1 $1 = (int (*)(int)) 0x83e43b8 (gdb) print ((char*)add1) $2 = 0x83e43b8 "h\2245\b\002"> > What happens when you execute your function the same way the Fibonacci > example does? (See examples/Fibonacci/fibonacci.cpp line 112).That works OK. Simon. -- Simon Burton, B.Sc. Licensed PO Box 8066 ANU Canberra 2601 Australia Ph. 61 02 6249 6940 http://arrowtheory.com
On Fri, 14 Apr 2006 04:05:10 +0200 Oscar Fuentes <oscarfv at telefonica.net> wrote:> > This indicates that the JIT is not working and your code is being > interpreted. I don't know about "llvm-config --libs jit" you are using > but I would try adding LLVMJIT.o to your link command the same way you > do with LLVMInterpreter.oActually if I _remove_ those other library link arguments and just left the ones provided by "llvm-config --libs" it works fine (yay!). Except it's a huge executable: 168Mb. And the linker warns about some symbols: /usr/bin/ld: `.gnu.linkonce.t._ZNK4llvm14TargetLowering12getValueTypeEPKNS_4TypeE' referenced in section `.rodata' of /home//users//simonb//lib/LLVMPowerPC.o: defined in discarded section `.gnu.linkonce.t._ZNK4llvm14TargetLowering12getValueTypeEPKNS_4TypeE' of /home//users//simonb//lib/LLVMPowerPC.o etc. If instead I use "llvm config --libs jit asmparser" it compiles but segfaults in the usual place. Here are the libs it uses in this case: $ llvm-config --libnames jit asmparser LLVMAsmParser.o LLVMJIT.o LLVMExecutionEngine.o LLVMCodeGen.o LLVMSelectionDAG.o libLLVMAnalysis.a libLLVMTarget.a libLLVMTransformUtils.a libLLVMipa.a libLLVMAnalysis.a libLLVMTarget.a libLLVMTransformUtils.a libLLVMipa.a LLVMCore.o libLLVMSupport.a libLLVMSystem.a LLVMbzip2.o Somewhat better is when I use "--libs engine asmparser". It works, and generates an exe around 77Mb. And no complaints when linking. thanks for your help Oscar. Simon. -- Simon Burton, B.Sc. Licensed PO Box 8066 ANU Canberra 2601 Australia Ph. 61 02 6249 6940 http://arrowtheory.com