Skip to content

Commit

Permalink
LiveRangeCalc: Rewrite subrange calculation
Browse files Browse the repository at this point in the history
This changes subrange calculation to calculate subranges sequentially
instead of in parallel. The code is easier to understand that way and
addresses the code review issues raised about LiveOutData being
hard to understand/needing more comments by removing them :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224272 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
MatzeB committed Dec 15, 2014
1 parent 8e7359d commit 6097277
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 242 deletions.
20 changes: 6 additions & 14 deletions lib/CodeGen/LiveIntervalAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ void LiveIntervals::computeVirtRegInterval(LiveInterval &LI) {
assert(LRCalc && "LRCalc not initialized.");
assert(LI.empty() && "Should only compute empty intervals.");
LRCalc->reset(MF, getSlotIndexes(), DomTree, &getVNInfoAllocator());
LRCalc->createDeadDefs(LI);
LRCalc->extendToUses(LI);
LRCalc->calculate(LI);
computeDeadValues(LI, LI);
}

Expand Down Expand Up @@ -251,22 +250,15 @@ void LiveIntervals::computeRegUnitRange(LiveRange &LR, unsigned Unit) {
// may share super-registers. That's OK because createDeadDefs() is
// idempotent. It is very rare for a register unit to have multiple roots, so
// uniquing super-registers is probably not worthwhile.
for (MCRegUnitRootIterator Roots(Unit, TRI); Roots.isValid(); ++Roots) {
for (MCSuperRegIterator Supers(*Roots, TRI, /*IncludeSelf=*/true);
Supers.isValid(); ++Supers) {
if (!MRI->reg_empty(*Supers))
LRCalc->createDeadDefs(LR, *Supers);
}
}

// Now extend LR to reach all uses.
// Ignore uses of reserved registers. We only track defs of those.
for (MCRegUnitRootIterator Roots(Unit, TRI); Roots.isValid(); ++Roots) {
for (MCSuperRegIterator Supers(*Roots, TRI, /*IncludeSelf=*/true);
Supers.isValid(); ++Supers) {
unsigned Reg = *Supers;
if (!MRI->isReserved(Reg) && !MRI->reg_empty(Reg))
LRCalc->extendToUses(LR, Reg);
if (MRI->reg_empty(Reg))
continue;
// Ignore uses of reserved registers. We only track defs of those.
bool IgnoreUses = MRI->isReserved(Reg);
LRCalc->calculate(LR, *Supers, IgnoreUses);
}
}
}
Expand Down
Loading

0 comments on commit 6097277

Please sign in to comment.