Skip to content

Commit

Permalink
Assert correct removal of SUnit in LatencyPriorityQueue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
d0k committed Nov 16, 2017
1 parent 89ec3b0 commit 94488e5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/CodeGen/LatencyPriorityQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 94488e5

Please sign in to comment.