@@ -79,7 +79,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
79
79
SILBuilder Builder;
80
80
DominanceInfo *DomTree = nullptr ;
81
81
SubstitutionMapWithLocalArchetypes Functor;
82
- TypeSubstitutionMap &LocalArchetypeSubs;
83
82
84
83
// The old-to-new value map.
85
84
llvm::DenseMap<SILValue, SILValue> ValueMap;
@@ -106,10 +105,10 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
106
105
using SILInstructionVisitor<ImplClass>::asImpl;
107
106
108
107
explicit SILCloner (SILFunction &F, DominanceInfo *DT = nullptr )
109
- : Builder(F), DomTree(DT), LocalArchetypeSubs(Functor.LocalArchetypeSubs) {}
108
+ : Builder(F), DomTree(DT) {}
110
109
111
110
explicit SILCloner (SILGlobalVariable *GlobVar)
112
- : Builder(GlobVar), LocalArchetypeSubs(Functor.LocalArchetypeSubs) {}
111
+ : Builder(GlobVar) {}
113
112
114
113
void clearClonerState () {
115
114
ValueMap.clear ();
@@ -198,7 +197,7 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
198
197
// / Register a re-mapping for local archetypes such as opened existentials.
199
198
void registerLocalArchetypeRemapping (ArchetypeType *From,
200
199
ArchetypeType *To) {
201
- auto result = LocalArchetypeSubs.insert (
200
+ auto result = Functor. LocalArchetypeSubs .insert (
202
201
std::make_pair (CanArchetypeType (From), CanType (To)));
203
202
assert (result.second );
204
203
(void )result;
@@ -336,17 +335,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
336
335
337
336
ProtocolConformanceRef getOpConformance (Type ty,
338
337
ProtocolConformanceRef conformance) {
339
- // If we have local archetypes to substitute, do so now.
340
- if (ty->hasLocalArchetype () && !LocalArchetypeSubs.empty ()) {
341
- conformance =
342
- conformance.subst (ty,
343
- QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
344
- MakeAbstractConformanceForGenericType ());
345
- ty = ty.subst (
346
- QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
347
- MakeAbstractConformanceForGenericType ());
348
- }
349
-
350
338
return asImpl ().remapConformance (ty, conformance);
351
339
}
352
340
@@ -448,8 +436,13 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
448
436
}
449
437
450
438
ProtocolConformanceRef remapConformance (Type Ty, ProtocolConformanceRef C) {
439
+ // If we have local archetypes to substitute, do so now.
440
+ if (Ty->hasLocalArchetype ())
441
+ C = C.subst (Ty, Functor, Functor);
442
+
451
443
return C;
452
444
}
445
+
453
446
// / Get the value that takes the place of the given `Value` within the cloned
454
447
// / region. The given value must already have been mapped by this cloner.
455
448
SILValue getMappedValue (SILValue Value);
0 commit comments