Skip to content

Commit 6184bb6

Browse files
committed
IRGen: Traverse function type to find opaque archetypes
1 parent 7d0bcda commit 6184bb6

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,30 +1341,25 @@ void IRGenerator::emitDynamicReplacements() {
13411341
// Collect all the type metadata accessor replacements.
13421342
SmallVector<OpaqueTypeArchetypeType *, 8> newFuncTypes;
13431343
SmallVector<OpaqueTypeArchetypeType *, 8> origFuncTypes;
1344+
llvm::SmallSet<OpaqueTypeArchetypeType *, 8> newUniqueOpaqueTypes;
1345+
llvm::SmallSet<OpaqueTypeArchetypeType *, 8> origUniqueOpaqueTypes;
13441346
for (auto *newFunc : DynamicReplacements) {
13451347
if (!newFunc->getLoweredFunctionType()->hasOpaqueArchetype())
13461348
continue;
1349+
CanType(newFunc->getLoweredFunctionType()).visit([&](CanType ty) {
1350+
if (auto opaque = ty->getAs<OpaqueTypeArchetypeType>())
1351+
if (newUniqueOpaqueTypes.insert(opaque).second)
1352+
newFuncTypes.push_back(opaque);
1353+
});
13471354
auto *origFunc = newFunc->getDynamicallyReplacedFunction();
13481355
assert(origFunc);
13491356
assert(origFunc->getLoweredFunctionType()->hasOpaqueArchetype());
1350-
auto conv = newFunc->getConventions();
1351-
// Storage setters don't have indirect results.
1352-
if (!conv.hasIndirectSILResults())
1353-
continue;
1354-
for (auto res : conv.getIndirectSILResultTypes()) {
1355-
if (!res.getASTType()->hasOpaqueArchetype())
1356-
continue;
1357-
newFuncTypes.push_back(
1358-
res.getASTType()->getAs<OpaqueTypeArchetypeType>());
1359-
}
1360-
conv = origFunc->getConventions();
1361-
assert(conv.hasIndirectSILResults());
1362-
for (auto res : conv.getIndirectSILResultTypes()) {
1363-
if (!res.getASTType()->hasOpaqueArchetype())
1364-
continue;
1365-
origFuncTypes.push_back(
1366-
res.getASTType()->getAs<OpaqueTypeArchetypeType>());
1367-
}
1357+
CanType(origFunc->getLoweredFunctionType()).visit([&](CanType ty) {
1358+
if (auto opaque = ty->getAs<OpaqueTypeArchetypeType>())
1359+
if (origUniqueOpaqueTypes.insert(opaque).second)
1360+
origFuncTypes.push_back(opaque);
1361+
});
1362+
13681363
assert(origFuncTypes.size() == newFuncTypes.size());
13691364
}
13701365

0 commit comments

Comments
 (0)