[llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 8 19:36:02 PST 2004


Changes in directory llvm/lib/CodeGen:

LiveVariables.cpp updated: 1.17 -> 1.18

---
Log message:

Only do stuff for the REAL number of physical registers we have, not 1024.
This speeds up live variables a lot, from .60/.39s -> .47/.26s in LLC, for
the first/second pass respectively.



---
Diffs of the changes:  (+8 -10)

Index: llvm/lib/CodeGen/LiveVariables.cpp
diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.17 llvm/lib/CodeGen/LiveVariables.cpp:1.18
--- llvm/lib/CodeGen/LiveVariables.cpp:1.17	Sat Jan 31 15:27:19 2004
+++ llvm/lib/CodeGen/LiveVariables.cpp	Sun Feb  8 19:35:21 2004
@@ -158,17 +158,18 @@
 }
 
 bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
+  const TargetInstrInfo &TII = MF.getTarget().getInstrInfo();
+  RegInfo = MF.getTarget().getRegisterInfo();
+  assert(RegInfo && "Target doesn't have register information?");
+
   // First time though, initialize AllocatablePhysicalRegisters for the target
   if (AllocatablePhysicalRegisters.empty()) {
-    const MRegisterInfo &MRI = *MF.getTarget().getRegisterInfo();
-    assert(&MRI && "Target doesn't have register information?");
-
     // Make space, initializing to false...
-    AllocatablePhysicalRegisters.resize(MRegisterInfo::FirstVirtualRegister);
+    AllocatablePhysicalRegisters.resize(RegInfo->getNumRegs());
 
     // Loop over all of the register classes...
-    for (MRegisterInfo::regclass_iterator RCI = MRI.regclass_begin(),
-           E = MRI.regclass_end(); RCI != E; ++RCI)
+    for (MRegisterInfo::regclass_iterator RCI = RegInfo->regclass_begin(),
+           E = RegInfo->regclass_end(); RCI != E; ++RCI)
       // Loop over all of the allocatable registers in the function...
       for (TargetRegisterClass::iterator I = (*RCI)->allocation_order_begin(MF),
              E = (*RCI)->allocation_order_end(MF); I != E; ++I)
@@ -191,9 +192,6 @@
   PhysRegInfo = PhysRegInfoA;
   PhysRegUsed = PhysRegUsedA;
 
-  const TargetInstrInfo &TII = MF.getTarget().getInstrInfo();
-  RegInfo = MF.getTarget().getRegisterInfo();
-
   /// Get some space for a respectable number of registers...
   VirtRegInfo.resize(64);
   
@@ -294,7 +292,7 @@
     
     // Loop over PhysRegInfo, killing any registers that are available at the
     // end of the basic block.  This also resets the PhysRegInfo map.
-    for (unsigned i = 0, e = MRegisterInfo::FirstVirtualRegister; i != e; ++i)
+    for (unsigned i = 0, e = RegInfo->getNumRegs(); i != e; ++i)
       if (PhysRegInfo[i])
 	HandlePhysRegDef(i, 0);
   }





More information about the llvm-commits mailing list