[PHIElimination] Update LiveVariables after handling an unspillable terminator
authorJay Foad <jay.foad@amd.com>
Fri, 1 Oct 2021 14:39:38 +0000 (15:39 +0100)
committerJay Foad <jay.foad@amd.com>
Tue, 5 Oct 2021 13:25:53 +0000 (14:25 +0100)
Update the LiveVariables analysis after the special handling for
unspillable terminators which was added in D91358. This is just enough
to fix some "Block should not be in AliveBlocks" / "Block missing from
AliveBlocks" errors in the codegen test suite when machine verification
is forced to run after PHIElimination (currently it is disabled).

Differential Revision: https://reviews.llvm.org/D110939

llvm/lib/CodeGen/PHIElimination.cpp

index 5480558..21d4bae 100644 (file)
@@ -461,6 +461,15 @@ void PHIElimination::LowerPHINode(MachineBasicBlock &MBB,
       assert(MRI->use_empty(SrcReg) &&
              "Expected a single use from UnspillableTerminator");
       SrcRegDef->getOperand(0).setReg(IncomingReg);
+
+      // Update LiveVariables.
+      if (LV) {
+        LiveVariables::VarInfo &SrcVI = LV->getVarInfo(SrcReg);
+        LiveVariables::VarInfo &IncomingVI = LV->getVarInfo(IncomingReg);
+        IncomingVI.AliveBlocks = std::move(SrcVI.AliveBlocks);
+        SrcVI.AliveBlocks.clear();
+      }
+
       continue;
     }