aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-12-16 21:35:08 +0000
committerOwen Anderson <resistor@mac.com>2008-12-16 21:35:08 +0000
commitd0b6a0d96764e0d5178dc71d8bd9b68a3eaa026e (patch)
tree3b5f0e684b0b5733855db4d9e81120cb5ff18cf3
parent85d3d4f35de33c6d0d3800bd87619c00d06a98e2 (diff)
downloadexternal_llvm-d0b6a0d96764e0d5178dc71d8bd9b68a3eaa026e.zip
external_llvm-d0b6a0d96764e0d5178dc71d8bd9b68a3eaa026e.tar.gz
external_llvm-d0b6a0d96764e0d5178dc71d8bd9b68a3eaa026e.tar.bz2
Add code to renumber split intervals into new vregs. This is disabled for now until I finish working out some iterator invalidation issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61104 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/PreAllocSplitting.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp
index fe1efe5..81dd0b6 100644
--- a/lib/CodeGen/PreAllocSplitting.cpp
+++ b/lib/CodeGen/PreAllocSplitting.cpp
@@ -169,6 +169,7 @@ namespace {
MachineBasicBlock* MBB,
int& SS,
SmallPtrSet<MachineInstr*, 4>& RefsInMBB);
+ void RenumberValno(VNInfo* VN);
};
} // end anonymous namespace
@@ -699,6 +700,10 @@ void PreAllocSplitting::RepairLiveInterval(LiveInterval* CurrLI,
ShrinkWrapLiveInterval(ValNo, BarrierMBB, NULL, DefMI->getParent(), Visited,
Uses, UseMIs, UseMBBs);
+#if 0
+ if (!ValNo->hasPHIKill)
+ RenumberValno();
+#endif
// FIXME: If ValNo->hasPHIKill is false, then renumber the val# by
// the restore.
@@ -707,6 +712,49 @@ void PreAllocSplitting::RepairLiveInterval(LiveInterval* CurrLI,
UpdateRegisterInterval(ValNo, LIs->getUseIndex(BarrierIdx)+1,
LIs->getDefIndex(RestoreIdx));
}
+
+/// RenumberValno - Split the given valno out into a new vreg, allowing it to
+/// be allocated to a different register. This function creates a new vreg,
+/// copies the valno and its live ranges over to the new vreg's interval,
+/// removes them from the old interval, and rewrites all uses and defs of
+/// the original reg to the new vreg within those ranges.
+void PreAllocSplitting::RenumberValno(VNInfo* VN) {
+ // Create the new vreg
+ unsigned NewVReg = MRI->createVirtualRegister(MRI->getRegClass(CurrLI->reg));
+
+ // Copy over the valno and ranges
+ LiveInterval& NewLI = LIs->getOrCreateInterval(NewVReg);
+ VNInfo* NewVN = NewLI.getNextValue(VN->def, VN->copy,
+ LIs->getVNInfoAllocator());
+ NewLI.copyValNumInfo(NewVN, VN);
+ NewLI.MergeValueInAsValue(*CurrLI, VN, NewVN);
+
+ // Remove the valno from the old interval
+ CurrLI->removeValNo(VN);
+
+ // Rewrite defs and uses. This is done in two stages to avoid invalidating
+ // the reg_iterator.
+ SmallVector<std::pair<MachineInstr*, unsigned>, 8> OpsToChange;
+
+ for (MachineRegisterInfo::reg_iterator I = MRI->reg_begin(CurrLI->reg),
+ E = MRI->reg_end(); I != E; ++I) {
+ MachineOperand& MO = I.getOperand();
+ unsigned InstrIdx = LIs->getInstructionIndex(&*I);
+
+ if ((MO.isUse() && NewLI.liveAt(LiveIntervals::getUseIndex(InstrIdx))) ||
+ (MO.isDef() && NewLI.liveAt(LiveIntervals::getDefIndex(InstrIdx))))
+ OpsToChange.push_back(std::make_pair(&*I, I.getOperandNo()));
+ }
+
+ for (SmallVector<std::pair<MachineInstr*, unsigned>, 8>::iterator I =
+ OpsToChange.begin(), E = OpsToChange.end(); I != E; ++I) {
+ MachineInstr* Inst = I->first;
+ unsigned OpIdx = I->second;
+ MachineOperand& MO = Inst->getOperand(OpIdx);
+ MO.setReg(NewVReg);
+ }
+}
+
bool PreAllocSplitting::Rematerialize(unsigned vreg, VNInfo* ValNo,
MachineInstr* DefMI,
MachineBasicBlock::iterator RestorePt,