Skip to content

Commit e9bd15f

Browse files
committed
SILOptimizer: More generic specializer plumbing for using the right resilience expansion
Also NFC for now.
1 parent 5c72a36 commit e9bd15f

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

include/swift/SILOptimizer/Utils/Generics.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ class ReabstractionInfo {
155155
return Serialized;
156156
}
157157

158+
ResilienceExpansion getResilienceExpansion() const {
159+
// FIXME: Expansion
160+
return ResilienceExpansion::Minimal;
161+
}
162+
158163
/// Returns true if the \p ParamIdx'th (non-result) formal parameter is
159164
/// converted from indirect to direct.
160165
bool isParamConverted(unsigned ParamIdx) const {

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,13 @@ void ReabstractionInfo::createSubstitutedAndSpecializedTypes() {
676676
unsigned IdxForResult = 0;
677677
for (SILResultInfo RI : SubstitutedType->getIndirectFormalResults()) {
678678
assert(RI.isFormalIndirect());
679-
if (substConv.getSILType(RI).isLoadable(M) && !RI.getType()->isVoid() &&
680-
shouldExpand(M, substConv.getSILType(RI).getObjectType())) {
679+
680+
auto ResultTy = substConv.getSILType(RI);
681+
auto &TL = M.Types.getTypeLowering(ResultTy,
682+
getResilienceExpansion());
683+
684+
if (TL.isLoadable() && !RI.getType()->isVoid() &&
685+
shouldExpand(M, ResultTy)) {
681686
Conversions.set(IdxForResult);
682687
break;
683688
}
@@ -690,7 +695,12 @@ void ReabstractionInfo::createSubstitutedAndSpecializedTypes() {
690695
for (SILParameterInfo PI : SubstitutedType->getParameters()) {
691696
auto IdxToInsert = IdxForParam;
692697
++IdxForParam;
693-
if (!substConv.getSILType(PI).isLoadable(M)) {
698+
699+
auto ParamTy = substConv.getSILType(PI);
700+
auto &TL = M.Types.getTypeLowering(ParamTy,
701+
getResilienceExpansion());
702+
703+
if (!TL.isLoadable()) {
694704
continue;
695705
}
696706

@@ -778,9 +788,8 @@ createSpecializedType(CanSILFunctionType SubstFTy, SILModule &M) const {
778788
if (isFormalResultConverted(IndirectResultIdx++)) {
779789
// Convert the indirect result to a direct result.
780790
SILType SILResTy = SILType::getPrimitiveObjectType(RI.getType());
781-
// FIXME: Expansion
782791
auto &TL = M.Types.getTypeLowering(SILResTy,
783-
ResilienceExpansion::Minimal);
792+
getResilienceExpansion());
784793

785794
// Indirect results are passed as owned, so we also need to pass the
786795
// direct result as owned (except it's a trivial type).
@@ -804,9 +813,8 @@ createSpecializedType(CanSILFunctionType SubstFTy, SILModule &M) const {
804813

805814
// Convert the indirect parameter to a direct parameter.
806815
SILType SILParamTy = SILType::getPrimitiveObjectType(PI.getType());
807-
// FIXME: Expansion
808816
auto &TL = M.Types.getTypeLowering(SILParamTy,
809-
ResilienceExpansion::Minimal);
817+
getResilienceExpansion());
810818

811819
// Indirect parameters are passed as owned/guaranteed, so we also
812820
// need to pass the direct/guaranteed parameter as

0 commit comments

Comments
 (0)