SIL: support calling SILModule::willDeleteInstruction twice for the same instruction.

This happens in AddressLowering.
This commit is contained in:
Erik Eckstein
2022-12-02 14:46:28 +01:00
parent 2ca9a3b9ce
commit 3b94b60420

View File

@@ -264,9 +264,11 @@ void SILModule::willDeleteInstruction(SILInstruction *I) {
if (const CanOpenedArchetypeType archeTy =
svi->getDefinedOpenedArchetype()) {
OpenedArchetypeKey key = {archeTy, svi->getFunction()};
assert(RootOpenedArchetypeDefs.lookup(key) == svi &&
"archetype def was not registered");
RootOpenedArchetypeDefs.erase(key);
// In case `willDeleteInstruction` is called twice for the same instruction,
// we need to check if the archetype is really still in the map for this
// instruction.
if (RootOpenedArchetypeDefs.lookup(key) == svi)
RootOpenedArchetypeDefs.erase(key);
}
}
}