diff options
50 files changed, 138 insertions, 191 deletions
diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index de839694dc..c36cb22780 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -155,9 +155,7 @@ public: /// void initialize(Module &M); - virtual void print(std::ostream &o, const Module *M) const; - void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); } - void dump() const; + void print(raw_ostream &o, Module *) const; protected: // destroy - Release memory for the call graph @@ -202,8 +200,7 @@ public: /// dump - Print out this call graph node. /// void dump() const; - void print(std::ostream &OS) const; - void print(std::ostream *OS) const { if (OS) print(*OS); } + void print(raw_ostream &OS) const; //===--------------------------------------------------------------------- // Methods to keep a call graph up to date with a function that has been diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 094fecf107..412f8ccf6d 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -22,7 +22,6 @@ #define LLVM_ANALYSIS_DOMINATORS_H #include "llvm/Pass.h" -#include "llvm/BasicBlock.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/ADT/DenseMap.h" @@ -830,7 +829,7 @@ public: DT->releaseMemory(); } - virtual void print(std::ostream &OS, const Module* M= 0) const; + virtual void print(raw_ostream &OS, const Module* M= 0) const; }; //===------------------------------------- @@ -978,7 +977,7 @@ public: /// print - Convert to human readable form /// - virtual void print(std::ostream &OS, const Module* = 0) const; + virtual void print(raw_ostream &OS, const Module* = 0) const; }; diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index c897af3a58..1337385848 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -37,8 +37,7 @@ public: /// passed in, then the types are printed symbolically if possible, using the /// symbol table from the module. /// - void print(std::ostream &o, const Module *M) const; - void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); } + void print(raw_ostream &o, const Module *M) const; private: /// IncorporateType - Incorporate one type and all of its subtypes into the diff --git a/include/llvm/Analysis/Interval.h b/include/llvm/Analysis/Interval.h index 1da2022f69..ca8ad73131 100644 --- a/include/llvm/Analysis/Interval.h +++ b/include/llvm/Analysis/Interval.h @@ -22,11 +22,11 @@ #include "llvm/ADT/GraphTraits.h" #include <vector> -#include <iosfwd> namespace llvm { class BasicBlock; +class raw_ostream; //===----------------------------------------------------------------------===// // @@ -98,8 +98,7 @@ public: bool isLoop() const; /// print - Show contents in human readable format... - void print(std::ostream &O) const; - void print(std::ostream *O) const { if (O) print(*O); } + void print(raw_ostream &O) const; }; /// succ_begin/succ_end - define methods so that Intervals may be used diff --git a/include/llvm/Analysis/IntervalPartition.h b/include/llvm/Analysis/IntervalPartition.h index feae6d82f8..c1214e7427 100644 --- a/include/llvm/Analysis/IntervalPartition.h +++ b/include/llvm/Analysis/IntervalPartition.h @@ -60,10 +60,7 @@ public: IntervalPartition(IntervalPartition &I, bool); // print - Show contents in human readable format... - virtual void print(std::ostream &O, const Module* = 0) const; - void print(std::ostream *O, const Module* M = 0) const { - if (O) print(*O, M); - } + virtual void print(raw_ostream &O, const Module* = 0) const; // getRootInterval() - Return the root interval that contains the starting // block of the function. diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 5435226283..3a09e7b058 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -938,7 +938,7 @@ public: virtual void releaseMemory() { LI.releaseMemory(); } - virtual void print(std::ostream &O, const Module* M = 0) const; + virtual void print(raw_ostream &O, const Module* M = 0) const; virtual void getAnalysisUsage(AnalysisUsage &AU) const; diff --git a/include/llvm/Analysis/LoopVR.h b/include/llvm/Analysis/LoopVR.h index a9f6636d79..3b098e6ca1 100644 --- a/include/llvm/Analysis/LoopVR.h +++ b/include/llvm/Analysis/LoopVR.h @@ -17,7 +17,6 @@ #include "llvm/Pass.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Support/ConstantRange.h" -#include <iosfwd> #include <map> namespace llvm { @@ -33,7 +32,7 @@ public: LoopVR() : FunctionPass(&ID) {} bool runOnFunction(Function &F); - virtual void print(std::ostream &os, const Module *) const; + virtual void print(raw_ostream &os, const Module *) const; void releaseMemory(); void getAnalysisUsage(AnalysisUsage &AU) const; diff --git a/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index ff579e3c4a..6c9e05fd4b 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/include/llvm/Analysis/PostDominators.h @@ -57,7 +57,7 @@ struct PostDominatorTree : public FunctionPass { return DT->properlyDominates(A, B); } - virtual void print(std::ostream &OS, const Module*) const; + virtual void print(raw_ostream &OS, const Module*) const; }; FunctionPass* createPostDomTree(); diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 558cd011f5..ea25853eda 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -601,11 +601,7 @@ namespace llvm { virtual bool runOnFunction(Function &F); virtual void releaseMemory(); virtual void getAnalysisUsage(AnalysisUsage &AU) const; - void print(raw_ostream &OS, const Module* = 0) const; - virtual void print(std::ostream &OS, const Module* = 0) const; - void print(std::ostream *OS, const Module* M = 0) const { - if (OS) print(*OS, M); - } + virtual void print(raw_ostream &OS, const Module* = 0) const; private: FoldingSet<SCEV> UniqueSCEVs; diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index b20cc6e212..da9ff30edf 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -347,7 +347,7 @@ namespace llvm { virtual bool runOnMachineFunction(MachineFunction&); /// print - Implement the dump method. - virtual void print(std::ostream &O, const Module* = 0) const; + virtual void print(raw_ostream &O, const Module* = 0) const; /// addIntervalsForSpills - Create new intervals for spilled defs / uses of /// the given interval. FIXME: It also returns the weight of the spill slot diff --git a/include/llvm/CodeGen/LiveStackAnalysis.h b/include/llvm/CodeGen/LiveStackAnalysis.h index 3d4dbf9370..d63a222475 100644 --- a/include/llvm/CodeGen/LiveStackAnalysis.h +++ b/include/llvm/CodeGen/LiveStackAnalysis.h @@ -102,7 +102,7 @@ namespace llvm { virtual bool runOnMachineFunction(MachineFunction&); /// print - Implement the dump method. - virtual void print(std::ostream &O, const Module* = 0) const; + virtual void print(raw_ostream &O, const Module* = 0) const; }; } diff --git a/include/llvm/CodeGen/MachineDominators.h b/include/llvm/CodeGen/MachineDominators.h index 1439b1bdfe..e56776b144 100644 --- a/include/llvm/CodeGen/MachineDominators.h +++ b/include/llvm/CodeGen/MachineDominators.h @@ -162,7 +162,7 @@ public: virtual void releaseMemory(); - virtual void print(std::ostream &OS, const Module*) const; + virtual void print(raw_ostream &OS, const Module*) const; }; //===------------------------------------- diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 374b933095..a214e4fcdd 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -30,9 +30,7 @@ #define LLVM_PASS_H #include "llvm/Support/DataTypes.h" -#include "llvm/Support/Streams.h" #include <cassert> -#include <iosfwd> #include <utility> #include <vector> @@ -47,6 +45,7 @@ class ImmutablePass; class PMStack; class AnalysisResolver; class PMDataManager; +class raw_ostream; // AnalysisID - Use the PassInfo to identify a pass... typedef const PassInfo* AnalysisID; @@ -103,8 +102,7 @@ public: /// provide the Module* in case the analysis doesn't need it it can just be /// ignored. /// - virtual void print(std::ostream &O, const Module *M) const; - void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); } + virtual void print(raw_ostream &O, const Module *M) const; void dump() const; // dump - Print to stderr. /// Each pass is responsible for assigning a pass manager to itself. @@ -202,9 +200,6 @@ public: AnalysisType &getAnalysisID(const PassInfo *PI, Function &F); }; -inline std::ostream &operator<<(std::ostream &OS, const Pass &P) { - P.print(OS, 0); return OS; -} //===----------------------------------------------------------------------===// /// ModulePass class - This class is used to implement unstructured diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index 3b72b0430f..e9c8c7cb2e 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -223,8 +223,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) { return OS; } -std::ostream &operator<<(std::ostream &OS, const ConstantRange &CR); - } // End llvm namespace #endif diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index a437e2048e..66ce3f2e20 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -66,7 +66,7 @@ public: virtual void passRegistered(const PassInfo *P) { if (ignorablePass(P) || !Opt) return; if (findOption(P->getPassArgument()) != getNumOptions()) { - cerr << "Two passes with the same argument (-" + errs() << "Two passes with the same argument (-" << P->getPassArgument() << ") attempted to be registered!\n"; llvm_unreachable(0); } diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index d9d023cc27..c2252dcb04 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -196,7 +196,6 @@ public: raw_ostream &operator<<(const std::string &Str) { // Avoid the fast path, it would only increase code size for a marginal win. - write(Str.data(), Str.length()); return *this; } @@ -220,6 +219,7 @@ public: this->operator<<(ftostr(N)); return *this; } + /// write_hex - Output \arg N in hexadecimal, without any prefix or padding. raw_ostream &write_hex(unsigned long long N); diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index 2364d984f9..f6ecfc596f 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -26,9 +26,6 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/GraphWriter.h" #include "llvm/Config/config.h" -#include <iosfwd> -#include <sstream> -#include <fstream> using namespace llvm; namespace llvm { @@ -96,7 +93,7 @@ namespace { return false; } - void print(std::ostream &OS, const Module* = 0) const {} + void print(raw_ostream &OS, const Module* = 0) const {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); @@ -118,7 +115,7 @@ namespace { return false; } - void print(std::ostream &OS, const Module* = 0) const {} + void print(raw_ostream &OS, const Module* = 0) const {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); @@ -150,7 +147,7 @@ namespace { return false; } - void print(std::ostream &OS, const Module* = 0) const {} + void print(raw_ostream &OS, const Module* = 0) const {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); @@ -179,7 +176,7 @@ namespace { cerr << "\n"; return false; } - void print(std::ostream &OS, const Module* = 0) const {} + void print(raw_ostream &OS, const Module* = 0) const {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 02b4c9ac6f..966e87c4cb 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -607,7 +607,7 @@ namespace { //===------------------------------------------------------------------===// // Implement Analyize interface // - void print(std::ostream &O, const Module* M) const { + void print(raw_ostream &O, const Module*) const { PrintPointsToGraph(); } }; diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 4d15a48d4e..f03e4b2ba2 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -18,8 +18,7 @@ #include "llvm/IntrinsicInst.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/Streams.h" -#include <ostream> +#include "llvm/Support/raw_ostream.h" using namespace llvm; namespace { @@ -68,30 +67,21 @@ public: AU.setPreservesAll(); } - void print(std::ostream *o, const Module *M) const { - if (o) print(*o, M); - } - - virtual void print(std::ostream &o, const Module *M) const { - o << "CallGraph Root is: "; + virtual void print(raw_ostream &OS, const Module *) const { + OS << "CallGraph Root is: "; if (Function *F = getRoot()->getFunction()) - o << F->getNameStr() << "\n"; - else - o << "<<null function: 0x" << getRoot() << ">>\n"; + OS << F->getName() << "\n"; + else { + OS << "<<null function: 0x" << getRoot() << ">>\n"; + } - CallGraph::print(o, M); + CallGraph::print(OS, 0); } virtual void releaseMemory() { destroy(); } - /// dump - Print out this call graph. - /// - inline void dump() const { - print(cerr, Mod); - } - CallGraphNode* getExternalCallingNode() const { return ExternalCallingNode; } CallGraphNode* getCallsExternalNode() const { return CallsExternalNode; } @@ -187,15 +177,11 @@ void CallGraph::destroy() { } } -void CallGraph::print(std::ostream &OS, const Module *M) const { +void CallGraph::print(raw_ostream &OS, Module*) const { for (CallGraph::const_iterator I = begin(), E = end(); I != E; ++I) I->second->print(OS); } -void CallGraph::dump() const { - print(cerr, 0); -} - //===----------------------------------------------------------------------===// // Implementations of public modification methods // @@ -242,21 +228,21 @@ CallGraphNode *CallGraph::getOrInsertFunction(const Function *F) { return CGN = new CallGraphNode(const_cast<Function*>(F)); } -void CallGraphNode::print(std::ostream &OS) const { +void CallGraphNode::print(raw_ostream &OS) const { if (Function *F = getFunction()) - OS << "Call graph node for function: '" << F->getNameStr() <<"'\n"; + OS << "Call graph node for function: '" << F->getName() <<"'\n"; else OS << "Call graph node <<null function: 0x" << this << ">>:\n"; for (const_iterator I = begin(), E = end(); I != E; ++I) if (Function *FI = I->second->getFunction()) - OS << " Calls function '" << FI->getNameStr() <<"'\n"; + OS << " Calls function '" << FI->getName() <<"'\n"; else OS << " Calls external node\n"; OS << "\n"; } -void CallGraphNode::dump() const { print(cerr); } +void CallGraphNode::dump() const { print(errs()); } /// removeCallEdgeFor - This method removes the edge in the node for the /// specified call site. Note that this method takes linear time, so it diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index df2f0f8bd6..00eddc4de8 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -20,6 +20,7 @@ #include "llvm/ADT/SCCIterator.h" #include "llvm/PassManagers.h" #include "llvm/Function.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -56,7 +57,7 @@ public: // Print passes managed by this manager void dumpPassStructure(unsigned Offset) { - llvm::cerr << std::string(Offset*2, ' ') << "Call Graph SCC Pass Manager\n"; + errs().indent(Offset*2) << "Call Graph SCC Pass Manager\n"; for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { Pass *P = getContainedPass(Index); P->dumpPassStructure(Offset + 1); @@ -65,9 +66,8 @@ public: } Pass *getContainedPass(unsigned N) { - assert ( N < PassVector.size() && "Pass number out of range!"); - Pass *FP = static_cast<Pass *>(PassVector[N]); - return FP; + assert(N < PassVector.size() && "Pass number out of range!"); + return static_cast<Pass *>(PassVector[N]); } virtual PassManagerType getPassManagerType() const { diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 920ee37455..c4fb0b9a4e 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -92,13 +92,12 @@ bool FindUsedTypes::runOnModule(Module &m) { // passed in, then the types are printed symbolically if possible, using the // symbol table from the module. // -void FindUsedTypes::print(std::ostream &OS, const Module *M) const { - raw_os_ostream RO(OS); - RO << "Types in use by this module:\n"; +void FindUsedTypes::print(raw_ostream &OS, const Module *M) const { + OS << "Types in use by this module:\n"; for (std::set<const Type *>::const_iterator I = UsedTypes.begin(), E = UsedTypes.end(); I != E; ++I) { - RO << " "; - WriteTypeSymbolic(RO, *I, M); - RO << '\n'; + OS << " "; + WriteTypeSymbolic(OS, *I, M); + OS << '\n'; } } diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index b0db671724..83724caf52 100644 --- a/lib/Analysis/InstCount.cpp +++ b/lib/Analysis/InstCount.cpp @@ -59,7 +59,7 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } - virtual void print(std::ostream &O, const Module *M) const {} + virtual void print(raw_ostream &O, const Module *M) const {} }; } diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp index 6a6b1b2048..ca9cdcaf24 100644 --- a/lib/Analysis/Interval.cpp +++ b/lib/Analysis/Interval.cpp @@ -37,8 +37,7 @@ bool Interval::isLoop() const { } -void Interval::print(std::ostream &O) const { - raw_os_ostream OS(O); +void Interval::print(raw_ostream &OS) const { OS << "-------------------------------------------------------------\n" << "Interval Contents:\n"; diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index cb8a85da55..1f17b77a5b 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -32,7 +32,7 @@ void IntervalPartition::releaseMemory() { RootInterval = 0; } -void IntervalPartition::print(std::ostream &O, const Module*) const { +void IntervalPartition::print(raw_ostream &O, const Module*) const { for(unsigned i = 0, e = Intervals.size(); i != e; ++i) Intervals[i]->print(O); } diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 75d89af2a5..5939dea4c0 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -309,8 +309,7 @@ void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<DominatorTree>(); } -void LoopInfo::print(std::ostream &OS, const Module*) const { - raw_os_ostream OSS(OS); - LI.print(OSS); +void LoopInfo::print(raw_ostream &OS, const Module*) const { |