SILModule: track opened archetypes per function.

In theory we could map opened archetypes per module because opened archetypes _should_ be unique across the module.
But currently in some rare cases SILGen re-uses the same opened archetype in multiple functions.
The fix is to add the SILFunction to the map's key.
That also requires that we update the map whenever instructions are moved from one function to another.

This fixes a compiler crash.

rdar://76916931
This commit is contained in:
Erik Eckstein
2021-04-23 14:13:26 +02:00
parent 619226b480
commit eecb9fa975
8 changed files with 118 additions and 28 deletions

View File

@@ -76,7 +76,7 @@ static void buildTypeDependentOperands(
SmallVectorImpl<SILValue> &TypeDependentOperands, SILFunction &F) {
for (auto archetype : OpenedArchetypes) {
SILValue def = F.getModule().getOpenedArchetypeDef(archetype);
SILValue def = F.getModule().getOpenedArchetypeDef(archetype, &F);
assert(def->getFunction() == &F &&
"def of opened archetype is in wrong function");
TypeDependentOperands.push_back(def);