From b7aa1cc3a43db83560edb59dcbde7bd5e03683fe Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 25 Feb 2020 16:04:41 -0800 Subject: [PATCH] [ORC] Remove the JITDylib::SymbolTableEntry::isInMaterializingState() method. It was being used inconsistently. Uses have been replaced with direct checks on the symbol state. --- llvm/include/llvm/ExecutionEngine/Orc/Core.h | 5 ----- llvm/lib/ExecutionEngine/Orc/Core.cpp | 19 ++++++++++++------- llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index 0d2cdc5..1462176 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -1019,11 +1019,6 @@ private: JITSymbolFlags getFlags() const { return Flags; } SymbolState getState() const { return static_cast(State); } - bool isInMaterializationPhase() const { - return getState() == SymbolState::Materializing || - getState() == SymbolState::Resolved; - } - bool hasMaterializerAttached() const { return MaterializerAttached; } bool isPendingRemoval() const { return PendingRemoval; } diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp index 992389a..e00c753 100644 --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -895,8 +895,8 @@ void JITDylib::replace(std::unique_ptr MU) { for (auto &KV : MU->getSymbols()) { auto SymI = Symbols.find(KV.first); assert(SymI != Symbols.end() && "Replacing unknown symbol"); - assert(SymI->second.isInMaterializationPhase() && - "Can not call replace on a symbol that is not materializing"); + assert(SymI->second.getState() == SymbolState::Materializing && + "Can not replace a symbol that ha is not materializing"); assert(!SymI->second.hasMaterializerAttached() && "Symbol should not have materializer attached already"); assert(UnmaterializedInfos.count(KV.first) == 0 && @@ -943,7 +943,9 @@ JITDylib::getRequestedSymbols(const SymbolFlagsMap &SymbolFlags) const { for (auto &KV : SymbolFlags) { assert(Symbols.count(KV.first) && "JITDylib does not cover this symbol?"); - assert(Symbols.find(KV.first)->second.isInMaterializationPhase() && + assert(Symbols.find(KV.first)->second.getState() != + SymbolState::NeverSearched && + Symbols.find(KV.first)->second.getState() != SymbolState::Ready && "getRequestedSymbols can only be called for symbols that have " "started materializing"); auto I = MaterializingInfos.find(KV.first); @@ -961,7 +963,7 @@ JITDylib::getRequestedSymbols(const SymbolFlagsMap &SymbolFlags) const { void JITDylib::addDependencies(const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies) { assert(Symbols.count(Name) && "Name not in symbol table"); - assert(Symbols[Name].isInMaterializationPhase() && + assert(Symbols[Name].getState() < SymbolState::Emitted && "Can not add dependencies for a symbol that is not materializing"); LLVM_DEBUG({ @@ -1432,7 +1434,8 @@ Error JITDylib::remove(const SymbolNameSet &Names) { } // Note symbol materializing. - if (I->second.isInMaterializationPhase()) { + if (I->second.getState() != SymbolState::NeverSearched && + I->second.getState() != SymbolState::Ready) { Materializing.insert(Name); continue; } @@ -1600,7 +1603,8 @@ Error JITDylib::lodgeQueryImpl(MaterializationUnitList &MUs, // Add the query to the PendingQueries list and continue, deleting the // element. - assert(SymI->second.isInMaterializationPhase() && + assert(SymI->second.getState() != SymbolState::NeverSearched && + SymI->second.getState() != SymbolState::Ready && "By this line the symbol should be materializing"); auto &MI = MaterializingInfos[Name]; MI.addQuery(Q); @@ -1720,7 +1724,8 @@ bool JITDylib::lookupImpl( } // Add the query to the PendingQueries list. - assert(SymI->second.isInMaterializationPhase() && + assert(SymI->second.getState() != SymbolState::NeverSearched && + SymI->second.getState() != SymbolState::Ready && "By this line the symbol should be materializing"); auto &MI = MaterializingInfos[Name]; MI.addQuery(Q); diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index 171ff37..ef97f2c 100644 --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -166,7 +166,7 @@ TEST_F(CoreAPIsStandardTest, RemoveSymbolsTest) { // Attempt 3: Search now that all symbols are fully materialized // (Foo, Baz), or not yet materialized (Bar). auto Err = JD.remove({Foo, Bar, Baz}); - EXPECT_FALSE(!!Err) << "Expected failure"; + EXPECT_FALSE(!!Err) << "Expected success"; } EXPECT_TRUE(BarDiscarded) << "\"Bar\" should have been discarded"; -- 2.7.4