diff --git a/include/llvm/ExecutionEngine/Orc/Layer.h b/include/llvm/ExecutionEngine/Orc/Layer.h index 18dd4573119..ed839b518b7 100644 --- a/include/llvm/ExecutionEngine/Orc/Layer.h +++ b/include/llvm/ExecutionEngine/Orc/Layer.h @@ -63,11 +63,10 @@ public: protected: std::unique_ptr M; + std::map SymbolToDefinition; private: void discard(const VSO &V, SymbolStringPtr Name) override; - - std::map Discardable; }; /// MaterializationUnit that materializes modules by calling the 'emit' method diff --git a/lib/ExecutionEngine/Orc/Layer.cpp b/lib/ExecutionEngine/Orc/Layer.cpp index 346dde4f7a8..1927bce45d4 100644 --- a/lib/ExecutionEngine/Orc/Layer.cpp +++ b/lib/ExecutionEngine/Orc/Layer.cpp @@ -46,17 +46,19 @@ IRMaterializationUnit::IRMaterializationUnit(ExecutionSession &ES, !G.hasAvailableExternallyLinkage()) { auto MangledName = Mangle(G.getName()); SymbolFlags[MangledName] = JITSymbolFlags::fromGlobalValue(G); - Discardable[MangledName] = &G; + SymbolToDefinition[MangledName] = &G; } } } void IRMaterializationUnit::discard(const VSO &V, SymbolStringPtr Name) { - auto I = Discardable.find(Name); - assert(I != Discardable.end() && + auto I = SymbolToDefinition.find(Name); + assert(I != SymbolToDefinition.end() && "Symbol not provided by this MU, or previously discarded"); + assert(!I->second->isDeclaration() && + "Discard should only apply to definitions"); I->second->setLinkage(GlobalValue::AvailableExternallyLinkage); - Discardable.erase(I); + SymbolToDefinition.erase(I); } BasicIRLayerMaterializationUnit::BasicIRLayerMaterializationUnit(