[llvm-commits] [llvm] r42397 - /llvm/trunk/lib/Analysis/IPA/Andersens.cpp
Chris Lattner
clattner at apple.com
Thu Sep 27 09:11:46 PDT 2007
On Sep 27, 2007, at 8:42 AM, Daniel Berlin wrote:
> // Node class - This class is used to represent a node in the
> constraint
> @@ -1735,6 +1750,7 @@
> /// 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 @@
> // 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);
std::set is inefficient for several reasons, particularly because
every insertion does a malloc. If this is performance critical code
you might want to try out SmallSet (assuming the set is small) or
some sort of hash table like DenseMap.
-Chris
More information about the llvm-commits
mailing list