[llvm-commits] [llvm] r44575 - /llvm/trunk/lib/CodeGen/VirtRegMap.cpp
Evan Cheng
evan.cheng at apple.com
Tue Dec 4 11:19:46 PST 2007
Author: evancheng
Date: Tue Dec 4 13:19:45 2007
New Revision: 44575
URL: http://llvm.org/viewvc/llvm-project?rev=44575&view=rev
Log:
Spiller unfold optimization bug: do not clobber a reusable stack slot value unless it can be modified.
Modified:
llvm/trunk/lib/CodeGen/VirtRegMap.cpp
Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=44575&r1=44574&r2=44575&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original)
+++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Tue Dec 4 13:19:45 2007
@@ -271,7 +271,7 @@
MachineBasicBlock::iterator &MII,
int Idx, unsigned PhysReg, int StackSlot,
const TargetRegisterClass *RC,
- MachineInstr *&LastStore,
+ bool isAvailable, MachineInstr *&LastStore,
AvailableSpills &Spills,
SmallSet<MachineInstr*, 4> &ReMatDefs,
BitVector &RegKills,
@@ -357,7 +357,7 @@
"Value not available!");
return SpillSlotsOrReMatsAvailable.find(SlotOrReMat)->second & 1;
}
-
+
/// disallowClobberPhysReg - Unset the CanClobber bit of the specified
/// stackslot register. The register is still available but is no longer
/// allowed to be modifed.
@@ -855,7 +855,7 @@
MachineBasicBlock::iterator &MII,
int Idx, unsigned PhysReg, int StackSlot,
const TargetRegisterClass *RC,
- MachineInstr *&LastStore,
+ bool isAvailable, MachineInstr *&LastStore,
AvailableSpills &Spills,
SmallSet<MachineInstr*, 4> &ReMatDefs,
BitVector &RegKills,
@@ -903,7 +903,7 @@
// in PhysReg.
Spills.ModifyStackSlotOrReMat(StackSlot);
Spills.ClobberPhysReg(PhysReg);
- Spills.addAvailable(StackSlot, LastStore, PhysReg);
+ Spills.addAvailable(StackSlot, LastStore, PhysReg, isAvailable);
++NumStores;
}
@@ -984,9 +984,9 @@
const TargetRegisterClass *RC = RegMap->getRegClass(VirtReg);
unsigned Phys = VRM.getPhys(VirtReg);
int StackSlot = VRM.getStackSlot(VirtReg);
- MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
- SpillRegToStackSlot(MBB, MII, i, Phys, StackSlot, RC, LastStore,
- Spills, ReMatDefs, RegKills, KillOps, VRM);
+ MRI->storeRegToStackSlot(MBB, next(MII), Phys, StackSlot, RC);
+ DOUT << "Store:\t" << *next(MII);
+ VRM.virtFolded(VirtReg, next(MII), VirtRegMap::isMod);
}
NextMII = next(MII);
}
@@ -1303,7 +1303,12 @@
if (MR & VirtRegMap::isModRef) {
unsigned PhysReg = Spills.getSpillSlotOrReMatPhysReg(SS);
SmallVector<MachineInstr*, 4> NewMIs;
+ // We can reuse this physreg as long as we are allowed to clobber
+ // the value and there isn't an earlier def that has already clobbered the
+ // physreg.
if (PhysReg &&
+ Spills.canClobberPhysReg(SS) &&
+ !ReusedOperands.isClobbered(PhysReg) &&
DeadStore->findRegisterUseOperandIdx(PhysReg, true) != -1 &&
MRI->unfoldMemoryOperand(MF, &MI, PhysReg, false, true, NewMIs)) {
MBB.insert(MII, NewMIs[0]);
@@ -1446,8 +1451,8 @@
if (!MO.isDead()) {
MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
- SpillRegToStackSlot(MBB, MII, -1, PhysReg, StackSlot, RC, LastStore,
- Spills, ReMatDefs, RegKills, KillOps, VRM);
+ SpillRegToStackSlot(MBB, MII, -1, PhysReg, StackSlot, RC, true,
+ LastStore, Spills, ReMatDefs, RegKills, KillOps, VRM);
NextMII = next(MII);
// Check to see if this is a noop copy. If so, eliminate the
@@ -1467,9 +1472,10 @@
}
}
ProcessNextInst:
- if (!Erased && !BackTracked)
+ if (!Erased && !BackTracked) {
for (MachineBasicBlock::iterator II = MI; II != NextMII; ++II)
UpdateKills(*II, RegKills, KillOps);
+ }
MII = NextMII;
}
}
More information about the llvm-commits
mailing list