@@ -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
@@ -2512,8 +2511,8 @@ static void setStaticInitAccess(SILValue memoryAddress) {
25122511
25132512// / updateInstructionForInitState - When an instruction being analyzed moves
25142513// / from being InitOrAssign to some concrete state, update it for that state.
2515- // / This includes rewriting them from assign instructions into their composite
2516- // / operations .
2514+ // / This includes marking assign instructions so they will be appropriately
2515+ // / handled during RawSILInstLowering .
25172516void LifetimeChecker::updateInstructionForInitState (unsigned UseID) {
25182517 DIMemoryUse &Use = Uses[UseID];
25192518 SILInstruction *Inst = Use.Inst ;
@@ -2562,14 +2561,17 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
25622561 return ; \
25632562 }
25642563#include " swift/AST/ReferenceStorage.def"
2565-
2566- // If this is an assign, rewrite it based on whether it is an initialization
2567- // or not.
2568- if (auto *AI = dyn_cast<AssignInst>(Inst)) {
2569- // Remove this instruction from our data structures, since we will be
2570- // removing it.
2564+
2565+ // Helper to remove the instruction from our data structures.
2566+ auto eraseUseInst = [&] {
25712567 Use.Inst = nullptr ;
25722568 llvm::erase_if (NonLoadUses[Inst], [&](unsigned id) { return id == UseID; });
2569+ };
2570+
2571+ // If this is an assign, mark it so that RawSILInstLowering can handle it
2572+ // appropriately.
2573+ if (auto *AI = dyn_cast<AssignInst>(Inst)) {
2574+ eraseUseInst ();
25732575
25742576 if (TheMemory.isClassInitSelf () &&
25752577 Use.Kind == DIUseKind::SelfInit) {
@@ -2603,10 +2605,7 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
26032605 }
26042606
26052607 if (auto *AI = dyn_cast<AssignOrInitInst>(Inst)) {
2606- // Remove this instruction from our data structures, since we will be
2607- // removing it.
2608- Use.Inst = nullptr ;
2609- llvm::erase_if (NonLoadUses[Inst], [&](unsigned id) { return id == UseID; });
2608+ eraseUseInst ();
26102609
26112610 switch (Use.Kind ) {
26122611 case DIUseKind::Assign:
@@ -3867,16 +3866,14 @@ static bool checkDefiniteInitialization(SILFunction &Fn) {
38673866
38683867namespace {
38693868
3870- // / Perform definitive initialization analysis and promote alloc_box uses into
3871- // / SSA registers for later SSA-based dataflow passes.
3869+ // / Perform definitive initialization analysis.
38723870class DefiniteInitialization : public SILFunctionTransform {
38733871 // / The entry point to the transformation.
38743872 void run () override {
38753873 // Don't rerun diagnostics on deserialized functions.
38763874 if (getFunction ()->wasDeserializedCanonical ())
38773875 return ;
38783876
3879- // Walk through and promote all of the alloc_box's that we can.
38803877 if (checkDefiniteInitialization (*getFunction ())) {
38813878 invalidateAnalysis (SILAnalysis::InvalidationKind::FunctionBody);
38823879 }
0 commit comments