diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-23 05:17:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-23 05:17:37 +0000 |
commit | 791102fb1192ac9483274e54cbc42480c9b1af10 (patch) | |
tree | 4729b1da9b9c946fb83bc177dd3d00bffcf85390 /lib/Analysis | |
parent | 79c5d3f9717756dc3ff56cfcaa3ae1a5930c457a (diff) | |
download | external_llvm-791102fb1192ac9483274e54cbc42480c9b1af10.zip external_llvm-791102fb1192ac9483274e54cbc42480c9b1af10.tar.gz external_llvm-791102fb1192ac9483274e54cbc42480c9b1af10.tar.bz2 |
eliminate the std::ostream form of WriteAsOperand and update clients.
This also updates dominator related stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79825 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/AliasAnalysisCounter.cpp | 36 | ||||
-rw-r--r-- | lib/Analysis/AliasAnalysisEvaluator.cpp | 15 | ||||
-rw-r--r-- | lib/Analysis/AliasSetTracker.cpp | 15 | ||||
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 6 | ||||
-rw-r--r-- | lib/Analysis/PostDominators.cpp | 11 |
5 files changed, 49 insertions, 34 deletions
diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index f1bd7c1..73956a1 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -42,33 +42,33 @@ namespace { } void printLine(const char *Desc, unsigned Val, unsigned Sum) { - cerr << " " << Val << " " << Desc << " responses (" - << Val*100/Sum << "%)\n"; + errs() << " " << Val << " " << Desc << " responses (" + << Val*100/Sum << "%)\n"; } ~AliasAnalysisCounter() { unsigned AASum = No+May+Must; unsigned MRSum = NoMR+JustRef+JustMod+MR; if (AASum + MRSum) { // Print a report if any counted queries occurred... - cerr << "\n===== Alias Analysis Counter Report =====\n" - << " Analysis counted: " << Name << "\n" - << " " << AASum << " Total Alias Queries Performed\n"; + errs() << "\n===== Alias Analysis Counter Report =====\n" + << " Analysis counted: " << Name << "\n" + << " " << AASum << " Total Alias Queries Performed\n"; if (AASum) { printLine("no alias", No, AASum); printLine("may alias", May, AASum); printLine("must alias", Must, AASum); - cerr << " Alias Analysis Counter Summary: " << No*100/AASum << "%/" - << May*100/AASum << "%/" << Must*100/AASum<<"%\n\n"; + errs() << " Alias Analysis Counter Summary: " << No*100/AASum << "%/" + << May*100/AASum << "%/" << Must*100/AASum<<"%\n\n"; } - cerr << " " << MRSum << " Total Mod/Ref Queries Performed\n"; + errs() << " " << MRSum << " Total Mod/Ref Queries Performed\n"; if (MRSum) { printLine("no mod/ref", NoMR, MRSum); printLine("ref", JustRef, MRSum); printLine("mod", JustMod, MRSum); printLine("mod/ref", MR, MRSum); - cerr << " Mod/Ref Analysis Counter Summary: " <<NoMR*100/MRSum<< "%/" - << JustRef*100/MRSum << "%/" << JustMod*100/MRSum << "%/" - << MR*100/MRSum <<"%\n\n"; + errs() << " Mod/Ref Analysis Counter Summary: " <<NoMR*100/MRSum + << "%/" << JustRef*100/MRSum << "%/" << JustMod*100/MRSum + << "%/" << MR*100/MRSum <<"%\n\n"; } } } @@ -139,13 +139,13 @@ AliasAnalysisCounter::alias(const Value *V1, unsigned V1Size, } if (PrintAll || (PrintAllFailures && R == MayAlias)) { - cerr << AliasString << ":\t"; - cerr << "[" << V1Size << "B] "; - WriteAsOperand(*cerr.stream(), V1, true, M); - cerr << ", "; - cerr << "[" << V2Size << "B] "; - WriteAsOperand(*cerr.stream(), V2, true, M); - cerr << "\n"; + errs() << AliasString << ":\t"; + errs() << "[" << V1Size << "B] "; + WriteAsOperand(errs(), V1, true, M); + errs() << ", "; + errs() << "[" << V2Size << "B] "; + WriteAsOperand(errs(), V2, true, M); + errs() << "\n"; } return R; diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index 942bc4b..5194e49 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -81,13 +81,16 @@ X("aa-eval", "Exhaustive Alias Analysis Precision Evaluator", false, true); FunctionPass *llvm::createAAEvalPass() { return new AAEval(); } -static void PrintResults(const char *Msg, bool P, const Value *V1, const Value *V2, - const Module *M) { +static void PrintResults(const char *Msg, bool P, const Value *V1, + const Value *V2, const Module *M) { if (P) { - std::stringstream s1, s2; - WriteAsOperand(s1, V1, true, M); - WriteAsOperand(s2, V2, true, M); - std::string o1(s1.str()), o2(s2.str()); + std::string o1, o2; + { + raw_string_ostream os1(o1), os2(o2); + WriteAsOperand(os1, V1, true, M); + WriteAsOperand(os2, V2, true, M); + } + if (o2 < o1) std::swap(o1, o2); errs() << " " << Msg << ":\t" diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 760964c..b056d00 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -22,7 +22,8 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/InstIterator.h" -#include "llvm/Support/Streams.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; /// mergeSetIn - Merge the specified alias set into this alias set. @@ -531,8 +532,8 @@ void AliasSetTracker::copyValue(Value *From, Value *To) { // AliasSet/AliasSetTracker Printing Support //===----------------------------------------------------------------------===// -void AliasSet::print(std::ostream &OS) const { - OS << " AliasSet[" << (void*)this << "," << RefCount << "] "; +void AliasSet::print(raw_ostream &OS) const { + OS << " AliasSet[" << format("0x%p", (void*)this) << "," << RefCount << "] "; OS << (AliasTy == MustAlias ? "must" : "may") << " alias, "; switch (AccessTy) { case NoModRef: OS << "No access "; break; @@ -564,7 +565,7 @@ void AliasSet::print(std::ostream &OS) const { OS << "\n"; } -void AliasSetTracker::print(std::ostream &OS) const { +void AliasSetTracker::print(raw_ostream &OS) const { OS << "Alias Set Tracker: " << AliasSets.size() << " alias sets for " << PointerMap.size() << " pointer values.\n"; for (const_iterator I = begin(), E = end(); I != E; ++I) @@ -572,8 +573,8 @@ void AliasSetTracker::print(std::ostream &OS) const { OS << "\n"; } -void AliasSet::dump() const { print (cerr); } -void AliasSetTracker::dump() const { print(cerr); } +void AliasSet::dump() const { print(errs()); } +void AliasSetTracker::dump() const { print(errs()); } //===----------------------------------------------------------------------===// // ASTCallbackVH Class Implementation @@ -614,7 +615,7 @@ namespace { for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) Tracker->add(&*I); - Tracker->print(cerr); + Tracker->print(errs()); delete Tracker; return false; } diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index bef6bef..75d89af 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -308,3 +308,9 @@ void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired<DominatorTree>(); } + +void LoopInfo::print(std::ostream &OS, const Module*) const { + raw_os_ostream OSS(OS); + LI.print(OSS); +} + diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 4853c2a..69522e8 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -33,15 +33,20 @@ F("postdomtree", "Post-Dominator Tree Construction", true, true); bool PostDominatorTree::runOnFunction(Function &F) { DT->recalculate(F); - DEBUG(DT->dump()); + DEBUG(DT->print(errs())); return false; } -PostDominatorTree::~PostDominatorTree() -{ +PostDominatorTree::~PostDominatorTree() { delete DT; } +void PostDominatorTree::print(std::ostream &OS, const Module *) const { + raw_os_ostream OSS(OS); + DT->print(OSS); +} + + FunctionPass* llvm::createPostDomTree() { return new PostDominatorTree(); } |