Skip to content

Commit c93ec45

Browse files
committed
SIL: Plumb resilience expansion through when lowering capture types
For now this is NFC.
1 parent a6158c9 commit c93ec45

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

include/swift/SIL/TypeLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,8 @@ class TypeConverter {
717717
TypeConverter &operator=(TypeConverter const &) = delete;
718718

719719
/// Return the CaptureKind to use when capturing a decl.
720-
CaptureKind getDeclCaptureKind(CapturedValue capture);
720+
CaptureKind getDeclCaptureKind(CapturedValue capture,
721+
ResilienceExpansion expansion);
721722

722723
/// Return a most-general-possible abstraction pattern.
723724
AbstractionPattern getMostGeneralAbstraction() {

lib/SIL/SILFunctionType.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ static std::pair<AbstractionPattern, CanType> updateResultTypeForForeignError(
714714
static void
715715
lowerCaptureContextParameters(SILModule &M, AnyFunctionRef function,
716716
CanGenericSignature genericSig,
717+
ResilienceExpansion expansion,
717718
SmallVectorImpl<SILParameterInfo> &inputs) {
718719

719720
// NB: The generic signature may be elided from the lowered function type
@@ -746,13 +747,11 @@ lowerCaptureContextParameters(SILModule &M, AnyFunctionRef function,
746747
auto type = VD->getInterfaceType();
747748
auto canType = type->getCanonicalType(origGenericSig);
748749

749-
// FIXME: Could be changed to Maximal at some point without impacting ABI,
750-
// as long as we make sure all call sites are non inlinable.
751750
auto &loweredTL =
752751
Types.getTypeLowering(AbstractionPattern(genericSig, canType), canType,
753-
ResilienceExpansion::Minimal);
752+
expansion);
754753
auto loweredTy = loweredTL.getLoweredType();
755-
switch (Types.getDeclCaptureKind(capture)) {
754+
switch (Types.getDeclCaptureKind(capture, expansion)) {
756755
case CaptureKind::None:
757756
break;
758757
case CaptureKind::Constant: {
@@ -985,7 +984,10 @@ static CanSILFunctionType getSILFunctionType(
985984
// from the function to which the argument is attached.
986985
if (constant && !constant->isDefaultArgGenerator()) {
987986
if (auto function = constant->getAnyFunctionRef()) {
988-
lowerCaptureContextParameters(M, *function, genericSig, inputs);
987+
// FIXME: Expansion
988+
auto expansion = ResilienceExpansion::Minimal;
989+
lowerCaptureContextParameters(M, *function, genericSig, expansion,
990+
inputs);
989991
}
990992
}
991993

lib/SIL/TypeLowering.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ static bool hasSingletonMetatype(CanType instanceType) {
8686
return HasSingletonMetatype().visit(instanceType);
8787
}
8888

89-
CaptureKind TypeConverter::getDeclCaptureKind(CapturedValue capture) {
89+
CaptureKind TypeConverter::getDeclCaptureKind(CapturedValue capture,
90+
ResilienceExpansion expansion) {
9091
auto decl = capture.getDecl();
9192
if (auto *var = dyn_cast<VarDecl>(decl)) {
9293
assert(var->hasStorage() &&
@@ -97,9 +98,7 @@ CaptureKind TypeConverter::getDeclCaptureKind(CapturedValue capture) {
9798
// by its address (like a var) instead.
9899
if (var->isImmutable() &&
99100
(!SILModuleConventions(M).useLoweredAddresses() ||
100-
// FIXME: Expansion
101-
!getTypeLowering(var->getType(),
102-
ResilienceExpansion::Minimal).isAddressOnly()))
101+
!getTypeLowering(var->getType(), expansion).isAddressOnly()))
103102
return CaptureKind::Constant;
104103

105104
// In-out parameters are captured by address.

lib/SILGen/SILGenFunction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ void SILGenFunction::emitCaptures(SILLocation loc,
197197

198198
auto *vd = capture.getDecl();
199199

200-
switch (SGM.Types.getDeclCaptureKind(capture)) {
200+
// FIXME: Expansion
201+
auto expansion = ResilienceExpansion::Minimal;
202+
switch (SGM.Types.getDeclCaptureKind(capture, expansion)) {
201203
case CaptureKind::None:
202204
break;
203205

lib/SILGen/SILGenProlog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,15 @@ static void emitCaptureArguments(SILGenFunction &SGF,
354354
closure.getGenericEnvironment(), interfaceType);
355355
};
356356

357-
switch (SGF.SGM.Types.getDeclCaptureKind(capture)) {
357+
// FIXME: Expansion
358+
auto expansion = ResilienceExpansion::Minimal;
359+
switch (SGF.SGM.Types.getDeclCaptureKind(capture, expansion)) {
358360
case CaptureKind::None:
359361
break;
360362

361363
case CaptureKind::Constant: {
362364
auto type = getVarTypeInCaptureContext();
363-
auto &lowering = SGF.SGM.Types.getTypeLowering(type,
364-
ResilienceExpansion::Minimal);
365+
auto &lowering = SGF.getTypeLowering(type);
365366
// Constant decls are captured by value.
366367
SILType ty = lowering.getLoweredType();
367368
SILValue val = SGF.F.begin()->createFunctionArgument(ty, VD);

0 commit comments

Comments
 (0)