@@ -519,8 +519,9 @@ namespace {
519519 class LoadableTypeLowering : public TypeLowering {
520520 protected:
521521 LoadableTypeLowering (SILType type, RecursiveProperties properties,
522- IsReferenceCounted_t isRefCounted)
523- : TypeLowering(type, properties, isRefCounted) {}
522+ IsReferenceCounted_t isRefCounted,
523+ ResilienceExpansion forExpansion)
524+ : TypeLowering(type, properties, isRefCounted, forExpansion) {}
524525
525526 public:
526527 void emitDestroyAddress (SILBuilder &B, SILLocation loc,
@@ -545,9 +546,9 @@ namespace {
545546 // / A class for trivial, fixed-layout, loadable types.
546547 class TrivialTypeLowering final : public LoadableTypeLowering {
547548 public:
548- TrivialTypeLowering (SILType type)
549+ TrivialTypeLowering (SILType type, ResilienceExpansion forExpansion )
549550 : LoadableTypeLowering(type, {IsTrivial, IsFixedABI, IsNotAddressOnly},
550- IsNotReferenceCounted) {}
551+ IsNotReferenceCounted, forExpansion ) {}
551552
552553 SILValue emitLoadOfCopy (SILBuilder &B, SILLocation loc, SILValue addr,
553554 IsTake_t isTake) const override {
@@ -609,16 +610,18 @@ namespace {
609610 class NonTrivialLoadableTypeLowering : public LoadableTypeLowering {
610611 public:
611612 NonTrivialLoadableTypeLowering (SILType type,
612- IsReferenceCounted_t isRefCounted)
613+ IsReferenceCounted_t isRefCounted,
614+ ResilienceExpansion forExpansion)
613615 : NonTrivialLoadableTypeLowering(type,
614616 {IsNotTrivial, IsFixedABI, IsNotAddressOnly},
615- isRefCounted) {}
617+ isRefCounted, forExpansion ) {}
616618
617619 // / This constructor is necessary because of opaque-values.
618620 NonTrivialLoadableTypeLowering (SILType type,
619621 RecursiveProperties properties,
620- IsReferenceCounted_t isRefCounted)
621- : LoadableTypeLowering(type, properties, isRefCounted) {
622+ IsReferenceCounted_t isRefCounted,
623+ ResilienceExpansion forExpansion)
624+ : LoadableTypeLowering(type, properties, isRefCounted, forExpansion) {
622625 assert (!properties.isTrivial ());
623626 }
624627
@@ -709,9 +712,9 @@ namespace {
709712 const = 0;
710713
711714 public:
712- LoadableAggTypeLowering (CanType type)
715+ LoadableAggTypeLowering (CanType type, ResilienceExpansion forExpansion )
713716 : NonTrivialLoadableTypeLowering(SILType::getPrimitiveObjectType(type),
714- IsNotReferenceCounted) {
717+ IsNotReferenceCounted, forExpansion ) {
715718 }
716719
717720 virtual SILValue rebuildAggregate (SILBuilder &B, SILLocation loc,
@@ -826,8 +829,8 @@ namespace {
826829 class LoadableTupleTypeLowering final
827830 : public LoadableAggTypeLowering<LoadableTupleTypeLowering, unsigned > {
828831 public:
829- LoadableTupleTypeLowering (CanType type)
830- : LoadableAggTypeLowering(type) {}
832+ LoadableTupleTypeLowering (CanType type, ResilienceExpansion forExpansion )
833+ : LoadableAggTypeLowering(type, forExpansion ) {}
831834
832835 SILValue emitRValueProject (SILBuilder &B, SILLocation loc,
833836 SILValue tupleValue, unsigned index,
@@ -862,8 +865,8 @@ namespace {
862865 class LoadableStructTypeLowering final
863866 : public LoadableAggTypeLowering<LoadableStructTypeLowering, VarDecl*> {
864867 public:
865- LoadableStructTypeLowering (CanType type)
866- : LoadableAggTypeLowering(type) {}
868+ LoadableStructTypeLowering (CanType type, ResilienceExpansion forExpansion )
869+ : LoadableAggTypeLowering(type, forExpansion ) {}
867870
868871 SILValue emitRValueProject (SILBuilder &B, SILLocation loc,
869872 SILValue structValue, VarDecl *field,
@@ -895,9 +898,10 @@ namespace {
895898 // / A lowering for loadable but non-trivial enum types.
896899 class LoadableEnumTypeLowering final : public NonTrivialLoadableTypeLowering {
897900 public:
898- LoadableEnumTypeLowering (CanType type)
901+ LoadableEnumTypeLowering (CanType type, ResilienceExpansion forExpansion )
899902 : NonTrivialLoadableTypeLowering(SILType::getPrimitiveObjectType(type),
900- IsNotReferenceCounted) {}
903+ IsNotReferenceCounted,
904+ forExpansion) {}
901905
902906 SILValue emitCopyValue (SILBuilder &B, SILLocation loc,
903907 SILValue value) const override {
@@ -935,8 +939,10 @@ namespace {
935939 class LeafLoadableTypeLowering : public NonTrivialLoadableTypeLowering {
936940 public:
937941 LeafLoadableTypeLowering (SILType type, RecursiveProperties properties,
938- IsReferenceCounted_t isRefCounted)
939- : NonTrivialLoadableTypeLowering(type, properties, isRefCounted) {}
942+ IsReferenceCounted_t isRefCounted,
943+ ResilienceExpansion forExpansion)
944+ : NonTrivialLoadableTypeLowering(type, properties, isRefCounted,
945+ forExpansion) {}
940946
941947 SILValue emitLoweredCopyValue (SILBuilder &B, SILLocation loc,
942948 SILValue value,
@@ -954,9 +960,9 @@ namespace {
954960 // / loadable.
955961 class ReferenceTypeLowering : public LeafLoadableTypeLowering {
956962 public:
957- ReferenceTypeLowering (SILType type)
963+ ReferenceTypeLowering (SILType type, ResilienceExpansion forExpansion )
958964 : LeafLoadableTypeLowering(type, RecursiveProperties::forReference(),
959- IsReferenceCounted) {}
965+ IsReferenceCounted, forExpansion ) {}
960966
961967 SILValue emitCopyValue (SILBuilder &B, SILLocation loc,
962968 SILValue value) const override {
@@ -985,9 +991,11 @@ namespace {
985991#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
986992 class Loadable ##Name##TypeLowering final : public LeafLoadableTypeLowering { \
987993 public: \
988- Loadable##Name##TypeLowering(SILType type) \
994+ Loadable##Name##TypeLowering(SILType type, \
995+ ResilienceExpansion forExpansion) \
989996 : LeafLoadableTypeLowering(type, RecursiveProperties::forReference(), \
990- IsReferenceCounted) {} \
997+ IsReferenceCounted, \
998+ forExpansion) {} \
991999 SILValue emitCopyValue (SILBuilder &B, SILLocation loc, \
9921000 SILValue value) const override { \
9931001 if (B.getFunction ().hasOwnership ()) \
@@ -1009,8 +1017,10 @@ namespace {
10091017 // / A class for non-trivial, address-only types.
10101018 class AddressOnlyTypeLowering : public TypeLowering {
10111019 public:
1012- AddressOnlyTypeLowering (SILType type, RecursiveProperties properties)
1013- : TypeLowering(type, properties, IsNotReferenceCounted)
1020+ AddressOnlyTypeLowering (SILType type, RecursiveProperties properties,
1021+ ResilienceExpansion forExpansion)
1022+ : TypeLowering(type, properties, IsNotReferenceCounted,
1023+ forExpansion)
10141024 {}
10151025
10161026 void emitCopyInto (SILBuilder &B, SILLocation loc,
@@ -1078,9 +1088,11 @@ namespace {
10781088 // / to catch obviously broken attempts to copy or destroy the buffer.
10791089 class UnsafeValueBufferTypeLowering : public AddressOnlyTypeLowering {
10801090 public:
1081- UnsafeValueBufferTypeLowering (SILType type)
1091+ UnsafeValueBufferTypeLowering (SILType type,
1092+ ResilienceExpansion forExpansion)
10821093 : AddressOnlyTypeLowering(type,
1083- {IsNotTrivial, IsFixedABI, IsAddressOnly}) {}
1094+ {IsNotTrivial, IsFixedABI, IsAddressOnly},
1095+ forExpansion) {}
10841096
10851097 void emitCopyInto (SILBuilder &B, SILLocation loc,
10861098 SILValue src, SILValue dest, IsTake_t isTake,
@@ -1106,8 +1118,10 @@ namespace {
11061118 // / FIXME: When you remove an unreachable, just delete the method.
11071119 class OpaqueValueTypeLowering : public LeafLoadableTypeLowering {
11081120 public:
1109- OpaqueValueTypeLowering (SILType type, RecursiveProperties properties)
1110- : LeafLoadableTypeLowering(type, properties, IsNotReferenceCounted) {}
1121+ OpaqueValueTypeLowering (SILType type, RecursiveProperties properties,
1122+ ResilienceExpansion forExpansion)
1123+ : LeafLoadableTypeLowering(type, properties, IsNotReferenceCounted,
1124+ forExpansion) {}
11111125
11121126 void emitCopyInto (SILBuilder &B, SILLocation loc,
11131127 SILValue src, SILValue dest, IsTake_t isTake,
@@ -1152,45 +1166,49 @@ namespace {
11521166 : TypeClassifierBase(TC.M, Sig, Expansion),
11531167 TC (TC), Dependent(Dependent) {}
11541168
1155- TypeLowering *
1156- handleTrivial (CanType type) {
1169+ TypeLowering *handleTrivial (CanType type) {
11571170 auto silType = SILType::getPrimitiveObjectType (type);
1158- return new (TC, Dependent) TrivialTypeLowering (silType);
1171+ return new (TC, Dependent) TrivialTypeLowering (silType, Expansion );
11591172 }
11601173
11611174 TypeLowering *handleReference (CanType type) {
11621175 auto silType = SILType::getPrimitiveObjectType (type);
1163- return new (TC, Dependent) ReferenceTypeLowering (silType);
1176+ return new (TC, Dependent) ReferenceTypeLowering (silType, Expansion );
11641177 }
11651178
11661179 TypeLowering *handleAddressOnly (CanType type,
11671180 RecursiveProperties properties) {
11681181 if (SILModuleConventions (M).useLoweredAddresses ()) {
11691182 auto silType = SILType::getPrimitiveAddressType (type);
1170- return new (TC, Dependent) AddressOnlyTypeLowering (silType, properties);
1183+ return new (TC, Dependent) AddressOnlyTypeLowering (silType, properties,
1184+ Expansion);
11711185 }
11721186 auto silType = SILType::getPrimitiveObjectType (type);
1173- return new (TC, Dependent) OpaqueValueTypeLowering (silType, properties);
1187+ return new (TC, Dependent) OpaqueValueTypeLowering (silType, properties,
1188+ Expansion);
11741189 }
11751190
11761191#define ALWAYS_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
11771192 TypeLowering * \
11781193 visit##Name##StorageType(Can##Name##StorageType type) { \
11791194 return new (TC, Dependent) Loadable##Name##TypeLowering ( \
1180- SILType::getPrimitiveObjectType (type)); \
1195+ SILType::getPrimitiveObjectType (type), \
1196+ Expansion); \
11811197 }
11821198#define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
11831199 TypeLowering * \
11841200 visitLoadable##Name##StorageType(Can##Name##StorageType type) { \
11851201 return new (TC, Dependent) Loadable##Name##TypeLowering ( \
1186- SILType::getPrimitiveObjectType (type)); \
1202+ SILType::getPrimitiveObjectType (type), \
1203+ Expansion); \
11871204 }
11881205#include " swift/AST/ReferenceStorage.def"
11891206
11901207 TypeLowering *
11911208 visitBuiltinUnsafeValueBufferType (CanBuiltinUnsafeValueBufferType type) {
11921209 auto silType = SILType::getPrimitiveAddressType (type);
1193- return new (TC, Dependent) UnsafeValueBufferTypeLowering (silType);
1210+ return new (TC, Dependent) UnsafeValueBufferTypeLowering (silType,
1211+ Expansion);
11941212 }
11951213
11961214 TypeLowering *visitTupleType (CanTupleType tupleType) {
@@ -1237,7 +1255,7 @@ namespace {
12371255 // is still address only, because we don't know how many bits
12381256 // are used for the discriminator.
12391257 if (D->isIndirect ()) {
1240- return new (TC, Dependent) LoadableEnumTypeLowering (enumType);
1258+ return new (TC, Dependent) LoadableEnumTypeLowering (enumType, Expansion );
12411259 }
12421260
12431261 // Accumulate the properties of all direct payloads.
@@ -1275,7 +1293,7 @@ namespace {
12751293 if (props.isTrivial ()) {
12761294 return handleTrivial (type);
12771295 }
1278- return new (TC, Dependent) LoadableLoweringClass (type);
1296+ return new (TC, Dependent) LoadableLoweringClass (type, Expansion );
12791297 }
12801298 };
12811299} // end anonymous namespace
@@ -1615,11 +1633,11 @@ getTypeLoweringForExpansion(TypeKey key,
16151633
16161634 // Search for a matching lowering in the linked list of lowerings.
16171635 while (true ) {
1618- if (lowering->forExpansion == forExpansion)
1636+ if (lowering->getResilienceExpansion () == forExpansion)
16191637 return *lowering;
1620- if (lowering->nextExpansion ) {
1638+ if (lowering->NextExpansion ) {
16211639 // Continue searching.
1622- lowering = lowering->nextExpansion ;
1640+ lowering = lowering->NextExpansion ;
16231641 continue ;
16241642 }
16251643
@@ -1629,8 +1647,7 @@ getTypeLoweringForExpansion(TypeKey key,
16291647 forExpansion,
16301648 key.isDependent ()).visit (key.SubstType );
16311649
1632- lowering->nextExpansion = theInfo;
1633- theInfo->forExpansion = forExpansion;
1650+ lowering->NextExpansion = theInfo;
16341651 return *theInfo;
16351652 }
16361653}
@@ -1653,8 +1670,6 @@ getTypeLoweringForUncachedLoweredType(TypeKey key,
16531670 forExpansion,
16541671 key.isDependent ()).visit (key.SubstType );
16551672
1656- theInfo->forExpansion = forExpansion;
1657-
16581673 if (key.OrigType .isForeign ()) {
16591674 assert (theInfo->isLoadable () && " Cannot lower address-only type with "
16601675 " foreign abstraction pattern" );
0 commit comments