aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-19 05:15:10 +0000
committerChris Lattner <sabre@nondot.org>2004-07-19 05:15:10 +0000
commit57eb15e316c8f186b988dea7f8962ffa827d4a71 (patch)
treeac815e854e1b942bed449e1bfc6dc64a30758dc1 /lib/CodeGen/LiveIntervalAnalysis.cpp
parent331cb7dde1bf0c52bfd17570d36e56b934d559f5 (diff)
See comments. The live intervals were not coming out of the spiller in sorted
order, causing the inactive list in the linearscan list to get unsorted, which basically fuxored everything up severely. These seems to fix the joiner, so with more testing I will enable it by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 5e9e495edc..9687e58981 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -185,6 +185,16 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
return true;
}
+namespace {
+ /// CompareIntervalStar - This is a simple comparison function for interval
+ /// pointers. It compares based on their starting point.
+ struct CompareIntervalStar {
+ bool operator()(LiveInterval *LHS, LiveInterval* RHS) const {
+ return LHS->start() < RHS->start();
+ }
+ };
+}
+
std::vector<LiveInterval*> LiveIntervals::addIntervalsForSpills(
const LiveInterval& li,
VirtRegMap& vrm,
@@ -210,7 +220,7 @@ std::vector<LiveInterval*> LiveIntervals::addIntervalsForSpills(
MachineBasicBlock::iterator mi = getInstructionFromIndex(index);
for_operand:
- for (unsigned i = 0; i < mi->getNumOperands(); ++i) {
+ for (unsigned i = 0; i != mi->getNumOperands(); ++i) {
MachineOperand& mop = mi->getOperand(i);
if (mop.isRegister() && mop.getReg() == li.reg) {
if (MachineInstr* fmi =
@@ -267,6 +277,15 @@ std::vector<LiveInterval*> LiveIntervals::addIntervalsForSpills(
}
}
+ // FIXME: This method MUST return intervals in sorted order. If a
+ // particular machine instruction both uses and defines the vreg being
+ // spilled (e.g., vr = vr + 1) and if the def is processed before the
+ // use, the list ends up not sorted.
+ //
+ // The proper way to fix this is to process all uses of the vreg before we
+ // process any defs. However, this would require refactoring the above
+ // blob of code, which I'm not feeling up to right now.
+ std::sort(added.begin(), added.end(), CompareIntervalStar());
return added;
}