Skip to content

Commit 88fb887

Browse files
committed
SIL: Fix opaque type erasure after clearing [serialized] flags
After serialization, we no longer need to enforce the resilience boundary between inlinable and non-inlinable functions, so we make a pass over the SIL to clear [serialized] flags and substitute any opaque return types. This duplicated a bit of logic elsewhere and did so incorrectly. Remove the unnecessary code since SILCloner already has the right support for substituting opaque return types. Fixes rdar://problem/115355709.
1 parent 583c51a commit 88fb887

File tree

2 files changed

+18
-36
lines changed

2 files changed

+18
-36
lines changed

lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,6 @@ class MapOpaqueArchetypes : public SILCloner<MapOpaqueArchetypes> {
4040
clonedEntryBlock = fun.createBasicBlock();
4141
}
4242

43-
SILType remapType(SILType Ty) {
44-
if (!Ty.getASTType()->hasOpaqueArchetype() ||
45-
!getBuilder()
46-
.getTypeExpansionContext()
47-
.shouldLookThroughOpaqueTypeArchetypes())
48-
return Ty;
49-
50-
return getBuilder().getTypeLowering(Ty).getLoweredType().getCategoryType(
51-
Ty.getCategory());
52-
}
53-
54-
CanType remapASTType(CanType ty) {
55-
if (!ty->hasOpaqueArchetype() ||
56-
!getBuilder()
57-
.getTypeExpansionContext()
58-
.shouldLookThroughOpaqueTypeArchetypes())
59-
return ty;
60-
// Remap types containing opaque result types in the current context.
61-
return getBuilder()
62-
.getTypeLowering(SILType::getPrimitiveObjectType(ty))
63-
.getLoweredType()
64-
.getASTType();
65-
}
66-
67-
ProtocolConformanceRef remapConformance(Type ty,
68-
ProtocolConformanceRef conf) {
69-
auto context = getBuilder().getTypeExpansionContext();
70-
auto conformance = conf;
71-
if (ty->hasOpaqueArchetype() &&
72-
context.shouldLookThroughOpaqueTypeArchetypes()) {
73-
conformance =
74-
substOpaqueTypesWithUnderlyingTypes(conformance, ty, context);
75-
}
76-
return conformance;
77-
}
78-
7943
void replace();
8044
};
8145
} // namespace
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module %s
3+
4+
// We substitute away opaque archetypes after serialization;
5+
// make sure this correctly handles unlowered types like
6+
// AST functions and packs.
7+
8+
public func horse<T>(_: T) {}
9+
10+
@_transparent public func packCallee<each T>(_ t: repeat each T) {
11+
repeat horse(each t)
12+
}
13+
14+
@inlinable public func packCaller() {
15+
packCallee(opaque())
16+
}
17+
18+
public func opaque() -> some Any { return 3 }

0 commit comments

Comments
 (0)