Skip to content

Commit 38263ca

Browse files
committed
DI: Small cleanups
- Handle DIMemoryUse::Kind::IndirectIn just like Load - Consolidate duplicated 'only touches trivial elements' check
1 parent 71c11b7 commit 38263ca

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ namespace {
459459

460460

461461
void handleStoreUse(unsigned UseID);
462-
void handleLoadUse(unsigned UseID);
462+
void handleLoadUse(const DIMemoryUse &Use);
463463
void handleLoadForTypeOfSelfUse(const DIMemoryUse &Use);
464464
void handleInOutUse(const DIMemoryUse &Use);
465465
void handleEscapeUse(const DIMemoryUse &Use);
@@ -765,15 +765,9 @@ void LifetimeChecker::doIt() {
765765
handleStoreUse(i);
766766
break;
767767

768-
case DIUseKind::IndirectIn: {
769-
bool IsSuperInitComplete, FailedSelfUse;
770-
// If the value is not definitively initialized, emit an error.
771-
if (!isInitializedAtUse(Use, &IsSuperInitComplete, &FailedSelfUse))
772-
handleLoadUseFailure(Use, IsSuperInitComplete, FailedSelfUse);
773-
break;
774-
}
768+
case DIUseKind::IndirectIn:
775769
case DIUseKind::Load:
776-
handleLoadUse(i);
770+
handleLoadUse(Use);
777771
break;
778772
case DIUseKind::InOutArgument:
779773
case DIUseKind::InOutSelfArgument:
@@ -814,9 +808,7 @@ void LifetimeChecker::doIt() {
814808
handleConditionalDestroys(ControlVariable);
815809
}
816810

817-
void LifetimeChecker::handleLoadUse(unsigned UseID) {
818-
DIMemoryUse &Use = Uses[UseID];
819-
811+
void LifetimeChecker::handleLoadUse(const DIMemoryUse &Use) {
820812
bool IsSuperInitComplete, FailedSelfUse;
821813
// If the value is not definitively initialized, emit an error.
822814
if (!isInitializedAtUse(Use, &IsSuperInitComplete, &FailedSelfUse))
@@ -2194,6 +2186,12 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
21942186

21952187
// Ignore deleted uses.
21962188
if (Use.Inst == nullptr) continue;
2189+
2190+
// If this ambiguous store is only of trivial types, then we don't need to
2191+
// do anything special. We don't even need keep the init bit for the
2192+
// element precise.
2193+
if (Use.onlyTouchesTrivialElements(TheMemory))
2194+
continue;
21972195

21982196
B.setInsertionPoint(Use.Inst);
21992197

@@ -2209,23 +2207,12 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
22092207

22102208
case DIUseKind::SelfInit:
22112209
case DIUseKind::Initialization:
2212-
// If this is an initialization of only trivial elements, then we don't
2213-
// need to update the bitvector.
2214-
if (Use.onlyTouchesTrivialElements(TheMemory))
2215-
continue;
2216-
22172210
APInt Bitmask = Use.getElementBitmask(NumMemoryElements);
22182211
SILBuilderWithScope SB(Use.Inst);
22192212
updateControlVariable(Loc, Bitmask, ControlVariableAddr, OrFn, SB);
22202213
continue;
22212214
}
22222215

2223-
// If this ambiguous store is only of trivial types, then we don't need to
2224-
// do anything special. We don't even need keep the init bit for the
2225-
// element precise.
2226-
if (Use.onlyTouchesTrivialElements(TheMemory))
2227-
continue;
2228-
22292216
// If this is the interesting case, we need to generate a CFG diamond for
22302217
// each element touched, destroying any live elements so that the resulting
22312218
// store is always an initialize. This disambiguates the dynamic

0 commit comments

Comments
 (0)