aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2017-11-16 10:18:07 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2017-11-16 10:18:07 +0000
commit94488e575aeabdee790e83a30768e457b901fa21 (patch)
tree536b3c38a245dda14746fc31168e7315d94ebb41
parent89ec3b09eb8d4d94cb9e384a1d85f1dcf9476dfe (diff)
Assert correct removal of SUnit in LatencyPriorityQueue
The LatencyPriorityQueue doesn't currently check whether the SU being removed really exists in the Queue. This method fails quietly when SU is not found and removes the last element from the Queue, leading to unexpected behavior. Unfortunately, this only occurs on our custom target, with the custom scheduler. In our case, when remove() is invoked, it removes the wrong SU at the end of the Queue, which is only discovered later when VerifyScheduledDAG() is invoked and finds that some nodes were not scheduled at all. As this is only reproducible with a lot of proprietary code, I'm hopeful this assert is straightforward enough to not necessitate a test. Patch by Ondrej Glasnak! Differential Revision: https://reviews.llvm.org/D40084 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318387 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/LatencyPriorityQueue.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/CodeGen/LatencyPriorityQueue.cpp b/lib/CodeGen/LatencyPriorityQueue.cpp
index 86ef898932a..8ffd51a550f 100644
--- a/lib/CodeGen/LatencyPriorityQueue.cpp
+++ b/lib/CodeGen/LatencyPriorityQueue.cpp
@@ -134,6 +134,7 @@ SUnit *LatencyPriorityQueue::pop() {
void LatencyPriorityQueue::remove(SUnit *SU) {
assert(!Queue.empty() && "Queue is empty!");
std::vector<SUnit *>::iterator I = find(Queue, SU);
+ assert(I != Queue.end() && "Queue doesn't contain the SU being removed!");
if (I != std::prev(Queue.end()))
std::swap(*I, Queue.back());
Queue.pop_back();