X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FMachineScheduler.cpp;h=57ae6dc02a4d4daf35d190f087323690bee19ec2;hb=1ce062fe567a08678d20149781c5e308e03d7d83;hp=9f67d6d0189b68115a23e408483cf49e6292d5f6;hpb=0b0d899f917d4771c940e7fa92990d981822a6db;p=oota-llvm.git diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp index 9f67d6d0189..57ae6dc02a4 100644 --- a/lib/CodeGen/MachineScheduler.cpp +++ b/lib/CodeGen/MachineScheduler.cpp @@ -369,8 +369,12 @@ void ScheduleDAGMI::releasePredecessors(SUnit *SU) { void ScheduleDAGMI::moveInstruction(MachineInstr *MI, MachineBasicBlock::iterator InsertPos) { + // Fix RegionBegin if the first instruction moves down. + if (&*RegionBegin == MI) + RegionBegin = llvm::next(RegionBegin); BB->splice(InsertPos, BB, MI); LIS->handleMove(MI); + // Fix RegionBegin if another instruction moves above the first instruction. if (RegionBegin == InsertPos) RegionBegin = MI; } @@ -440,6 +444,8 @@ void ScheduleDAGMI::schedule() { if (&*llvm::prior(CurrentBottom) == MI) --CurrentBottom; else { + if (&*CurrentTop == MI) + CurrentTop = llvm::next(CurrentTop); moveInstruction(MI, CurrentBottom); CurrentBottom = MI; }