Revert "LiveRegUnits: Add accumulateBackward() function"

This seems to be breaking some bots.

This reverts commit r292543.

llvm-svn: 292574
This commit is contained in:
Matthias Braun 2017-01-20 03:58:42 +00:00
parent 4d0d252288
commit d9217c0b86
3 changed files with 32 additions and 51 deletions

View File

@ -76,10 +76,6 @@ public:
/// The regmask has the same format as the one in the RegMask machine operand. /// The regmask has the same format as the one in the RegMask machine operand.
void removeRegsNotPreserved(const uint32_t *RegMask); void removeRegsNotPreserved(const uint32_t *RegMask);
/// Adds register units not preserved by the regmask \p RegMask.
/// The regmask has the same format as the one in the RegMask machine operand.
void addRegsInMask(const uint32_t *RegMask);
/// Returns true if no part of physical register \p Reg is live. /// Returns true if no part of physical register \p Reg is live.
bool available(unsigned Reg) const { bool available(unsigned Reg) const {
for (MCRegUnitIterator Unit(Reg, TRI); Unit.isValid(); ++Unit) { for (MCRegUnitIterator Unit(Reg, TRI); Unit.isValid(); ++Unit) {
@ -92,11 +88,6 @@ public:
/// Updates liveness when stepping backwards over the instruction \p MI. /// Updates liveness when stepping backwards over the instruction \p MI.
void stepBackward(const MachineInstr &MI); void stepBackward(const MachineInstr &MI);
/// Mark all register units live during instruction \p MI.
/// This can be used to accumulate live/unoccupied registers over a range of
/// instructions.
void accumulateBackward(const MachineInstr &MI);
/// Adds registers living out of block \p MBB. /// Adds registers living out of block \p MBB.
/// Live out registers are the union of the live-in registers of the successor /// Live out registers are the union of the live-in registers of the successor
/// blocks and pristine registers. Live out registers of the end block are the /// blocks and pristine registers. Live out registers of the end block are the

View File

@ -26,15 +26,6 @@ void LiveRegUnits::removeRegsNotPreserved(const uint32_t *RegMask) {
} }
} }
void LiveRegUnits::addRegsInMask(const uint32_t *RegMask) {
for (unsigned U = 0, E = TRI->getNumRegUnits(); U != E; ++U) {
for (MCRegUnitRootIterator RootReg(U, TRI); RootReg.isValid(); ++RootReg) {
if (MachineOperand::clobbersPhysReg(RegMask, *RootReg))
Units.set(U);
}
}
}
void LiveRegUnits::stepBackward(const MachineInstr &MI) { void LiveRegUnits::stepBackward(const MachineInstr &MI) {
// Remove defined registers and regmask kills from the set. // Remove defined registers and regmask kills from the set.
for (ConstMIBundleOperands O(MI); O.isValid(); ++O) { for (ConstMIBundleOperands O(MI); O.isValid(); ++O) {
@ -60,21 +51,6 @@ void LiveRegUnits::stepBackward(const MachineInstr &MI) {
} }
} }
void LiveRegUnits::accumulateBackward(const MachineInstr &MI) {
// Add defs, uses and regmask clobbers to the set.
for (ConstMIBundleOperands O(MI); O.isValid(); ++O) {
if (O->isReg()) {
unsigned Reg = O->getReg();
if (!TargetRegisterInfo::isPhysicalRegister(Reg))
continue;
if (!O->isDef() && !O->readsReg())
continue;
addReg(Reg);
} else if (O->isRegMask())
addRegsInMask(O->getRegMask());
}
}
/// Add live-in registers of basic block \p MBB to \p LiveUnits. /// Add live-in registers of basic block \p MBB to \p LiveUnits.
static void addLiveIns(LiveRegUnits &LiveUnits, const MachineBasicBlock &MBB) { static void addLiveIns(LiveRegUnits &LiveUnits, const MachineBasicBlock &MBB) {
for (const auto &LI : MBB.liveins()) for (const auto &LI : MBB.liveins())

View File

@ -493,29 +493,43 @@ bool AArch64A57FPLoadBalancing::colorChainSet(std::vector<Chain*> GV,
int AArch64A57FPLoadBalancing::scavengeRegister(Chain *G, Color C, int AArch64A57FPLoadBalancing::scavengeRegister(Chain *G, Color C,
MachineBasicBlock &MBB) { MachineBasicBlock &MBB) {
// Can we find an appropriate register that is available throughout the life RegScavenger RS;
// of the chain? Simulate liveness backwards until the end of the chain. RS.enterBasicBlock(MBB);
LiveRegUnits Units(*TRI); RS.forward(MachineBasicBlock::iterator(G->getStart()));
Units.addLiveOuts(MBB);
MachineBasicBlock::iterator I = MBB.end(), ChainEnd = G->end();
do {
--I;
Units.stepBackward(*I);
} while (I != ChainEnd);
// Check which register units are alive throughout the chain. // Can we find an appropriate register that is available throughout the life
MachineBasicBlock::iterator ChainBegin = G->begin(); // of the chain?
assert(ChainBegin != ChainEnd && "Chain should contain instructions"); unsigned RegClassID = G->getStart()->getDesc().OpInfo[0].RegClass;
do { BitVector AvailableRegs = RS.getRegsAvailable(TRI->getRegClass(RegClassID));
--I; for (MachineBasicBlock::iterator I = G->begin(), E = G->end(); I != E; ++I) {
Units.accumulateBackward(*I); RS.forward(I);
} while (I != ChainBegin); AvailableRegs &= RS.getRegsAvailable(TRI->getRegClass(RegClassID));
// Remove any registers clobbered by a regmask or any def register that is
// immediately dead.
for (auto J : I->operands()) {
if (J.isRegMask())
AvailableRegs.clearBitsNotInMask(J.getRegMask());
if (J.isReg() && J.isDef()) {
MCRegAliasIterator AI(J.getReg(), TRI, /*IncludeSelf=*/true);
if (J.isDead())
for (; AI.isValid(); ++AI)
AvailableRegs.reset(*AI);
#ifndef NDEBUG
else
for (; AI.isValid(); ++AI)
assert(!AvailableRegs[*AI] &&
"Non-dead def should have been removed by now!");
#endif
}
}
}
// Make sure we allocate in-order, to get the cheapest registers first. // Make sure we allocate in-order, to get the cheapest registers first.
unsigned RegClassID = ChainBegin->getDesc().OpInfo[0].RegClass;
auto Ord = RCI.getOrder(TRI->getRegClass(RegClassID)); auto Ord = RCI.getOrder(TRI->getRegClass(RegClassID));
for (auto Reg : Ord) { for (auto Reg : Ord) {
if (!Units.available(Reg)) if (!AvailableRegs[Reg])
continue; continue;
if (C == getColor(Reg)) if (C == getColor(Reg))
return Reg; return Reg;