[llvm-commits] [llvm] r56412 - in /llvm/trunk: include/llvm/CodeGen/LiveVariables.h lib/CodeGen/LiveVariables.cpp

Dan Gohman gohman at apple.com
Sun Sep 21 14:11:42 PDT 2008


Author: djg
Date: Sun Sep 21 16:11:41 2008
New Revision: 56412

URL: http://llvm.org/viewvc/llvm-project?rev=56412&view=rev
Log:
Factor out code into HandleVirtRegDef, for consistency with
Handle{Virt,Phys}Reg{Def,Use}. Remove a redundant check
for register zero, and redundant checks for isPhysicalRegister.

Modified:
    llvm/trunk/include/llvm/CodeGen/LiveVariables.h
    llvm/trunk/lib/CodeGen/LiveVariables.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveVariables.h?rev=56412&r1=56411&r2=56412&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveVariables.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveVariables.h Sun Sep 21 16:11:41 2008
@@ -263,6 +263,7 @@
   void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
                                MachineBasicBlock *BB,
                                std::vector<MachineBasicBlock*> &WorkList);
+  void HandleVirtRegDef(unsigned reg, MachineInstr *MI);
   void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB,
                         MachineInstr *MI);
 };

Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=56412&r1=56411&r2=56412&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Sun Sep 21 16:11:41 2008
@@ -177,6 +177,14 @@
     MarkVirtRegAliveInBlock(VRInfo, MRI->getVRegDef(reg)->getParent(), *PI);
 }
 
+void LiveVariables::HandleVirtRegDef(unsigned Reg, MachineInstr *MI) {
+  VarInfo &VRInfo = getVarInfo(Reg);
+
+  if (VRInfo.AliveBlocks.none())
+    // If vr is not alive in any block, then defaults to dead.
+    VRInfo.Kills.push_back(MI);
+}
+
 /// FindLastPartialDef - Return the last partial def of the specified register.
 /// Also returns the sub-register that's defined.
 MachineInstr *LiveVariables::FindLastPartialDef(unsigned Reg,
@@ -552,8 +560,6 @@
         const MachineOperand &MO = MI->getOperand(i);
         if (MO.isRegister() && MO.getReg()) {
           unsigned MOReg = MO.getReg();
-          if (!MOReg)
-            continue;
           if (MO.isUse())
             UseRegs.push_back(MOReg);
           if (MO.isDef())
@@ -566,24 +572,17 @@
         unsigned MOReg = UseRegs[i];
         if (TargetRegisterInfo::isVirtualRegister(MOReg))
           HandleVirtRegUse(MOReg, MBB, MI);
-        else if (TargetRegisterInfo::isPhysicalRegister(MOReg) &&
-                 !ReservedRegisters[MOReg])
+        else if (!ReservedRegisters[MOReg])
           HandlePhysRegUse(MOReg, MI);
       }
 
       // Process all defs.
       for (unsigned i = 0, e = DefRegs.size(); i != e; ++i) {
         unsigned MOReg = DefRegs[i];
-        if (TargetRegisterInfo::isVirtualRegister(MOReg)) {
-          VarInfo &VRInfo = getVarInfo(MOReg);
-
-          if (VRInfo.AliveBlocks.none())
-            // If vr is not alive in any block, then defaults to dead.
-            VRInfo.Kills.push_back(MI);
-        } else if (TargetRegisterInfo::isPhysicalRegister(MOReg) &&
-                   !ReservedRegisters[MOReg]) {
+        if (TargetRegisterInfo::isVirtualRegister(MOReg))
+          HandleVirtRegDef(MOReg, MI);
+        else if (!ReservedRegisters[MOReg])
           HandlePhysRegDef(MOReg, MI);
-        }
       }
     }
 





More information about the llvm-commits mailing list