Bring UsedBlocks back. StrongPHIElimination needs this information.
authorOwen Anderson <resistor@mac.com>
Thu, 8 Nov 2007 01:20:48 +0000 (01:20 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 8 Nov 2007 01:20:48 +0000 (01:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43866 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveVariables.cpp
lib/CodeGen/PHIElimination.cpp
lib/CodeGen/TwoAddressInstructionPass.cpp

index 7e8965ea840d9ce6e4d748506c78a443cd844b4f..2af8bf316e15aa4d48dbfa814dc3adcfa457e911 100644 (file)
@@ -50,6 +50,9 @@ void LiveVariables::VarInfo::dump() const {
   cerr << "  Alive in blocks: ";
   for (unsigned i = 0, e = AliveBlocks.size(); i != e; ++i)
     if (AliveBlocks[i]) cerr << i << ", ";
+  cerr << "  Used in blocks: ";
+  for (unsigned i = 0, e = UsedBlocks.size(); i != e; ++i)
+    if (UsedBlocks[i]) cerr << i << ", ";
   cerr << "\n  Killed by:";
   if (Kills.empty())
     cerr << " No instructions.\n";
@@ -72,6 +75,7 @@ LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) {
   }
   VarInfo &VI = VirtRegInfo[RegIdx];
   VI.AliveBlocks.resize(MF->getNumBlockIDs());
+  VI.UsedBlocks.resize(MF->getNumBlockIDs());
   return VI;
 }
 
@@ -154,6 +158,9 @@ void LiveVariables::HandleVirtRegUse(VarInfo &VRInfo, MachineBasicBlock *MBB,
                                      MachineInstr *MI) {
   assert(VRInfo.DefInst && "Register use before def!");
 
+  unsigned BBNum = MBB->getNumber();
+
+  VRInfo.UsedBlocks[BBNum] = true;
   VRInfo.NumUses++;
 
   // Check to see if this basic block is already a kill block...
@@ -176,7 +183,7 @@ void LiveVariables::HandleVirtRegUse(VarInfo &VRInfo, MachineBasicBlock *MBB,
   // If this virtual register is already marked as alive in this basic block,
   // that means it is alive in at least one of the successor block, it's not
   // a kill.
-  if (!VRInfo.AliveBlocks[MBB->getNumber()])
+  if (!VRInfo.AliveBlocks[BBNum])
     VRInfo.Kills.push_back(MI);
 
   // Update all dominating blocks to mark them known live.
index ffec6ca6d78ce8d70dff0cc3a57f83f6e93f995f..371fb072b5b8572406c440db88777678e08b5fb1 100644 (file)
@@ -167,6 +167,8 @@ void PNE::LowerAtomicPHINode(MachineBasicBlock &MBB,
     // Realize that the destination register is defined by the PHI copy now, not
     // the PHI itself.
     LV->getVarInfo(DestReg).DefInst = PHICopy;
+
+    LV->getVarInfo(IncomingReg).UsedBlocks[MBB.getNumber()] = true;
   }
 
   // Adjust the VRegPHIUseCount map to account for the removal of this PHI
@@ -217,6 +219,7 @@ void PNE::LowerAtomicPHINode(MachineBasicBlock &MBB,
     // instruction kills the incoming value.
     //
     LiveVariables::VarInfo &InRegVI = LV->getVarInfo(SrcReg);
+    InRegVI.UsedBlocks[opBlock.getNumber()] = true;
 
     // Loop over all of the successors of the basic block, checking to see
     // if the value is either live in the block, or if it is killed in the
index 277257bd61d46417cda2ba2ae3b4b384702fbf99..b8d38dc229ef4b6e15fb145824988c2ae258df3b 100644 (file)
@@ -202,6 +202,10 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
           LiveVariables::VarInfo& varInfo = LV.getVarInfo(regA);
           varInfo.DefInst = prevMi;
 
+          // update live variables for regB
+          LiveVariables::VarInfo& varInfoB = LV.getVarInfo(regB);
+          // regB is used in this BB.
+          varInfoB.UsedBlocks[mbbi->getNumber()] = true;
           if (LV.removeVirtualRegisterKilled(regB, mbbi, mi))
             LV.addVirtualRegisterKilled(regB, prevMi);