summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegisterPressure.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-08-30 04:36:57 +0000
committerAndrew Trick <atrick@apple.com>2013-08-30 04:36:57 +0000
commit663bd9922776e5f7bc17dfc574efe3fe05ceb12c (patch)
tree2e827dbaff482f7d57d7b32d68735a42992846ff /lib/CodeGen/RegisterPressure.cpp
parent1362dcb5899bc88f0e567dd10e2e9003a79ace21 (diff)
downloadllvm-663bd9922776e5f7bc17dfc574efe3fe05ceb12c.tar.gz
llvm-663bd9922776e5f7bc17dfc574efe3fe05ceb12c.tar.bz2
llvm-663bd9922776e5f7bc17dfc574efe3fe05ceb12c.tar.xz
mi-sched: update PressureDiffs on-the-fly for liveness.
This removes all expensive pressure tracking logic from the scheduling critical path of node comparison. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegisterPressure.cpp')
-rw-r--r--lib/CodeGen/RegisterPressure.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/CodeGen/RegisterPressure.cpp b/lib/CodeGen/RegisterPressure.cpp
index 8328b500af..1be203f36d 100644
--- a/lib/CodeGen/RegisterPressure.cpp
+++ b/lib/CodeGen/RegisterPressure.cpp
@@ -399,10 +399,9 @@ static void collectPDiff(PressureDiff &PDiff, RegisterOperands &RegOpers,
const MachineRegisterInfo *MRI) {
assert(!PDiff.begin()->isValid() && "stale PDiff");
- for (unsigned i = 0, e = RegOpers.Defs.size(); i != e; ++i) {
- if (!containsReg(RegOpers.Uses, RegOpers.Defs[i]))
- PDiff.addPressureChange(RegOpers.Defs[i], true, MRI);
- }
+ for (unsigned i = 0, e = RegOpers.Defs.size(); i != e; ++i)
+ PDiff.addPressureChange(RegOpers.Defs[i], true, MRI);
+
for (unsigned i = 0, e = RegOpers.Uses.size(); i != e; ++i)
PDiff.addPressureChange(RegOpers.Uses[i], false, MRI);
}
@@ -437,9 +436,13 @@ void RegPressureTracker::discoverLiveOut(unsigned Reg) {
increaseSetPressure(P.MaxSetPressure, MRI->getPressureSets(Reg));
}
-/// Recede across the previous instruction.
-/// Record the pressure difference if it is provided.
-bool RegPressureTracker::recede(PressureDiff *PDiff) {
+/// Recede across the previous instruction. If LiveUses is provided, record any
+/// RegUnits that are made live by the current instruction's uses. This includes
+/// registers that are both defined and used by the instruction. If a pressure
+/// difference pointer is provided record the changes is pressure caused by this
+/// instruction independent of liveness.
+bool RegPressureTracker::recede(SmallVectorImpl<unsigned> *LiveUses,
+ PressureDiff *PDiff) {
// Check for the top of the analyzable region.
if (CurrPos == MBB->begin()) {
closeRegion();
@@ -496,11 +499,16 @@ bool RegPressureTracker::recede(PressureDiff *PDiff) {
// Adjust liveouts if LiveIntervals are available.
if (RequireIntervals) {
const LiveInterval *LI = getInterval(Reg);
- if (LI && !LI->isKilledAtInstr(SlotIdx))
- discoverLiveOut(Reg);
+ // Check if this LR is killed and not redefined here.
+ if (LI && !LI->isKilledAtInstr(SlotIdx)
+ && !LI->isDefinedByInstr(SlotIdx)) {
+ discoverLiveOut(Reg);
+ }
}
increaseRegPressure(Reg);
LiveRegs.insert(Reg);
+ if (LiveUses && !containsReg(*LiveUses, Reg))
+ LiveUses->push_back(Reg);
}
}
if (TrackUntiedDefs) {
@@ -773,22 +781,10 @@ getMaxUpwardPressureDelta(const MachineInstr *MI, PressureDiff *PDiff,
/// @param MaxPressureLimit Is the max pressure within the region, not
/// necessarily at the current position.
void RegPressureTracker::
-getUpwardPressureDelta(const MachineInstr *MI, /*const*/ PressureDiff &PDiff1,
+getUpwardPressureDelta(const MachineInstr *MI, /*const*/ PressureDiff &PDiff,
RegPressureDelta &Delta,
ArrayRef<PressureChange> CriticalPSets,
ArrayRef<unsigned> MaxPressureLimit) const {
- RegisterOperands RegOpers(TRI, MRI, /*IgnoreDead=*/true);
- collectOperands(MI, RegOpers);
-
- // Decrease the pressure change for live uses.
- PressureDiff PDiff = PDiff1;
- for (unsigned i = 0, e = RegOpers.Uses.size(); i != e; ++i) {
- if (LiveRegs.contains(RegOpers.Uses[i]))
- PDiff.addPressureChange(RegOpers.Uses[i], true, MRI);
- }
-
- // Now directly query pressure from PDiff. Everything above this can be
- // cached and updated independent of the query.
unsigned CritIdx = 0, CritEnd = CriticalPSets.size();
for (PressureDiff::const_iterator
PDiffI = PDiff.begin(), PDiffE = PDiff.end();