diff --git a/include/llvm/ExecutionEngine/Orc/Core.h b/include/llvm/ExecutionEngine/Orc/Core.h index be5152d09ad..0424d5043cc 100644 --- a/include/llvm/ExecutionEngine/Orc/Core.h +++ b/include/llvm/ExecutionEngine/Orc/Core.h @@ -825,47 +825,46 @@ public: /// have been added and not yet removed). void removeGenerator(DefinitionGenerator &G); - /// Set the search order to be used when fixing up definitions in JITDylib. - /// This will replace the previous search order, and apply to any symbol + /// Set the link order to be used when fixing up definitions in JITDylib. + /// This will replace the previous link order, and apply to any symbol /// resolutions made for definitions in this JITDylib after the call to - /// setSearchOrder (even if the definition itself was added before the + /// setLinkOrder (even if the definition itself was added before the /// call). /// - /// If SearchThisJITDylibFirst is set, which by default it is, then this - /// JITDylib will add itself to the beginning of the SearchOrder (Clients - /// should *not* put this JITDylib in the list in this case, to avoid - /// redundant lookups). + /// If LinkAgainstThisJITDylibFirst is true (the default) then this JITDylib + /// will add itself to the beginning of the LinkOrder (Clients should not + /// put this JITDylib in the list in this case, to avoid redundant lookups). /// - /// If SearchThisJITDylibFirst is false then the search order will be used as - /// given. The main motivation for this feature is to support deliberate + /// If LinkAgainstThisJITDylibFirst is false then the link order will be used + /// as-is. The primary motivation for this feature is to support deliberate /// shadowing of symbols in this JITDylib by a facade JITDylib. For example, /// the facade may resolve function names to stubs, and the stubs may compile /// lazily by looking up symbols in this dylib. Adding the facade dylib - /// as the first in the search order (instead of this dylib) ensures that + /// as the first in the link order (instead of this dylib) ensures that /// definitions within this dylib resolve to the lazy-compiling stubs, /// rather than immediately materializing the definitions in this dylib. - void setSearchOrder(JITDylibSearchOrder NewSearchOrder, - bool SearchThisJITDylibFirst = true); + void setLinkOrder(JITDylibSearchOrder NewSearchOrder, + bool LinkAgainstThisJITDylibFirst = true); - /// Add the given JITDylib to the search order for definitions in this + /// Add the given JITDylib to the link order for definitions in this /// JITDylib. - void addToSearchOrder(JITDylib &JD, - JITDylibLookupFlags JDLookupFlags = - JITDylibLookupFlags::MatchExportedSymbolsOnly); + void addToLinkOrder(JITDylib &JD, + JITDylibLookupFlags JDLookupFlags = + JITDylibLookupFlags::MatchExportedSymbolsOnly); - /// Replace OldJD with NewJD in the search order if OldJD is present. + /// Replace OldJD with NewJD in the link order if OldJD is present. /// Otherwise this operation is a no-op. - void replaceInSearchOrder(JITDylib &OldJD, JITDylib &NewJD, - JITDylibLookupFlags JDLookupFlags = - JITDylibLookupFlags::MatchExportedSymbolsOnly); + void replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD, + JITDylibLookupFlags JDLookupFlags = + JITDylibLookupFlags::MatchExportedSymbolsOnly); - /// Remove the given JITDylib from the search order for this JITDylib if it is + /// Remove the given JITDylib from the link order for this JITDylib if it is /// present. Otherwise this operation is a no-op. - void removeFromSearchOrder(JITDylib &JD); + void removeFromLinkOrder(JITDylib &JD); - /// Do something with the search order (run under the session lock). + /// Do something with the link order (run under the session lock). template - auto withSearchOrderDo(Func &&F) + auto withLinkOrderDo(Func &&F) -> decltype(F(std::declval())); /// Define all symbols provided by the materialization unit to be part of this @@ -1049,7 +1048,7 @@ private: UnmaterializedInfosMap UnmaterializedInfos; MaterializingInfosMap MaterializingInfos; std::vector> DefGenerators; - JITDylibSearchOrder SearchOrder; + JITDylibSearchOrder LinkOrder; }; /// Platforms set up standard symbols and mediate interactions between dynamic @@ -1297,9 +1296,9 @@ GeneratorT &JITDylib::addGenerator(std::unique_ptr DefGenerator) { } template -auto JITDylib::withSearchOrderDo(Func &&F) +auto JITDylib::withLinkOrderDo(Func &&F) -> decltype(F(std::declval())) { - return ES.runSessionLocked([&]() { return F(SearchOrder); }); + return ES.runSessionLocked([&]() { return F(LinkOrder); }); } template diff --git a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp index a8e88a9785c..9e38dc36faa 100644 --- a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp +++ b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp @@ -179,21 +179,20 @@ CompileOnDemandLayer::getPerDylibResources(JITDylib &TargetD) { if (I == DylibResources.end()) { auto &ImplD = getExecutionSession().createBareJITDylib(TargetD.getName() + ".impl"); - JITDylibSearchOrder NewSearchOrder; - TargetD.withSearchOrderDo( - [&](const JITDylibSearchOrder &TargetSearchOrder) { - NewSearchOrder = TargetSearchOrder; - }); + JITDylibSearchOrder NewLinkOrder; + TargetD.withLinkOrderDo([&](const JITDylibSearchOrder &TargetLinkOrder) { + NewLinkOrder = TargetLinkOrder; + }); - assert( - !NewSearchOrder.empty() && NewSearchOrder.front().first == &TargetD && - NewSearchOrder.front().second == JITDylibLookupFlags::MatchAllSymbols && - "TargetD must be at the front of its own search order and match " - "non-exported symbol"); - NewSearchOrder.insert(std::next(NewSearchOrder.begin()), - {&ImplD, JITDylibLookupFlags::MatchAllSymbols}); - ImplD.setSearchOrder(NewSearchOrder, false); - TargetD.setSearchOrder(std::move(NewSearchOrder), false); + assert(!NewLinkOrder.empty() && NewLinkOrder.front().first == &TargetD && + NewLinkOrder.front().second == + JITDylibLookupFlags::MatchAllSymbols && + "TargetD must be at the front of its own search order and match " + "non-exported symbol"); + NewLinkOrder.insert(std::next(NewLinkOrder.begin()), + {&ImplD, JITDylibLookupFlags::MatchAllSymbols}); + ImplD.setLinkOrder(NewLinkOrder, false); + TargetD.setLinkOrder(std::move(NewLinkOrder), false); PerDylibResources PDR(ImplD, BuildIndirectStubsManager()); I = DylibResources.insert(std::make_pair(&TargetD, std::move(PDR))).first; diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index 97755802bb2..7aaf62141c8 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -1157,30 +1157,29 @@ void JITDylib::notifyFailed(FailedSymbolsWorklist Worklist) { Q->handleFailed(make_error(FailedSymbolsMap)); } -void JITDylib::setSearchOrder(JITDylibSearchOrder NewSearchOrder, - bool SearchThisJITDylibFirst) { +void JITDylib::setLinkOrder(JITDylibSearchOrder NewLinkOrder, + bool LinkAgainstThisJITDylibFirst) { ES.runSessionLocked([&]() { - if (SearchThisJITDylibFirst) { - SearchOrder.clear(); - if (NewSearchOrder.empty() || NewSearchOrder.front().first != this) - SearchOrder.push_back( + if (LinkAgainstThisJITDylibFirst) { + LinkOrder.clear(); + if (NewLinkOrder.empty() || NewLinkOrder.front().first != this) + LinkOrder.push_back( std::make_pair(this, JITDylibLookupFlags::MatchAllSymbols)); - SearchOrder.insert(SearchOrder.end(), NewSearchOrder.begin(), - NewSearchOrder.end()); + LinkOrder.insert(LinkOrder.end(), NewLinkOrder.begin(), + NewLinkOrder.end()); } else - SearchOrder = std::move(NewSearchOrder); + LinkOrder = std::move(NewLinkOrder); }); } -void JITDylib::addToSearchOrder(JITDylib &JD, - JITDylibLookupFlags JDLookupFlags) { - ES.runSessionLocked([&]() { SearchOrder.push_back({&JD, JDLookupFlags}); }); +void JITDylib::addToLinkOrder(JITDylib &JD, JITDylibLookupFlags JDLookupFlags) { + ES.runSessionLocked([&]() { LinkOrder.push_back({&JD, JDLookupFlags}); }); } -void JITDylib::replaceInSearchOrder(JITDylib &OldJD, JITDylib &NewJD, - JITDylibLookupFlags JDLookupFlags) { +void JITDylib::replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD, + JITDylibLookupFlags JDLookupFlags) { ES.runSessionLocked([&]() { - for (auto &KV : SearchOrder) + for (auto &KV : LinkOrder) if (KV.first == &OldJD) { KV = {&NewJD, JDLookupFlags}; break; @@ -1188,14 +1187,14 @@ void JITDylib::replaceInSearchOrder(JITDylib &OldJD, JITDylib &NewJD, }); } -void JITDylib::removeFromSearchOrder(JITDylib &JD) { +void JITDylib::removeFromLinkOrder(JITDylib &JD) { ES.runSessionLocked([&]() { - auto I = std::find_if(SearchOrder.begin(), SearchOrder.end(), + auto I = std::find_if(LinkOrder.begin(), LinkOrder.end(), [&](const JITDylibSearchOrder::value_type &KV) { return KV.first == &JD; }); - if (I != SearchOrder.end()) - SearchOrder.erase(I); + if (I != LinkOrder.end()) + LinkOrder.erase(I); }); } @@ -1529,7 +1528,7 @@ void JITDylib::dump(raw_ostream &OS) { ES.runSessionLocked([&, this]() { OS << "JITDylib \"" << JITDylibName << "\" (ES: " << format("0x%016" PRIx64, reinterpret_cast(&ES)) << "):\n" - << "Search order: " << SearchOrder << "\n" + << "Link order: " << LinkOrder << "\n" << "Symbol table:\n"; for (auto &KV : Symbols) { @@ -1610,7 +1609,7 @@ JITDylib::MaterializingInfo::takeQueriesMeeting(SymbolState RequiredState) { JITDylib::JITDylib(ExecutionSession &ES, std::string Name) : ES(ES), JITDylibName(std::move(Name)) { - SearchOrder.push_back({this, JITDylibLookupFlags::MatchAllSymbols}); + LinkOrder.push_back({this, JITDylibLookupFlags::MatchAllSymbols}); } Error JITDylib::defineImpl(MaterializationUnit &MU) { diff --git a/lib/ExecutionEngine/Orc/LLJIT.cpp b/lib/ExecutionEngine/Orc/LLJIT.cpp index 0ee1beef8bf..c8d7b4d2db0 100644 --- a/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -374,8 +374,8 @@ private: continue; Visited.insert(&NextJD); DFSLinkOrder.push_back(&NextJD); - NextJD.withSearchOrderDo([&](const JITDylibSearchOrder &SearchOrder) { - for (auto &KV : SearchOrder) + NextJD.withLinkOrderDo([&](const JITDylibSearchOrder &LinkOrder) { + for (auto &KV : LinkOrder) WorkStack.push_back(KV.first); }); } diff --git a/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/lib/ExecutionEngine/Orc/MachOPlatform.cpp index c547c8ef7f1..15c3aa79a2a 100644 --- a/lib/ExecutionEngine/Orc/MachOPlatform.cpp +++ b/lib/ExecutionEngine/Orc/MachOPlatform.cpp @@ -271,8 +271,8 @@ std::vector MachOPlatform::getDFSLinkOrder(JITDylib &JD) { continue; Visited.insert(NextJD); Result.push_back(NextJD); - NextJD->withSearchOrderDo([&](const JITDylibSearchOrder &SO) { - for (auto &KV : SO) + NextJD->withLinkOrderDo([&](const JITDylibSearchOrder &LO) { + for (auto &KV : LO) WorkStack.push_back(KV.first); }); } diff --git a/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp index 83d3f676dc4..02066b458df 100644 --- a/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp +++ b/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp @@ -50,9 +50,9 @@ public: void lookup(const LookupMap &Symbols, std::unique_ptr LC) override { - JITDylibSearchOrder SearchOrder; - MR.getTargetJITDylib().withSearchOrderDo( - [&](const JITDylibSearchOrder &O) { SearchOrder = O; }); + JITDylibSearchOrder LinkOrder; + MR.getTargetJITDylib().withLinkOrderDo( + [&](const JITDylibSearchOrder &LO) { LinkOrder = LO; }); auto &ES = Layer.getExecutionSession(); @@ -90,7 +90,7 @@ public: MR.addDependencies(KV.first, InternalDeps); } - ES.lookup(LookupKind::Static, SearchOrder, std::move(LookupSet), + ES.lookup(LookupKind::Static, LinkOrder, std::move(LookupSet), SymbolState::Resolved, std::move(OnResolve), [this](const SymbolDependenceMap &Deps) { registerDependencies(Deps); diff --git a/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp index 5ded369f3bd..21925726072 100644 --- a/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp +++ b/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp @@ -47,10 +47,10 @@ public: MR.addDependenciesForAll(Deps); }; - JITDylibSearchOrder SearchOrder; - MR.getTargetJITDylib().withSearchOrderDo( - [&](const JITDylibSearchOrder &JDs) { SearchOrder = JDs; }); - ES.lookup(LookupKind::Static, SearchOrder, InternedSymbols, + JITDylibSearchOrder LinkOrder; + MR.getTargetJITDylib().withLinkOrderDo( + [&](const JITDylibSearchOrder &LO) { LinkOrder = LO; }); + ES.lookup(LookupKind::Static, LinkOrder, InternedSymbols, SymbolState::Resolved, std::move(OnResolvedWithUnwrap), RegisterDependencies); } diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 4cb808baba4..981e0812d45 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -942,8 +942,8 @@ int runOrcLazyJIT(const char *ProgName) { orc::JITDylib *JD = J->getJITDylibByName(*JDItr); if (!JD) { JD = &ExitOnErr(J->createJITDylib(*JDItr)); - J->getMainJITDylib().addToSearchOrder(*JD); - JD->addToSearchOrder(J->getMainJITDylib()); + J->getMainJITDylib().addToLinkOrder(*JD); + JD->addToLinkOrder(J->getMainJITDylib()); } IdxToDylib[JITDylibs.getPosition(JDItr - JITDylibs.begin())] = JD; } diff --git a/tools/llvm-jitlink/llvm-jitlink.cpp b/tools/llvm-jitlink/llvm-jitlink.cpp index 9058a7907b0..961cd77c0ec 100644 --- a/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/tools/llvm-jitlink/llvm-jitlink.cpp @@ -657,13 +657,13 @@ Error loadObjects(Session &S) { // Set every dylib to link against every other, in command line order. for (auto *JD : S.JDSearchOrder) { auto LookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly; - JITDylibSearchOrder O; + JITDylibSearchOrder LinkOrder; for (auto *JD2 : S.JDSearchOrder) { if (JD2 == JD) continue; - O.push_back(std::make_pair(JD2, LookupFlags)); + LinkOrder.push_back(std::make_pair(JD2, LookupFlags)); } - JD->setSearchOrder(std::move(O)); + JD->setLinkOrder(std::move(LinkOrder)); } }