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

Alkis Evlogimenos alkis at cs.uiuc.edu
Sun Mar 14 01:21:01 PST 2004


Changes in directory llvm/lib/CodeGen:

RegAllocLocal.cpp updated: 1.60 -> 1.61
LiveIntervals.cpp updated: 1.65 -> 1.66

---
Log message:

Change MRegisterInfo::foldMemoryOperand to return the folded
instruction to make the API more flexible.


---
Diffs of the changes:  (+12 -11)

Index: llvm/lib/CodeGen/RegAllocLocal.cpp
diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.60 llvm/lib/CodeGen/RegAllocLocal.cpp:1.61
--- llvm/lib/CodeGen/RegAllocLocal.cpp:1.60	Thu Feb 26 16:00:20 2004
+++ llvm/lib/CodeGen/RegAllocLocal.cpp	Sun Mar 14 01:19:51 2004
@@ -487,13 +487,12 @@
     assignVirtToPhysReg(VirtReg, PhysReg);
   } else {         // No registers available.
     // If we can fold this spill into this instruction, do so now.
-    MachineBasicBlock::iterator MII = MI;
-    if (RegInfo->foldMemoryOperand(MII, OpNum, FrameIndex)) {
+    if (MachineInstr* FMI = RegInfo->foldMemoryOperand(MI, OpNum, FrameIndex)){
       ++NumFolded;
       // Since we changed the address of MI, make sure to update live variables
       // to know that the new instruction has the properties of the old one.
-      LV->instructionChanged(MI, MII);
-      return MII;
+      LV->instructionChanged(MI, FMI);
+      return MBB.insert(MBB.erase(MI), FMI);
     }
 
     // It looks like we can't fold this virtual register load into this


Index: llvm/lib/CodeGen/LiveIntervals.cpp
diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.65 llvm/lib/CodeGen/LiveIntervals.cpp:1.66
--- llvm/lib/CodeGen/LiveIntervals.cpp:1.65	Mon Mar  1 14:05:10 2004
+++ llvm/lib/CodeGen/LiveIntervals.cpp	Sun Mar 14 01:19:51 2004
@@ -209,13 +209,15 @@
             for (unsigned i = 0; i < mi->getNumOperands(); ++i) {
                 MachineOperand& mop = mi->getOperand(i);
                 if (mop.isRegister() && mop.getReg() == li.reg) {
-                    MachineInstr* old = mi;
-                    if (mri_->foldMemoryOperand(mi, i, slot)) {
-                        lv_->instructionChanged(old, mi);
-                        vrm.virtFolded(li.reg, old, mi);
-                        mi2iMap_.erase(old);
-                        i2miMap_[index/InstrSlots::NUM] = mi;
-                        mi2iMap_[mi] = index;
+                    if (MachineInstr* fmi =
+                        mri_->foldMemoryOperand(mi, i, slot)) {
+                        lv_->instructionChanged(mi, fmi);
+                        vrm.virtFolded(li.reg, mi, fmi);
+                        mi2iMap_.erase(mi);
+                        i2miMap_[index/InstrSlots::NUM] = fmi;
+                        mi2iMap_[fmi] = index;
+                        MachineBasicBlock& mbb = *mi->getParent();
+                        mi = mbb.insert(mbb.erase(mi), fmi);
                         ++numFolded;
                         goto for_operand;
                     }





More information about the llvm-commits mailing list