From db367e952e8198706ab73ffc5f7bd7ba3e8164c8 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 23 Oct 2018 20:54:43 +0000 Subject: [PATCH] Revert r345077 "[ORC] Change how non-exported symbols are matched during lookup." Doesn't build on Windows. The call to 'lookup' is ambiguous. Clang and MSVC agree, anyway. http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/787 C:\b\slave\clang-x64-windows-msvc\build\llvm.src\unittests\ExecutionEngine\Orc\CoreAPIsTest.cpp(315): error C2668: 'llvm::orc::ExecutionSession::lookup': ambiguous call to overloaded function C:\b\slave\clang-x64-windows-msvc\build\llvm.src\include\llvm/ExecutionEngine/Orc/Core.h(823): note: could be 'llvm::Expected llvm::orc::ExecutionSession::lookup(llvm::ArrayRef,llvm::orc::SymbolStringPtr)' C:\b\slave\clang-x64-windows-msvc\build\llvm.src\include\llvm/ExecutionEngine/Orc/Core.h(817): note: or 'llvm::Expected llvm::orc::ExecutionSession::lookup(const llvm::orc::JITDylibSearchList &,llvm::orc::SymbolStringPtr)' C:\b\slave\clang-x64-windows-msvc\build\llvm.src\unittests\ExecutionEngine\Orc\CoreAPIsTest.cpp(315): note: while trying to match the argument list '(initializer list, llvm::orc::SymbolStringPtr)' llvm-svn: 345078 --- llvm/include/llvm/ExecutionEngine/JITSymbol.h | 12 -- llvm/include/llvm/ExecutionEngine/Orc/Core.h | 99 +++++++------- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- .../ExecutionEngine/Orc/CompileOnDemandLayer.cpp | 17 +-- llvm/lib/ExecutionEngine/Orc/Core.cpp | 151 +++++++++------------ llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp | 5 +- llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | 8 +- llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp | 4 +- .../Orc/RTDyldObjectLinkingLayer.cpp | 9 +- .../OrcLazy/Inputs/hidden-definitions.ll | 6 - .../ExecutionEngine/OrcLazy/hidden-visibility.ll | 17 --- llvm/tools/lli/lli.cpp | 46 +------ .../unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | 61 ++++----- .../Orc/RTDyldObjectLinkingLayerTest.cpp | 8 +- 15 files changed, 170 insertions(+), 277 deletions(-) delete mode 100644 llvm/test/ExecutionEngine/OrcLazy/Inputs/hidden-definitions.ll delete mode 100644 llvm/test/ExecutionEngine/OrcLazy/hidden-visibility.ll diff --git a/llvm/include/llvm/ExecutionEngine/JITSymbol.h b/llvm/include/llvm/ExecutionEngine/JITSymbol.h index 05c9590..18b972e 100644 --- a/llvm/include/llvm/ExecutionEngine/JITSymbol.h +++ b/llvm/include/llvm/ExecutionEngine/JITSymbol.h @@ -40,18 +40,6 @@ class SymbolRef; /// Represents an address in the target process's address space. using JITTargetAddress = uint64_t; -/// Convert a JITTargetAddress to a pointer. -template T jitTargetAddressToPointer(JITTargetAddress Addr) { - static_assert(std::is_pointer::value, "T must be a pointer type"); - uintptr_t IntPtr = static_cast(Addr); - assert(IntPtr == Addr && "JITTargetAddress value out of range for uintptr_t"); - return reinterpret_cast(IntPtr); -} - -template JITTargetAddress pointerToJITTargetAddress(T *Ptr) { - return static_cast(reinterpret_cast(Ptr)); -} - /// Flags for symbols in the JIT. class JITSymbolFlags { public: diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index 39d306e..2e56854 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -54,8 +54,8 @@ using SymbolFlagsMap = DenseMap; /// symbols to be obtained for logging. using SymbolDependenceMap = DenseMap; -/// A list of (JITDylib*, bool) pairs. -using JITDylibSearchList = std::vector>; +/// A list of JITDylib pointers. +using JITDylibList = std::vector; /// Render a SymbolStringPtr. raw_ostream &operator<<(raw_ostream &OS, const SymbolStringPtr &Sym); @@ -85,8 +85,8 @@ raw_ostream &operator<<(raw_ostream &OS, const SymbolDependenceMap &Deps); /// Render a MaterializationUnit. raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU); -/// Render a JITDylibSearchList. -raw_ostream &operator<<(raw_ostream &OS, const JITDylibSearchList &JDs); +/// Render a JITDylibList. +raw_ostream &operator<<(raw_ostream &OS, const JITDylibList &JDs); /// Callback to notify client that symbols have been resolved. using SymbolsResolvedCallback = std::function)>; @@ -351,15 +351,14 @@ using SymbolAliasMap = DenseMap; class ReExportsMaterializationUnit : public MaterializationUnit { public: /// SourceJD is allowed to be nullptr, in which case the source JITDylib is - /// taken to be whatever JITDylib these definitions are materialized in (and - /// MatchNonExported has no effect). This is useful for defining aliases - /// within a JITDylib. + /// taken to be whatever JITDylib these definitions are materialized in. This + /// is useful for defining aliases within a JITDylib. /// /// Note: Care must be taken that no sets of aliases form a cycle, as such /// a cycle will result in a deadlock when any symbol in the cycle is /// resolved. - ReExportsMaterializationUnit(JITDylib *SourceJD, bool MatchNonExported, - SymbolAliasMap Aliases, VModuleKey K); + ReExportsMaterializationUnit(JITDylib *SourceJD, SymbolAliasMap Aliases, + VModuleKey K); StringRef getName() const override; @@ -369,7 +368,6 @@ private: static SymbolFlagsMap extractFlags(const SymbolAliasMap &Aliases); JITDylib *SourceJD = nullptr; - bool MatchNonExported = false; SymbolAliasMap Aliases; }; @@ -387,19 +385,16 @@ private: inline std::unique_ptr symbolAliases(SymbolAliasMap Aliases, VModuleKey K = VModuleKey()) { return llvm::make_unique( - nullptr, true, std::move(Aliases), std::move(K)); + nullptr, std::move(Aliases), std::move(K)); } /// Create a materialization unit for re-exporting symbols from another JITDylib /// with alternative names/flags. -/// If MatchNonExported is true then non-exported symbols from SourceJD can be -/// re-exported. If it is false, attempts to re-export a non-exported symbol -/// will result in a "symbol not found" error. inline std::unique_ptr reexports(JITDylib &SourceJD, SymbolAliasMap Aliases, - bool MatchNonExported = false, VModuleKey K = VModuleKey()) { + VModuleKey K = VModuleKey()) { return llvm::make_unique( - &SourceJD, MatchNonExported, std::move(Aliases), std::move(K)); + &SourceJD, std::move(Aliases), std::move(K)); } /// Build a SymbolAliasMap for the common case where you want to re-export @@ -416,14 +411,13 @@ public: /// Create a reexports generator. If an Allow predicate is passed, only /// symbols for which the predicate returns true will be reexported. If no /// Allow predicate is passed, all symbols will be exported. - ReexportsGenerator(JITDylib &SourceJD, bool MatchNonExported = false, + ReexportsGenerator(JITDylib &SourceJD, SymbolPredicate Allow = SymbolPredicate()); SymbolNameSet operator()(JITDylib &JD, const SymbolNameSet &Names); private: JITDylib &SourceJD; - bool MatchNonExported = false; SymbolPredicate Allow; }; @@ -542,18 +536,16 @@ public: /// as the first in the search 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(JITDylibSearchList NewSearchOrder, - bool SearchThisJITDylibFirst = true, - bool MatchNonExportedInThisDylib = true); + void setSearchOrder(JITDylibList NewSearchOrder, + bool SearchThisJITDylibFirst = true); /// Add the given JITDylib to the search order for definitions in this /// JITDylib. - void addToSearchOrder(JITDylib &JD, bool MatcNonExported = false); + void addToSearchOrder(JITDylib &JD); /// Replace OldJD with NewJD in the search order if OldJD is present. /// Otherwise this operation is a no-op. - void replaceInSearchOrder(JITDylib &OldJD, JITDylib &NewJD, - bool MatchNonExported = false); + void replaceInSearchOrder(JITDylib &OldJD, JITDylib &NewJD); /// Remove the given JITDylib from the search order for this JITDylib if it is /// present. Otherwise this operation is a no-op. @@ -562,7 +554,7 @@ public: /// Do something with the search order (run under the session lock). template auto withSearchOrderDo(Func &&F) - -> decltype(F(std::declval())); + -> decltype(F(std::declval())); /// Define all symbols provided by the materialization unit to be part of this /// JITDylib. @@ -650,12 +642,12 @@ private: const SymbolNameSet &Names); void lodgeQuery(std::shared_ptr &Q, - SymbolNameSet &Unresolved, bool MatchNonExported, - MaterializationUnitList &MUs); + SymbolNameSet &Unresolved, JITDylib *MatchNonExportedInJD, + bool MatchNonExported, MaterializationUnitList &MUs); void lodgeQueryImpl(std::shared_ptr &Q, - SymbolNameSet &Unresolved, bool MatchNonExported, - MaterializationUnitList &MUs); + SymbolNameSet &Unresolved, JITDylib *MatchNonExportedInJD, + bool MatchNonExported, MaterializationUnitList &MUs); LookupImplActionFlags lookupImpl(std::shared_ptr &Q, @@ -690,7 +682,7 @@ private: UnmaterializedInfosMap UnmaterializedInfos; MaterializingInfosMap MaterializingInfos; GeneratorFunction DefGenerator; - JITDylibSearchList SearchOrder; + JITDylibList SearchOrder; }; /// An ExecutionSession represents a running JIT program. @@ -774,10 +766,6 @@ public: /// Search the given JITDylib list for the given symbols. /// - /// SearchOrder lists the JITDylibs to search. For each dylib, the associated - /// boolean indicates whether the search should match against non-exported - /// (hidden visibility) symbols in that dylib (true means match against - /// non-exported symbols, false means do not match). /// /// The OnResolve callback will be called once all requested symbols are /// resolved, or if an error occurs prior to resolution. @@ -794,9 +782,19 @@ public: /// dependenant symbols for this query (e.g. it is being made by a top level /// client to get an address to call) then the value NoDependenciesToRegister /// can be used. - void lookup(const JITDylibSearchList &SearchOrder, SymbolNameSet Symbols, + /// + /// If the MatchNonExportedInJD pointer is non-null, then the lookup will find + /// non-exported symbols defined in the JITDylib pointed to by + /// MatchNonExportedInJD. + /// If MatchNonExported is true the lookup will find non-exported symbols in + /// any JITDylib (setting MatchNonExportedInJD is redundant in such cases). + /// If MatchNonExported is false and MatchNonExportedInJD is null, + /// non-exported symbols will never be found. + void lookup(const JITDylibList &JDs, SymbolNameSet Symbols, SymbolsResolvedCallback OnResolve, SymbolsReadyCallback OnReady, - RegisterDependenciesFunction RegisterDependencies); + RegisterDependenciesFunction RegisterDependencies, + JITDylib *MatchNonExportedInJD = nullptr, + bool MatchNonExported = false); /// Blocking version of lookup above. Returns the resolved symbol map. /// If WaitUntilReady is true (the default), will not return until all @@ -805,29 +803,24 @@ public: /// or an error occurs. If WaitUntilReady is false and an error occurs /// after resolution, the function will return a success value, but the /// error will be reported via reportErrors. - Expected lookup(const JITDylibSearchList &SearchOrder, + Expected lookup(const JITDylibList &JDs, const SymbolNameSet &Symbols, RegisterDependenciesFunction RegisterDependencies = NoDependenciesToRegister, - bool WaitUntilReady = true); - - /// Convenience version of blocking lookup. - /// Searches each of the JITDylibs in the search order in turn for the given - /// symbol. - Expected lookup(const JITDylibSearchList &SearchOrder, - SymbolStringPtr Symbol); + bool WaitUntilReady = true, + JITDylib *MatchNonExportedInJD = nullptr, + bool MatchNonExported = false); /// Convenience version of blocking lookup. - /// Searches each of the JITDylibs in the search order in turn for the given - /// symbol. The search will not find non-exported symbols. - Expected lookup(ArrayRef SearchOrder, - SymbolStringPtr Symbol); + /// Performs a single-symbol lookup. + Expected lookup(const JITDylibList &JDs, + SymbolStringPtr Symbol, + bool MatchNonExported = false); /// Convenience version of blocking lookup. - /// Searches each of the JITDylibs in the search order in turn for the given - /// symbol. The search will not find non-exported symbols. - Expected lookup(ArrayRef SearchOrder, - StringRef Symbol); + /// Performs a single-symbol lookup, auto-interning the given symbol name. + Expected lookup(const JITDylibList &JDs, StringRef Symbol, + bool MatchNonExported = false); /// Materialize the given unit. void dispatchMaterialization(JITDylib &JD, @@ -873,7 +866,7 @@ private: template auto JITDylib::withSearchOrderDo(Func &&F) - -> decltype(F(std::declval())) { + -> decltype(F(std::declval())) { return ES.runSessionLocked([&]() { return F(SearchOrder); }); } diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h index ce3e5d5..b7ef883 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -144,7 +144,7 @@ public: /// LLLazyJIT with the given number of compile threads. static Expected> Create(JITTargetMachineBuilder JTMB, DataLayout DL, - JITTargetAddress ErrorAddr, unsigned NumCompileThreads = 0); + unsigned NumCompileThreads = 0); /// Set an IR transform (e.g. pass manager pipeline) to run on each function /// when it is compiled. diff --git a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp index 241eb36..de1fa07 100644 --- a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp @@ -157,7 +157,7 @@ void CompileOnDemandLayer::emit(MaterializationResponsibility R, return; } - R.replace(reexports(PDR.getImplDylib(), std::move(NonCallables), true)); + R.replace(reexports(PDR.getImplDylib(), std::move(NonCallables))); R.replace(lazyReexports(LCTMgr, PDR.getISManager(), PDR.getImplDylib(), std::move(Callables))); } @@ -166,17 +166,10 @@ CompileOnDemandLayer::PerDylibResources & CompileOnDemandLayer::getPerDylibResources(JITDylib &TargetD) { auto I = DylibResources.find(&TargetD); if (I == DylibResources.end()) { - auto &ImplD = getExecutionSession().createJITDylib( - TargetD.getName() + ".impl", false); - TargetD.withSearchOrderDo([&](const JITDylibSearchList &TargetSearchOrder) { - auto NewSearchOrder = TargetSearchOrder; - assert(!NewSearchOrder.empty() && - NewSearchOrder.front().first == &TargetD && - NewSearchOrder.front().second == true && - "TargetD must be at the front of its own search order and match " - "non-exported symbol"); - NewSearchOrder.insert(std::next(NewSearchOrder.begin()), {&ImplD, true}); - ImplD.setSearchOrder(std::move(NewSearchOrder), false); + auto &ImplD = + getExecutionSession().createJITDylib(TargetD.getName() + ".impl"); + TargetD.withSearchOrderDo([&](const JITDylibList &TargetSearchOrder) { + ImplD.setSearchOrder(TargetSearchOrder, false); }); PerDylibResources PDR(ImplD, BuildIndirectStubsManager()); I = DylibResources.insert(std::make_pair(&TargetD, std::move(PDR))).first; diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp index 8a9740e..df4d002 100644 --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -205,16 +205,14 @@ raw_ostream &operator<<(raw_ostream &OS, const MaterializationUnit &MU) { return OS << ")"; } -raw_ostream &operator<<(raw_ostream &OS, const JITDylibSearchList &JDs) { +raw_ostream &operator<<(raw_ostream &OS, const JITDylibList &JDs) { OS << "["; if (!JDs.empty()) { - assert(JDs.front().first && "JITDylibList entries must not be null"); - OS << " (\"" << JDs.front().first->getName() << "\", " - << (JDs.front().second ? "true" : "false") << ")"; - for (auto &KV : make_range(std::next(JDs.begin()), JDs.end())) { - assert(KV.first && "JITDylibList entries must not be null"); - OS << ", (\"" << KV.first->getName() << "\", " - << (KV.second ? "true" : "false") << ")"; + assert(JDs.front() && "JITDylibList entries must not be null"); + OS << " " << JDs.front()->getName(); + for (auto *JD : make_range(std::next(JDs.begin()), JDs.end())) { + assert(JD && "JITDylibList entries must not be null"); + OS << ", " << JD->getName(); } } OS << " ]"; @@ -528,11 +526,9 @@ AbsoluteSymbolsMaterializationUnit::extractFlags(const SymbolMap &Symbols) { } ReExportsMaterializationUnit::ReExportsMaterializationUnit( - JITDylib *SourceJD, bool MatchNonExported, SymbolAliasMap Aliases, - VModuleKey K) + JITDylib *SourceJD, SymbolAliasMap Aliases, VModuleKey K) : MaterializationUnit(extractFlags(Aliases), std::move(K)), - SourceJD(SourceJD), MatchNonExported(MatchNonExported), - Aliases(std::move(Aliases)) {} + SourceJD(SourceJD), Aliases(std::move(Aliases)) {} StringRef ReExportsMaterializationUnit::getName() const { return ""; @@ -560,7 +556,7 @@ void ReExportsMaterializationUnit::materialize( if (!Aliases.empty()) { if (SourceJD) - R.replace(reexports(*SourceJD, std::move(Aliases), MatchNonExported)); + R.replace(reexports(*SourceJD, std::move(Aliases))); else R.replace(symbolAliases(std::move(Aliases))); } @@ -660,8 +656,8 @@ void ReExportsMaterializationUnit::materialize( auto OnReady = [&ES](Error Err) { ES.reportError(std::move(Err)); }; - ES.lookup({{&SrcJD, MatchNonExported}}, QuerySymbols, std::move(OnResolve), - std::move(OnReady), std::move(RegisterDependencies)); + ES.lookup({&SrcJD}, QuerySymbols, std::move(OnResolve), std::move(OnReady), + std::move(RegisterDependencies), nullptr, true); } } @@ -702,10 +698,8 @@ buildSimpleReexportsAliasMap(JITDylib &SourceJD, const SymbolNameSet &Symbols) { } ReexportsGenerator::ReexportsGenerator(JITDylib &SourceJD, - bool MatchNonExported, SymbolPredicate Allow) - : SourceJD(SourceJD), MatchNonExported(MatchNonExported), - Allow(std::move(Allow)) {} + : SourceJD(SourceJD), Allow(std::move(Allow)) {} SymbolNameSet ReexportsGenerator::operator()(JITDylib &JD, const SymbolNameSet &Names) { @@ -722,7 +716,7 @@ SymbolNameSet ReexportsGenerator::operator()(JITDylib &JD, } if (!Added.empty()) - cantFail(JD.define(reexports(SourceJD, AliasMap, MatchNonExported))); + cantFail(JD.define(reexports(SourceJD, AliasMap))); return Added; } @@ -1047,41 +1041,30 @@ void JITDylib::notifyFailed(const SymbolNameSet &FailedSymbols) { Q->handleFailed(make_error(FailedSymbols)); } -void JITDylib::setSearchOrder(JITDylibSearchList NewSearchOrder, - bool SearchThisJITDylibFirst, - bool MatchNonExportedInThisDylib) { - if (SearchThisJITDylibFirst && NewSearchOrder.front().first != this) - NewSearchOrder.insert(NewSearchOrder.begin(), - {this, MatchNonExportedInThisDylib}); +void JITDylib::setSearchOrder(JITDylibList NewSearchOrder, + bool SearchThisJITDylibFirst) { + if (SearchThisJITDylibFirst && NewSearchOrder.front() != this) + NewSearchOrder.insert(NewSearchOrder.begin(), this); ES.runSessionLocked([&]() { SearchOrder = std::move(NewSearchOrder); }); } -void JITDylib::addToSearchOrder(JITDylib &JD, bool MatchNonExported) { - ES.runSessionLocked([&]() { - SearchOrder.push_back({&JD, MatchNonExported}); - }); +void JITDylib::addToSearchOrder(JITDylib &JD) { + ES.runSessionLocked([&]() { SearchOrder.push_back(&JD); }); } -void JITDylib::replaceInSearchOrder(JITDylib &OldJD, JITDylib &NewJD, - bool MatchNonExported) { +void JITDylib::replaceInSearchOrder(JITDylib &OldJD, JITDylib &NewJD) { ES.runSessionLocked([&]() { - auto I = std::find_if(SearchOrder.begin(), SearchOrder.end(), - [&](const JITDylibSearchList::value_type &KV) { - return KV.first == &OldJD; - }); + auto I = std::find(SearchOrder.begin(), SearchOrder.end(), &OldJD); if (I != SearchOrder.end()) - *I = {&NewJD, MatchNonExported}; + *I = &NewJD; }); } void JITDylib::removeFromSearchOrder(JITDylib &JD) { ES.runSessionLocked([&]() { - auto I = std::find_if(SearchOrder.begin(), SearchOrder.end(), - [&](const JITDylibSearchList::value_type &KV) { - return KV.first == &JD; - }); + auto I = std::find(SearchOrder.begin(), SearchOrder.end(), &JD); if (I != SearchOrder.end()) SearchOrder.erase(I); }); @@ -1178,17 +1161,18 @@ SymbolNameSet JITDylib::lookupFlagsImpl(SymbolFlagsMap &Flags, } void JITDylib::lodgeQuery(std::shared_ptr &Q, - SymbolNameSet &Unresolved, bool MatchNonExported, + SymbolNameSet &Unresolved, + JITDylib *MatchNonExportedInJD, bool MatchNonExported, MaterializationUnitList &MUs) { assert(Q && "Query can not be null"); - lodgeQueryImpl(Q, Unresolved, MatchNonExported, MUs); + lodgeQueryImpl(Q, Unresolved, MatchNonExportedInJD, MatchNonExported, MUs); if (DefGenerator && !Unresolved.empty()) { auto NewDefs = DefGenerator(*this, Unresolved); if (!NewDefs.empty()) { for (auto &D : NewDefs) Unresolved.erase(D); - lodgeQueryImpl(Q, NewDefs, MatchNonExported, MUs); + lodgeQueryImpl(Q, NewDefs, MatchNonExportedInJD, MatchNonExported, MUs); assert(NewDefs.empty() && "All fallback defs should have been found by lookupImpl"); } @@ -1197,7 +1181,7 @@ void JITDylib::lodgeQuery(std::shared_ptr &Q, void JITDylib::lodgeQueryImpl( std::shared_ptr &Q, SymbolNameSet &Unresolved, - bool MatchNonExported, + JITDylib *MatchNonExportedInJD, bool MatchNonExported, std::vector> &MUs) { std::vector ToRemove; @@ -1207,9 +1191,12 @@ void JITDylib::lodgeQueryImpl( if (SymI == Symbols.end()) continue; - // If this is a non exported symbol and we're skipping those then skip it. - if (!SymI->second.getFlags().isExported() && !MatchNonExported) - continue; + // If this is a non-exported symbol, then check the values of + // MatchNonExportedInJD and MatchNonExported. Skip if we should not match + // against this symbol. + if (!SymI->second.getFlags().isExported()) + if (!MatchNonExported && MatchNonExportedInJD != this) + continue; // If we matched against Name in JD, mark it to be removed from the Unresolved // set. @@ -1395,9 +1382,8 @@ void JITDylib::dump(raw_ostream &OS) { << "\" (ES: " << format("0x%016x", reinterpret_cast(&ES)) << "):\n" << "Search order: ["; - for (auto &KV : SearchOrder) - OS << " (\"" << KV.first->getName() << "\", " - << (KV.second ? "all" : "exported only") << ")"; + for (auto *JD : SearchOrder) + OS << " \"" << JD->getName() << "\""; OS << " ]\n" << "Symbol table:\n"; @@ -1445,7 +1431,7 @@ void JITDylib::dump(raw_ostream &OS) { JITDylib::JITDylib(ExecutionSession &ES, std::string Name) : ES(ES), JITDylibName(std::move(Name)) { - SearchOrder.push_back({this, true}); + SearchOrder.push_back(this); } Error JITDylib::defineImpl(MaterializationUnit &MU) { @@ -1738,10 +1724,12 @@ Expected ExecutionSession::legacyLookup( #endif } -void ExecutionSession::lookup( - const JITDylibSearchList &SearchOrder, SymbolNameSet Symbols, - SymbolsResolvedCallback OnResolve, SymbolsReadyCallback OnReady, - RegisterDependenciesFunction RegisterDependencies) { +void ExecutionSession::lookup(const JITDylibList &JDs, SymbolNameSet Symbols, + SymbolsResolvedCallback OnResolve, + SymbolsReadyCallback OnReady, + RegisterDependenciesFunction RegisterDependencies, + JITDylib *MatchNonExportedInJD, + bool MatchNonExported) { // lookup can be re-entered recursively if running on a single thread. Run any // outstanding MUs in case this query depends on them, otherwise this lookup @@ -1757,14 +1745,12 @@ void ExecutionSession::lookup( bool QueryFailed = false; runSessionLocked([&]() { - for (auto &KV : SearchOrder) { - assert(KV.first && "JITDylibList entries must not be null"); - assert(!CollectedMUsMap.count(KV.first) && + for (auto *JD : JDs) { + assert(JD && "JITDylibList entries must not be null"); + assert(!CollectedMUsMap.count(JD) && "JITDylibList should not contain duplicate entries"); - - auto &JD = *KV.first; - auto MatchNonExported = KV.second; - JD.lodgeQuery(Q, Unresolved, MatchNonExported, CollectedMUsMap[&JD]); + JD->lodgeQuery(Q, Unresolved, MatchNonExportedInJD, MatchNonExported, + CollectedMUsMap[JD]); } if (Unresolved.empty()) { @@ -1815,9 +1801,11 @@ void ExecutionSession::lookup( runOutstandingMUs(); } -Expected ExecutionSession::lookup( - const JITDylibSearchList &SearchOrder, const SymbolNameSet &Symbols, - RegisterDependenciesFunction RegisterDependencies, bool WaitUntilReady) { +Expected +ExecutionSession::lookup(const JITDylibList &JDs, const SymbolNameSet &Symbols, + RegisterDependenciesFunction RegisterDependencies, + bool WaitUntilReady, JITDylib *MatchNonExportedInJD, + bool MatchNonExported) { #if LLVM_ENABLE_THREADS // In the threaded case we use promises to return the results. std::promise PromisedResult; @@ -1884,7 +1872,8 @@ Expected ExecutionSession::lookup( #endif // Perform the asynchronous lookup. - lookup(SearchOrder, Symbols, OnResolve, OnReady, RegisterDependencies); + lookup(JDs, Symbols, OnResolve, OnReady, RegisterDependencies, + MatchNonExportedInJD, MatchNonExported); #if LLVM_ENABLE_THREADS auto ResultFuture = PromisedResult.get_future(); @@ -1927,13 +1916,14 @@ Expected ExecutionSession::lookup( #endif } -Expected -ExecutionSession::lookup(const JITDylibSearchList &SearchOrder, - SymbolStringPtr Name) { +/// Look up a symbol by searching a list of JDs. +Expected ExecutionSession::lookup(const JITDylibList &JDs, + SymbolStringPtr Name, + bool MatchNonExported) { SymbolNameSet Names({Name}); - if (auto ResultMap = lookup(SearchOrder, std::move(Names), - NoDependenciesToRegister, true)) { + if (auto ResultMap = lookup(JDs, std::move(Names), NoDependenciesToRegister, + true, nullptr, MatchNonExported)) { assert(ResultMap->size() == 1 && "Unexpected number of results"); assert(ResultMap->count(Name) && "Missing result for symbol"); return std::move(ResultMap->begin()->second); @@ -1941,21 +1931,10 @@ ExecutionSession::lookup(const JITDylibSearchList &SearchOrder, return ResultMap.takeError(); } -Expected -ExecutionSession::lookup(ArrayRef SearchOrder, - SymbolStringPtr Name) { - SymbolNameSet Names({Name}); - - JITDylibSearchList FullSearchOrder(SearchOrder.size()); - for (auto *JD : SearchOrder) - FullSearchOrder.push_back({JD, false}); - - return lookup(FullSearchOrder, Name); -} - -Expected -ExecutionSession::lookup(ArrayRef SearchOrder, StringRef Name) { - return lookup(SearchOrder, intern(Name)); +Expected ExecutionSession::lookup(const JITDylibList &JDs, + StringRef Name, + bool MatchNonExported) { + return lookup(JDs, intern(Name), MatchNonExported); } void ExecutionSession::dump(raw_ostream &OS) { diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp index 3a1984e..21a604f 100644 --- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp @@ -129,8 +129,9 @@ Error CtorDtorRunner::run() { } auto &ES = JD.getExecutionSession(); - if (auto CtorDtorMap = ES.lookup({{&JD, true}}, std::move(Names), - NoDependenciesToRegister, true)) { + if (auto CtorDtorMap = + ES.lookup({&JD}, std::move(Names), NoDependenciesToRegister, true, + nullptr, true)) { for (auto &KV : CtorDtorsByPriority) { for (auto &Name : KV.second) { assert(CtorDtorMap->count(Name) && "No entry for Name"); diff --git a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp index 205821b..c10d15a 100644 --- a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp +++ b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp @@ -101,7 +101,7 @@ JITTargetAddress JITCompileCallbackManager::executeCompileCallback( Name = I->second; } - if (auto Sym = ES.lookup({{&CallbacksJD, true}}, Name)) + if (auto Sym = ES.lookup({&CallbacksJD}, Name, true)) return Sym->getAddress(); else { llvm::dbgs() << "Didn't find callback.\n"; diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index 8486fe4..ac71a5e 100644 --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -76,7 +76,7 @@ Error LLJIT::addObjectFile(JITDylib &JD, std::unique_ptr Obj) { Expected LLJIT::lookupLinkerMangled(JITDylib &JD, StringRef Name) { - return ES->lookup({{&JD, true}}, ES->intern(Name)); + return ES->lookup({&JD}, ES->intern(Name)); } LLJIT::LLJIT(std::unique_ptr ES, @@ -144,13 +144,13 @@ void LLJIT::recordCtorDtors(Module &M) { } Expected> -LLLazyJIT::Create(JITTargetMachineBuilder JTMB, DataLayout DL, - JITTargetAddress ErrorAddr, unsigned NumCompileThreads) { + LLLazyJIT::Create(JITTargetMachineBuilder JTMB, DataLayout DL, + unsigned NumCompileThreads) { auto ES = llvm::make_unique(); const Triple &TT = JTMB.getTargetTriple(); - auto LCTMgr = createLocalLazyCallThroughManager(TT, *ES, ErrorAddr); + auto LCTMgr = createLocalLazyCallThroughManager(TT, *ES, 0); if (!LCTMgr) return LCTMgr.takeError(); diff --git a/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp b/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp index ba8e2a9..af4c508 100644 --- a/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp @@ -52,8 +52,8 @@ LazyCallThroughManager::callThroughToSymbol(JITTargetAddress TrampolineAddr) { SymbolName = I->second.second; } - auto LookupResult = ES.lookup({{SourceJD, true}}, {SymbolName}, - NoDependenciesToRegister, true); + auto LookupResult = ES.lookup({SourceJD}, {SymbolName}, + NoDependenciesToRegister, true, nullptr, true); if (!LookupResult) { ES.reportError(LookupResult.takeError()); diff --git a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp index 299d761..616251c 100644 --- a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp @@ -50,11 +50,10 @@ public: MR.addDependenciesForAll(Deps); }; - JITDylibSearchList SearchOrder; - MR.getTargetJITDylib().withSearchOrderDo( - [&](const JITDylibSearchList &JDs) { SearchOrder = JDs; }); - ES.lookup(SearchOrder, InternedSymbols, OnResolvedWithUnwrap, OnReady, - RegisterDependencies); + MR.getTargetJITDylib().withSearchOrderDo([&](const JITDylibList &JDs) { + ES.lookup(JDs, InternedSymbols, OnResolvedWithUnwrap, OnReady, + RegisterDependencies, &MR.getTargetJITDylib()); + }); } Expected getResponsibilitySet(const LookupSet &Symbols) { diff --git a/llvm/test/ExecutionEngine/OrcLazy/Inputs/hidden-definitions.ll b/llvm/test/ExecutionEngine/OrcLazy/Inputs/hidden-definitions.ll deleted file mode 100644 index 8d1f4b9..0000000 --- a/llvm/test/ExecutionEngine/OrcLazy/Inputs/hidden-definitions.ll +++ /dev/null @@ -1,6 +0,0 @@ -@bar = hidden global i32 0 - -define hidden i32 @foo() { -entry: - ret i32 0 -} diff --git a/llvm/test/ExecutionEngine/OrcLazy/hidden-visibility.ll b/llvm/test/ExecutionEngine/OrcLazy/hidden-visibility.ll deleted file mode 100644 index 199fd64..0000000 --- a/llvm/test/ExecutionEngine/OrcLazy/hidden-visibility.ll +++ /dev/null @@ -1,17 +0,0 @@ -; RUN: lli -jit-kind=orc-lazy -extra-module %p/Inputs/hidden-definitions.ll %s -; RUN: not lli -jit-kind=orc-lazy -jd libFoo -extra-module %p/Inputs/hidden-definitions.ll %s -; -; Check that hidden symbols in another module are visible when the module is -; added to the same JITDylib, and not visible if it is added to a different -; JITDylib. - -@bar = external global i32 -declare i32 @foo() - -define i32 @main(i32 %argc, i8** nocapture readnone %argv) { -entry: - %0 = call i32() @foo() - %1 = load i32, i32* @bar - %2 = add i32 %0, %1 - ret i32 %2 -} diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index c3c57e2..f4585dc 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -115,11 +115,6 @@ namespace { "rather than individual functions"), cl::init(false)); - cl::list - JITDylibs("jd", - cl::desc("Specifies the JITDylib to be used for any subsequent " - "-extra-module arguments.")); - // The MCJIT supports building for a target address space separate from // the JIT compilation process. Use a forked process and a copying // memory manager with IPC to execute using this functionality. @@ -754,8 +749,6 @@ static orc::IRTransformLayer::TransformFunction createDebugDumper() { llvm_unreachable("Unknown DumpKind"); } -static void exitOnLazyCallThroughFailure() { exit(1); } - int runOrcLazyJIT(const char *ProgName) { // Start setting up the JIT environment. @@ -785,11 +778,7 @@ int runOrcLazyJIT(const char *ProgName) { : None); DataLayout DL = ExitOnErr(JTMB.getDefaultDataLayoutForTarget()); - - auto J = ExitOnErr(orc::LLLazyJIT::Create( - std::move(JTMB), DL, - pointerToJITTargetAddress(exitOnLazyCallThroughFailure), - LazyJITCompileThreads)); + auto J = ExitOnErr(orc::LLLazyJIT::Create(std::move(JTMB), DL, LazyJITCompileThreads)); if (PerModuleLazy) J->setPartitionFunction(orc::CompileOnDemandLayer::compileWholeModule); @@ -814,32 +803,13 @@ int runOrcLazyJIT(const char *ProgName) { // Add the main module. ExitOnErr(J->addLazyIRModule(std::move(MainModule))); - // Create JITDylibs and add any extra modules. - { - // Create JITDylibs, keep a map from argument index to dylib. We will use - // -extra-module argument indexes to determine what dylib to use for each - // -extra-module. - std::map IdxToDylib; - IdxToDylib[0] = &J->getMainJITDylib(); - for (auto JDItr = JITDylibs.begin(), JDEnd = JITDylibs.end(); - JDItr != JDEnd; ++JDItr) { - IdxToDylib[JITDylibs.getPosition(JDItr - JITDylibs.begin())] = - &J->createJITDylib(*JDItr); - } + // Add any extra modules. + for (auto &ModulePath : ExtraModules) { + auto M = parseIRFile(ModulePath, Err, *TSCtx.getContext()); + if (!M) + reportError(Err, ProgName); - for (auto EMItr = ExtraModules.begin(), EMEnd = ExtraModules.end(); - EMItr != EMEnd; ++EMItr) { - auto M = parseIRFile(*EMItr, Err, *TSCtx.getContext()); - if (!M) - reportError(Err, ProgName); - - auto EMIdx = ExtraModules.getPosition(EMItr - ExtraModules.begin()); - assert(EMIdx != 0 && "ExtraModule should have index > 0"); - auto JDItr = std::prev(IdxToDylib.lower_bound(EMIdx)); - auto &JD = *JDItr->second; - ExitOnErr( - J->addLazyIRModule(JD, orc::ThreadSafeModule(std::move(M), TSCtx))); - } + ExitOnErr(J->addLazyIRModule(orc::ThreadSafeModule(std::move(M), TSCtx))); } // Add the objects. @@ -867,8 +837,6 @@ int runOrcLazyJIT(const char *ProgName) { AltEntryThreads.push_back(std::thread([EntryPoint]() { EntryPoint(); })); } - J->getExecutionSession().dump(llvm::dbgs()); - // Run main. auto MainSym = ExitOnErr(J->lookup("main")); typedef int (*MainFnPtr)(int, const char *[]); diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index 1444ba7..1ccc475 100644 --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -48,8 +48,7 @@ TEST_F(CoreAPIsStandardTest, BasicSuccessfulLookup) { FooMR = std::make_shared(std::move(R)); }))); - ES.lookup({{&JD, false}}, {Foo}, OnResolution, OnReady, - NoDependenciesToRegister); + ES.lookup({&JD}, {Foo}, OnResolution, OnReady, NoDependenciesToRegister); EXPECT_FALSE(OnResolutionRun) << "Should not have been resolved yet"; EXPECT_FALSE(OnReadyRun) << "Should not have been marked ready yet"; @@ -102,8 +101,7 @@ TEST_F(CoreAPIsStandardTest, EmptyLookup) { OnReadyRun = true; }; - ES.lookup({{&JD, false}}, {}, OnResolution, OnReady, - NoDependenciesToRegister); + ES.lookup({&JD}, {}, OnResolution, OnReady, NoDependenciesToRegister); EXPECT_TRUE(OnResolvedRun) << "OnResolved was not run for empty query"; EXPECT_TRUE(OnReadyRun) << "OnReady was not run for empty query"; @@ -150,7 +148,7 @@ TEST_F(CoreAPIsStandardTest, RemoveSymbolsTest) { bool OnResolvedRun = false; bool OnReadyRun = false; - ES.lookup({{&JD, false}}, {Foo, Baz}, + ES.lookup({&JD}, {Foo, Baz}, [&](Expected Result) { EXPECT_TRUE(!!Result) << "OnResolved failed unexpectedly"; consumeError(Result.takeError()); @@ -231,8 +229,7 @@ TEST_F(CoreAPIsStandardTest, LookupWithHiddenSymbols) { auto &JD2 = ES.createJITDylib("JD2"); cantFail(JD2.define(absoluteSymbols({{Bar, QuxSym}}))); - /// Try a blocking lookup. - auto Result = cantFail(ES.lookup({{&JD, false}, {&JD2, false}}, {Foo, Bar})); + auto Result = cantFail(ES.lookup({&JD, &JD2}, {Foo, Bar})); EXPECT_EQ(Result.size(), 2U) << "Unexpected number of results"; EXPECT_EQ(Result.count(Foo), 1U) << "Missing result for \"Foo\""; @@ -278,7 +275,7 @@ TEST_F(CoreAPIsStandardTest, TestBasicAliases) { {Qux, {Bar, JITSymbolFlags::Weak}}}))); cantFail(JD.define(absoluteSymbols({{Qux, QuxSym}}))); - auto Result = ES.lookup({{&JD, false}}, {Baz, Qux}); + auto Result = ES.lookup({&JD}, {Baz, Qux}); EXPECT_TRUE(!!Result) << "Unexpected lookup failure"; EXPECT_EQ(Result->count(Baz), 1U) << "No result for \"baz\""; EXPECT_EQ(Result->count(Qux), 1U) << "No result for \"qux\""; @@ -293,7 +290,7 @@ TEST_F(CoreAPIsStandardTest, TestChainedAliases) { cantFail(JD.define(symbolAliases( {{Baz, {Bar, BazSym.getFlags()}}, {Bar, {Foo, BarSym.getFlags()}}}))); - auto Result = ES.lookup({{&JD, false}}, {Bar, Baz}); + auto Result = ES.lookup({&JD}, {Bar, Baz}); EXPECT_TRUE(!!Result) << "Unexpected lookup failure"; EXPECT_EQ(Result->count(Bar), 1U) << "No result for \"bar\""; EXPECT_EQ(Result->count(Baz), 1U) << "No result for \"baz\""; @@ -312,7 +309,7 @@ TEST_F(CoreAPIsStandardTest, TestBasicReExports) { cantFail(JD2.define(reexports(JD, {{Bar, {Foo, BarSym.getFlags()}}}))); - auto Result = cantFail(ES.lookup({{&JD2, false}}, Bar)); + auto Result = cantFail(ES.lookup({&JD2}, Bar)); EXPECT_EQ(Result.getAddress(), FooSym.getAddress()) << "Re-export Bar for symbol Foo should match FooSym's address"; } @@ -338,7 +335,7 @@ TEST_F(CoreAPIsStandardTest, TestThatReExportsDontUnnecessarilyMaterialize) { cantFail(JD2.define(reexports( JD, {{Baz, {Foo, BazSym.getFlags()}}, {Qux, {Bar, QuxSym.getFlags()}}}))); - auto Result = cantFail(ES.lookup({{&JD2, false}}, Baz)); + auto Result = cantFail(ES.lookup({&JD2}, Baz)); EXPECT_EQ(Result.getAddress(), FooSym.getAddress()) << "Re-export Baz for symbol Foo should match FooSym's address"; @@ -353,13 +350,13 @@ TEST_F(CoreAPIsStandardTest, TestReexportsGenerator) { auto Filter = [this](SymbolStringPtr Name) { return Name != Bar; }; - JD.setGenerator(ReexportsGenerator(JD2, false, Filter)); + JD.setGenerator(ReexportsGenerator(JD2, Filter)); auto Flags = JD.lookupFlags({Foo, Bar, Baz}); EXPECT_EQ(Flags.size(), 1U) << "Unexpected number of results"; EXPECT_EQ(Flags[Foo], FooSym.getFlags()) << "Unexpected flags for Foo"; - auto Result = cantFail(ES.lookup({{&JD, false}}, Foo)); + auto Result = cantFail(ES.lookup({&JD}, Foo)); EXPECT_EQ(Result.getAddress(), FooSym.getAddress()) << "Incorrect reexported symbol address"; @@ -380,7 +377,7 @@ TEST_F(CoreAPIsStandardTest, TestTrivialCircularDependency) { FooReady = true; }; - ES.lookup({{&JD, false}}, {Foo}, std::move(OnResolution), std::move(OnReady), + ES.lookup({&JD}, {Foo}, std::move(OnResolution), std::move(OnReady), NoDependenciesToRegister); FooR->resolve({{Foo, FooSym}}); @@ -437,8 +434,8 @@ TEST_F(CoreAPIsStandardTest, TestCircularDependenceInOneJITDylib) { // Issue a lookup for Foo. Use NoDependenciesToRegister: We're going to add // the dependencies manually below. - ES.lookup({{&JD, false}}, {Foo}, std::move(OnFooResolution), - std::move(OnFooReady), NoDependenciesToRegister); + ES.lookup({&JD}, {Foo}, std::move(OnFooResolution), std::move(OnFooReady), + NoDependenciesToRegister); bool BarResolved = false; bool BarReady = false; @@ -452,8 +449,8 @@ TEST_F(CoreAPIsStandardTest, TestCircularDependenceInOneJITDylib) { BarReady = true; }; - ES.lookup({{&JD, false}}, {Bar}, std::move(OnBarResolution), - std::move(OnBarReady), NoDependenciesToRegister); + ES.lookup({&JD}, {Bar}, std::move(OnBarResolution), std::move(OnBarReady), + NoDependenciesToRegister); bool BazResolved = false; bool BazReady = false; @@ -468,8 +465,8 @@ TEST_F(CoreAPIsStandardTest, TestCircularDependenceInOneJITDylib) { BazReady = true; }; - ES.lookup({{&JD, false}}, {Baz}, std::move(OnBazResolution), - std::move(OnBazReady), NoDependenciesToRegister); + ES.lookup({&JD}, {Baz}, std::move(OnBazResolution), std::move(OnBazReady), + NoDependenciesToRegister); // Add a circular dependency: Foo -> Bar, Bar -> Baz, Baz -> Foo. FooR->addDependenciesForAll({{&JD, SymbolNameSet({Bar})}}); @@ -591,7 +588,7 @@ TEST_F(CoreAPIsStandardTest, AddAndMaterializeLazySymbol) { OnReadyRun = true; }; - ES.lookup({{&JD, false}}, Names, std::move(OnResolution), std::move(OnReady), + ES.lookup({&JD}, Names, std::move(OnResolution), std::move(OnReady), NoDependenciesToRegister); EXPECT_TRUE(FooMaterialized) << "Foo was not materialized"; @@ -640,7 +637,7 @@ TEST_F(CoreAPIsStandardTest, TestBasicWeakSymbolMaterialization) { OnReadyRun = true; }; - ES.lookup({{&JD, false}}, {Bar}, std::move(OnResolution), std::move(OnReady), + ES.lookup({&JD}, {Bar}, std::move(OnResolution), std::move(OnReady), NoDependenciesToRegister); EXPECT_TRUE(OnResolvedRun) << "OnResolved not run"; @@ -669,13 +666,13 @@ TEST_F(CoreAPIsStandardTest, DefineMaterializingSymbol) { }); cantFail(JD.define(MU)); - cantFail(ES.lookup({{&JD, false}}, Foo)); + cantFail(ES.lookup({&JD}, Foo)); // Assert that materialization is complete by now. ExpectNoMoreMaterialization = true; // Look up bar to verify that no further materialization happens. - auto BarResult = cantFail(ES.lookup({{&JD, false}}, Bar)); + auto BarResult = cantFail(ES.lookup({&JD}, Bar)); EXPECT_EQ(BarResult.getAddress(), BarSym.getAddress()) << "Expected Bar == BarSym"; } @@ -688,7 +685,7 @@ TEST_F(CoreAPIsStandardTest, GeneratorTest) { return SymbolNameSet({Bar}); }); - auto Result = cantFail(ES.lookup({{&JD, false}}, {Foo, Bar})); + auto Result = cantFail(ES.lookup({&JD}, {Foo, Bar})); EXPECT_EQ(Result.count(Bar), 1U) << "Expected to find fallback def for 'bar'"; EXPECT_EQ(Result[Bar].getAddress(), BarSym.getAddress()) @@ -704,7 +701,7 @@ TEST_F(CoreAPIsStandardTest, FailResolution) { cantFail(JD.define(MU)); SymbolNameSet Names({Foo, Bar}); - auto Result = ES.lookup({{&JD, false}}, Names); + auto Result = ES.lookup({&JD}, Names); EXPECT_FALSE(!!Result) << "Expected failure"; if (!Result) { @@ -736,7 +733,7 @@ TEST_F(CoreAPIsStandardTest, TestLookupWithUnthreadedMaterialization) { cantFail(JD.define(MU)); - auto FooLookupResult = cantFail(ES.lookup({{&JD, false}}, Foo)); + auto FooLookupResult = cantFail(ES.lookup({&JD}, Foo)); EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress()) << "lookup returned an incorrect address"; @@ -757,7 +754,7 @@ TEST_F(CoreAPIsStandardTest, TestLookupWithThreadedMaterialization) { cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); - auto FooLookupResult = cantFail(ES.lookup({{&JD, false}}, Foo)); + auto FooLookupResult = cantFail(ES.lookup({&JD}, Foo)); EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress()) << "lookup returned an incorrect address"; @@ -805,14 +802,14 @@ TEST_F(CoreAPIsStandardTest, TestGetRequestedSymbolsAndReplace) { EXPECT_FALSE(FooMaterialized) << "Foo should not be materialized yet"; EXPECT_FALSE(BarMaterialized) << "Bar should not be materialized yet"; - auto FooSymResult = cantFail(ES.lookup({{&JD, false}}, Foo)); + auto FooSymResult = cantFail(ES.lookup({&JD}, Foo)); EXPECT_EQ(FooSymResult.getAddress(), FooSym.getAddress()) << "Address mismatch for Foo"; EXPECT_TRUE(FooMaterialized) << "Foo should be materialized now"; EXPECT_FALSE(BarMaterialized) << "Bar still should not be materialized"; - auto BarSymResult = cantFail(ES.lookup({{&JD, false}}, Bar)); + auto BarSymResult = cantFail(ES.lookup({&JD}, Bar)); EXPECT_EQ(BarSymResult.getAddress(), BarSym.getAddress()) << "Address mismatch for Bar"; EXPECT_TRUE(BarMaterialized) << "Bar should be materialized now"; @@ -832,7 +829,7 @@ TEST_F(CoreAPIsStandardTest, TestMaterializationResponsibilityDelegation) { cantFail(JD.define(MU)); - auto Result = ES.lookup({{&JD, false}}, {Foo, Bar}); + auto Result = ES.lookup({&JD}, {Foo, Bar}); EXPECT_TRUE(!!Result) << "Result should be a success value"; EXPECT_EQ(Result->count(Foo), 1U) << "\"Foo\" entry missing"; @@ -864,7 +861,7 @@ TEST_F(CoreAPIsStandardTest, TestMaterializeWeakSymbol) { auto OnReady = [](Error Err) { cantFail(std::move(Err)); }; - ES.lookup({{&JD, false}}, {Foo}, std::move(OnResolution), std::move(OnReady), + ES.lookup({&JD}, {Foo}, std::move(OnResolution), std::move(OnReady), NoDependenciesToRegister); auto MU2 = llvm::make_unique( diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp index b6c362b..1660670 100644 --- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp @@ -66,7 +66,7 @@ static bool testSetProcessAllSections(std::unique_ptr Obj, ObjLayer.setProcessAllSections(ProcessAllSections); cantFail(ObjLayer.add(JD, std::move(Obj), ES.allocateVModule())); - ES.lookup({{&JD, false}}, {Foo}, OnResolveDoNothing, OnReadyDoNothing, + ES.lookup({&JD}, {Foo}, OnResolveDoNothing, OnReadyDoNothing, NoDependenciesToRegister); return DebugSectionSeen; } @@ -157,8 +157,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestOverrideObjectFlags) { ObjLayer.setOverrideObjectFlagsWithResponsibilityFlags(true); cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule())); - ES.lookup({{&JD, false}}, {Foo}, - [](Expected R) { cantFail(std::move(R)); }, + ES.lookup({&JD}, {Foo}, [](Expected R) { cantFail(std::move(R)); }, [](Error Err) { cantFail(std::move(Err)); }, NoDependenciesToRegister); } @@ -220,8 +219,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestAutoClaimResponsibilityForSymbols) { ObjLayer.setAutoClaimResponsibilityForObjectSymbols(true); cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule())); - ES.lookup({{&JD, false}}, {Foo}, - [](Expected R) { cantFail(std::move(R)); }, + ES.lookup({&JD}, {Foo}, [](Expected R) { cantFail(std::move(R)); }, [](Error Err) { cantFail(std::move(Err)); }, NoDependenciesToRegister); } -- 2.7.4