SIL: introduce a PlaceholderValue and use it in the parser and deserializer.

... instead of a GlobalAddrInst.
This is cleaner and makes the handling of forward-referenced values in the deserializer a bit simpler.
This commit is contained in:
Erik Eckstein
2021-04-09 11:17:09 +02:00
parent 8e95ae8375
commit df2a89f3b3
10 changed files with 80 additions and 41 deletions

View File

@@ -500,8 +500,7 @@ SILParser::~SILParser() {
for (auto &Entry : ForwardRefLocalValues) {
if (ValueBase *dummyVal = LocalValues[Entry.first()]) {
dummyVal->replaceAllUsesWith(SILUndef::get(dummyVal->getType(), SILMod));
SILInstruction::destroy(cast<GlobalAddrInst>(dummyVal));
SILMod.deallocateInst(cast<GlobalAddrInst>(dummyVal));
::delete cast<PlaceholderValue>(dummyVal);
}
}
}
@@ -687,7 +686,7 @@ SILValue SILParser::getLocalValue(UnresolvedValueName Name, SILType Type,
// it until we see a real definition.
ForwardRefLocalValues[Name.Name] = Name.NameLoc;
Entry = new (SILMod) GlobalAddrInst(getDebugLoc(B, Loc), Type);
Entry = ::new PlaceholderValue(Type);
return Entry;
}
@@ -715,8 +714,7 @@ void SILParser::setLocalValue(ValueBase *Value, StringRef Name,
} else {
// Forward references only live here if they have a single result.
Entry->replaceAllUsesWith(Value);
SILInstruction::destroy(cast<GlobalAddrInst>(Entry));
SILMod.deallocateInst(cast<GlobalAddrInst>(Entry));
::delete cast<PlaceholderValue>(Entry);
}
Entry = Value;
return;