@@ -100,15 +100,21 @@ struct ValueStorage {
100
100
// The definition of this value is fully translated to lowered SIL.
101
101
unsigned isRewritten : 1 ;
102
102
103
- // This is a use-projection into an enum. Tracked to avoid projecting enums
104
- // across phis, which would result in piecewise initialization.
105
- unsigned initializesEnum : 1 ;
103
+ // This is a use-projection which performs an initialization side-effect,
104
+ // either into an enum or an existential.
105
+ //
106
+ // Tracked to avoid projecting enums/existentials across phis, which would
107
+ // result in piecewise initialization.
108
+ //
109
+ // Note that the corresponding value is the payload, not the
110
+ // enum instruction.
111
+ unsigned initializes : 1 ;
106
112
107
113
ValueStorage (SILValue storageAddress): storageAddress(storageAddress) {
108
114
isDefProjection = false ;
109
115
isUseProjection = false ;
110
116
isRewritten = false ;
111
- initializesEnum = false ;
117
+ initializes = false ;
112
118
113
119
// The initial storage address is only valid when the value is effectively
114
120
// already rewritten.
@@ -299,12 +305,13 @@ class ValueStorageMap {
299
305
}
300
306
301
307
// / Return the non-projection storage that this storage refers to. If this
302
- // / storage holds an Enum or any intermediate storage that projects into this
303
- // / storage holds an Enum, then return nullptr.
304
- const ValueStorage *getNonEnumBaseStorage (SILValue value) {
308
+ // / storage requires materializing an instruction that performs
309
+ // / initialization side effects (init_enum_data_addr, init_existential_addr),
310
+ // / return nullptr.
311
+ const ValueStorage *getNonInitializingBaseStorage (SILValue value) {
305
312
for (auto *pair : getProjections (value)) {
306
313
auto const &storage = pair->storage ;
307
- if (storage.initializesEnum )
314
+ if (storage.initializes )
308
315
return nullptr ;
309
316
310
317
if (storage.isUseProjection ) {
@@ -318,12 +325,12 @@ class ValueStorageMap {
318
325
}
319
326
320
327
// / Return the non-projection storage that this storage refers to, or nullptr
321
- // / if \p allowInitEnum is true and the storage initializes an Enum.
322
- const ValueStorage *getBaseStorage (SILValue value, bool allowInitEnum ) {
323
- if (allowInitEnum )
328
+ // / if \p allowInit is true and the storage initializes an Enum.
329
+ const ValueStorage *getBaseStorage (SILValue value, bool allowInit ) {
330
+ if (allowInit )
324
331
return &getBaseStorage (value);
325
332
326
- return getNonEnumBaseStorage (value);
333
+ return getNonInitializingBaseStorage (value);
327
334
}
328
335
329
336
void setStorageAddress (SILValue value, SILValue addr) {
0 commit comments