llvm.org GIT mirror llvm / 45cfe54
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 Chris Lattner 10 years ago
50 changed file(s) with 142 addition(s) and 195 deletion(s). Raw diff Collapse all Expand all
154154 ///
155155 void initialize(Module &M);
156156
157 virtual void print(std::ostream &o, const Module *M) const;
158 void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
159 void dump() const;
157 void print(raw_ostream &o, Module *) const;
160158
161159 protected:
162160 // destroy - Release memory for the call graph
201199 /// dump - Print out this call graph node.
202200 ///
203201 void dump() const;
204 void print(std::ostream &OS) const;
205 void print(std::ostream *OS) const { if (OS) print(*OS); }
202 void print(raw_ostream &OS) const;
206203
207204 //===---------------------------------------------------------------------
208205 // Methods to keep a call graph up to date with a function that has been
2121 #define LLVM_ANALYSIS_DOMINATORS_H
2222
2323 #include "llvm/Pass.h"
24 #include "llvm/BasicBlock.h"
2524 #include "llvm/Function.h"
2625 #include "llvm/Instructions.h"
2726 #include "llvm/ADT/DenseMap.h"
829828 DT->releaseMemory();
830829 }
831830
832 virtual void print(std::ostream &OS, const Module* M= 0) const;
831 virtual void print(raw_ostream &OS, const Module* M= 0) const;
833832 };
834833
835834 //===-------------------------------------
977976
978977 /// print - Convert to human readable form
979978 ///
980 virtual void print(std::ostream &OS, const Module* = 0) const;
979 virtual void print(raw_ostream &OS, const Module* = 0) const;
981980 };
982981
983982
3636 /// passed in, then the types are printed symbolically if possible, using the
3737 /// symbol table from the module.
3838 ///
39 void print(std::ostream &o, const Module *M) const;
40 void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
39 void print(raw_ostream &o, const Module *M) const;
4140
4241 private:
4342 /// IncorporateType - Incorporate one type and all of its subtypes into the
2121
2222 #include "llvm/ADT/GraphTraits.h"
2323 #include
24 #include
2524
2625 namespace llvm {
2726
2827 class BasicBlock;
28 class raw_ostream;
2929
3030 //===----------------------------------------------------------------------===//
3131 //
9797 bool isLoop() const;
9898
9999 /// print - Show contents in human readable format...
100 void print(std::ostream &O) const;
101 void print(std::ostream *O) const { if (O) print(*O); }
100 void print(raw_ostream &O) const;
102101 };
103102
104103 /// succ_begin/succ_end - define methods so that Intervals may be used
5959 IntervalPartition(IntervalPartition &I, bool);
6060
6161 // print - Show contents in human readable format...
62 virtual void print(std::ostream &O, const Module* = 0) const;
63 void print(std::ostream *O, const Module* M = 0) const {
64 if (O) print(*O, M);
65 }
62 virtual void print(raw_ostream &O, const Module* = 0) const;
6663
6764 // getRootInterval() - Return the root interval that contains the starting
6865 // block of the function.
937937
938938 virtual void releaseMemory() { LI.releaseMemory(); }
939939
940 virtual void print(std::ostream &O, const Module* M = 0) const;
940 virtual void print(raw_ostream &O, const Module* M = 0) const;
941941
942942 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
943943
1616 #include "llvm/Pass.h"
1717 #include "llvm/Analysis/ScalarEvolution.h"
1818 #include "llvm/Support/ConstantRange.h"
19 #include
2019 #include
2120
2221 namespace llvm {
3231 LoopVR() : FunctionPass(&ID) {}
3332
3433 bool runOnFunction(Function &F);
35 virtual void print(std::ostream &os, const Module *) const;
34 virtual void print(raw_ostream &os, const Module *) const;
3635 void releaseMemory();
3736
3837 void getAnalysisUsage(AnalysisUsage &AU) const;
5656 return DT->properlyDominates(A, B);
5757 }
5858
59 virtual void print(std::ostream &OS, const Module*) const;
59 virtual void print(raw_ostream &OS, const Module*) const;
6060 };
6161
6262 FunctionPass* createPostDomTree();
600600 virtual bool runOnFunction(Function &F);
601601 virtual void releaseMemory();
602602 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
603 void print(raw_ostream &OS, const Module* = 0) const;
604 virtual void print(std::ostream &OS, const Module* = 0) const;
605 void print(std::ostream *OS, const Module* M = 0) const {
606 if (OS) print(*OS, M);
607 }
603 virtual void print(raw_ostream &OS, const Module* = 0) const;
608604
609605 private:
610606 FoldingSet UniqueSCEVs;
346346 virtual bool runOnMachineFunction(MachineFunction&);
347347
348348 /// print - Implement the dump method.
349 virtual void print(std::ostream &O, const Module* = 0) const;
349 virtual void print(raw_ostream &O, const Module* = 0) const;
350350
351351 /// addIntervalsForSpills - Create new intervals for spilled defs / uses of
352352 /// the given interval. FIXME: It also returns the weight of the spill slot
101101 virtual bool runOnMachineFunction(MachineFunction&);
102102
103103 /// print - Implement the dump method.
104 virtual void print(std::ostream &O, const Module* = 0) const;
104 virtual void print(raw_ostream &O, const Module* = 0) const;
105105 };
106106 }
107107
161161
162162 virtual void releaseMemory();
163163
164 virtual void print(std::ostream &OS, const Module*) const;
164 virtual void print(raw_ostream &OS, const Module*) const;
165165 };
166166
167167 //===-------------------------------------
2929 #define LLVM_PASS_H
3030
3131 #include "llvm/Support/DataTypes.h"
32 #include "llvm/Support/Streams.h"
3332 #include
34 #include
3533 #include
3634 #include
3735
4644 class PMStack;
4745 class AnalysisResolver;
4846 class PMDataManager;
47 class raw_ostream;
4948
5049 // AnalysisID - Use the PassInfo to identify a pass...
5150 typedef const PassInfo* AnalysisID;
102101 /// provide the Module* in case the analysis doesn't need it it can just be
103102 /// ignored.
104103 ///
105 virtual void print(std::ostream &O, const Module *M) const;
106 void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); }
104 virtual void print(raw_ostream &O, const Module *M) const;
107105 void dump() const; // dump - Print to stderr.
108106
109107 /// Each pass is responsible for assigning a pass manager to itself.
201199 AnalysisType &getAnalysisID(const PassInfo *PI, Function &F);
202200 };
203201
204 inline std::ostream &operator<<(std::ostream &OS, const Pass &P) {
205 P.print(OS, 0); return OS;
206 }
207202
208203 //===----------------------------------------------------------------------===//
209204 /// ModulePass class - This class is used to implement unstructured
222222 return OS;
223223 }
224224
225 std::ostream &operator<<(std::ostream &OS, const ConstantRange &CR);
226
227225 } // End llvm namespace
228226
229227 #endif
6565 virtual void passRegistered(const PassInfo *P) {
6666 if (ignorablePass(P) || !Opt) return;
6767 if (findOption(P->getPassArgument()) != getNumOptions()) {
68 cerr << "Two passes with the same argument (-"
68 errs() << "Two passes with the same argument (-"
6969 << P->getPassArgument() << ") attempted to be registered!\n";
7070 llvm_unreachable(0);
7171 }
195195
196196 raw_ostream &operator<<(const std::string &Str) {
197197 // Avoid the fast path, it would only increase code size for a marginal win.
198
199198 write(Str.data(), Str.length());
200199 return *this;
201200 }
219218 this->operator<<(ftostr(N));
220219 return *this;
221220 }
221
222222
223223 /// write_hex - Output \arg N in hexadecimal, without any prefix or padding.
224224 raw_ostream &write_hex(unsigned long long N);
2525 #include "llvm/Support/Compiler.h"
2626 #include "llvm/Support/GraphWriter.h"
2727 #include "llvm/Config/config.h"
28 #include
29 #include
30 #include
3128 using namespace llvm;
3229
3330 namespace llvm {
9592 return false;
9693 }
9794
98 void print(std::ostream &OS, const Module* = 0) const {}
95 void print(raw_ostream &OS, const Module* = 0) const {}
9996
10097 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
10198 AU.setPreservesAll();
117114 return false;
118115 }
119116
120 void print(std::ostream &OS, const Module* = 0) const {}
117 void print(raw_ostream &OS, const Module* = 0) const {}
121118
122119 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
123120 AU.setPreservesAll();
149146 return false;
150147 }
151148
152 void print(std::ostream &OS, const Module* = 0) const {}
149 void print(raw_ostream &OS, const Module* = 0) const {}
153150
154151 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
155152 AU.setPreservesAll();
178175 cerr << "\n";
179176 return false;
180177 }
181 void print(std::ostream &OS, const Module* = 0) const {}
178 void print(raw_ostream &OS, const Module* = 0) const {}
182179
183180 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
184181 AU.setPreservesAll();
606606 //===------------------------------------------------------------------===//
607607 // Implement Analyize interface
608608 //
609 void print(std::ostream &O, const Module* M) const {
609 void print(raw_ostream &O, const Module*) const {
610610 PrintPointsToGraph();
611611 }
612612 };
1717 #include "llvm/IntrinsicInst.h"
1818 #include "llvm/Support/CallSite.h"
1919 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/Streams.h"
21 #include
20 #include "llvm/Support/raw_ostream.h"
2221 using namespace llvm;
2322
2423 namespace {
6766 AU.setPreservesAll();
6867 }
6968
70 void print(std::ostream *o, const Module *M) const {
71 if (o) print(*o, M);
72 }
73
74 virtual void print(std::ostream &o, const Module *M) const {
75 o << "CallGraph Root is: ";
69 virtual void print(raw_ostream &OS, const Module *) const {
70 OS << "CallGraph Root is: ";
7671 if (Function *F = getRoot()->getFunction())
77 o << F->getNameStr() << "\n";
78 else
79 o << "<>\n";
72 OS << F->getName() << "\n";
73 else {
74 OS << "<>\n";
75 }
8076
81 CallGraph::print(o, M);
77 CallGraph::print(OS, 0);
8278 }
8379
8480 virtual void releaseMemory() {
8581 destroy();
8682 }
8783
88 /// dump - Print out this call graph.
89 ///
90 inline void dump() const {
91 print(cerr, Mod);
92 }
93
9484 CallGraphNode* getExternalCallingNode() const { return ExternalCallingNode; }
9585 CallGraphNode* getCallsExternalNode() const { return CallsExternalNode; }
9686
186176 }
187177 }
188178
189 void CallGraph::print(std::ostream &OS, const Module *M) const {
179 void CallGraph::print(raw_ostream &OS, Module*) const {
190180 for (CallGraph::const_iterator I = begin(), E = end(); I != E; ++I)
191181 I->second->print(OS);
192 }
193
194 void CallGraph::dump() const {
195 print(cerr, 0);
196182 }
197183
198184 //===----------------------------------------------------------------------===//
241227 return CGN = new CallGraphNode(const_cast(F));
242228 }
243229
244 void CallGraphNode::print(std::ostream &OS) const {
230 void CallGraphNode::print(raw_ostream &OS) const {
245231 if (Function *F = getFunction())
246 OS << "Call graph node for function: '" << F->getNameStr() <<"'\n";
232 OS << "Call graph node for function: '" << F->getName() <<"'\n";
247233 else
248234 OS << "Call graph node <>:\n";
249235
250236 for (const_iterator I = begin(), E = end(); I != E; ++I)
251237 if (Function *FI = I->second->getFunction())
252 OS << " Calls function '" << FI->getNameStr() <<"'\n";
238 OS << " Calls function '" << FI->getName() <<"'\n";
253239 else
254240 OS << " Calls external node\n";
255241 OS << "\n";
256242 }
257243
258 void CallGraphNode::dump() const { print(cerr); }
244 void CallGraphNode::dump() const { print(errs()); }
259245
260246 /// removeCallEdgeFor - This method removes the edge in the node for the
261247 /// specified call site. Note that this method takes linear time, so it
1919 #include "llvm/ADT/SCCIterator.h"
2020 #include "llvm/PassManagers.h"
2121 #include "llvm/Function.h"
22 #include "llvm/Support/raw_ostream.h"
2223 using namespace llvm;
2324
2425 //===----------------------------------------------------------------------===//
5556
5657 // Print passes managed by this manager
5758 void dumpPassStructure(unsigned Offset) {
58 llvm::cerr << std::string(Offset*2, ' ') << "Call Graph SCC Pass Manager\n";
59 errs().indent(Offset*2) << "Call Graph SCC Pass Manager\n";
5960 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
6061 Pass *P = getContainedPass(Index);
6162 P->dumpPassStructure(Offset + 1);
6465 }
6566
6667 Pass *getContainedPass(unsigned N) {
67 assert ( N < PassVector.size() && "Pass number out of range!");
68 Pass *FP = static_cast(PassVector[N]);
69 return FP;
68 assert(N < PassVector.size() && "Pass number out of range!");
69 return static_cast(PassVector[N]);
7070 }
7171
7272 virtual PassManagerType getPassManagerType() const {
9191 // passed in, then the types are printed symbolically if possible, using the
9292 // symbol table from the module.
9393 //
94 void FindUsedTypes::print(std::ostream &OS, const Module *M) const {
95 raw_os_ostream RO(OS);
96 RO << "Types in use by this module:\n";
94 void FindUsedTypes::print(raw_ostream &OS, const Module *M) const {
95 OS << "Types in use by this module:\n";
9796 for (std::set::const_iterator I = UsedTypes.begin(),
9897 E = UsedTypes.end(); I != E; ++I) {
99 RO << " ";
100 WriteTypeSymbolic(RO, *I, M);
101 RO << '\n';
98 OS << " ";
99 WriteTypeSymbolic(OS, *I, M);
100 OS << '\n';
102101 }
103102 }
5858 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
5959 AU.setPreservesAll();
6060 }
61 virtual void print(std::ostream &O, const Module *M) const {}
61 virtual void print(raw_ostream &O, const Module *M) const {}
6262
6363 };
6464 }
3636 }
3737
3838
39 void Interval::print(std::ostream &O) const {
40 raw_os_ostream OS(O);
39 void Interval::print(raw_ostream &OS) const {
4140 OS << "-------------------------------------------------------------\n"
4241 << "Interval Contents:\n";
4342
3131 RootInterval = 0;
3232 }
3333
34 void IntervalPartition::print(std::ostream &O, const Module*) const {
34 void IntervalPartition::print(raw_ostream &O, const Module*) const {
3535 for(unsigned i = 0, e = Intervals.size(); i != e; ++i)
3636 Intervals[i]->print(O);
3737 }
308308 AU.addRequired();
309309 }
310310
311 void LoopInfo::print(std::ostream &OS, const Module*) const {
312 raw_os_ostream OSS(OS);
313 LI.print(OSS);
314 }
315
311 void LoopInfo::print(raw_ostream &OS, const Module*) const {
312 LI.print(OS);
313 }
314
227227
228228 bool LoopVR::runOnFunction(Function &F) { Map.clear(); return false; }
229229
230 void LoopVR::print(std::ostream &os, const Module *) const {
231 raw_os_ostream OS(os);
230 void LoopVR::print(raw_ostream &OS, const Module *) const {
232231 for (std::map::const_iterator I = Map.begin(),
233232 E = Map.end(); I != E; ++I) {
234233 OS << *I->first << ": " << *I->second << '\n';
4040 delete DT;
4141 }
4242
43 void PostDominatorTree::print(std::ostream &OS, const Module *) const {
44 raw_os_ostream OSS(OS);
45 DT->print(OSS);
43 void PostDominatorTree::print(raw_ostream &OS, const Module *) const {
44 DT->print(OS);
4645 }
4746
4847
51925192 PrintLoopInfo(OS, &SE, *I);
51935193 }
51945194
5195 void ScalarEvolution::print(std::ostream &o, const Module *M) const {
5196 raw_os_ostream OS(o);
5197 print(OS, M);
5198 }
9292 }
9393 }
9494
95 cerr << "unsupported GC: " << Name << "\n";
95 errs() << "unsupported GC: " << Name << "\n";
9696 llvm_unreachable(0);
9797 }
9898
2828 #include "llvm/Target/TargetRegisterInfo.h"
2929 #include "llvm/Support/Compiler.h"
3030 #include "llvm/Support/ErrorHandling.h"
31 #include "llvm/Support/raw_ostream.h"
3132
3233 using namespace llvm;
3334
107108 bool GCStrategy::initializeCustomLowering(Module &M) { return false; }
108109
109110 bool GCStrategy::performCustomLowering(Function &F) {
110 cerr << "gc " << getName() << " must override performCustomLowering.\n";
111 errs() << "gc " << getName() << " must override performCustomLowering.\n";
111112 llvm_unreachable(0);
112113 return 0;
113114 }
1515 #include "llvm/Module.h"
1616 #include "llvm/Type.h"
1717 #include "llvm/CodeGen/IntrinsicLowering.h"
18 #include "llvm/Support/ErrorHandling.h"
1819 #include "llvm/Support/IRBuilder.h"
19 #include "llvm/Support/ErrorHandling.h"
20 #include "llvm/Support/raw_ostream.h"
2021 #include "llvm/Target/TargetData.h"
2122 #include "llvm/ADT/SmallVector.h"
2223 using namespace llvm;
395396 case Intrinsic::stacksave:
396397 case Intrinsic::stackrestore: {
397398 if (!Warned)
398 cerr << "WARNING: this target does not support the llvm.stack"
399 << (Callee->getIntrinsicID() == Intrinsic::stacksave ?
399 errs() << "WARNING: this target does not support the llvm.stack"
400 << (Callee->getIntrinsicID() == Intrinsic::stacksave ?
400401 "save" : "restore") << " intrinsic.\n";
401402 Warned = true;
402403 if (Callee->getIntrinsicID() == Intrinsic::stacksave)
406407
407408 case Intrinsic::returnaddress:
408409 case Intrinsic::frameaddress:
409 cerr << "WARNING: this target does not support the llvm."
410 << (Callee->getIntrinsicID() == Intrinsic::returnaddress ?
410 errs() << "WARNING: this target does not support the llvm."
411 << (Callee->getIntrinsicID() == Intrinsic::returnaddress ?
411412 "return" : "frame") << "address intrinsic.\n";
412413 CI->replaceAllUsesWith(ConstantPointerNull::get(
413414 cast(CI->getType())));
419420 case Intrinsic::pcmarker:
420421 break; // Simply strip out pcmarker on unsupported architectures
421422 case Intrinsic::readcyclecounter: {
422 cerr << "WARNING: this target does not support the llvm.readcyclecoun"
423 << "ter intrinsic. It is being lowered to a constant 0\n";
423 errs() << "WARNING: this target does not support the llvm.readcyclecoun"
424 << "ter intrinsic. It is being lowered to a constant 0\n";
424425 CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0));
425426 break;
426427 }
515515 }
516516
517517 /// print - Implement the dump method.
518 void LiveIntervals::print(std::ostream &O, const Module* ) const {
519 raw_os_ostream OS(O);
518 void LiveIntervals::print(raw_ostream &OS, const Module* ) const {
520519 OS << "********** INTERVALS **********\n";
521520 for (const_iterator I = begin(), E = end(); I != E; ++I) {
522521 I->second->print(OS, tri_);
5252 }
5353
5454 /// print - Implement the dump method.
55 void LiveStacks::print(std::ostream &O, const Module*) const {
56 raw_os_ostream OS(O);
55 void LiveStacks::print(raw_ostream &OS, const Module*) const {
5756
5857 OS << "********** INTERVALS **********\n";
5958 for (const_iterator I = begin(), E = end(); I != E; ++I) {
5151 DT->releaseMemory();
5252 }
5353
54 void MachineDominatorTree::print(std::ostream &OS, const Module*) const {
55 raw_os_ostream OSS(OS);
56 DT->print(OSS);
54 void MachineDominatorTree::print(raw_ostream &OS, const Module*) const {
55 DT->print(OS);
5756 }
120120 }
121121
122122 /// print - Implement the dump method.
123 virtual void print(std::ostream &O, const Module* M = 0) const {
123 virtual void print(raw_ostream &O, const Module* M = 0) const {
124124 LIs->print(O, M);
125125 }
126126
127 void print(std::ostream *O, const Module* M = 0) const {
128 if (O) print(*O, M);
129 }
130127
131128 private:
132129 MachineBasicBlock::iterator
6868 ISD::ArgFlagsTy ArgFlags = Ins[i].Flags;
6969 if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
7070 #ifndef NDEBUG
71 cerr << "Formal argument #" << i << " has unhandled type "
72 << ArgVT.getEVTString();
71 errs() << "Formal argument #" << i << " has unhandled type "
72 << ArgVT.getEVTString();
7373 #endif
7474 llvm_unreachable(0);
7575 }
8686 ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
8787 if (Fn(i, VT, VT, CCValAssign::Full, ArgFlags, *this)) {
8888 #ifndef NDEBUG
89 cerr << "Return operand #" << i << " has unhandled type "
90 << VT.getEVTString();
89 errs() << "Return operand #" << i << " has unhandled type "
90 << VT.getEVTString();
9191 #endif
9292 llvm_unreachable(0);
9393 }
105105 ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
106106 if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
107107 #ifndef NDEBUG
108 cerr << "Call operand #" << i << " has unhandled type "
109 << ArgVT.getEVTString();
108 errs() << "Call operand #" << i << " has unhandled type "
109 << ArgVT.getEVTString();
110110 #endif
111111 llvm_unreachable(0);
112112 }
124124 ISD::ArgFlagsTy ArgFlags = Flags[i];
125125 if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
126126 #ifndef NDEBUG
127 cerr << "Call operand #" << i << " has unhandled type "
128 << ArgVT.getEVTString();
127 errs() << "Call operand #" << i << " has unhandled type "
128 << ArgVT.getEVTString();
129129 #endif
130130 llvm_unreachable(0);
131131 }
141141 ISD::ArgFlagsTy Flags = Ins[i].Flags;
142142 if (Fn(i, VT, VT, CCValAssign::Full, Flags, *this)) {
143143 #ifndef NDEBUG
144 cerr << "Call result #" << i << " has unhandled type "
145 << VT.getEVTString();
144 errs() << "Call result #" << i << " has unhandled type "
145 << VT.getEVTString();
146146 #endif
147147 llvm_unreachable(0);
148148 }
154154 void CCState::AnalyzeCallResult(EVT VT, CCAssignFn Fn) {
155155 if (Fn(0, VT, VT, CCValAssign::Full, ISD::ArgFlagsTy(), *this)) {
156156 #ifndef NDEBUG
157 cerr << "Call result has unhandled type "
158 << VT.getEVTString();
157 errs() << "Call result has unhandled type "
158 << VT.getEVTString();
159159 #endif
160160 llvm_unreachable(0);
161161 }
3434 #include "llvm/Support/Compiler.h"
3535 #include "llvm/Support/ErrorHandling.h"
3636 #include "llvm/Support/MathExtras.h"
37 #include "llvm/Support/raw_ostream.h"
3738 #include "llvm/ADT/DenseMap.h"
3839 #include "llvm/ADT/SmallVector.h"
3940 #include "llvm/ADT/SmallPtrSet.h"
949950 switch (Node->getOpcode()) {
950951 default:
951952 #ifndef NDEBUG
952 cerr << "NODE: "; Node->dump(&DAG); cerr << "\n";
953 errs() << "NODE: ";
954 Node->dump(&DAG);
955 errs() << "\n";
953956 #endif
954957 llvm_unreachable("Do not know how to legalize this operator!");
955958
658658 if (!Erased && N->getValueType(N->getNumValues()-1) != MVT::Flag &&
659659 !N->isMachineOpcode() && !doNotCSE(N)) {
660660 N->dump(this);
661 cerr << "\n";
661 errs() << "\n";
662662 llvm_unreachable("Node is not in map!");
663663 }
664664 #endif
56435643 if (N->getOperand(i).getNode()->hasOneUse())
56445644 DumpNodes(N->getOperand(i).getNode(), indent+2, G);
56455645 else
5646 cerr << "\n" << std::string(indent+2, ' ')
5647 << (void*)N->getOperand(i).getNode() << ": ";
5648
5649
5650 cerr << "\n" << std::string(indent, ' ');
5646 errs() << "\n" << std::string(indent+2, ' ')
5647 << (void*)N->getOperand(i).getNode() << ": ";
5648
5649
5650 errs() << "\n";
5651 errs().indent(indent);
56515652 N->dump(G);
56525653 }
56535654
56545655 void SelectionDAG::dump() const {
5655 cerr << "SelectionDAG has " << AllNodes.size() << " nodes:";
5656 errs() << "SelectionDAG has " << AllNodes.size() << " nodes:";
56565657
56575658 for (allnodes_const_iterator I = allnodes_begin(), E = allnodes_end();
56585659 I != E; ++I) {
56635664
56645665 if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this);
56655666
5666 cerr << "\n\n";
5667 errs() << "\n\n";
56675668 }
56685669
56695670 void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const {
27912791 }
27922792
27932793 /// print - Implement the dump method.
2794 void SimpleRegisterCoalescing::print(std::ostream &O, const Module* m) const {
2794 void SimpleRegisterCoalescing::print(raw_ostream &O, const Module* m) const {
27952795 li_->print(O, m);
27962796 }
27972797
136136 }
137137
138138 /// print - Implement the dump method.
139 virtual void print(std::ostream &O, const Module* = 0) const;
140 void print(std::ostream *O, const Module* M = 0) const {
141 if (O) print(*O, M);
142 }
139 virtual void print(raw_ostream &O, const Module* = 0) const;
143140
144141 private:
145142 /// joinIntervals - join compatible live intervals
596596 print(errs());
597597 }
598598
599 std::ostream &llvm::operator<<(std::ostream &o,
600 const ConstantRange &CR) {
601 raw_os_ostream OS(o);
602 OS << CR;
603 return o;
604 }
599
26342634
26352635 if (Result) {
26362636 #ifndef NDEBUG
2637 cerr << "Call operand #" << i << " has unhandled type "
2637 errs() << "Call operand #" << i << " has unhandled type "
26382638 << ArgVT.getEVTString() << "\n";
26392639 #endif
26402640 llvm_unreachable(0);
5454
5555 void ExtAddrMode::dump() const {
5656 print(errs());
57 cerr << '\n';
57 errs() << '\n';
5858 }
5959
6060
4747 return false;
4848 }
4949
50 void DominatorTree::print(std::ostream &OS, const Module *) const {
51 raw_os_ostream OSS(OS);
52 DT->print(OSS);
50 void DominatorTree::print(raw_ostream &OS, const Module *) const {
51 DT->print(OS);
5352 }
5453
5554
263262 return *Result;
264263 }
265264
266 void DominanceFrontierBase::print(std::ostream &O, const Module* ) const {
267 raw_os_ostream OS(O);
265 void DominanceFrontierBase::print(raw_ostream &OS, const Module* ) const {
268266 for (const_iterator I = begin(), E = end(); I != E; ++I) {
269267 OS << " DomFrontier for BB";
270268 if (I->first)
1818 #include "llvm/ModuleProvider.h"
1919 #include "llvm/ADT/STLExtras.h"
2020 #include "llvm/Support/ManagedStatic.h"
21 #include "llvm/Support/raw_ostream.h"
2122 #include "llvm/System/Atomic.h"
2223 #include "llvm/System/Mutex.h"
2324 #include "llvm/System/Threading.h"
4445
4546 // dumpPassStructure - Implement the -debug-passes=Structure option
4647 void Pass::dumpPassStructure(unsigned Offset) {
47 cerr << std::string(Offset*2, ' ') << getPassName() << "\n";
48 errs().indent(Offset*2) << getPassName() << "\n";
4849 }
4950
5051 /// getPassName - Return a nice clean name for a pass. This usually
6162 // to print out the contents of an analysis. Otherwise it is not necessary to
6263 // implement this method.
6364 //
64 void Pass::print(std::ostream &O,const Module*) const {
65 void Pass::print(raw_ostream &O,const Module*) const {
6566 O << "Pass::print not implemented for pass: '" << getPassName() << "'!\n";
6667 }
6768
6869 // dump - call print(cerr);
6970 void Pass::dump() const {
70 print(*cerr.stream(), 0);
71 print(errs(), 0);
7172 }
7273
7374 //===----------------------------------------------------------------------===//
3333 static char ID; // Pass ID, replacement for typeid
3434 ExternalFunctionsPassedConstants() : ModulePass(&ID) {}
3535 virtual bool runOnModule(Module &M) {
36 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
37 if (I->isDeclaration()) {
38 bool PrintedFn = false;
39 for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
40 UI != E; ++UI)
41 if (Instruction *User = dyn_cast(*UI)) {
42 CallSite CS = CallSite::get(User);
43 if (CS.getInstruction()) {
44 for (CallSite::arg_iterator AI = CS.arg_begin(),
45 E = CS.arg_end(); AI != E; ++AI)
46 if (isa(*AI)) {
47 if (!PrintedFn) {
48 errs() << "Function '" << I->getName() << "':\n";
49 PrintedFn = true;
50 }
51 errs() << *User;
52 break;
53 }
54 }
36 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
37 if (!I->isDeclaration()) continue;
38
39 bool PrintedFn = false;
40 for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
41 UI != E; ++UI) {
42 Instruction *User = dyn_cast(*UI);
43 if (!User) continue;
44
45 CallSite CS = CallSite::get(User);
46 if (!CS.getInstruction()) continue;
47
48 for (CallSite::arg_iterator AI = CS.arg_begin(),
49 E = CS.arg_end(); AI != E; ++AI) {
50 if (!isa(*AI)) continue;
51
52 if (!PrintedFn) {
53 errs() << "Function '" << I->getName() << "':\n";
54 PrintedFn = true;
5555 }
56 errs() << *User;
57 break;
58 }
5659 }
60 }
5761
5862 return false;
5963 }
7781 AU.addRequiredTransitive();
7882 }
7983 virtual bool runOnModule(Module &M) {
80 getAnalysis().print(std::cerr, &M);
84 getAnalysis().print(errs(), &M);
8185 return false;
8286 }
8387 };
6969 return false;
7070 }
7171
72 void print(std::ostream &OS) const {}
73 void print(std::ostream &OS, const llvm::Module*) const {}
72 void print(raw_ostream &OS, const llvm::Module*) const {}
7473
7574 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
7675 AU.addRequired();
3838 CFGSCC() : FunctionPass(&ID) {}
3939 bool runOnFunction(Function& func);
4040
41 void print(std::ostream &O, const Module* = 0) const { }
41 void print(raw_ostream &O, const Module* = 0) const { }
4242
4343 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
4444 AU.setPreservesAll();
5252 // run - Print out SCCs in the call graph for the specified module.
5353 bool runOnModule(Module &M);
5454
55 void print(std::ostream &O, const Module* = 0) const { }
55 void print(raw_ostream &O, const Module* = 0) const { }
5656
5757 // getAnalysisUsage - This pass requires the CallGraph.
5858 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
139139 Function *F = SCC[i]->getFunction();
140140 if (F) {
141141 outs().flush();
142 getAnalysisID(PassToPrint).print(cout, F->getParent());
142 getAnalysisID(PassToPrint).print(outs(), F->getParent());
143143 cout << std::flush;
144144 }
145145 }
168168 if (!Quiet) {
169169 outs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
170170 outs().flush();
171 getAnalysisID(PassToPrint).print(cout, &M);
171 getAnalysisID(PassToPrint).print(outs(), &M);
172172 cout << std::flush;
173173 }
174174
198198 }
199199 // Get and print pass...
200200 outs().flush();
201 getAnalysisID(PassToPrint).print(cout, F.getParent());
201 getAnalysisID(PassToPrint).print(outs(), F.getParent());
202202 cout << std::flush;
203203 return false;
204204 }
223223 if (!Quiet) {
224224 outs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
225225 outs().flush();
226 getAnalysisID(PassToPrint).print(cout,
226 getAnalysisID(PassToPrint).print(outs(),
227227 L->getHeader()->getParent()->getParent());
228228 cout << std::flush;
229229 }
255255
256256 // Get and print pass...
257257 outs().flush();
258 getAnalysisID(PassToPrint).print(cout, BB.getParent()->getParent());
258 getAnalysisID(PassToPrint).print(outs(), BB.getParent()->getParent());
259259 cout << std::flush;
260260 return false;
261261 }
20702070 << "}\n\n";
20712071
20722072 OS << "void CannotYetSelectIntrinsic(SDValue N) DISABLE_INLINE {\n"
2073 << " cerr << \"Cannot yet select: \";\n"
2073 << " errs() << \"Cannot yet select: \";\n"
20742074 << " unsigned iid = cast(N.getOperand("
20752075 << "N.getOperand(0).getValueType() == MVT::Other))->getZExtValue();\n"
20762076 << " llvm_report_error(\"Cannot yet select: intrinsic %\" +\n"