summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-07-29 23:12:33 +0000
committerLang Hames <lhames@gmail.com>2015-07-29 23:12:33 +0000
commit3393cfdef8d2ecdbe93ea97d1d912abc83644cbe (patch)
treecc784bfbdfbba8e28173a5941ac7c62fee4a5097 /llvm/lib
parente0d68e381b72c6e9d68de305874669a63cccc35d (diff)
downloadbcm5719-llvm-3393cfdef8d2ecdbe93ea97d1d912abc83644cbe.tar.gz
bcm5719-llvm-3393cfdef8d2ecdbe93ea97d1d912abc83644cbe.zip
[MCJIT] Fix PR20656 by teaching MCJIT to honor ExecutionEngine's global mapping.
This is important for users of the C API who can't supply custom symbol resolvers yet. llvm-svn: 243589
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp11
-rw-r--r--llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp6
2 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 67b843737cd..1fc6bb5fe16 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -189,10 +189,17 @@ uint64_t ExecutionEngineState::RemoveMapping(StringRef Name) {
}
std::string ExecutionEngine::getMangledName(const GlobalValue *GV) {
+ assert(GV->hasName() && "Global must have name.");
+
MutexGuard locked(lock);
- Mangler Mang;
SmallString<128> FullName;
- Mang.getNameWithPrefix(FullName, GV, false);
+
+ const DataLayout &DL =
+ GV->getParent()->getDataLayout().isDefault()
+ ? getDataLayout()
+ : GV->getParent()->getDataLayout();
+
+ Mangler::getNameWithPrefix(FullName, GV->getName(), DL);
return FullName.str();
}
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 492478da89f..c201f39a375 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -270,6 +270,12 @@ void MCJIT::finalizeModule(Module *M) {
RuntimeDyld::SymbolInfo MCJIT::findExistingSymbol(const std::string &Name) {
SmallString<128> FullName;
Mangler::getNameWithPrefix(FullName, Name, getDataLayout());
+
+ if (void *Addr = getPointerToGlobalIfAvailable(FullName))
+ return RuntimeDyld::SymbolInfo(static_cast<uint64_t>(
+ reinterpret_cast<uintptr_t>(Addr)),
+ JITSymbolFlags::Exported);
+
return Dyld.getSymbol(FullName);
}
OpenPOWER on IntegriCloud