diff --git a/include/llvm/Analysis/LiveVar/ValueSet.h b/include/llvm/Analysis/LiveVar/ValueSet.h index 6c0a21f9095..048d8df4c55 100644 --- a/include/llvm/Analysis/LiveVar/ValueSet.h +++ b/include/llvm/Analysis/LiveVar/ValueSet.h @@ -16,39 +16,4 @@ ostream &operator<<(ostream &out, RAV Val); typedef std::set ValueSet; void printSet(const ValueSet &S); - -// set_union(A, B) - Compute A := A u B, return whether A changed. -// -template -bool set_union(std::set &S1, const std::set &S2) { - bool Changed = false; - - for (std::set::const_iterator SI = S2.begin(), SE = S2.end(); - SI != SE; ++SI) - if (S1.insert(*SI).second) - Changed = true; - - return Changed; -} - -// set_difference(A, B) - Return A - B -// -template -std::set set_difference(const std::set &S1, const std::set &S2) { - std::set Result; - for (std::set::const_iterator SI = S1.begin(), SE = S1.end(); - SI != SE; ++SI) - if (S2.find(*SI) == S2.end()) // if the element is not in set2 - Result.insert(*SI); - return Result; -} - -// set_subtract(A, B) - Compute A := A - B -// -template -void set_subtract(std::set &S1, const std::set &S2) { - for (std::set::const_iterator SI = S2.begin() ; SI != S2.end(); ++SI) - S1.erase(*SI); -} - #endif diff --git a/include/llvm/CodeGen/ValueSet.h b/include/llvm/CodeGen/ValueSet.h index 6c0a21f9095..048d8df4c55 100644 --- a/include/llvm/CodeGen/ValueSet.h +++ b/include/llvm/CodeGen/ValueSet.h @@ -16,39 +16,4 @@ ostream &operator<<(ostream &out, RAV Val); typedef std::set ValueSet; void printSet(const ValueSet &S); - -// set_union(A, B) - Compute A := A u B, return whether A changed. -// -template -bool set_union(std::set &S1, const std::set &S2) { - bool Changed = false; - - for (std::set::const_iterator SI = S2.begin(), SE = S2.end(); - SI != SE; ++SI) - if (S1.insert(*SI).second) - Changed = true; - - return Changed; -} - -// set_difference(A, B) - Return A - B -// -template -std::set set_difference(const std::set &S1, const std::set &S2) { - std::set Result; - for (std::set::const_iterator SI = S1.begin(), SE = S1.end(); - SI != SE; ++SI) - if (S2.find(*SI) == S2.end()) // if the element is not in set2 - Result.insert(*SI); - return Result; -} - -// set_subtract(A, B) - Compute A := A - B -// -template -void set_subtract(std::set &S1, const std::set &S2) { - for (std::set::const_iterator SI = S2.begin() ; SI != S2.end(); ++SI) - S1.erase(*SI); -} - #endif diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 458978355a7..aad6e1cb386 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -9,27 +9,10 @@ #include "llvm/Method.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" +#include "Support/SetOperations.h" #include using std::set; - -//===----------------------------------------------------------------------===// -// Helper Template -//===----------------------------------------------------------------------===// - -// set_intersect - Identical to set_intersection, except that it works on -// set<>'s and is nicer to use. Functionally, this iterates through S1, -// removing elements that are not contained in S2. -// -template -void set_intersect(set &S1, const set &S2) { - for (typename set::iterator I = S1.begin(); I != S1.end();) { - const Ty &E = *I; - ++I; - if (!S2.count(E)) S1.erase(E); // Erase element if not in S2 - } -} - //===----------------------------------------------------------------------===// // DominatorSet Implementation //===----------------------------------------------------------------------===// diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 458978355a7..aad6e1cb386 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -9,27 +9,10 @@ #include "llvm/Method.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" +#include "Support/SetOperations.h" #include using std::set; - -//===----------------------------------------------------------------------===// -// Helper Template -//===----------------------------------------------------------------------===// - -// set_intersect - Identical to set_intersection, except that it works on -// set<>'s and is nicer to use. Functionally, this iterates through S1, -// removing elements that are not contained in S2. -// -template -void set_intersect(set &S1, const set &S2) { - for (typename set::iterator I = S1.begin(); I != S1.end();) { - const Ty &E = *I; - ++I; - if (!S2.count(E)) S1.erase(E); // Erase element if not in S2 - } -} - //===----------------------------------------------------------------------===// // DominatorSet Implementation //===----------------------------------------------------------------------===//