Skip to content

Commit eab1800

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

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);
@@ -764,15 +764,9 @@ void LifetimeChecker::doIt() {
764764
handleStoreUse(i);
765765
break;
766766

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

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

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

21972195
B.setInsertionPoint(Use.Inst);
21982196

@@ -2208,23 +2206,12 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
22082206

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

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

0 commit comments

Comments
 (0)