Skip to content

Commit 0bf0a1e

Browse files
committed
[SILGen] Eliminate more SubstitutionLists for accessor calls.
1 parent 482f55d commit 0bf0a1e

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

lib/SILGen/SILGenConstructor.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -951,15 +951,15 @@ void SILGenFunction::emitMemberInitializers(DeclContext *dc,
951951
// signature of the type, with replacement archetypes from the
952952
// constructor's context (which might be in an extension of
953953
// the type, which adds additional generic requirements).
954-
SubstitutionList subs;
954+
SubstitutionMap subs;
955955
auto *genericEnv = dc->getGenericEnvironmentOfContext();
956956
auto typeGenericSig = nominal->getGenericSignatureOfContext();
957957

958958
if (genericEnv && typeGenericSig) {
959959
// Generate a set of substitutions for the initialization function,
960960
// whose generic signature is that of the type context, and whose
961961
// replacement types are the archetypes of the initializer itself.
962-
auto subMap = typeGenericSig->getSubstitutionMap(
962+
subs = typeGenericSig->getSubstitutionMap(
963963
[&](SubstitutableType *type) {
964964
if (auto gp = type->getAs<GenericTypeParamType>()) {
965965
return genericEnv->mapTypeIntoContext(gp);
@@ -973,9 +973,6 @@ void SILGenFunction::emitMemberInitializers(DeclContext *dc,
973973
return ProtocolConformanceRef(
974974
conformedProtocol->getDecl());
975975
});
976-
SmallVector<Substitution, 4> subsVec;
977-
typeGenericSig->getSubstitutions(subMap, subsVec);
978-
subs = SGM.getASTContext().AllocateCopy(subsVec);
979976
}
980977

981978
// Get the type of the initialization result, in terms

lib/SILGen/SILGenConvert.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ ManagedValue SILGenFunction::emitExistentialErasure(
593593
emitRValueForStorageLoad(
594594
loc, nativeError, concreteFormalType,
595595
/*super*/ false, nsErrorVar, RValue(),
596-
nsErrorVarSubstitutions.toList(),
596+
nsErrorVarSubstitutions,
597597
AccessSemantics::Ordinary, nsErrorType, SGFContext())
598598
.getAsSingleValue(*this, loc);
599599

lib/SILGen/SILGenExpr.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ static SILDeclRef getRValueAccessorDeclRef(SILGenFunction &SGF,
11291129
static RValue
11301130
emitRValueWithAccessor(SILGenFunction &SGF, SILLocation loc,
11311131
AbstractStorageDecl *storage,
1132-
SubstitutionList substitutions,
1132+
SubstitutionMap substitutions,
11331133
ArgumentSource &&baseRV, RValue &&subscriptRV,
11341134
bool isSuper, AccessStrategy strategy,
11351135
SILDeclRef accessor,
@@ -1148,7 +1148,7 @@ emitRValueWithAccessor(SILGenFunction &SGF, SILLocation loc,
11481148
// The easy path here is if we don't need to use an addressor.
11491149
case AccessStrategy::DirectToAccessor:
11501150
case AccessStrategy::DispatchToAccessor: {
1151-
return SGF.emitGetAccessor(loc, accessor, substitutions,
1151+
return SGF.emitGetAccessor(loc, accessor, substitutions.toList(),
11521152
std::move(baseRV), isSuper, isDirectUse,
11531153
std::move(subscriptRV), C);
11541154
}
@@ -1161,7 +1161,7 @@ emitRValueWithAccessor(SILGenFunction &SGF, SILLocation loc,
11611161
SILType storageType = storageTL.getLoweredType().getAddressType();
11621162

11631163
auto addressorResult =
1164-
SGF.emitAddressorAccessor(loc, accessor, substitutions,
1164+
SGF.emitAddressorAccessor(loc, accessor, substitutions.toList(),
11651165
std::move(baseRV), isSuper, isDirectUse,
11661166
std::move(subscriptRV), storageType);
11671167

@@ -1204,7 +1204,7 @@ emitRValueWithAccessor(SILGenFunction &SGF, SILLocation loc,
12041204
RValue SILGenFunction::emitRValueForStorageLoad(
12051205
SILLocation loc, ManagedValue base, CanType baseFormalType,
12061206
bool isSuper, AbstractStorageDecl *storage, RValue indexes,
1207-
SubstitutionList substitutions,
1207+
SubstitutionMap substitutions,
12081208
AccessSemantics semantics, Type propTy, SGFContext C,
12091209
bool isBaseGuaranteed) {
12101210
AccessStrategy strategy =
@@ -2498,8 +2498,7 @@ class NominalTypeMemberRefRValueEmitter {
24982498
SGF.emitRValueForStorageLoad(Expr, base, baseFormalType,
24992499
Expr->isSuper(),
25002500
Field, {},
2501-
Expr->getMember().getSubstitutions()
2502-
.toList(),
2501+
Expr->getMember().getSubstitutions(),
25032502
Expr->getAccessSemantics(),
25042503
Expr->getType(), Context);
25052504
return result;
@@ -2541,8 +2540,7 @@ class NominalTypeMemberRefRValueEmitter {
25412540
SGF.emitRValueForStorageLoad(Expr, base, baseFormalType,
25422541
Expr->isSuper(),
25432542
Field, {},
2544-
Expr->getMember().getSubstitutions()
2545-
.toList(),
2543+
Expr->getMember().getSubstitutions(),
25462544
Expr->getAccessSemantics(),
25472545
Expr->getType(), Context,
25482546
base.isPlusZeroRValueOrTrivial());
@@ -2657,7 +2655,7 @@ SILGenFunction::emitApplyOfDefaultArgGenerator(SILLocation loc,
26572655
RValue SILGenFunction::emitApplyOfStoredPropertyInitializer(
26582656
SILLocation loc,
26592657
const PatternBindingEntry &entry,
2660-
SubstitutionList subs,
2658+
SubstitutionMap subs,
26612659
CanType resultType,
26622660
AbstractionPattern origResultType,
26632661
SGFContext C) {
@@ -2673,8 +2671,8 @@ RValue SILGenFunction::emitApplyOfStoredPropertyInitializer(
26732671
ResultPlanPtr resultPlan =
26742672
ResultPlanBuilder::computeResultPlan(*this, calleeTypeInfo, loc, C);
26752673
ArgumentScope argScope(*this, loc);
2676-
return emitApply(std::move(resultPlan), std::move(argScope), loc, fnRef, subs,
2677-
{}, calleeTypeInfo, ApplyOptions::None, C);
2674+
return emitApply(std::move(resultPlan), std::move(argScope), loc, fnRef,
2675+
subs.toList(), {}, calleeTypeInfo, ApplyOptions::None, C);
26782676
}
26792677

26802678
static void emitTupleShuffleExprInto(RValueEmitter &emitter,
@@ -3202,7 +3200,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
32023200
auto resultSubst = subSGF.emitRValueForStorageLoad(loc, baseSubstValue,
32033201
baseType, /*super*/false,
32043202
property, std::move(indexValue),
3205-
subs.toList(), AccessSemantics::Ordinary,
3203+
subs, AccessSemantics::Ordinary,
32063204
propertyType, SGFContext())
32073205
.getAsSingleValue(subSGF, loc);
32083206
if (resultSubst.getType().getAddressType() != resultArg->getType())

lib/SILGen/SILGenFunction.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
10831083
CanType baseFormalType,
10841084
bool isSuper, AbstractStorageDecl *storage,
10851085
RValue indexes,
1086-
SubstitutionList substitutions,
1086+
SubstitutionMap substitutions,
10871087
AccessSemantics semantics, Type propTy,
10881088
SGFContext C,
10891089
bool isBaseGuaranteed = false);
@@ -1312,7 +1312,7 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
13121312
RValue emitApplyOfStoredPropertyInitializer(
13131313
SILLocation loc,
13141314
const PatternBindingEntry &entry,
1315-
SubstitutionList subs,
1315+
SubstitutionMap subs,
13161316
CanType resultType,
13171317
AbstractionPattern origResultType,
13181318
SGFContext C);

0 commit comments

Comments
 (0)