From 45cfe545ec8177262dabc70580ce05feaa1c3880 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 23 Aug 2009 06:03:38 +0000 Subject: Change Pass::print to take a raw ostream instead of std::ostream, update all code that this affects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79830 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/opt/AnalysisWrappers.cpp | 44 +++++++++++++++++++++++------------------- tools/opt/GraphPrinters.cpp | 3 +-- tools/opt/PrintSCC.cpp | 4 ++-- tools/opt/opt.cpp | 10 +++++----- 4 files changed, 32 insertions(+), 29 deletions(-) (limited to 'tools/opt') diff --git a/tools/opt/AnalysisWrappers.cpp b/tools/opt/AnalysisWrappers.cpp index 2ab69ea61e..18360f837e 100644 --- a/tools/opt/AnalysisWrappers.cpp +++ b/tools/opt/AnalysisWrappers.cpp @@ -34,27 +34,31 @@ namespace { static char ID; // Pass ID, replacement for typeid ExternalFunctionsPassedConstants() : ModulePass(&ID) {} virtual bool runOnModule(Module &M) { - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->isDeclaration()) { - bool PrintedFn = false; - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); - UI != E; ++UI) - if (Instruction *User = dyn_cast(*UI)) { - CallSite CS = CallSite::get(User); - if (CS.getInstruction()) { - for (CallSite::arg_iterator AI = CS.arg_begin(), - E = CS.arg_end(); AI != E; ++AI) - if (isa(*AI)) { - if (!PrintedFn) { - errs() << "Function '" << I->getName() << "':\n"; - PrintedFn = true; - } - errs() << *User; - break; - } - } + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { + if (!I->isDeclaration()) continue; + + bool PrintedFn = false; + for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); + UI != E; ++UI) { + Instruction *User = dyn_cast(*UI); + if (!User) continue; + + CallSite CS = CallSite::get(User); + if (!CS.getInstruction()) continue; + + for (CallSite::arg_iterator AI = CS.arg_begin(), + E = CS.arg_end(); AI != E; ++AI) { + if (!isa(*AI)) continue; + + if (!PrintedFn) { + errs() << "Function '" << I->getName() << "':\n"; + PrintedFn = true; } + errs() << *User; + break; + } } + } return false; } @@ -78,7 +82,7 @@ namespace { AU.addRequiredTransitive(); } virtual bool runOnModule(Module &M) { - getAnalysis().print(std::cerr, &M); + getAnalysis().print(errs(), &M); return false; } }; diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp index 5d581e4af0..6bd0a6e9f7 100644 --- a/tools/opt/GraphPrinters.cpp +++ b/tools/opt/GraphPrinters.cpp @@ -70,8 +70,7 @@ namespace { return false; } - void print(std::ostream &OS) const {} - void print(std::ostream &OS, const llvm::Module*) const {} + void print(raw_ostream &OS, const llvm::Module*) const {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); diff --git a/tools/opt/PrintSCC.cpp b/tools/opt/PrintSCC.cpp index a0aa4e90e7..66709ffa19 100644 --- a/tools/opt/PrintSCC.cpp +++ b/tools/opt/PrintSCC.cpp @@ -39,7 +39,7 @@ namespace { CFGSCC() : FunctionPass(&ID) {} bool runOnFunction(Function& func); - void print(std::ostream &O, const Module* = 0) const { } + void print(raw_ostream &O, const Module* = 0) const { } virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); @@ -53,7 +53,7 @@ namespace { // run - Print out SCCs in the call graph for the specified module. bool runOnModule(Module &M); - void print(std::ostream &O, const Module* = 0) const { } + void print(raw_ostream &O, const Module* = 0) const { } // getAnalysisUsage - This pass requires the CallGraph. virtual void getAnalysisUsage(AnalysisUsage &AU) const { diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 4f24198640..f41b202349 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -140,7 +140,7 @@ struct CallGraphSCCPassPrinter : public CallGraphSCCPass { Function *F = SCC[i]->getFunction(); if (F) { outs().flush(); - getAnalysisID(PassToPrint).print(cout, F->getParent()); + getAnalysisID(PassToPrint).print(outs(), F->getParent()); cout << std::flush; } } @@ -169,7 +169,7 @@ struct ModulePassPrinter : public ModulePass { if (!Quiet) { outs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n"; outs().flush(); - getAnalysisID(PassToPrint).print(cout, &M); + getAnalysisID(PassToPrint).print(outs(), &M); cout << std::flush; } @@ -199,7 +199,7 @@ struct FunctionPassPrinter : public FunctionPass { } // Get and print pass... outs().flush(); - getAnalysisID(PassToPrint).print(cout, F.getParent()); + getAnalysisID(PassToPrint).print(outs(), F.getParent()); cout << std::flush; return false; } @@ -224,7 +224,7 @@ struct LoopPassPrinter : public LoopPass { if (!Quiet) { outs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n"; outs().flush(); - getAnalysisID(PassToPrint).print(cout, + getAnalysisID(PassToPrint).print(outs(), L->getHeader()->getParent()->getParent()); cout << std::flush; } @@ -256,7 +256,7 @@ struct BasicBlockPassPrinter : public BasicBlockPass { // Get and print pass... outs().flush(); - getAnalysisID(PassToPrint).print(cout, BB.getParent()->getParent()); + getAnalysisID(PassToPrint).print(outs(), BB.getParent()->getParent()); cout << std::flush; return false; } -- cgit v1.2.3