@@ -147,15 +147,21 @@ struct ValueStorage {
147
147
// The definition of this value is fully translated to lowered SIL.
148
148
unsigned isRewritten : 1 ;
149
149
150
- // This is a use-projection into an enum. Tracked to avoid projecting enums
151
- // across phis, which would result in piecewise initialization.
152
- unsigned initializesEnum : 1 ;
150
+ // This is a use-projection which performs an initialization side-effect,
151
+ // either into an enum or an existential.
152
+ //
153
+ // Tracked to avoid projecting enums/existentials across phis, which would
154
+ // result in piecewise initialization.
155
+ //
156
+ // Note that the corresponding value is the payload, not the
157
+ // enum instruction.
158
+ unsigned initializes : 1 ;
153
159
154
160
ValueStorage (SILValue storageAddress): storageAddress(storageAddress) {
155
161
isDefProjection = false ;
156
162
isUseProjection = false ;
157
163
isRewritten = false ;
158
- initializesEnum = false ;
164
+ initializes = false ;
159
165
160
166
// The initial storage address is only valid when the value is effectively
161
167
// already rewritten.
@@ -346,12 +352,13 @@ class ValueStorageMap {
346
352
}
347
353
348
354
// / Return the non-projection storage that this storage refers to. If this
349
- // / storage holds an Enum or any intermediate storage that projects into this
350
- // / storage holds an Enum, then return nullptr.
351
- const ValueStorage *getNonEnumBaseStorage (SILValue value) {
355
+ // / storage requires materializing an instruction that performs
356
+ // / initialization side effects (init_enum_data_addr, init_existential_addr),
357
+ // / return nullptr.
358
+ const ValueStorage *getNonInitializingBaseStorage (SILValue value) {
352
359
for (auto *pair : getProjections (value)) {
353
360
auto const &storage = pair->storage ;
354
- if (storage.initializesEnum )
361
+ if (storage.initializes )
355
362
return nullptr ;
356
363
357
364
if (storage.isUseProjection ) {
@@ -365,12 +372,12 @@ class ValueStorageMap {
365
372
}
366
373
367
374
// / Return the non-projection storage that this storage refers to, or nullptr
368
- // / if \p allowInitEnum is true and the storage initializes an Enum.
369
- const ValueStorage *getBaseStorage (SILValue value, bool allowInitEnum ) {
370
- if (allowInitEnum )
375
+ // / if \p allowInit is true and the storage initializes an Enum.
376
+ const ValueStorage *getBaseStorage (SILValue value, bool allowInit ) {
377
+ if (allowInit )
371
378
return &getBaseStorage (value);
372
379
373
- return getNonEnumBaseStorage (value);
380
+ return getNonInitializingBaseStorage (value);
374
381
}
375
382
376
383
void setStorageAddress (SILValue value, SILValue addr) {
0 commit comments