[llvm] r318387 - Assert correct removal of SUnit in LatencyPriorityQueue
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 02:18:07 PST 2017
Author: d0k
Date: Thu Nov 16 02:18:07 2017
New Revision: 318387
URL: http://llvm.org/viewvc/llvm-project?rev=318387&view=rev
Log:
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
Modified:
llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp
Modified: llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp?rev=318387&r1=318386&r2=318387&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp (original)
+++ llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp Thu Nov 16 02:18:07 2017
@@ -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();
More information about the llvm-commits
mailing list