[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
This commit is contained in:
Lang Hames 2018-06-17 16:59:52 +00:00
parent b0e986f88e
commit 11adecfb2c
1 changed files with 12 additions and 2 deletions

View File

@ -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);