@@ -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
@@ -2514,8 +2513,8 @@ static void setStaticInitAccess(SILValue memoryAddress) {
2514
2513
2515
2514
// / updateInstructionForInitState - When an instruction being analyzed moves
2516
2515
// / 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 .
2519
2518
void LifetimeChecker::updateInstructionForInitState (unsigned UseID) {
2520
2519
DIMemoryUse &Use = Uses[UseID];
2521
2520
SILInstruction *Inst = Use.Inst ;
@@ -2564,14 +2563,17 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
2564
2563
return ; \
2565
2564
}
2566
2565
#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 = [&] {
2573
2569
Use.Inst = nullptr ;
2574
2570
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 ();
2575
2577
2576
2578
if (TheMemory.isClassInitSelf () &&
2577
2579
Use.Kind == DIUseKind::SelfInit) {
@@ -2605,10 +2607,7 @@ void LifetimeChecker::updateInstructionForInitState(unsigned UseID) {
2605
2607
}
2606
2608
2607
2609
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 ();
2612
2611
2613
2612
switch (Use.Kind ) {
2614
2613
case DIUseKind::Assign:
@@ -3869,16 +3868,14 @@ static bool checkDefiniteInitialization(SILFunction &Fn) {
3869
3868
3870
3869
namespace {
3871
3870
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.
3874
3872
class DefiniteInitialization : public SILFunctionTransform {
3875
3873
// / The entry point to the transformation.
3876
3874
void run () override {
3877
3875
// Don't rerun diagnostics on deserialized functions.
3878
3876
if (getFunction ()->wasDeserializedCanonical ())
3879
3877
return ;
3880
3878
3881
- // Walk through and promote all of the alloc_box's that we can.
3882
3879
if (checkDefiniteInitialization (*getFunction ())) {
3883
3880
invalidateAnalysis (SILAnalysis::InvalidationKind::FunctionBody);
3884
3881
}
0 commit comments