summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/JIT
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT')
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JIT.cpp13
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp3
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);
}
OpenPOWER on IntegriCloud