From 11adecfb2ca7f97551aaa0df32507bf7c432ba18 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sun, 17 Jun 2018 16:59:52 +0000 Subject: [PATCH] [ORC] In MaterializationResponsibility, only maintain the Materializing flag on symbols in debug mode. The MaterializationResponsibility class hijacks the Materializing flag to track symbols that have not yet been resolved in order to guard against redundant resolution. Since this is an API contract check and only enforced in debug mode there is no reason to maintain the flag state in release mode. llvm-svn: 334909 --- llvm/lib/ExecutionEngine/Orc/Core.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp index 894e210..96baf62 100644 --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -228,8 +228,10 @@ MaterializationResponsibility::MaterializationResponsibility( : V(V), SymbolFlags(std::move(SymbolFlags)) { assert(!this->SymbolFlags.empty() && "Materializing nothing?"); +#ifndef NDEBUG for (auto &KV : this->SymbolFlags) KV.second |= JITSymbolFlags::Materializing; +#endif } MaterializationResponsibility::~MaterializationResponsibility() { @@ -242,15 +244,21 @@ SymbolNameSet MaterializationResponsibility::getRequestedSymbols() { } void MaterializationResponsibility::resolve(const SymbolMap &Symbols) { +#ifndef NDEBUG for (auto &KV : Symbols) { auto I = SymbolFlags.find(KV.first); assert(I != SymbolFlags.end() && "Resolving symbol outside this responsibility set"); assert(I->second.isMaterializing() && "Duplicate resolution"); I->second &= ~JITSymbolFlags::Materializing; - assert(KV.second.getFlags() == I->second && - "Resolving symbol with incorrect flags"); + if (I->second.isWeak()) + assert(I->second == (KV.second.getFlags() | JITSymbolFlags::Weak) && + "Resolving symbol with incorrect flags"); + else + assert(I->second == KV.second.getFlags() && + "Resolving symbol with incorrect flags"); } +#endif V.resolve(Symbols); } @@ -274,7 +282,9 @@ Error MaterializationResponsibility::defineMaterializing( // symbol error. for (auto &KV : NewSymbolFlags) { auto I = SymbolFlags.insert(KV).first; +#ifndef NDEBUG I->second |= JITSymbolFlags::Materializing; +#endif } return V.defineMaterializing(NewSymbolFlags); -- 2.7.4