summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-02-05 01:43:49 +0000
committerChris Lattner <sabre@nondot.org>2002-02-05 01:43:49 +0000
commit0665a5f1f5716a69982f4bcd654e5ace975d0c0a (patch)
tree67856963d43737337cb4c9c2d7940989d9e16341 /lib/Analysis
parentf39f379f9ec2e2908c89fdc809c9665c7484edb1 (diff)
downloadllvm-0665a5f1f5716a69982f4bcd654e5ace975d0c0a.tar.gz
llvm-0665a5f1f5716a69982f4bcd654e5ace975d0c0a.tar.bz2
llvm-0665a5f1f5716a69982f4bcd654e5ace975d0c0a.tar.xz
* Code Cleanups
* Introduce RAV to allow stream I/O instead of using printValue git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1710 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/LiveVar/BBLiveVar.cpp18
-rw-r--r--lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp2
-rw-r--r--lib/Analysis/LiveVar/ValueSet.cpp68
3 files changed, 29 insertions, 59 deletions
diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp
index b8b9e53c10..81bbd38756 100644
--- a/lib/Analysis/LiveVar/BBLiveVar.cpp
+++ b/lib/Analysis/LiveVar/BBLiveVar.cpp
@@ -70,13 +70,9 @@ void BBLiveVar::calcDefUseSets() {
PhiArgMap[ArgVal] = cast<BasicBlock>(BBVal);
- if (DEBUG_LV > 1) {
- cerr << " - phi operand ";
- printValue(ArgVal);
- cerr << " came from BB ";
- printValue(PhiArgMap[ArgVal]);
- cerr << "\n";
- }
+ if (DEBUG_LV > 1)
+ cerr << " - phi operand " << RAV(ArgVal) << " came from BB "
+ << RAV(PhiArgMap[ArgVal]) << "\n";
} // if( IsPhi )
} // if a use
} // for all operands
@@ -105,9 +101,7 @@ void BBLiveVar::addDef(const Value *Op) {
InSet.erase(Op); // this definition kills any uses
InSetChanged = true;
- if (DEBUG_LV > 1) {
- cerr << " +Def: "; printValue( Op ); cerr << "\n";
- }
+ if (DEBUG_LV > 1) cerr << " +Def: " << RAV(Op) << "\n";
}
@@ -119,9 +113,7 @@ void BBLiveVar::addUse(const Value *Op) {
OutSet.erase(Op); // remove if there is a def below this use
InSetChanged = true;
- if (DEBUG_LV > 1) {
- cerr << " Use: "; printValue( Op ); cerr << "\n";
- }
+ if (DEBUG_LV > 1) cerr << " Use: " << RAV(Op) << "\n";
}
diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
index 07ac10f1b4..cfe0fe4ba0 100644
--- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
@@ -62,7 +62,7 @@ void MethodLiveVarInfo::constructBBs(const Method *M) {
BBI != BBE; ++BBI, ++POId) {
const BasicBlock *BB = *BBI; // get the current BB
- if (DEBUG_LV) { std::cerr << " For BB "; printValue(BB); cerr << ":\n"; }
+ if (DEBUG_LV) std::cerr << " For BB " << RAV(BB) << ":\n";
// create a new BBLiveVar
BBLiveVar *LVBB = new BBLiveVar(BB, POId);
diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp
index 8bf0b4df25..431ccc6222 100644
--- a/lib/Analysis/LiveVar/ValueSet.cpp
+++ b/lib/Analysis/LiveVar/ValueSet.cpp
@@ -1,64 +1,42 @@
+
+
#include "llvm/Analysis/LiveVar/ValueSet.h"
#include "llvm/ConstantVals.h"
-#include <algorithm>
#include <iostream>
-using std::cerr;
-using std::endl;
-using std::pair;
-using std::hash_set;
-void printValue(const Value *v) { // func to print a Value
+ostream &operator<<(ostream &O, RAV V) { // func to print a Value
+ const Value *v = V.V;
if (v->hasName())
- cerr << v << "(" << v->getName() << ") ";
+ return O << v << "(" << v->getName() << ") ";
else if (Constant *C = dyn_cast<Constant>(v))
- cerr << v << "(" << C->getStrValue() << ") ";
+ return O << v << "(" << C->getStrValue() << ") ";
else
- cerr << v << " ";
+ return O << v << " ";
}
+bool ValueSet::setUnion( const ValueSet *S) {
+ bool Changed = false;
-//---------------- Method implementations --------------------------
- // for performing two set unions
-bool ValueSet::setUnion( const ValueSet *set1) {
- pair<iterator, bool> result;
- bool changed = false;
-
- for(const_iterator set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
- // for all all elements in set1
- result = insert(*set1it); // insert to this set
- if(result.second == true) changed = true;
- }
+ for (const_iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI)
+ if (insert(*SI).second)
+ Changed = true;
- return changed;
+ return Changed;
}
-
- // for performing set difference
-void ValueSet::setDifference( const ValueSet *const set1,
- const ValueSet *const set2) {
-
- const_iterator set1it, set2it;
- for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
- // for all elements in set1
- iterator set2it = set2->find( *set1it ); // find wether the elem is in set2
- if( set2it == set2->end() ) // if the element is not in set2
- insert( *set1it ); // insert to this set
- }
+void ValueSet::setDifference(const ValueSet *S1, const ValueSet *S2) {
+ for (const_iterator SI = S1->begin(), SE = S1->end() ; SI != SE; ++SI)
+ if (S2->find(*SI) == S2->end()) // if the element is not in set2
+ insert(*SI);
}
-
- // for performing set subtraction
-void ValueSet::setSubtract( const ValueSet *const set1) {
- const_iterator set1it;
- for( set1it = set1->begin() ; set1it != set1->end(); ++set1it)
- // for all elements in set1
- erase( *set1it ); // erase that element from this set
+void ValueSet::setSubtract(const ValueSet *S) {
+ for (const_iterator SI = S->begin() ; SI != S->end(); ++SI)
+ erase(*SI);
}
-
-
-
-void ValueSet::printSet() const { // for printing a live variable set
- for_each(begin(), end(), printValue);
+void ValueSet::printSet() const {
+ for (const_iterator I = begin(), E = end(); I != E; ++I)
+ std::cerr << RAV(*I);
}