@@ -1114,8 +1114,7 @@ void LifetimeChecker::injectActorHops() {
11141114
11151115void LifetimeChecker::doIt () {
11161116 // With any escapes tallied up, we can work through all the uses, checking
1117- // for definitive initialization, promoting loads, rewriting assigns, and
1118- // performing other tasks.
1117+ // for definitive initialization and performing other tasks.
11191118
11201119 // Note that this should not use a for-each loop, as the Uses list can grow
11211120 // and reallocate as we iterate over it.
@@ -1185,7 +1184,7 @@ void LifetimeChecker::doIt() {
11851184 }
11861185 }
11871186
1188- // If we emitted an error, there is no reason to proceed with load promotion .
1187+ // If we emitted an error, there is no reason to proceed.
11891188 if (!EmittedErrorLocs.empty ()) {
11901189 // Since we failed DI, for now, turn off the move checker on the entire
11911190 // function. With time, we should be able to allow for move checker checks
@@ -2514,8 +2513,8 @@ static void setStaticInitAccess(SILValue memoryAddress) {
25142513
25152514// / updateInstructionForInitState - When an instruction being analyzed moves
25162515// / from being InitOrAssign to some concrete state, update it for that state.
2517- // / This includes rewriting them from assign instructions into their composite
2518- // / operations .
2516+ // / This includes marking assign instructions so they will be appropriately
2517+ // / handled during RawSILInstLowering .
25192518void LifetimeChecker::updateInstructionForInitState (unsigned UseID) {
25202519 DIMemoryUse &Use = Uses[UseID];
25212520 SILInstruction *Inst = Use.Inst ;
@@ -2564,14 +2563,17 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
25642563 return ; \
25652564 }
25662565#include " swift/AST/ReferenceStorage.def"
2567-
2568- // If this is an assign, rewrite it based on whether it is an initialization
2569- // or not.
2570- if (auto *AI = dyn_cast<AssignInst>(Inst)) {
2571- // Remove this instruction from our data structures, since we will be
2572- // removing it.
2566+
2567+ // Helper to remove the instruction from our data structures.
2568+ auto eraseUseInst = [&] {
25732569 Use.Inst = nullptr ;
25742570 llvm::erase_if (NonLoadUses[Inst], [&](unsigned id) { return id == UseID; });
2571+ };
2572+
2573+ // If this is an assign, mark it so that RawSILInstLowering can handle it
2574+ // appropriately.
2575+ if (auto *AI = dyn_cast<AssignInst>(Inst)) {
2576+ eraseUseInst ();
25752577
25762578 if (TheMemory.isClassInitSelf () &&
25772579 Use.Kind == DIUseKind::SelfInit) {
@@ -2605,10 +2607,7 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
26052607 }
26062608
26072609 if (auto *AI = dyn_cast<AssignOrInitInst>(Inst)) {
2608- // Remove this instruction from our data structures, since we will be
2609- // removing it.
2610- Use.Inst = nullptr ;
2611- llvm::erase_if (NonLoadUses[Inst], [&](unsigned id) { return id == UseID; });
2610+ eraseUseInst ();
26122611
26132612 switch (Use.Kind ) {
26142613 case DIUseKind::Assign:
@@ -3869,16 +3868,14 @@ static bool checkDefiniteInitialization(SILFunction &Fn) {
38693868
38703869namespace {
38713870
3872- // / Perform definitive initialization analysis and promote alloc_box uses into
3873- // / SSA registers for later SSA-based dataflow passes.
3871+ // / Perform definitive initialization analysis.
38743872class DefiniteInitialization : public SILFunctionTransform {
38753873 // / The entry point to the transformation.
38763874 void run () override {
38773875 // Don't rerun diagnostics on deserialized functions.
38783876 if (getFunction ()->wasDeserializedCanonical ())
38793877 return ;
38803878
3881- // Walk through and promote all of the alloc_box's that we can.
38823879 if (checkDefiniteInitialization (*getFunction ())) {
38833880 invalidateAnalysis (SILAnalysis::InvalidationKind::FunctionBody);
38843881 }
0 commit comments