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

Chris Lattner lattner at cs.uiuc.edu
Sun Jan 23 14:56:00 PST 2005



Changes in directory llvm/lib/CodeGen:

RegAllocSimple.cpp updated: 1.61 -> 1.62
---
Log message:

Update physregsused info.


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

 RegAllocSimple.cpp |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/RegAllocSimple.cpp
diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.61 llvm/lib/CodeGen/RegAllocSimple.cpp:1.62
--- llvm/lib/CodeGen/RegAllocSimple.cpp:1.61	Wed Sep  1 17:55:35 2004
+++ llvm/lib/CodeGen/RegAllocSimple.cpp	Sun Jan 23 16:55:45 2005
@@ -35,6 +35,7 @@
     MachineFunction *MF;
     const TargetMachine *TM;
     const MRegisterInfo *RegInfo;
+    bool *PhysRegsEverUsed;
     
     // StackSlotForVirtReg - Maps SSA Regs => frame index on the stack where
     // these values are spilled
@@ -118,8 +119,10 @@
     assert(RI+regIdx != RE && "Not enough registers!");
     unsigned PhysReg = *(RI+regIdx);
     
-    if (!RegsUsed[PhysReg])
+    if (!RegsUsed[PhysReg]) {
+      PhysRegsEverUsed[PhysReg] = true;
       return PhysReg;
+    }
   }
 }
 
@@ -156,19 +159,20 @@
 
     RegsUsed.resize(RegInfo->getNumRegs());
     
-    // a preliminary pass that will invalidate any registers that
-    // are used by the instruction (including implicit uses)
+    // This is a preliminary pass that will invalidate any registers that are
+    // used by the instruction (including implicit uses).
     unsigned Opcode = MI->getOpcode();
     const TargetInstrDescriptor &Desc = TM->getInstrInfo()->get(Opcode);
-    const unsigned *Regs = Desc.ImplicitUses;
-    while (*Regs)
-      RegsUsed[*Regs++] = true;
+    const unsigned *Regs;
+    for (Regs = Desc.ImplicitUses; *Regs; ++Regs)
+      RegsUsed[*Regs] = true;
     
-    Regs = Desc.ImplicitDefs;
-    while (*Regs)
-      RegsUsed[*Regs++] = true;
+    for (Regs = Desc.ImplicitDefs; *Regs; ++Regs) {
+      RegsUsed[*Regs] = true;
+      PhysRegsEverUsed[*Regs] = true;
+    }
     
-    // Loop over uses, move from memory into registers
+    // Loop over uses, move from memory into registers.
     for (int i = MI->getNumOperands() - 1; i >= 0; --i) {
       MachineOperand &op = MI->getOperand(i);
       
@@ -225,6 +229,10 @@
   TM = &MF->getTarget();
   RegInfo = TM->getRegisterInfo();
 
+  PhysRegsEverUsed = new bool[RegInfo->getNumRegs()];
+  std::fill(PhysRegsEverUsed, PhysRegsEverUsed+RegInfo->getNumRegs(), false);
+  Fn.setUsedPhysRegs(PhysRegsEverUsed);
+
   // Loop over all of the basic blocks, eliminating virtual register references
   for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end();
        MBB != MBBe; ++MBB)






More information about the llvm-commits mailing list