@@ -51,11 +51,12 @@ struct LifetimeDescriptor {
51
51
} Named;
52
52
struct {
53
53
unsigned index;
54
+ bool isAddress;
54
55
} Ordered;
55
56
struct {
56
57
} Self;
57
58
Value (StringRef name) : Named ({name}) {}
58
- Value (unsigned index) : Ordered ({index}) {}
59
+ Value (unsigned index, bool isAddress ) : Ordered ({index, isAddress }) {}
59
60
Value () : Self () {}
60
61
} value;
61
62
@@ -71,10 +72,10 @@ struct LifetimeDescriptor {
71
72
SourceLoc loc)
72
73
: value{name}, kind(DescriptorKind::Named),
73
74
parsedLifetimeDependenceKind (parsedLifetimeDependenceKind), loc(loc) {}
74
- LifetimeDescriptor (unsigned index,
75
+ LifetimeDescriptor (unsigned index, bool isAddress,
75
76
ParsedLifetimeDependenceKind parsedLifetimeDependenceKind,
76
77
SourceLoc loc)
77
- : value{index}, kind(DescriptorKind::Ordered),
78
+ : value{index, isAddress }, kind(DescriptorKind::Ordered),
78
79
parsedLifetimeDependenceKind (parsedLifetimeDependenceKind), loc(loc) {}
79
80
LifetimeDescriptor (ParsedLifetimeDependenceKind parsedLifetimeDependenceKind,
80
81
SourceLoc loc)
@@ -91,8 +92,9 @@ struct LifetimeDescriptor {
91
92
static LifetimeDescriptor
92
93
forOrdered (unsigned index,
93
94
ParsedLifetimeDependenceKind parsedLifetimeDependenceKind,
94
- SourceLoc loc) {
95
- return {index, parsedLifetimeDependenceKind, loc};
95
+ SourceLoc loc,
96
+ bool isAddress = false ) {
97
+ return {index, isAddress, parsedLifetimeDependenceKind, loc};
96
98
}
97
99
static LifetimeDescriptor
98
100
forSelf (ParsedLifetimeDependenceKind parsedLifetimeDependenceKind,
@@ -113,6 +115,12 @@ struct LifetimeDescriptor {
113
115
assert (kind == DescriptorKind::Ordered);
114
116
return value.Ordered .index ;
115
117
}
118
+
119
+ bool isAddressable () const {
120
+ return kind == DescriptorKind::Ordered
121
+ ? value.Ordered .isAddress
122
+ : false ;
123
+ }
116
124
117
125
DescriptorKind getDescriptorKind () const { return kind; }
118
126
@@ -206,8 +214,9 @@ class LifetimeEntry final
206
214
class LifetimeDependenceInfo {
207
215
IndexSubset *inheritLifetimeParamIndices;
208
216
IndexSubset *scopeLifetimeParamIndices;
217
+ llvm::PointerIntPair<IndexSubset *, 1 , bool >
218
+ addressableParamIndicesAndImmortal;
209
219
unsigned targetIndex;
210
- bool immortal;
211
220
212
221
static LifetimeDependenceInfo getForIndex (AbstractFunctionDecl *afd,
213
222
unsigned targetIndex,
@@ -238,11 +247,14 @@ class LifetimeDependenceInfo {
238
247
public:
239
248
LifetimeDependenceInfo (IndexSubset *inheritLifetimeParamIndices,
240
249
IndexSubset *scopeLifetimeParamIndices,
241
- unsigned targetIndex, bool isImmortal)
250
+ unsigned targetIndex, bool isImmortal,
251
+ // set during SIL type lowering
252
+ IndexSubset *addressableParamIndices = nullptr )
242
253
: inheritLifetimeParamIndices(inheritLifetimeParamIndices),
243
254
scopeLifetimeParamIndices (scopeLifetimeParamIndices),
244
- targetIndex(targetIndex), immortal(isImmortal) {
245
- assert (isImmortal || inheritLifetimeParamIndices ||
255
+ addressableParamIndicesAndImmortal(addressableParamIndices, isImmortal),
256
+ targetIndex(targetIndex) {
257
+ assert (this ->isImmortal () || inheritLifetimeParamIndices ||
246
258
scopeLifetimeParamIndices);
247
259
assert (!inheritLifetimeParamIndices ||
248
260
!inheritLifetimeParamIndices->isEmpty ());
@@ -252,11 +264,11 @@ class LifetimeDependenceInfo {
252
264
operator bool () const { return !empty (); }
253
265
254
266
bool empty () const {
255
- return !immortal && inheritLifetimeParamIndices == nullptr &&
267
+ return !isImmortal () && inheritLifetimeParamIndices == nullptr &&
256
268
scopeLifetimeParamIndices == nullptr ;
257
269
}
258
270
259
- bool isImmortal () const { return immortal ; }
271
+ bool isImmortal () const { return addressableParamIndicesAndImmortal. getInt () ; }
260
272
261
273
unsigned getTargetIndex () const { return targetIndex; }
262
274
@@ -266,11 +278,18 @@ class LifetimeDependenceInfo {
266
278
bool hasScopeLifetimeParamIndices () const {
267
279
return scopeLifetimeParamIndices != nullptr ;
268
280
}
281
+ bool hasAddressableParamIndices () const {
282
+ return addressableParamIndicesAndImmortal.getPointer () != nullptr ;
283
+ }
269
284
270
285
IndexSubset *getInheritIndices () const { return inheritLifetimeParamIndices; }
271
286
272
287
IndexSubset *getScopeIndices () const { return scopeLifetimeParamIndices; }
273
288
289
+ IndexSubset *getAddressableIndices () const {
290
+ return addressableParamIndicesAndImmortal.getPointer ();
291
+ }
292
+
274
293
bool checkInherit (int index) const {
275
294
return inheritLifetimeParamIndices
276
295
&& inheritLifetimeParamIndices->contains (index);
@@ -300,15 +319,15 @@ class LifetimeDependenceInfo {
300
319
return this ->isImmortal () == other.isImmortal () &&
301
320
this ->getTargetIndex () == other.getTargetIndex () &&
302
321
this ->getInheritIndices () == other.getInheritIndices () &&
322
+ this ->getAddressableIndices () == other.getAddressableIndices () &&
303
323
this ->getScopeIndices () == other.getScopeIndices ();
304
324
}
305
325
306
326
bool operator !=(const LifetimeDependenceInfo &other) const {
307
- return this ->isImmortal () != other.isImmortal () &&
308
- this ->getTargetIndex () != other.getTargetIndex () &&
309
- this ->getInheritIndices () != other.getInheritIndices () &&
310
- this ->getScopeIndices () != other.getScopeIndices ();
327
+ return !(*this == other);
311
328
}
329
+
330
+ SWIFT_DEBUG_DUMPER (dump());
312
331
};
313
332
314
333
std::optional<LifetimeDependenceInfo>
0 commit comments