diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2007-09-27 15:42:23 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@dberlin.org> | 2007-09-27 15:42:23 +0000 |
commit | c7a12ae24ac5290e4e35f746cfb9e01eda4eb661 (patch) | |
tree | dfc6981cfdaa0f509a779f9257b96610226ee5d5 /lib | |
parent | 9a2f93121b31bf6345d1552bdc43037f89714d86 (diff) | |
download | external_llvm-c7a12ae24ac5290e4e35f746cfb9e01eda4eb661.zip external_llvm-c7a12ae24ac5290e4e35f746cfb9e01eda4eb661.tar.gz external_llvm-c7a12ae24ac5290e4e35f746cfb9e01eda4eb661.tar.bz2 |
Ignore redundant constraints
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42397 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/IPA/Andersens.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 4ede5e1..63a6cb5 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -134,6 +134,21 @@ namespace { assert(Offset == 0 || Ty != AddressOf && "Offset is illegal on addressof constraints"); } + bool operator==(const Constraint &RHS) const { + return RHS.Type == Type + && RHS.Dest == Dest + && RHS.Src == Src + && RHS.Offset == Offset; + } + bool operator<(const Constraint &RHS) const { + if (RHS.Type != Type) + return RHS.Type < Type; + else if (RHS.Dest != Dest) + return RHS.Dest < Dest; + else if (RHS.Src != Src) + return RHS.Src < Src; + return RHS.Offset < Offset; + } }; // Node class - This class is used to represent a node in the constraint @@ -1735,6 +1750,7 @@ void Andersens::HUValNum(unsigned NodeIndex) { /// replaced by their the pointer equivalence class representative. void Andersens::RewriteConstraints() { std::vector<Constraint> NewConstraints; + std::set<Constraint> Seen; PEClass2Node.clear(); PENLEClass2Node.clear(); @@ -1768,12 +1784,14 @@ void Andersens::RewriteConstraints() { // it. if (C.Src == C.Dest && C.Type == Constraint::Copy) continue; - + C.Src = FindEquivalentNode(RHSNode, RHSLabel); C.Dest = FindEquivalentNode(FindNode(LHSNode), LHSLabel); - if (C.Src == C.Dest && C.Type == Constraint::Copy) + if (C.Src == C.Dest && C.Type == Constraint::Copy + || Seen.count(C) != 0) continue; + Seen.insert(C); NewConstraints.push_back(C); } Constraints.swap(NewConstraints); |