@@ -147,16 +147,23 @@ enum IsResilient_t : bool {
147
147
IsResilient = true
148
148
};
149
149
150
+ // / Does this type contain an opaque result type that affects type lowering?
151
+ enum IsTypeExpansionSensitive_t : bool {
152
+ IsNotTypeExpansionSensitive = false ,
153
+ IsTypeExpansionSensitive = true
154
+ };
155
+
150
156
// / Extended type information used by SIL.
151
157
class TypeLowering {
152
158
public:
153
159
class RecursiveProperties {
154
160
// These are chosen so that bitwise-or merges the flags properly.
155
161
enum : unsigned {
156
- NonTrivialFlag = 1 << 0 ,
157
- NonFixedABIFlag = 1 << 1 ,
158
- AddressOnlyFlag = 1 << 2 ,
159
- ResilientFlag = 1 << 3 ,
162
+ NonTrivialFlag = 1 << 0 ,
163
+ NonFixedABIFlag = 1 << 1 ,
164
+ AddressOnlyFlag = 1 << 2 ,
165
+ ResilientFlag = 1 << 3 ,
166
+ TypeExpansionSensitiveFlag = 1 << 4 ,
160
167
};
161
168
162
169
uint8_t Flags;
@@ -165,15 +172,17 @@ class TypeLowering {
165
172
// / a trivial, loadable, fixed-layout type.
166
173
constexpr RecursiveProperties () : Flags(0 ) {}
167
174
168
- constexpr RecursiveProperties (IsTrivial_t isTrivial,
169
- IsFixedABI_t isFixedABI,
170
- IsAddressOnly_t isAddressOnly,
171
- IsResilient_t isResilient)
172
- : Flags((isTrivial ? 0U : NonTrivialFlag) |
173
- (isFixedABI ? 0U : NonFixedABIFlag) |
174
- (isAddressOnly ? AddressOnlyFlag : 0U ) |
175
- (isResilient ? ResilientFlag : 0U )) {}
176
-
175
+ constexpr RecursiveProperties (
176
+ IsTrivial_t isTrivial, IsFixedABI_t isFixedABI,
177
+ IsAddressOnly_t isAddressOnly, IsResilient_t isResilient,
178
+ IsTypeExpansionSensitive_t isTypeExpansionSensitive =
179
+ IsNotTypeExpansionSensitive)
180
+ : Flags((isTrivial ? 0U : NonTrivialFlag) |
181
+ (isFixedABI ? 0U : NonFixedABIFlag) |
182
+ (isAddressOnly ? AddressOnlyFlag : 0U ) |
183
+ (isResilient ? ResilientFlag : 0U ) |
184
+ (isTypeExpansionSensitive ? TypeExpansionSensitiveFlag : 0U )) {}
185
+
177
186
constexpr bool operator ==(RecursiveProperties p) const {
178
187
return Flags == p.Flags ;
179
188
}
@@ -183,7 +192,7 @@ class TypeLowering {
183
192
}
184
193
185
194
static constexpr RecursiveProperties forReference () {
186
- return {IsNotTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient };
195
+ return {IsNotTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient};
187
196
}
188
197
189
198
static constexpr RecursiveProperties forOpaque () {
@@ -194,6 +203,7 @@ class TypeLowering {
194
203
return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient};
195
204
}
196
205
206
+
197
207
void addSubobject (RecursiveProperties other) {
198
208
Flags |= other.Flags ;
199
209
}
@@ -210,10 +220,19 @@ class TypeLowering {
210
220
IsResilient_t isResilient () const {
211
221
return IsResilient_t ((Flags & ResilientFlag) != 0 );
212
222
}
223
+ IsTypeExpansionSensitive_t isTypeExpansionSensitive () const {
224
+ return IsTypeExpansionSensitive_t (
225
+ (Flags & TypeExpansionSensitiveFlag) != 0 );
226
+ }
213
227
214
228
void setNonTrivial () { Flags |= NonTrivialFlag; }
215
229
void setNonFixedABI () { Flags |= NonFixedABIFlag; }
216
230
void setAddressOnly () { Flags |= AddressOnlyFlag; }
231
+ void setTypeExpansionSensitive (
232
+ IsTypeExpansionSensitive_t isTypeExpansionSensitive) {
233
+ Flags = (Flags & ~TypeExpansionSensitiveFlag) |
234
+ (isTypeExpansionSensitive ? TypeExpansionSensitiveFlag : 0 );
235
+ }
217
236
};
218
237
219
238
private:
@@ -305,6 +324,12 @@ class TypeLowering {
305
324
return Properties.isResilient ();
306
325
}
307
326
327
+ // / Does this type contain an opaque result type that could influence how the
328
+ // / type is lowered if we could look through to the underlying type.
329
+ bool isTypeExpansionSensitive () const {
330
+ return Properties.isTypeExpansionSensitive ();
331
+ }
332
+
308
333
ResilienceExpansion getResilienceExpansion () const {
309
334
return expansionContext.getResilienceExpansion ();
310
335
}
@@ -705,8 +730,6 @@ class TypeConverter {
705
730
706
731
llvm::DenseMap<SILDeclRef, CaptureInfo> LoweredCaptures;
707
732
708
- llvm::DenseMap<CanType, bool > opaqueArchetypeFields;
709
-
710
733
// / Cache of loadable SILType to number of (estimated) fields
711
734
// /
712
735
// / Second element is a ResilienceExpansion.
@@ -719,17 +742,15 @@ class TypeConverter {
719
742
Optional<CanType> BridgedType##Ty;
720
743
#include " swift/SIL/BridgedTypes.def"
721
744
722
- const TypeLowering &
723
- getTypeLoweringForLoweredType (AbstractionPattern origType,
724
- CanType loweredType,
725
- TypeExpansionContext forExpansion,
726
- bool origHadOpaqueTypeArchetype);
745
+ const TypeLowering &getTypeLoweringForLoweredType (
746
+ AbstractionPattern origType, CanType loweredType,
747
+ TypeExpansionContext forExpansion,
748
+ IsTypeExpansionSensitive_t isTypeExpansionSensitive);
727
749
728
- const TypeLowering *
729
- getTypeLoweringForExpansion (TypeKey key,
730
- TypeExpansionContext forExpansion,
731
- const TypeLowering *lowering,
732
- bool origHadOpaqueTypeArchetype);
750
+ const TypeLowering *getTypeLoweringForExpansion (
751
+ TypeKey key, TypeExpansionContext forExpansion,
752
+ const TypeLowering *minimalExpansionLowering,
753
+ IsTypeExpansionSensitive_t isOrigTypeExpansionSensitive);
733
754
734
755
public:
735
756
ModuleDecl &M;
@@ -884,8 +905,6 @@ class TypeConverter {
884
905
885
906
CanType getLoweredTypeOfGlobal (VarDecl *var);
886
907
887
- bool hasOpaqueArchetypeOrPropertiesOrCases (CanType ty);
888
-
889
908
// / Return the SILFunctionType for a native function value of the
890
909
// / given type.
891
910
CanSILFunctionType getSILFunctionType (TypeExpansionContext context,
0 commit comments