[llvm-commits] [llvm] r52654 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp

Dan Gohman gohman at apple.com
Mon Jun 23 16:40:09 PDT 2008


Author: djg
Date: Mon Jun 23 18:40:09 2008
New Revision: 52654

URL: http://llvm.org/viewvc/llvm-project?rev=52654&view=rev
Log:
Use the new PriorityQueue in ScheduleDAGList too, which also
needs arbitrary-element removal.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp?rev=52654&r1=52653&r2=52654&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp Mon Jun 23 18:40:09 2008
@@ -28,9 +28,9 @@
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/ADT/PriorityQueue.h"
 #include "llvm/ADT/Statistic.h"
 #include <climits>
-#include <queue>
 using namespace llvm;
 
 STATISTIC(NumNoops , "Number of noops inserted");
@@ -315,7 +315,7 @@
     /// mobility.
     std::vector<unsigned> NumNodesSolelyBlocking;
 
-    std::priority_queue<SUnit*, std::vector<SUnit*>, latency_sort> Queue;
+    PriorityQueue<SUnit*, std::vector<SUnit*>, latency_sort> Queue;
 public:
     LatencyPriorityQueue() : Queue(latency_sort(this)) {
     }
@@ -373,25 +373,9 @@
       return V;
     }
 
-    /// remove - This is a really inefficient way to remove a node from a
-    /// priority queue.  We should roll our own heap to make this better or
-    /// something.
     void remove(SUnit *SU) {
-      std::vector<SUnit*> Temp;
-      
       assert(!Queue.empty() && "Not in queue!");
-      while (Queue.top() != SU) {
-        Temp.push_back(Queue.top());
-        Queue.pop();
-        assert(!Queue.empty() && "Not in queue!");
-      }
-
-      // Remove the node from the PQ.
-      Queue.pop();
-      
-      // Add all the other nodes back.
-      for (unsigned i = 0, e = Temp.size(); i != e; ++i)
-        Queue.push(Temp[i]);
+      Queue.erase_one(SU);
     }
 
     // ScheduledNode - As nodes are scheduled, we look to see if there are any





More information about the llvm-commits mailing list