summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-08-11 20:03:09 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-08-11 20:03:09 +0000
commit38eea4a76f015d6ee7afdb3a7a02ac6789104815 (patch)
tree76d2c2a5a7363de797833256b510a5f65c71073b /llvm/lib/CodeGen/MachineScheduler.cpp
parent9e4da07125504a0886fc7c224d233d317643d267 (diff)
downloadbcm5719-llvm-38eea4a76f015d6ee7afdb3a7a02ac6789104815.tar.gz
bcm5719-llvm-38eea4a76f015d6ee7afdb3a7a02ac6789104815.zip
CodeGen: Avoid dereferencing end() in MachineScheduler
Check MachineInstr::isDebugValue for the same instruction as we're calling isSchedBoundary, avoiding the possibility of dereferencing end(). This is a functionality change even when I!=end(). Matthias had a look and agrees this is the right resolution (as opposed to checking for end()). This is triggered by a huge number of tests, but they happen to magically pass right now. I found this because WIP patches for PR26753 convert them into crashes. llvm-svn: 278394
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index d921e2977cc..01ef9d834b6 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -458,9 +458,10 @@ void MachineSchedulerBase::scheduleRegions(ScheduleDAGInstrs &Scheduler,
unsigned NumRegionInstrs = 0;
MachineBasicBlock::iterator I = RegionEnd;
for (;I != MBB->begin(); --I) {
- if (isSchedBoundary(&*std::prev(I), &*MBB, MF, TII))
+ MachineInstr &MI = *std::prev(I);
+ if (isSchedBoundary(&MI, &*MBB, MF, TII))
break;
- if (!I->isDebugValue())
+ if (!MI.isDebugValue())
++NumRegionInstrs;
}
// Notify the scheduler of the region, even if we may skip scheduling
OpenPOWER on IntegriCloud