@@ -1114,8 +1114,7 @@ void LifetimeChecker::injectActorHops() {
1114
1114
1115
1115
void LifetimeChecker::doIt () {
1116
1116
// 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.
1119
1118
1120
1119
// Note that this should not use a for-each loop, as the Uses list can grow
1121
1120
// and reallocate as we iterate over it.
@@ -1185,7 +1184,7 @@ void LifetimeChecker::doIt() {
1185
1184
}
1186
1185
}
1187
1186
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.
1189
1188
if (!EmittedErrorLocs.empty ()) {
1190
1189
// Since we failed DI, for now, turn off the move checker on the entire
1191
1190
// function. With time, we should be able to allow for move checker checks
@@ -2512,8 +2511,8 @@ static void setStaticInitAccess(SILValue memoryAddress) {
2512
2511
2513
2512
// / updateInstructionForInitState - When an instruction being analyzed moves
2514
2513
// / 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 .
2517
2516
void LifetimeChecker::updateInstructionForInitState (unsigned UseID) {
2518
2517
DIMemoryUse &Use = Uses[UseID];
2519
2518
SILInstruction *Inst = Use.Inst ;
@@ -2562,14 +2561,17 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
2562
2561
return ; \
2563
2562
}
2564
2563
#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 = [&] {
2571
2567
Use.Inst = nullptr ;
2572
2568
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 ();
2573
2575
2574
2576
if (TheMemory.isClassInitSelf () &&
2575
2577
Use.Kind == DIUseKind::SelfInit) {
@@ -2603,10 +2605,7 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
2603
2605
}
2604
2606
2605
2607
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 ();
2610
2609
2611
2610
switch (Use.Kind ) {
2612
2611
case DIUseKind::Assign:
@@ -3867,16 +3866,14 @@ static bool checkDefiniteInitialization(SILFunction &Fn) {
3867
3866
3868
3867
namespace {
3869
3868
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.
3872
3870
class DefiniteInitialization : public SILFunctionTransform {
3873
3871
// / The entry point to the transformation.
3874
3872
void run () override {
3875
3873
// Don't rerun diagnostics on deserialized functions.
3876
3874
if (getFunction ()->wasDeserializedCanonical ())
3877
3875
return ;
3878
3876
3879
- // Walk through and promote all of the alloc_box's that we can.
3880
3877
if (checkDefiniteInitialization (*getFunction ())) {
3881
3878
invalidateAnalysis (SILAnalysis::InvalidationKind::FunctionBody);
3882
3879
}
0 commit comments