diff options
author | Chris Lattner <sabre@nondot.org> | 2006-08-16 01:24:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-08-16 01:24:12 +0000 |
commit | 0621caef44e97026fb42a03be1d259c9041eee01 (patch) | |
tree | 32112126e647e629a953d5308ec761d69dc56e6b /llvm/lib/ExecutionEngine/JIT | |
parent | 9ed9ddeae41cb88d46d1030c2a7a5b644d4d0a5f (diff) | |
download | bcm5719-llvm-0621caef44e97026fb42a03be1d259c9041eee01.tar.gz bcm5719-llvm-0621caef44e97026fb42a03be1d259c9041eee01.zip |
initial changes to support JIT'ing from multiple module providers, implicitly
linking the program on the fly.
llvm-svn: 29721
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT')
-rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JIT.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp | 3 |
2 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp index f241240af94..3995141eade 100644 --- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp @@ -263,8 +263,19 @@ void *JIT::getPointerToFunction(Function *F) { if (void *Addr = getPointerToGlobalIfAvailable(F)) return Addr; // Check if function already code gen'd - // Make sure we read in the function if it exists in this Module + // Make sure we read in the function if it exists in this Module. if (F->hasNotBeenReadFromBytecode()) { + // Determine the module provider this function is provided by. + Module *M = F->getParent(); + ModuleProvider *MP = 0; + for (unsigned i = 0, e = Modules.size(); i != e; ++i) { + if (Modules[i]->getModule() == M) { + MP = Modules[i]; + break; + } + } + assert(MP && "Function isn't in a module we know about!"); + std::string ErrorMsg; if (MP->materializeFunction(F, &ErrorMsg)) { std::cerr << "Error reading function '" << F->getName() diff --git a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp index dc9ba28371e..e266c7555ae 100644 --- a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -972,8 +972,7 @@ MachineCodeEmitter *JIT::createEmitter(JIT &jit) { // resolve their addresses at runtime, and this is the way to do it. extern "C" { void *getPointerToNamedFunction(const char *Name) { - Module &M = TheJIT->getModule(); - if (Function *F = M.getNamedFunction(Name)) + if (Function *F = TheJIT->FindFunctionNamed(Name)) return TheJIT->getPointerToFunction(F); return TheJIT->getPointerToNamedFunction(Name); } |