diff options
| author | Daniel Berlin <dberlin@dberlin.org> | 2007-09-29 00:50:40 +0000 |
|---|---|---|
| committer | Daniel Berlin <dberlin@dberlin.org> | 2007-09-29 00:50:40 +0000 |
| commit | 342181c51d81f9efad0a39cc95a89037b5644b82 (patch) | |
| tree | 25287d78db2948721698e5700cb4d6227dc4c0f1 /llvm/lib | |
| parent | 2717f3bd60774a6b0172a2f45b7dfc10133b97ef (diff) | |
| download | bcm5719-llvm-342181c51d81f9efad0a39cc95a89037b5644b82.tar.gz bcm5719-llvm-342181c51d81f9efad0a39cc95a89037b5644b82.zip | |
Switch to densemap rather than std::set
llvm-svn: 42462
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/IPA/Andersens.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/IPA/Andersens.cpp b/llvm/lib/Analysis/IPA/Andersens.cpp index 63a6cb553e0..b6cb8f8f15b 100644 --- a/llvm/lib/Analysis/IPA/Andersens.cpp +++ b/llvm/lib/Analysis/IPA/Andersens.cpp @@ -134,12 +134,18 @@ 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 { + return !(*this == RHS); + } + bool operator<(const Constraint &RHS) const { if (RHS.Type != Type) return RHS.Type < Type; @@ -151,6 +157,23 @@ namespace { } }; + struct ConstraintKeyInfo { + static inline Constraint getEmptyKey() { + return Constraint(Constraint::Copy, ~0UL, ~0UL, ~0UL); + } + static inline Constraint getTombstoneKey() { + return Constraint(Constraint::Copy, ~0UL - 1, ~0UL - 1, ~0UL - 1); + } + static unsigned getHashValue(const Constraint &C) { + return C.Src ^ C.Dest ^ C.Type ^ C.Offset; + } + static bool isEqual(const Constraint &LHS, + const Constraint &RHS) { + return LHS.Type == RHS.Type && LHS.Dest == RHS.Dest + && LHS.Src == RHS.Src && LHS.Offset == RHS.Offset; + } + }; + // Node class - This class is used to represent a node in the constraint // graph. Due to various optimizations, it is not always the case that // there is a mapping from a Node to a Value. In particular, we add @@ -1750,7 +1773,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; + DenseMap<Constraint, bool, ConstraintKeyInfo> Seen; PEClass2Node.clear(); PENLEClass2Node.clear(); @@ -1788,10 +1811,10 @@ void Andersens::RewriteConstraints() { C.Src = FindEquivalentNode(RHSNode, RHSLabel); C.Dest = FindEquivalentNode(FindNode(LHSNode), LHSLabel); if (C.Src == C.Dest && C.Type == Constraint::Copy - || Seen.count(C) != 0) + || Seen[C] == true) continue; - Seen.insert(C); + Seen[C] = true; NewConstraints.push_back(C); } Constraints.swap(NewConstraints); |

