mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
Revert r61158 for now, as it caused some test failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61159 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -41,7 +41,6 @@ static cl::opt<int> PreSplitLimit("pre-split-limit", cl::init(-1), cl::Hidden);
|
|||||||
STATISTIC(NumSplits, "Number of intervals split");
|
STATISTIC(NumSplits, "Number of intervals split");
|
||||||
STATISTIC(NumRemats, "Number of intervals split by rematerialization");
|
STATISTIC(NumRemats, "Number of intervals split by rematerialization");
|
||||||
STATISTIC(NumFolds, "Number of intervals split with spill folding");
|
STATISTIC(NumFolds, "Number of intervals split with spill folding");
|
||||||
STATISTIC(NumRenumbers, "Number of intervals renumbered into new registers");
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class VISIBILITY_HIDDEN PreAllocSplitting : public MachineFunctionPass {
|
class VISIBILITY_HIDDEN PreAllocSplitting : public MachineFunctionPass {
|
||||||
@@ -138,7 +137,7 @@ namespace {
|
|||||||
|
|
||||||
void UpdateSpillSlotInterval(VNInfo*, unsigned, unsigned);
|
void UpdateSpillSlotInterval(VNInfo*, unsigned, unsigned);
|
||||||
|
|
||||||
VNInfo* UpdateRegisterInterval(VNInfo*, unsigned, unsigned);
|
void UpdateRegisterInterval(VNInfo*, unsigned, unsigned);
|
||||||
|
|
||||||
bool ShrinkWrapToLastUse(MachineBasicBlock*, VNInfo*,
|
bool ShrinkWrapToLastUse(MachineBasicBlock*, VNInfo*,
|
||||||
SmallVector<MachineOperand*, 4>&,
|
SmallVector<MachineOperand*, 4>&,
|
||||||
@@ -410,7 +409,7 @@ PreAllocSplitting::UpdateSpillSlotInterval(VNInfo *ValNo, unsigned SpillIndex,
|
|||||||
/// UpdateRegisterInterval - Given the specified val# of the current live
|
/// UpdateRegisterInterval - Given the specified val# of the current live
|
||||||
/// interval is being split, and the spill and restore indices, update the live
|
/// interval is being split, and the spill and restore indices, update the live
|
||||||
/// interval accordingly.
|
/// interval accordingly.
|
||||||
VNInfo*
|
void
|
||||||
PreAllocSplitting::UpdateRegisterInterval(VNInfo *ValNo, unsigned SpillIndex,
|
PreAllocSplitting::UpdateRegisterInterval(VNInfo *ValNo, unsigned SpillIndex,
|
||||||
unsigned RestoreIndex) {
|
unsigned RestoreIndex) {
|
||||||
assert(LIs->getMBBFromIndex(RestoreIndex) == BarrierMBB &&
|
assert(LIs->getMBBFromIndex(RestoreIndex) == BarrierMBB &&
|
||||||
@@ -513,8 +512,6 @@ PreAllocSplitting::UpdateRegisterInterval(VNInfo *ValNo, unsigned SpillIndex,
|
|||||||
unsigned End = After[i].second;
|
unsigned End = After[i].second;
|
||||||
CurrLI->addRange(LiveRange(Start, End, AValNo));
|
CurrLI->addRange(LiveRange(Start, End, AValNo));
|
||||||
}
|
}
|
||||||
|
|
||||||
return AValNo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ShrinkWrapToLastUse - There are uses of the current live interval in the
|
/// ShrinkWrapToLastUse - There are uses of the current live interval in the
|
||||||
@@ -703,14 +700,17 @@ void PreAllocSplitting::RepairLiveInterval(LiveInterval* CurrLI,
|
|||||||
ShrinkWrapLiveInterval(ValNo, BarrierMBB, NULL, DefMI->getParent(), Visited,
|
ShrinkWrapLiveInterval(ValNo, BarrierMBB, NULL, DefMI->getParent(), Visited,
|
||||||
Uses, UseMIs, UseMBBs);
|
Uses, UseMIs, UseMBBs);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!ValNo->hasPHIKill)
|
||||||
|
RenumberValno();
|
||||||
|
#endif
|
||||||
|
// FIXME: If ValNo->hasPHIKill is false, then renumber the val# by
|
||||||
|
// the restore.
|
||||||
|
|
||||||
// Remove live range from barrier to the restore. FIXME: Find a better
|
// Remove live range from barrier to the restore. FIXME: Find a better
|
||||||
// point to re-start the live interval.
|
// point to re-start the live interval.
|
||||||
VNInfo* AfterValNo = UpdateRegisterInterval(ValNo,
|
UpdateRegisterInterval(ValNo, LIs->getUseIndex(BarrierIdx)+1,
|
||||||
LIs->getUseIndex(BarrierIdx)+1,
|
LIs->getDefIndex(RestoreIdx));
|
||||||
LIs->getDefIndex(RestoreIdx));
|
|
||||||
// Attempt to renumber the new valno into a new vreg.
|
|
||||||
if (!AfterValNo->hasPHIKill)
|
|
||||||
RenumberValno(AfterValNo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RenumberValno - Split the given valno out into a new vreg, allowing it to
|
/// RenumberValno - Split the given valno out into a new vreg, allowing it to
|
||||||
@@ -722,41 +722,15 @@ void PreAllocSplitting::RenumberValno(VNInfo* VN) {
|
|||||||
// Create the new vreg
|
// Create the new vreg
|
||||||
unsigned NewVReg = MRI->createVirtualRegister(MRI->getRegClass(CurrLI->reg));
|
unsigned NewVReg = MRI->createVirtualRegister(MRI->getRegClass(CurrLI->reg));
|
||||||
|
|
||||||
// Create the new live interval
|
// Copy over the valno and ranges
|
||||||
LiveInterval& NewLI = LIs->getOrCreateInterval(NewVReg);
|
LiveInterval& NewLI = LIs->getOrCreateInterval(NewVReg);
|
||||||
SmallVector<VNInfo*, 4> VNsToCopy;
|
VNInfo* NewVN = NewLI.getNextValue(VN->def, VN->copy,
|
||||||
VNsToCopy.push_back(VN);
|
LIs->getVNInfoAllocator());
|
||||||
|
NewLI.copyValNumInfo(NewVN, VN);
|
||||||
// Walk through and copy the valno we care about, and any other valnos
|
NewLI.MergeValueInAsValue(*CurrLI, VN, NewVN);
|
||||||
// that are two-address redefinitions of the one we care about. These
|
|
||||||
// will need to be rewritten as well.
|
|
||||||
while (!VNsToCopy.empty()) {
|
|
||||||
VNInfo* OldVN = VNsToCopy.back();
|
|
||||||
VNsToCopy.pop_back();
|
|
||||||
|
|
||||||
// Copy the valno over
|
|
||||||
VNInfo* NewVN = NewLI.getNextValue(OldVN->def, OldVN->copy,
|
|
||||||
LIs->getVNInfoAllocator());
|
|
||||||
NewLI.copyValNumInfo(NewVN, OldVN);
|
|
||||||
NewLI.MergeValueInAsValue(*CurrLI, OldVN, NewVN);
|
|
||||||
|
|
||||||
// Locate two-address redefinitions
|
|
||||||
for (SmallVector<unsigned, 4>::iterator KI = NewVN->kills.begin(),
|
|
||||||
KE = NewVN->kills.end(); KI != KE; ++KI) {
|
|
||||||
MachineInstr* MI = LIs->getInstructionFromIndex(*KI);
|
|
||||||
unsigned DefIdx = MI->findRegisterDefOperandIdx(CurrLI->reg);
|
|
||||||
if (DefIdx == ~0U) continue;
|
|
||||||
if (MI->isRegReDefinedByTwoAddr(DefIdx)) {
|
|
||||||
VNInfo* NextVN =
|
|
||||||
CurrLI->findDefinedVNInfo(LiveIntervals::getDefIndex(*KI));
|
|
||||||
VNsToCopy.push_back(NextVN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the valno from the old interval
|
|
||||||
CurrLI->removeValNo(OldVN);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Remove the valno from the old interval
|
||||||
|
CurrLI->removeValNo(VN);
|
||||||
|
|
||||||
// Rewrite defs and uses. This is done in two stages to avoid invalidating
|
// Rewrite defs and uses. This is done in two stages to avoid invalidating
|
||||||
// the reg_iterator.
|
// the reg_iterator.
|
||||||
@@ -779,8 +753,6 @@ void PreAllocSplitting::RenumberValno(VNInfo* VN) {
|
|||||||
MachineOperand& MO = Inst->getOperand(OpIdx);
|
MachineOperand& MO = Inst->getOperand(OpIdx);
|
||||||
MO.setReg(NewVReg);
|
MO.setReg(NewVReg);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumRenumbers++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PreAllocSplitting::Rematerialize(unsigned vreg, VNInfo* ValNo,
|
bool PreAllocSplitting::Rematerialize(unsigned vreg, VNInfo* ValNo,
|
||||||
@@ -1125,6 +1097,8 @@ bool PreAllocSplitting::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// Make sure blocks are numbered in order.
|
// Make sure blocks are numbered in order.
|
||||||
MF.RenumberBlocks();
|
MF.RenumberBlocks();
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
// FIXME: Go top down.
|
||||||
MachineBasicBlock *Entry = MF.begin();
|
MachineBasicBlock *Entry = MF.begin();
|
||||||
SmallPtrSet<MachineBasicBlock*,16> Visited;
|
SmallPtrSet<MachineBasicBlock*,16> Visited;
|
||||||
|
|
||||||
@@ -1143,6 +1117,22 @@ bool PreAllocSplitting::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
MadeChange |= SplitRegLiveIntervals(BarrierRCs);
|
MadeChange |= SplitRegLiveIntervals(BarrierRCs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
for (MachineFunction::reverse_iterator I = MF.rbegin(), E = MF.rend();
|
||||||
|
I != E; ++I) {
|
||||||
|
BarrierMBB = &*I;
|
||||||
|
for (MachineBasicBlock::reverse_iterator II = BarrierMBB->rbegin(),
|
||||||
|
EE = BarrierMBB->rend(); II != EE; ++II) {
|
||||||
|
Barrier = &*II;
|
||||||
|
const TargetRegisterClass **BarrierRCs =
|
||||||
|
Barrier->getDesc().getRegClassBarriers();
|
||||||
|
if (!BarrierRCs)
|
||||||
|
continue;
|
||||||
|
BarrierIdx = LIs->getInstructionIndex(Barrier);
|
||||||
|
MadeChange |= SplitRegLiveIntervals(BarrierRCs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return MadeChange;
|
return MadeChange;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user