I have build LLVM in debug mode. Here are the informations of the segfault :
memcpy() at 0x7ffff6f6581e
LoadIntFromMemory() at ExecutionEngine.cpp:887 0xb3c297
llvm::ExecutionEngine::LoadValueFromMemory() at ExecutionEngine.cpp:915 0xb3c3f9
llvm::Interpreter::visitLoadInst() at Execution.cpp:812 0xa1f855
llvm::InstVisitor<llvm::Interpreter, void>::visitLoad() at 0xa28357
llvm::InstVisitor<llvm::Interpreter, void>::visit() at 0xa26b4e
llvm::Interpreter::run() at Execution.cpp:1,328 0xa235ff
llvm::Interpreter::runFunction() at Interpreter.cpp:95 0xa166fa
…
So the segfaults happens because of the memcpy call in the LoadIntFromMemory function in ExecutionEngine.cpp on line 887… Any clue ?
Adding .setOptLevel(llvm::CodeGenOpt::None) to the EngineBuilder creation reduces the time by 25% but that is still not enough 
2010/11/3 Török Edwin <edwintorok@gmail.com>
Hi,
I have build LLVM in debug mode. Here are the informations of the
segfault : memcpy() at 0x7ffff6f6581e
LoadIntFromMemory() at ExecutionEngine.cpp:887 0xb3c297
llvm::ExecutionEngine::LoadValueFromMemory() at ExecutionEngine.cpp:915
0xb3c3f9
llvm::Interpreter::visitLoadInst() at Execution.cpp:812 0xa1f855
llvm::InstVisitor<llvm::Interpreter, void>::visitLoad() at 0xa28357
llvm::InstVisitor<llvm::Interpreter, void>::visit() at 0xa26b4e
llvm::Interpreter::run() at Execution.cpp:1,328 0xa235ff
llvm::Interpreter::runFunction() at Interpreter.cpp:95 0xa166fa
....
So the segfaults happens because of the memcpy call in the
LoadIntFromMemory function in ExecutionEngine.cpp on line 887... Any
clue ?
usually this kind of thing means that your bitcode is doing something bad, such
as writing to random memory locations, and you just happened to get away with
it when using the JIT. Try running under valgrind (either the interpreter or,
if you can, make a real program out of your bitcode and run that under valgrind).
Ciao,
Duncan.
Hi Salomon, please don't forget to reply to the list too (I've CC'd the list).
I don't think my code is doing anything worng...
No, it looks fine to me, and the interpreter certainly supports this. That
suggests that the value of %str is not being transmitted to the function right.
If it is getting the wrong pointer value, that would explain why it barfs.
Ciao,
Duncan.
Thank you.
Anyway, I have written my own interpreter.
It took me 20 minutes when I passed all the day searching for making the LLVM interpreter working…