Skip to content

Commit d03e5da

Browse files
committed
SIL: support calling SILModule::willDeleteInstruction twice for the same instruction.
This happens in AddressLowering.
1 parent 82e7e9a commit d03e5da

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/SIL/IR/SILModule.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,11 @@ void SILModule::willDeleteInstruction(SILInstruction *I) {
264264
if (const CanOpenedArchetypeType archeTy =
265265
svi->getDefinedOpenedArchetype()) {
266266
OpenedArchetypeKey key = {archeTy, svi->getFunction()};
267-
assert(RootOpenedArchetypeDefs.lookup(key) == svi &&
268-
"archetype def was not registered");
269-
RootOpenedArchetypeDefs.erase(key);
267+
// In case `willDeleteInstruction` is called twice for the same instruction,
268+
// we need to check if the archetype is really still in the map for this
269+
// instruction.
270+
if (RootOpenedArchetypeDefs.lookup(key) == svi)
271+
RootOpenedArchetypeDefs.erase(key);
270272
}
271273
}
272274
}

0 commit comments

Comments
 (0)