[LLVMdev] Strange LLVM Crash
Nyx
mcheva at cs.mcgill.ca
Fri Mar 13 20:09:51 PDT 2009
I'm implementing a JIT and getting some strange crashes. I'm unsure exactly
what's causing them, but it seems to occur when I call the getReturnType()
method on some LLVM function objects. More precisely, I'm registering some
native C++ functions as LLVM functions through the addGlobalMapping method
of an execution engine object. I then keep a pointer to those LLVM function
objects, which I use later on to create call instructions to those native
C++ functions.
// Create a function type object for the function
llvm::FunctionType* pFuncType = llvm::FunctionType::get(returnType,
argTypes, false);
// Create a function object with external linkage and the specified
function type
llvm::Function* pFuncObj = llvm::Function::Create(
pFuncType,
llvm::Function::ExternalLinkage,
name,
s_pModule
);
// Add a global mapping in the execution engine for the function pointer
s_pExecEngine->addGlobalMapping(pFuncObj, pFuncPtr);
The crash does not occur the first time I JIT compile a function, but the
second or third time I compile some other function, I will get a crash when
trying to create a call instruction. If I try to call the getReturnType()
method on the function object before creating the call, I also get a crash.
All of my functions are getting put into the same LLVM module, so I'm
wondering if LLVM somehow invalidates my function object pointers when I JIT
functions, perhaps when I run optimization passes on my LLVM module? Should
I not keep pointers to those function objects?
Any hints will be appreciated.
--
View this message in context: http://www.nabble.com/Strange-LLVM-Crash-tp22508882p22508882.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
More information about the llvm-dev
mailing list