summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-13 16:47:53 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-13 16:47:53 +0000
commitc1c622ef0dd29d1bafd580790aec5231af50abf2 (patch)
tree8faa95b69ab7d3088cc9ed3ddba9f57354892acb /lib
parentde9ddbf19ada796c17e3c42eae477055616130df (diff)
downloadllvm-c1c622ef0dd29d1bafd580790aec5231af50abf2.tar.gz
llvm-c1c622ef0dd29d1bafd580790aec5231af50abf2.tar.bz2
llvm-c1c622ef0dd29d1bafd580790aec5231af50abf2.tar.xz
Use a separate LiveRangeCalc for the complement in spill modes.
The complement interval may overlap the other intervals created, so use a separate LiveRangeCalc instance to compute its live range. A LiveRangeCalc instance can only be shared among non-overlapping intervals. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139603 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SplitKit.cpp28
-rw-r--r--lib/CodeGen/SplitKit.h13
2 files changed, 30 insertions, 11 deletions
diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp
index b1416cc17e..324052844a 100644
--- a/lib/CodeGen/SplitKit.cpp
+++ b/lib/CodeGen/SplitKit.cpp
@@ -319,7 +319,11 @@ void SplitEditor::reset(LiveRangeEdit &LRE, ComplementSpillMode SM) {
OpenIdx = 0;
RegAssign.clear();
Values.clear();
- LRCalc.reset(&VRM.getMachineFunction());
+
+ // Reset the LiveRangeCalc instances needed for this spill mode.
+ LRCalc[0].reset(&VRM.getMachineFunction());
+ if (SpillMode)
+ LRCalc[1].reset(&VRM.getMachineFunction());
// We don't need an AliasAnalysis since we will only be performing
// cheap-as-a-copy remats anyway.
@@ -390,8 +394,8 @@ void SplitEditor::markComplexMapped(unsigned RegIdx, const VNInfo *ParentVNI) {
// extendRange - Extend the live range to reach Idx.
// Potentially create phi-def values.
void SplitEditor::extendRange(unsigned RegIdx, SlotIndex Idx) {
- LRCalc.extend(Edit->get(RegIdx), Idx.getNextSlot(),
- LIS.getSlotIndexes(), &MDT, &LIS.getVNInfoAllocator());
+ getLRCalc(RegIdx).extend(Edit->get(RegIdx), Idx.getNextSlot(),
+ LIS.getSlotIndexes(), &MDT, &LIS.getVNInfoAllocator());
}
VNInfo *SplitEditor::defFromParent(unsigned RegIdx,
@@ -633,6 +637,8 @@ bool SplitEditor::transferValues() {
continue;
}
+ LiveRangeCalc &LRC = getLRCalc(RegIdx);
+
// This value has multiple defs in RegIdx, but it wasn't rematerialized,
// so the live range is accurate. Add live-in blocks in [Start;End) to the
// LiveInBlocks.
@@ -648,7 +654,7 @@ bool SplitEditor::transferValues() {
DEBUG(dbgs() << ':' << VNI->id << "*BB#" << MBB->getNumber());
// MBB has its own def. Is it also live-out?
if (BlockEnd <= End)
- LRCalc.setLiveOutValue(MBB, VNI);
+ LRC.setLiveOutValue(MBB, VNI);
// Skip to the next block for live-in.
++MBB;
@@ -667,16 +673,16 @@ bool SplitEditor::transferValues() {
std::min(BlockEnd, End).getPrevSlot());
assert(VNI && "Missing def for complex mapped parent PHI");
if (End >= BlockEnd)
- LRCalc.setLiveOutValue(MBB, VNI); // Live-out as well.
+ LRC.setLiveOutValue(MBB, VNI); // Live-out as well.
} else {
// This block needs a live-in value. The last block covered may not
// be live-out.
if (End < BlockEnd)
- LRCalc.addLiveInBlock(LI, MDT[MBB], End);
+ LRC.addLiveInBlock(LI, MDT[MBB], End);
else {
// Live-through, and we don't know the value.
- LRCalc.addLiveInBlock(LI, MDT[MBB]);
- LRCalc.setLiveOutValue(MBB, 0);
+ LRC.addLiveInBlock(LI, MDT[MBB]);
+ LRC.setLiveOutValue(MBB, 0);
}
}
BlockStart = BlockEnd;
@@ -687,7 +693,11 @@ bool SplitEditor::transferValues() {
DEBUG(dbgs() << '\n');
}
- LRCalc.calculateValues(LIS.getSlotIndexes(), &MDT, &LIS.getVNInfoAllocator());
+ LRCalc[0].calculateValues(LIS.getSlotIndexes(), &MDT,
+ &LIS.getVNInfoAllocator());
+ if (SpillMode)
+ LRCalc[1].calculateValues(LIS.getSlotIndexes(), &MDT,
+ &LIS.getVNInfoAllocator());
return Skipped;
}
diff --git a/lib/CodeGen/SplitKit.h b/lib/CodeGen/SplitKit.h
index c00b8d366a..cd6a3065b9 100644
--- a/lib/CodeGen/SplitKit.h
+++ b/lib/CodeGen/SplitKit.h
@@ -273,8 +273,17 @@ private:
/// The new value has no live ranges anywhere.
ValueMap Values;
- /// LRCalc - Cache for computing live ranges and SSA update.
- LiveRangeCalc LRCalc;
+ /// LRCalc - Cache for computing live ranges and SSA update. Each instance
+ /// can only handle non-overlapping live ranges, so use a separate
+ /// LiveRangeCalc instance for the complement interval when in spill mode.
+ LiveRangeCalc LRCalc[2];
+
+ /// getLRCalc - Return the LRCalc to use for RegIdx. In spill mode, the
+ /// complement interval can overlap the other intervals, so it gets its own
+ /// LRCalc instance. When not in spill mode, all intervals can share one.
+ LiveRangeCalc &getLRCalc(unsigned RegIdx) {
+ return LRCalc[SpillMode != SM_Partition && RegIdx != 0];
+ }
/// defValue - define a value in RegIdx from ParentVNI at Idx.
/// Idx does not have to be ParentVNI->def, but it must be contained within