diff options
author | Lang Hames <lhames@gmail.com> | 2018-07-21 00:12:05 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-07-21 00:12:05 +0000 |
commit | 9d8e9ef4914ecd5a62fa32667787fa0a306401c7 (patch) | |
tree | 35f45301107dd4e7490cccaab8bb3831b76276ba /lib/ExecutionEngine/Orc | |
parent | 845fa153ca1815d7f873aaf7369fd00ad0dc1e24 (diff) |
[ORC] Re-apply r336760 with fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337637 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Orc')
-rw-r--r-- | lib/ExecutionEngine/Orc/Core.cpp | 38 | ||||
-rw-r--r-- | lib/ExecutionEngine/Orc/Legacy.cpp | 2 | ||||
-rw-r--r-- | lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp | 2 |
3 files changed, 38 insertions, 4 deletions
diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index 2bfe0803a53..4325d57f73d 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -11,6 +11,7 @@ #include "llvm/Config/llvm-config.h" #include "llvm/ExecutionEngine/Orc/OrcError.h" #include "llvm/IR/Mangler.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" #if LLVM_ENABLE_THREADS @@ -685,6 +686,13 @@ MaterializationResponsibility::delegate(const SymbolNameSet &Symbols) { } void MaterializationResponsibility::addDependencies( + const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies) { + assert(SymbolFlags.count(Name) && + "Symbol not covered by this MaterializationResponsibility instance"); + V.addDependencies(Name, Dependencies); +} + +void MaterializationResponsibility::addDependenciesForAll( const SymbolDependenceMap &Dependencies) { for (auto &KV : SymbolFlags) V.addDependencies(KV.first, Dependencies); @@ -797,8 +805,25 @@ void ReExportsMaterializationUnit::materialize( QueryInfos.pop_back(); - auto RegisterDependencies = [&](const SymbolDependenceMap &Deps) { - R.addDependencies(Deps); + auto RegisterDependencies = [QueryInfo, + &SrcV](const SymbolDependenceMap &Deps) { + // If there were no materializing symbols, just bail out. + if (Deps.empty()) + return; + + // Otherwise the only deps should be on SrcV. + assert(Deps.size() == 1 && Deps.count(&SrcV) && + "Unexpected dependencies for reexports"); + + auto &SrcVDeps = Deps.find(&SrcV)->second; + SymbolDependenceMap PerAliasDepsMap; + auto &PerAliasDeps = PerAliasDepsMap[&SrcV]; + + for (auto &KV : QueryInfo->Aliases) + if (SrcVDeps.count(KV.second.Aliasee)) { + PerAliasDeps = {KV.second.Aliasee}; + QueryInfo->R.addDependencies(KV.first, PerAliasDepsMap); + } }; auto OnResolve = [QueryInfo](Expected<SymbolMap> Result) { @@ -979,6 +1004,15 @@ void VSO::addDependencies(const SymbolStringPtr &Name, auto &DepsOnOtherVSO = MI.UnfinalizedDependencies[&OtherVSO]; for (auto &OtherSymbol : KV.second) { +#ifndef NDEBUG + // Assert that this symbol exists and has not been finalized already. + auto SymI = OtherVSO.Symbols.find(OtherSymbol); + assert(SymI != OtherVSO.Symbols.end() && + (SymI->second.getFlags().isLazy() || + SymI->second.getFlags().isMaterializing()) && + "Dependency on finalized symbol"); +#endif + auto &OtherMI = OtherVSO.MaterializingInfos[OtherSymbol]; if (OtherMI.IsFinalized) diff --git a/lib/ExecutionEngine/Orc/Legacy.cpp b/lib/ExecutionEngine/Orc/Legacy.cpp index 22775ef14f8..18be9a042f7 100644 --- a/lib/ExecutionEngine/Orc/Legacy.cpp +++ b/lib/ExecutionEngine/Orc/Legacy.cpp @@ -31,7 +31,7 @@ JITSymbolResolverAdapter::lookup(const LookupSet &Symbols) { auto RegisterDependencies = [&](const SymbolDependenceMap &Deps) { if (MR) - MR->addDependencies(Deps); + MR->addDependenciesForAll(Deps); }; auto InternedResult = diff --git a/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp index 6edf616660e..71b4b73ca6d 100644 --- a/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp +++ b/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp @@ -26,7 +26,7 @@ public: InternedSymbols.insert(ES.getSymbolStringPool().intern(S)); auto RegisterDependencies = [&](const SymbolDependenceMap &Deps) { - MR.addDependencies(Deps); + MR.addDependenciesForAll(Deps); }; auto InternedResult = |