diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index 8f920edb4fd..591aefb910e 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -488,8 +488,6 @@ void VSO::resolve(const SymbolMap &Resolved) { for (const auto &KV : Resolved) { auto &Name = KV.first; auto Sym = KV.second; - JITSymbolFlags ResolvedFlags = Sym.getFlags(); - ResolvedFlags &= ~JITSymbolFlags::Weak; assert(!Sym.getFlags().isLazy() && !Sym.getFlags().isMaterializing() && "Materializing flags should be managed internally"); @@ -502,11 +500,14 @@ void VSO::resolve(const SymbolMap &Resolved) { "Symbol should be materializing"); assert(I->second.getAddress() == 0 && "Symbol has already been resolved"); - assert(ResolvedFlags == - JITSymbolFlags::stripTransientFlags(I->second.getFlags()) && + assert((Sym.getFlags() & ~JITSymbolFlags::Weak) == + (JITSymbolFlags::stripTransientFlags(I->second.getFlags()) & + ~JITSymbolFlags::Weak) && "Resolved flags should match the declared flags"); // Once resolved, symbols can never be weak. + JITSymbolFlags ResolvedFlags = Sym.getFlags(); + ResolvedFlags &= ~JITSymbolFlags::Weak; ResolvedFlags |= JITSymbolFlags::Materializing; I->second = JITEvaluatedSymbol(Sym.getAddress(), ResolvedFlags); @@ -780,7 +781,6 @@ VSO::lookupImpl(std::shared_ptr &Q, for (auto &KV : MU->getSymbols()) { auto SymK = Symbols.find(KV.first); auto Flags = SymK->second.getFlags(); - Flags &= ~JITSymbolFlags::Weak; Flags &= ~JITSymbolFlags::Lazy; Flags |= JITSymbolFlags::Materializing; SymK->second.setFlags(Flags); @@ -871,7 +871,8 @@ Error VSO::defineImpl(MaterializationUnit &MU) { if (!Added) { if (KV.second.isStrong()) { - if (EntryItr->second.getFlags().isStrong()) + if (EntryItr->second.getFlags().isStrong() || + (EntryItr->second.getFlags() & JITSymbolFlags::Materializing)) Duplicates.insert(KV.first); else ExistingDefsOverridden.push_back(EntryItr); @@ -905,8 +906,6 @@ Error VSO::defineImpl(MaterializationUnit &MU) { !ExistingDefItr->second.getFlags().isMaterializing() && "Overridden existing def should be in the Lazy state"); - ExistingDefItr->second.getFlags() &= ~JITSymbolFlags::Weak; - auto UMII = UnmaterializedInfos.find(ExistingDefItr->first); assert(UMII != UnmaterializedInfos.end() && "Overridden existing def should have an UnmaterializedInfo");