summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-10-22 21:17:56 +0000
committerLang Hames <lhames@gmail.com>2018-10-22 21:17:56 +0000
commit95abadec0bace0093993f6320c741e2b1e0ec14b (patch)
tree8a5ecc30b2be1696f3c3e2b6a22267b62cdae74d /llvm/lib/ExecutionEngine
parentfb41544af8176aadbc2ec55d3683423af00952e5 (diff)
downloadbcm5719-llvm-95abadec0bace0093993f6320c741e2b1e0ec14b.tar.gz
bcm5719-llvm-95abadec0bace0093993f6320c741e2b1e0ec14b.zip
[ORC] Guard access to the MemMgrs vector in RTDyldObjectLinkingLayer.
Otherwise we can end up with a data-race when linking concurrently. This should fix an intermittent failure in the multiple-compile-threads-basic.ll testcase. llvm-svn: 344956
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
index 8511e41c4f2..616251c7e00 100644
--- a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
@@ -121,8 +121,15 @@ void RTDyldObjectLinkingLayer::emit(MaterializationResponsibility R,
}
auto K = R.getVModuleKey();
- MemMgrs.push_back(GetMemoryManager());
- auto &MemMgr = *MemMgrs.back();
+ RuntimeDyld::MemoryManager *MemMgr = nullptr;
+
+ // Create a record a memory manager for this object.
+ {
+ auto Tmp = GetMemoryManager();
+ std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);
+ MemMgrs.push_back(std::move(Tmp));
+ MemMgr = MemMgrs.back().get();
+ }
JITDylibSearchOrderResolver Resolver(*SharedR);
@@ -134,7 +141,7 @@ void RTDyldObjectLinkingLayer::emit(MaterializationResponsibility R,
* duplicate defs.
*/
jitLinkForORC(
- **Obj, std::move(O), MemMgr, Resolver, ProcessAllSections,
+ **Obj, std::move(O), *MemMgr, Resolver, ProcessAllSections,
[this, K, SharedR, &Obj, InternalSymbols](
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> LoadedObjInfo,
std::map<StringRef, JITEvaluatedSymbol> ResolvedSymbols) {
OpenPOWER on IntegriCloud