[llvm-commits] [llvm] r42397 - /llvm/trunk/lib/Analysis/IPA/Andersens.cpp

Daniel Berlin dberlin at dberlin.org
Thu Sep 27 09:20:24 PDT 2007


On 9/27/07, Chris Lattner <clattner at apple.com> wrote:
>
> 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.


It's not performance critical, but the sets aren't small.  They can be
hundreds of thousands.

I was looking for something like DenseSet, but couldn't find it.

Should i just use DenseMap<Constraint, bool> then?



More information about the llvm-commits mailing list