[llvm-commits] [llvm] r108613 - in /llvm/trunk/lib/CodeGen: PBQP/Heuristics/Briggs.h RegAllocPBQP.cpp

Lang Hames lhames at gmail.com
Fri Jul 16 23:31:41 PDT 2010


Author: lhames
Date: Sat Jul 17 01:31:41 2010
New Revision: 108613

URL: http://llvm.org/viewvc/llvm-project?rev=108613&view=rev
Log:
Iterating over sets of pointers in a heuristic was a bad idea. Switching
any command line paramater changed the register allocation produced by
PBQP.

Turns out variety is not the spice of life.

Fixed some comparators, added others. All good now.


Modified:
    llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h
    llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp

Modified: llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h?rev=108613&r1=108612&r2=108613&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h (original)
+++ llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h Sat Jul 17 01:31:41 2010
@@ -52,9 +52,7 @@
         bool operator()(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr) const {
           if (s->getSolverDegree(n1Itr) > s->getSolverDegree(n2Itr))
             return true;
-          if (s->getSolverDegree(n1Itr) < s->getSolverDegree(n2Itr))
-            return false;
-          return (&*n1Itr < &*n2Itr);
+          return false;
         }
       private:
         HeuristicSolverImpl<Briggs> *s;
@@ -69,9 +67,7 @@
                   cost2 = g->getNodeCosts(n2Itr)[0] / s->getSolverDegree(n2Itr);
           if (cost1 < cost2)
             return true;
-          if (cost1 > cost2)
-            return false;
-          return (&*n1Itr < &*n2Itr);
+          return false;
         }
 
       private:

Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=108613&r1=108612&r2=108613&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Sat Jul 17 01:31:41 2010
@@ -104,7 +104,15 @@
     virtual bool runOnMachineFunction(MachineFunction &MF);
 
   private:
-    typedef std::map<const LiveInterval*, unsigned> LI2NodeMap;
+
+    class LIOrdering {
+    public:
+      bool operator()(const LiveInterval *li1, const LiveInterval *li2) const {
+        return li1->reg < li2->reg;
+      }
+    };
+
+    typedef std::map<const LiveInterval*, unsigned, LIOrdering> LI2NodeMap;
     typedef std::vector<const LiveInterval*> Node2LIMap;
     typedef std::vector<unsigned> AllowedSet;
     typedef std::vector<AllowedSet> AllowedSetMap;
@@ -112,7 +120,7 @@
     typedef std::pair<unsigned, unsigned> RegPair;
     typedef std::map<RegPair, PBQP::PBQPNum> CoalesceMap;
 
-    typedef std::set<LiveInterval*> LiveIntervalSet;
+    typedef std::set<LiveInterval*, LIOrdering> LiveIntervalSet;
 
     typedef std::vector<PBQP::Graph::NodeItr> NodeVector;
 





More information about the llvm-commits mailing list