Move some calls to getVRegDef higher in the callgraph, so they don't get executed...
authorOwen Anderson <resistor@mac.com>
Tue, 15 Jan 2008 22:58:11 +0000 (22:58 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 15 Jan 2008 22:58:11 +0000 (22:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46027 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveVariables.h
lib/CodeGen/LiveVariables.cpp

index 311d37eeb39d45dd236b5f8a0cf8dd427310bc2b..a392cdaffbd96c964d465d4dfa9ae1dc137788e1 100644 (file)
@@ -303,8 +303,10 @@ public:
   /// register.
   VarInfo &getVarInfo(unsigned RegIdx);
 
-  void MarkVirtRegAliveInBlock(unsigned reg, MachineBasicBlock *BB);
-  void MarkVirtRegAliveInBlock(unsigned reg, MachineBasicBlock *BB,
+  void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
+                               MachineBasicBlock *BB);
+  void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
+                               MachineBasicBlock *BB,
                                std::vector<MachineBasicBlock*> &WorkList);
   void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB,
                         MachineInstr *MI);
index 70dd02927c2534bb536c27781ab228b2bb75e825..79c3192fdfd1481ebdb12614987125f451de5afb 100644 (file)
@@ -112,12 +112,11 @@ bool LiveVariables::ModifiesRegister(MachineInstr *MI, unsigned Reg) const {
   return false;
 }
 
-void LiveVariables::MarkVirtRegAliveInBlock(unsigned reg,
+void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo,
+                                            MachineBasicBlock *DefBlock,
                                             MachineBasicBlock *MBB,
                                     std::vector<MachineBasicBlock*> &WorkList) {
   unsigned BBNum = MBB->getNumber();
-
-  VarInfo& VRInfo = getVarInfo(reg);
   
   // Check to see if this basic block is one of the killing blocks.  If so,
   // remove it...
@@ -127,8 +126,7 @@ void LiveVariables::MarkVirtRegAliveInBlock(unsigned reg,
       break;
     }
   
-  MachineRegisterInfo& MRI = MBB->getParent()->getRegInfo();
-  if (MBB == MRI.getVRegDef(reg)->getParent()) return;  // Terminate recursion
+  if (MBB == DefBlock) return;  // Terminate recursion
 
   if (VRInfo.AliveBlocks[BBNum])
     return;  // We already know the block is live
@@ -141,14 +139,15 @@ void LiveVariables::MarkVirtRegAliveInBlock(unsigned reg,
     WorkList.push_back(*PI);
 }
 
-void LiveVariables::MarkVirtRegAliveInBlock(unsigned reg,
+void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo,
+                                            MachineBasicBlock *DefBlock,
                                             MachineBasicBlock *MBB) {
   std::vector<MachineBasicBlock*> WorkList;
-  MarkVirtRegAliveInBlock(reg, MBB, WorkList);
+  MarkVirtRegAliveInBlock(VRInfo, DefBlock, MBB, WorkList);
   while (!WorkList.empty()) {
     MachineBasicBlock *Pred = WorkList.back();
     WorkList.pop_back();
-    MarkVirtRegAliveInBlock(reg, Pred, WorkList);
+    MarkVirtRegAliveInBlock(VRInfo, DefBlock, Pred, WorkList);
   }
 }
 
@@ -190,7 +189,7 @@ void LiveVariables::HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB,
   // Update all dominating blocks to mark them known live.
   for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
          E = MBB->pred_end(); PI != E; ++PI)
-    MarkVirtRegAliveInBlock(reg, *PI);
+    MarkVirtRegAliveInBlock(VRInfo, MRI.getVRegDef(reg)->getParent(), *PI);
 }
 
 bool LiveVariables::addRegisterKilled(unsigned IncomingReg, MachineInstr *MI,
@@ -432,6 +431,7 @@ void LiveVariables::HandlePhysRegDef(unsigned Reg, MachineInstr *MI) {
 bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
   MF = &mf;
   RegInfo = MF->getTarget().getRegisterInfo();
+  MachineRegisterInfo& MRI = mf.getRegInfo();
   assert(RegInfo && "Target doesn't have register information?");
 
   ReservedRegisters = RegInfo->getReservedRegs(mf);
@@ -523,7 +523,8 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
       for (SmallVector<unsigned, 4>::iterator I = VarInfoVec.begin(),
              E = VarInfoVec.end(); I != E; ++I) {
         // Only mark it alive only in the block we are representing.
-        MarkVirtRegAliveInBlock(*I, MBB);
+        MarkVirtRegAliveInBlock(getVarInfo(*I), MRI.getVRegDef(*I)->getParent(),
+                                MBB);
       }
     }
 
@@ -560,7 +561,6 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
   // Convert and transfer the dead / killed information we have gathered into
   // VirtRegInfo onto MI's.
   //
-  MachineRegisterInfo& MRI = mf.getRegInfo();
   for (unsigned i = 0, e1 = VirtRegInfo.size(); i != e1; ++i)
     for (unsigned j = 0, e2 = VirtRegInfo[i].Kills.size(); j != e2; ++j) {
       if (VirtRegInfo[i].Kills[j] == MRI.getVRegDef(i +