summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-01-20 03:58:42 +0000
committerMatthias Braun <matze@braunis.de>2017-01-20 03:58:42 +0000
commitd9217c0b86aeca0b0088687776d0fea966297c3d (patch)
tree4fa553983d68f4c45ad9e71bb04ac07a29ab21ce /llvm/lib
parent4d0d252288592ba41ef8ae5f1427d9b32c9c1e7f (diff)
downloadbcm5719-llvm-d9217c0b86aeca0b0088687776d0fea966297c3d.tar.gz
bcm5719-llvm-d9217c0b86aeca0b0088687776d0fea966297c3d.zip
Revert "LiveRegUnits: Add accumulateBackward() function"
This seems to be breaking some bots. This reverts commit r292543. llvm-svn: 292574
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/LiveRegUnits.cpp24
-rw-r--r--llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp50
2 files changed, 32 insertions, 42 deletions
diff --git a/llvm/lib/CodeGen/LiveRegUnits.cpp b/llvm/lib/CodeGen/LiveRegUnits.cpp
index 0a10b4e6265..14da799a63f 100644
--- a/llvm/lib/CodeGen/LiveRegUnits.cpp
+++ b/llvm/lib/CodeGen/LiveRegUnits.cpp
@@ -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) {
// Remove defined registers and regmask kills from the set.
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.
static void addLiveIns(LiveRegUnits &LiveUnits, const MachineBasicBlock &MBB) {
for (const auto &LI : MBB.liveins())
diff --git a/llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp b/llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
index a589719e9b7..0aa597bcdc5 100644
--- a/llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
+++ b/llvm/lib/Target/AArch64/AArch64A57FPLoadBalancing.cpp
@@ -493,29 +493,43 @@ bool AArch64A57FPLoadBalancing::colorChainSet(std::vector<Chain*> GV,
int AArch64A57FPLoadBalancing::scavengeRegister(Chain *G, Color C,
MachineBasicBlock &MBB) {
+ RegScavenger RS;
+ RS.enterBasicBlock(MBB);
+ RS.forward(MachineBasicBlock::iterator(G->getStart()));
+
// Can we find an appropriate register that is available throughout the life
- // of the chain? Simulate liveness backwards until the end of the chain.
- LiveRegUnits Units(*TRI);
- 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.
- MachineBasicBlock::iterator ChainBegin = G->begin();
- assert(ChainBegin != ChainEnd && "Chain should contain instructions");
- do {
- --I;
- Units.accumulateBackward(*I);
- } while (I != ChainBegin);
+ // of the chain?
+ unsigned RegClassID = G->getStart()->getDesc().OpInfo[0].RegClass;
+ BitVector AvailableRegs = RS.getRegsAvailable(TRI->getRegClass(RegClassID));
+ for (MachineBasicBlock::iterator I = G->begin(), E = G->end(); I != E; ++I) {
+ RS.forward(I);
+ 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.
- unsigned RegClassID = ChainBegin->getDesc().OpInfo[0].RegClass;
auto Ord = RCI.getOrder(TRI->getRegClass(RegClassID));
for (auto Reg : Ord) {
- if (!Units.available(Reg))
+ if (!AvailableRegs[Reg])
continue;
if (C == getColor(Reg))
return Reg;
OpenPOWER on IntegriCloud