[PATCH] [ExecutionEngine] FindFunctionNamed: Skip declarations
Phabricator
reviews at reviews.llvm.org
Tue Jan 27 11:30:56 PST 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7068
Files:
llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
Index: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
===================================================================
--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
@@ -392,4 +392,23 @@
ptr = TheJIT->getFunctionAddress(FB2->getName().str());
checkAccumulate(ptr);
}
+
+// Test that FindFunctionNamed finds the definition of
+// a function in the correct module. We check two functions
+// in two different modules, to make sure that for at least
+// one of them MCJIT had to ignore the extern declaration.
+TEST_F(MCJITMultipleModuleTest, FindFunctionNamed_test) {
+ SKIP_UNSUPPORTED_PLATFORM;
+
+ std::unique_ptr<Module> A, B;
+ Function *FA, *FB1, *FB2;
+ createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
+
+ createJIT(std::move(A));
+ TheJIT->addModule(std::move(B));
+
+ EXPECT_EQ(FA, TheJIT->FindFunctionNamed(FA->getName().data()));
+ EXPECT_EQ(FB1, TheJIT->FindFunctionNamed(FB1->getName().data()));
+}
+
}
Index: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
===================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -408,7 +408,8 @@
ModulePtrSet::iterator I,
ModulePtrSet::iterator E) {
for (; I != E; ++I) {
- if (Function *F = (*I)->getFunction(FnName))
+ Function *F = (*I)->getFunction(FnName);
+ if (F && !F->isDeclaration())
return F;
}
return nullptr;
Index: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
===================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -142,7 +142,8 @@
Function *ExecutionEngine::FindFunctionNamed(const char *FnName) {
for (unsigned i = 0, e = Modules.size(); i != e; ++i) {
- if (Function *F = Modules[i]->getFunction(FnName))
+ Function *F = Modules[i]->getFunction(FnName);
+ if (F && !F->isDeclaration())
return F;
}
return nullptr;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7068.18833.patch
Type: text/x-patch
Size: 2228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150127/a53043e4/attachment.bin>
More information about the llvm-commits
mailing list