Skip to content

Commit 377efb2

Browse files
committed
SIL: Simplify MapOpaqueArchetypes
1 parent 7aebd1e commit 377efb2

File tree

2 files changed

+3
-52
lines changed

2 files changed

+3
-52
lines changed

lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,56 +40,7 @@ class MapOpaqueArchetypes : public SILCloner<MapOpaqueArchetypes> {
4040
clonedEntryBlock = fun.createBasicBlock();
4141
}
4242

43-
SILType remapType(SILType Ty) {
44-
// Substitute local archetypes, if we have any.
45-
if (Ty.hasLocalArchetype()) {
46-
Ty = Ty.subst(getBuilder().getModule(), Functor, Functor,
47-
CanGenericSignature());
48-
}
49-
50-
if (!Ty.hasOpaqueArchetype() ||
51-
!getBuilder()
52-
.getTypeExpansionContext()
53-
.shouldLookThroughOpaqueTypeArchetypes())
54-
return Ty;
55-
56-
return getBuilder().getTypeLowering(Ty).getLoweredType().getCategoryType(
57-
Ty.getCategory());
58-
}
59-
60-
CanType remapASTType(CanType ty) {
61-
// Substitute local archetypes, if we have any.
62-
if (ty->hasLocalArchetype())
63-
ty = ty.subst(Functor, Functor)->getCanonicalType();
64-
65-
if (!ty->hasOpaqueArchetype() ||
66-
!getBuilder()
67-
.getTypeExpansionContext()
68-
.shouldLookThroughOpaqueTypeArchetypes())
69-
return ty;
70-
71-
return substOpaqueTypesWithUnderlyingTypes(
72-
ty,
73-
TypeExpansionContext(getBuilder().getFunction()),
74-
/*allowLoweredTypes=*/false);
75-
}
76-
77-
ProtocolConformanceRef remapConformance(Type ty,
78-
ProtocolConformanceRef conf) {
79-
// If we have local archetypes to substitute, do so now.
80-
if (ty->hasLocalArchetype()) {
81-
conf = conf.subst(ty, Functor, Functor);
82-
ty = ty.subst(Functor, Functor);
83-
}
84-
85-
auto context = getBuilder().getTypeExpansionContext();
86-
if (ty->hasOpaqueArchetype() &&
87-
context.shouldLookThroughOpaqueTypeArchetypes()) {
88-
conf =
89-
substOpaqueTypesWithUnderlyingTypes(conf, ty, context);
90-
}
91-
return conf;
92-
}
43+
bool shouldSubstOpaqueArchetypes() const { return true; }
9344

9445
void replace();
9546
};

test/SILOptimizer/specialize_opaque_result_types2.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ bb0(%0 : $*T):
3535
return %5 : $@callee_owned () -> @out T // id: %7
3636
}
3737

38-
// CHECK-LABEL: sil shared [noinline] @$s17getGenericClosure1A19exportsOpaqueReturnQryFQOyQo__Tg5 : $@convention(thin) (Int) -> @owned @callee_owned () -> @out Int {
38+
// CHECK-LABEL: sil shared [noinline] @$s17getGenericClosureSi_Tg5 : $@convention(thin) (Int) -> @owned @callee_owned () -> @out Int {
3939
// CHECK: alloc_box $<τ_0_0> { var τ_0_0 } <Int>
40-
// CHECK: } // end sil function '$s17getGenericClosure1A19exportsOpaqueReturnQryFQOyQo__Tg5'
40+
// CHECK: } // end sil function '$s17getGenericClosureSi_Tg5'
4141

4242
sil [transparent] [serialized] @specializePartialApplies : $@convention(thin) (@in SomeButt) -> () {
4343
bb0(%0 : $*SomeButt):

0 commit comments

Comments
 (0)