From: Matthias Braun Date: Thu, 17 Sep 2015 21:12:24 +0000 (+0000) Subject: Revert "(HEAD -> master, origin/master, origin/HEAD) RegisterPressure: Move LiveInReg... X-Git-Tag: android-x86-7.1-r4~43482 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d68f4c039e5afe0bc210aa987bc2e75efe7824db;p=android-x86%2Fexternal-llvm.git Revert "(HEAD -> master, origin/master, origin/HEAD) RegisterPressure: Move LiveInRegs/LiveOutRegs from RegisterPressure to PressureTracker" This reverts commit r247943. Accidental commit, code review was not finished yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247945 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index 4e6f7c82068..c64087c5965 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -31,6 +31,10 @@ struct RegisterPressure { /// Map of max reg pressure indexed by pressure set ID, not class ID. std::vector MaxSetPressure; + /// List of live in virtual registers or physical register units. + SmallVector LiveInRegs; + SmallVector LiveOutRegs; + void dump(const TargetRegisterInfo *TRI) const; }; @@ -263,10 +267,6 @@ class RegPressureTracker { /// Set of vreg defs that start a live range. SparseSet UntiedDefs; - /// List of live in virtual registers or physical register units. - SmallVector LiveInRegs; - /// List of live out virtual registers or physical register units. - SmallVector LiveOutRegs; /// Live-through pressure. std::vector LiveThruPressure; @@ -323,8 +323,6 @@ public: LiveThruPressure.assign(PressureSet.begin(), PressureSet.end()); } - ArrayRef getLiveIn() const { return LiveInRegs; } - ArrayRef getLiveOut() const { return LiveOutRegs; } ArrayRef getLiveThru() const { return LiveThruPressure; } /// Get the resulting register pressure over the traversed region. diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp index 3eaefa8691e..bc89b134f85 100644 --- a/lib/CodeGen/MachineScheduler.cpp +++ b/lib/CodeGen/MachineScheduler.cpp @@ -878,8 +878,8 @@ void ScheduleDAGMILive::initRegPressure() { DEBUG(RPTracker.dump()); // Initialize the live ins and live outs. - TopRPTracker.addLiveRegs(RPTracker.getLiveIn()); - BotRPTracker.addLiveRegs(RPTracker.getLiveOut()); + TopRPTracker.addLiveRegs(RPTracker.getPressure().LiveInRegs); + BotRPTracker.addLiveRegs(RPTracker.getPressure().LiveOutRegs); // Close one end of the tracker so we can call // getMaxUpward/DownwardPressureDelta before advancing across any @@ -896,7 +896,7 @@ void ScheduleDAGMILive::initRegPressure() { // For each live out vreg reduce the pressure change associated with other // uses of the same vreg below the live-out reaching def. - updatePressureDiffs(RPTracker.getLiveOut()); + updatePressureDiffs(RPTracker.getPressure().LiveOutRegs); // Account for liveness generated by the region boundary. if (LiveRegionEnd != RegionEnd) { @@ -1135,7 +1135,7 @@ unsigned ScheduleDAGMILive::computeCyclicCriticalPath() { unsigned MaxCyclicLatency = 0; // Visit each live out vreg def to find def/use pairs that cross iterations. - ArrayRef LiveOuts = RPTracker.getLiveOut(); + ArrayRef LiveOuts = RPTracker.getPressure().LiveOutRegs; for (ArrayRef::iterator RI = LiveOuts.begin(), RE = LiveOuts.end(); RI != RE; ++RI) { unsigned Reg = *RI; diff --git a/lib/CodeGen/RegisterPressure.cpp b/lib/CodeGen/RegisterPressure.cpp index 5a0b221c803..237e465e906 100644 --- a/lib/CodeGen/RegisterPressure.cpp +++ b/lib/CodeGen/RegisterPressure.cpp @@ -58,6 +58,14 @@ LLVM_DUMP_METHOD void RegisterPressure::dump(const TargetRegisterInfo *TRI) const { dbgs() << "Max Pressure: "; dumpRegSetPressure(MaxSetPressure, TRI); + dbgs() << "Live In: "; + for (unsigned i = 0, e = LiveInRegs.size(); i < e; ++i) + dbgs() << PrintVRegOrUnit(LiveInRegs[i], TRI) << " "; + dbgs() << '\n'; + dbgs() << "Live Out: "; + for (unsigned i = 0, e = LiveOutRegs.size(); i < e; ++i) + dbgs() << PrintVRegOrUnit(LiveOutRegs[i], TRI) << " "; + dbgs() << '\n'; } LLVM_DUMP_METHOD @@ -67,14 +75,6 @@ void RegPressureTracker::dump() const { dumpRegSetPressure(CurrSetPressure, TRI); } P.dump(TRI); - dbgs() << "Live In: "; - for (unsigned i = 0, e = LiveInRegs.size(); i < e; ++i) - dbgs() << PrintVRegOrUnit(LiveInRegs[i], TRI) << " "; - dbgs() << '\n'; - dbgs() << "Live Out: "; - for (unsigned i = 0, e = LiveOutRegs.size(); i < e; ++i) - dbgs() << PrintVRegOrUnit(LiveOutRegs[i], TRI) << " "; - dbgs() << '\n'; } void PressureDiff::dump(const TargetRegisterInfo &TRI) const { @@ -112,12 +112,16 @@ void RegPressureTracker::decreaseRegPressure(ArrayRef RegUnits) { void IntervalPressure::reset() { TopIdx = BottomIdx = SlotIndex(); MaxSetPressure.clear(); + LiveInRegs.clear(); + LiveOutRegs.clear(); } /// Clear the result so it can be used for another round of pressure tracking. void RegionPressure::reset() { TopPos = BottomPos = MachineBasicBlock::const_iterator(); MaxSetPressure.clear(); + LiveInRegs.clear(); + LiveOutRegs.clear(); } /// If the current top is not less than or equal to the next index, open it. @@ -126,6 +130,7 @@ void IntervalPressure::openTop(SlotIndex NextTop) { if (TopIdx <= NextTop) return; TopIdx = SlotIndex(); + LiveInRegs.clear(); } /// If the current top is the previous instruction (before receding), open it. @@ -133,6 +138,7 @@ void RegionPressure::openTop(MachineBasicBlock::const_iterator PrevTop) { if (TopPos != PrevTop) return; TopPos = MachineBasicBlock::const_iterator(); + LiveInRegs.clear(); } /// If the current bottom is not greater than the previous index, open it. @@ -140,6 +146,7 @@ void IntervalPressure::openBottom(SlotIndex PrevBottom) { if (BottomIdx > PrevBottom) return; BottomIdx = SlotIndex(); + LiveInRegs.clear(); } /// If the current bottom is the previous instr (before advancing), open it. @@ -147,6 +154,7 @@ void RegionPressure::openBottom(MachineBasicBlock::const_iterator PrevBottom) { if (BottomPos != PrevBottom) return; BottomPos = MachineBasicBlock::const_iterator(); + LiveInRegs.clear(); } const LiveRange *RegPressureTracker::getLiveRange(unsigned Reg) const { @@ -167,8 +175,6 @@ void RegPressureTracker::reset() { static_cast(P).reset(); else static_cast(P).reset(); - LiveInRegs.clear(); - LiveOutRegs.clear(); LiveRegs.PhysRegs.clear(); LiveRegs.VirtRegs.clear(); @@ -243,10 +249,10 @@ void RegPressureTracker::closeTop() { else static_cast(P).TopPos = CurrPos; - assert(LiveInRegs.empty() && "inconsistent max pressure result"); - LiveInRegs.reserve(LiveRegs.PhysRegs.size() + LiveRegs.VirtRegs.size()); - LiveInRegs.append(LiveRegs.PhysRegs.begin(), LiveRegs.PhysRegs.end()); - LiveInRegs.append(LiveRegs.VirtRegs.begin(), LiveRegs.VirtRegs.end()); + assert(P.LiveInRegs.empty() && "inconsistent max pressure result"); + P.LiveInRegs.reserve(LiveRegs.PhysRegs.size() + LiveRegs.VirtRegs.size()); + P.LiveInRegs.append(LiveRegs.PhysRegs.begin(), LiveRegs.PhysRegs.end()); + P.LiveInRegs.append(LiveRegs.VirtRegs.begin(), LiveRegs.VirtRegs.end()); } /// Set the boundary for the bottom of the region and summarize live outs. @@ -256,10 +262,10 @@ void RegPressureTracker::closeBottom() { else static_cast(P).BottomPos = CurrPos; - assert(LiveOutRegs.empty() && "inconsistent max pressure result"); - LiveOutRegs.reserve(LiveRegs.PhysRegs.size() + LiveRegs.VirtRegs.size()); - LiveOutRegs.append(LiveRegs.PhysRegs.begin(), LiveRegs.PhysRegs.end()); - LiveOutRegs.append(LiveRegs.VirtRegs.begin(), LiveRegs.VirtRegs.end()); + assert(P.LiveOutRegs.empty() && "inconsistent max pressure result"); + P.LiveOutRegs.reserve(LiveRegs.PhysRegs.size() + LiveRegs.VirtRegs.size()); + P.LiveOutRegs.append(LiveRegs.PhysRegs.begin(), LiveRegs.PhysRegs.end()); + P.LiveOutRegs.append(LiveRegs.VirtRegs.begin(), LiveRegs.VirtRegs.end()); } /// Finalize the region boundaries and record live ins and live outs. @@ -283,8 +289,8 @@ void RegPressureTracker::closeRegion() { void RegPressureTracker::initLiveThru(const RegPressureTracker &RPTracker) { LiveThruPressure.assign(TRI->getNumRegPressureSets(), 0); assert(isBottomClosed() && "need bottom-up tracking to intialize."); - for (unsigned i = 0, e = LiveOutRegs.size(); i < e; ++i) { - unsigned Reg = LiveOutRegs[i]; + for (unsigned i = 0, e = P.LiveOutRegs.size(); i < e; ++i) { + unsigned Reg = P.LiveOutRegs[i]; if (TargetRegisterInfo::isVirtualRegister(Reg) && !RPTracker.hasUntiedDef(Reg)) { increaseSetPressure(LiveThruPressure, MRI->getPressureSets(Reg)); @@ -425,22 +431,22 @@ void RegPressureTracker::addLiveRegs(ArrayRef Regs) { /// Add Reg to the live in set and increase max pressure. void RegPressureTracker::discoverLiveIn(unsigned Reg) { assert(!LiveRegs.contains(Reg) && "avoid bumping max pressure twice"); - if (containsReg(LiveInRegs, Reg)) + if (containsReg(P.LiveInRegs, Reg)) return; // At live in discovery, unconditionally increase the high water mark. - LiveInRegs.push_back(Reg); + P.LiveInRegs.push_back(Reg); increaseSetPressure(P.MaxSetPressure, MRI->getPressureSets(Reg)); } /// Add Reg to the live out set and increase max pressure. void RegPressureTracker::discoverLiveOut(unsigned Reg) { assert(!LiveRegs.contains(Reg) && "avoid bumping max pressure twice"); - if (containsReg(LiveOutRegs, Reg)) + if (containsReg(P.LiveOutRegs, Reg)) return; // At live out discovery, unconditionally increase the high water mark. - LiveOutRegs.push_back(Reg); + P.LiveOutRegs.push_back(Reg); increaseSetPressure(P.MaxSetPressure, MRI->getPressureSets(Reg)); } @@ -477,11 +483,8 @@ bool RegPressureTracker::recede(SmallVectorImpl *LiveUses, SlotIdx = LIS->getInstructionIndex(CurrPos).getRegSlot(); // Open the top of the region using slot indexes. - if (isTopClosed()) { - if (RequireIntervals) - static_cast(P).openTop(SlotIdx); - LiveInRegs.clear(); - } + if (RequireIntervals && isTopClosed()) + static_cast(P).openTop(SlotIdx); RegisterOperands RegOpers(TRI, MRI); collectOperands(CurrPos, RegOpers); @@ -570,7 +573,6 @@ bool RegPressureTracker::advance() { static_cast(P).openBottom(SlotIdx); else static_cast(P).openBottom(CurrPos); - LiveOutRegs.clear(); } RegisterOperands RegOpers(TRI, MRI);