diff options
author | Lang Hames <lhames@gmail.com> | 2010-07-17 06:31:41 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2010-07-17 06:31:41 +0000 |
commit | d0f6f017319bbc32b57c2e574d774ac91fe20f18 (patch) | |
tree | cabc045feb55ff6743e3cea246eac2cbbcdc6ea8 | |
parent | dc1ad22d5351fca6885ba4ecb18967f8ada7d42a (diff) | |
download | external_llvm-d0f6f017319bbc32b57c2e574d774ac91fe20f18.tar.gz external_llvm-d0f6f017319bbc32b57c2e574d774ac91fe20f18.tar.bz2 external_llvm-d0f6f017319bbc32b57c2e574d774ac91fe20f18.zip |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108613 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/PBQP/Heuristics/Briggs.h | 8 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocPBQP.cpp | 12 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/CodeGen/PBQP/Heuristics/Briggs.h b/lib/CodeGen/PBQP/Heuristics/Briggs.h index 4c1ce119ed..18eaf7c0da 100644 --- a/lib/CodeGen/PBQP/Heuristics/Briggs.h +++ b/lib/CodeGen/PBQP/Heuristics/Briggs.h @@ -52,9 +52,7 @@ namespace PBQP { 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 @@ namespace PBQP { cost2 = g->getNodeCosts(n2Itr)[0] / s->getSolverDegree(n2Itr); if (cost1 < cost2) return true; - if (cost1 > cost2) - return false; - return (&*n1Itr < &*n2Itr); + return false; } private: diff --git a/lib/CodeGen/RegAllocPBQP.cpp b/lib/CodeGen/RegAllocPBQP.cpp index 45104b48fe..a7ea8e7c3a 100644 --- a/lib/CodeGen/RegAllocPBQP.cpp +++ b/lib/CodeGen/RegAllocPBQP.cpp @@ -104,7 +104,15 @@ namespace { 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 @@ namespace { 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; |