diff options
author | Reid Kleckner <reid@kleckner.net> | 2009-09-30 20:15:38 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2009-09-30 20:15:38 +0000 |
commit | c277ab08a24d2dbe9b4ff1a9154ea6115ed6a4e3 (patch) | |
tree | 961f33a75eced084518a387d00095b6a98782d25 /lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp | |
parent | 69cc57c3259249cd9e64735ba79da2ce0e64a4b5 (diff) | |
download | external_llvm-c277ab08a24d2dbe9b4ff1a9154ea6115ed6a4e3.zip external_llvm-c277ab08a24d2dbe9b4ff1a9154ea6115ed6a4e3.tar.gz external_llvm-c277ab08a24d2dbe9b4ff1a9154ea6115ed6a4e3.tar.bz2 |
Fix integer overflow in instruction scheduling. This can happen if we have
basic blocks that are so long that their size overflows a short.
Also assert that overflow does not happen in the future, as requested by Evan.
This fixes PR4401.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index a9d1878..bd6e048 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -278,6 +278,7 @@ void ScheduleDAGRRList::CapturePred(SDep *PredEdge) { AvailableQueue->remove(PredSU); } + assert(PredSU->NumSuccsLeft < UINT_MAX && "NumSuccsLeft will overflow!"); ++PredSU->NumSuccsLeft; } @@ -824,17 +825,17 @@ void ScheduleDAGRRList::ListScheduleBottomUp() { /// the AvailableQueue if the count reaches zero. Also update its cycle bound. void ScheduleDAGRRList::ReleaseSucc(SUnit *SU, const SDep *SuccEdge) { SUnit *SuccSU = SuccEdge->getSUnit(); - --SuccSU->NumPredsLeft; - + #ifndef NDEBUG - if (SuccSU->NumPredsLeft < 0) { + if (SuccSU->NumPredsLeft == 0) { errs() << "*** Scheduling failed! ***\n"; SuccSU->dump(this); errs() << " has been released too many times!\n"; llvm_unreachable(0); } #endif - + --SuccSU->NumPredsLeft; + // If all the node's predecessors are scheduled, this node is ready // to be scheduled. Ignore the special ExitSU node. if (SuccSU->NumPredsLeft == 0 && SuccSU != &ExitSU) { |