aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-05-17 18:35:03 +0000
committerAndrew Trick <atrick@apple.com>2012-05-17 18:35:03 +0000
commit811d9268e4bd1e7f77d430ce1f352188020375f4 (patch)
tree9daef7fe688797f77689b82456ed3f51e73c975a /lib/CodeGen/MachineScheduler.cpp
parent24617213ba8e9d1e0f10af33d88285a92304ab95 (diff)
misched: fix liveness iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157003 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--lib/CodeGen/MachineScheduler.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp
index 7a099cdade..41b4b719f2 100644
--- a/lib/CodeGen/MachineScheduler.cpp
+++ b/lib/CodeGen/MachineScheduler.cpp
@@ -149,7 +149,7 @@ priorNonDebug(MachineBasicBlock::iterator I, MachineBasicBlock::iterator Beg) {
/// non-debug instruction.
static MachineBasicBlock::iterator
nextIfDebug(MachineBasicBlock::iterator I, MachineBasicBlock::iterator End) {
- while(I != End) {
+ for(; I != End; ++I) {
if (!I->isDebugValue())
break;
}
@@ -449,17 +449,19 @@ void ScheduleDAGMI::releasePredecessors(SUnit *SU) {
void ScheduleDAGMI::moveInstruction(MachineInstr *MI,
MachineBasicBlock::iterator InsertPos) {
- // Fix RegionBegin if the first instruction moves down.
+ // Advance RegionBegin if the first instruction moves down.
if (&*RegionBegin == MI)
- RegionBegin = llvm::next(RegionBegin);
+ ++RegionBegin;
+
+ // Update the instruction stream.
BB->splice(InsertPos, BB, MI);
+
+ // Update LiveIntervals
LIS->handleMove(MI);
- // Fix RegionBegin if another instruction moves above the first instruction.
+
+ // Recede RegionBegin if an instruction moves above the first.
if (RegionBegin == InsertPos)
RegionBegin = MI;
- // Fix TopRPTracker if we move something above CurrentTop.
- if (CurrentTop == InsertPos)
- TopRPTracker.setPos(MI);
}
bool ScheduleDAGMI::checkSchedLimit() {
@@ -571,8 +573,10 @@ void ScheduleDAGMI::schedule() {
assert(SU->isTopReady() && "node still has unscheduled dependencies");
if (&*CurrentTop == MI)
CurrentTop = nextIfDebug(++CurrentTop, CurrentBottom);
- else
+ else {
moveInstruction(MI, CurrentTop);
+ TopRPTracker.setPos(MI);
+ }
// Update top scheduled pressure.
TopRPTracker.advance();
@@ -588,8 +592,10 @@ void ScheduleDAGMI::schedule() {
if (&*priorII == MI)
CurrentBottom = priorII;
else {
- if (&*CurrentTop == MI)
- CurrentTop = nextIfDebug(++CurrentTop, CurrentBottom);
+ if (&*CurrentTop == MI) {
+ CurrentTop = nextIfDebug(++CurrentTop, priorII);
+ TopRPTracker.setPos(CurrentTop);
+ }
moveInstruction(MI, CurrentBottom);
CurrentBottom = MI;
}