llvm.org GIT mirror llvm / 944fac7
Switch the asmprinter (.ll) and all the stuff it requires over to use raw_ostream instead of std::ostream. Among other goodness, this speeds up llvm-dis of kc++ with a release build from 0.85s to 0.49s (88% faster). Other interesting changes: 1) This makes Value::print be non-virtual. 2) AP[S]Int and ConstantRange can no longer print to ostream directly, use raw_ostream instead. 3) This fixes a bug in raw_os_ostream where it didn't flush itself when destroyed. 4) This adds a new SDNode::print method, instead of only allowing "dump". A lot of APIs have both std::ostream and raw_ostream versions, it would be useful to go through and systematically anihilate the std::ostream versions. This passes dejagnu, but there may be minor fallout, plz let me know if so and I'll fix it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55263 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
36 changed file(s) with 276 addition(s) and 257 deletion(s). Raw diff Collapse all Expand all
3131 #include "llvm/ExecutionEngine/JIT.h"
3232 #include "llvm/ExecutionEngine/Interpreter.h"
3333 #include "llvm/ExecutionEngine/GenericValue.h"
34 #include
34 #include "llvm/Support/raw_ostream.h"
3535 using namespace llvm;
3636
3737 static Function *CreateFibFunction(Module *M) {
9999 ExistingModuleProvider *MP = new ExistingModuleProvider(M);
100100 ExecutionEngine *EE = ExecutionEngine::create(MP, false);
101101
102 std::cerr << "verifying... ";
102 errs() << "verifying... ";
103103 if (verifyModule(*M)) {
104 std::cerr << argv[0] << ": Error constructing function!\n";
104 errs() << argv[0] << ": Error constructing function!\n";
105105 return 1;
106106 }
107107
108 std::cerr << "OK\n";
109 std::cerr << "We just constructed this LLVM module:\n\n---------\n" << *M;
110 std::cerr << "---------\nstarting fibonacci(" << n << ") with JIT...\n";
108 errs() << "OK\n";
109 errs() << "We just constructed this LLVM module:\n\n---------\n" << *M;
110 errs() << "---------\nstarting fibonacci(" << n << ") with JIT...\n";
111111
112112 // Call the Fibonacci function with argument n:
113113 std::vector Args(1);
115115 GenericValue GV = EE->runFunction(FibF, Args);
116116
117117 // import result of execution
118 std::cout << "Result: " << GV.IntVal << "\n";
118 outs() << "Result: " << GV.IntVal << "\n";
119119 return 0;
120120 }
4141 #include "llvm/ExecutionEngine/JIT.h"
4242 #include "llvm/ExecutionEngine/Interpreter.h"
4343 #include "llvm/ExecutionEngine/GenericValue.h"
44 #include
44 #include "llvm/Support/raw_ostream.h"
4545 using namespace llvm;
4646
4747 int main() {
9898 ExistingModuleProvider* MP = new ExistingModuleProvider(M);
9999 ExecutionEngine* EE = ExecutionEngine::create(MP, false);
100100
101 std::cout << "We just constructed this LLVM module:\n\n" << *M;
102 std::cout << "\n\nRunning foo: " << std::flush;
101 outs() << "We just constructed this LLVM module:\n\n" << *M;
102 outs() << "\n\nRunning foo: ";
103 outs().flush();
103104
104105 // Call the `foo' function with no arguments:
105106 std::vector noargs;
106107 GenericValue gv = EE->runFunction(FooF, noargs);
107108
108109 // Import result of execution:
109 std::cout << "Result: " << gv.IntVal << "\n";
110 outs() << "Result: " << gv.IntVal << "\n";
110111 return 0;
111112 }
1818 #include "llvm/Support/MathExtras.h"
1919 #include
2020 #include
21 #include
2221 #include
2322
2423 namespace llvm {
2524 class Serializer;
2625 class Deserializer;
2726 class FoldingSetNodeID;
27 class raw_ostream;
2828
2929 template
3030 class SmallVectorImpl;
11141114 /// @}
11151115 /// @name Conversion Functions
11161116 /// @{
1117
1118 void print(std::ostream &OS, bool isSigned) const;
1117 void print(raw_ostream &OS, bool isSigned) const;
11191118
11201119 /// toString - Converts an APInt to a string and append it to Str. Str is
11211120 /// commonly a SmallString.
13841383 return V2 != V1;
13851384 }
13861385
1387 inline std::ostream &operator<<(std::ostream &OS, const APInt &I) {
1386 inline raw_ostream &operator<<(raw_ostream &OS, const APInt &I) {
13881387 I.print(OS, true);
13891388 return OS;
13901389 }
238238 void Profile(FoldingSetNodeID& ID) const;
239239 };
240240
241 inline std::ostream &operator<<(std::ostream &OS, const APSInt &I) {
241 inline raw_ostream &operator<<(raw_ostream &OS, const APSInt &I) {
242242 I.print(OS, I.isSigned());
243243 return OS;
244244 }
6464 /// removeAttr - Remove a ParamAttr from an argument
6565 void removeAttr(ParameterAttributes);
6666
67 virtual void print(std::ostream &OS) const;
68 void print(std::ostream *OS) const {
69 if (OS) print(*OS);
70 }
71
7267 /// classof - Methods for support type inquiry through isa, cast, and
7368 /// dyn_cast:
7469 ///
1616 #ifndef LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H
1717 #define LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H
1818
19 #include
20
2119 namespace llvm {
2220
2321 class Function;
2422 class BasicBlock;
2523 class Instruction;
24 class raw_ostream;
2625
2726 struct AssemblyAnnotationWriter {
2827
3029
3130 // emitFunctionAnnot - This may be implemented to emit a string right before
3231 // the start of a function.
33 virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) {}
32 virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {}
3433
3534 // emitBasicBlockStartAnnot - This may be implemented to emit a string right
3635 // after the basic block label, but before the first instruction in the block.
37 virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, std::ostream &OS){
36 virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, raw_ostream &OS){
3837 }
3938
4039 // emitBasicBlockEndAnnot - This may be implemented to emit a string right
4140 // after the basic block.
42 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, std::ostream &OS){
41 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS){
4342 }
4443
4544 // emitInstructionAnnot - This may be implemented to emit a string right
4645 // before an instruction is emitted.
47 virtual void emitInstructionAnnot(const Instruction *I, std::ostream &OS) {}
46 virtual void emitInstructionAnnot(const Instruction *I, raw_ostream &OS) {}
4847 };
4948
5049 } // End llvm namespace
2323 class Type;
2424 class Module;
2525 class Value;
26 class raw_ostream;
2627
2728 // WriteTypeSymbolic - This attempts to write the specified type as a symbolic
2829 // type, iff there is an entry in the Module's symbol table for the specified
2930 // type or one of its component types. This is slower than a simple x << Type;
3031 //
3132 void WriteTypeSymbolic(std::ostream &, const Type *, const Module *M);
33 void WriteTypeSymbolic(raw_ostream &, const Type *, const Module *M);
3234
3335 // WriteAsOperand - Write the name of the specified value out to the specified
3436 // ostream. This can be useful when you just want to print int %reg126, not the
3840 //
3941 void WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true,
4042 const Module *Context = 0);
43 void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy = true,
44 const Module *Context = 0);
4145
4246 } // End llvm namespace
4347
156156 const InstListType &getInstList() const { return InstList; }
157157 InstListType &getInstList() { return InstList; }
158158
159 virtual void print(std::ostream &OS) const { print(OS, 0); }
160 void print(std::ostream *OS) const { if (OS) print(*OS); }
161 void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
162
163159 /// Methods for support type inquiry through isa, cast, and dyn_cast:
164160 static inline bool classof(const BasicBlock *) { return true; }
165161 static inline bool classof(const Value *V) {
2828 class TargetMachine;
2929 class Type;
3030 class MachineConstantPool;
31 class raw_ostream;
3132
3233 /// Abstract base class for all machine specific constantpool value subclasses.
3334 ///
4950
5051 /// print - Implement operator<<...
5152 ///
52 virtual void print(std::ostream &O) const = 0;
53 void print(std::ostream &O) const;
5354 void print(std::ostream *O) const { if (O) print(*O); }
55 virtual void print(raw_ostream &O) const = 0;
5456 };
5557
5658 inline std::ostream &operator<<(std::ostream &OS,
5860 V.print(OS);
5961 return OS;
6062 }
63
64 inline raw_ostream &operator<<(raw_ostream &OS,
65 const MachineConstantPoolValue &V) {
66 V.print(OS);
67 return OS;
68 }
69
6170
6271 /// This class is a data container for one entry in a MachineConstantPool.
6372 /// It contains a pointer to the value and an offset from the start of
12591259 ///
12601260 std::string getOperationName(const SelectionDAG *G = 0) const;
12611261 static const char* getIndexedModeName(ISD::MemIndexedMode AM);
1262 void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
12621263 void dump() const;
12631264 void dump(const SelectionDAG *G) const;
12641265
5757 /// getNullValue.
5858 virtual bool isNullValue() const = 0;
5959
60 virtual void print(std::ostream &O) const;
61 void print(std::ostream *O) const { if (O) print(*O); }
62
6360 /// canTrap - Return true if evaluation of this constant could trap. This is
6461 /// true for things like constant expressions that could divide by zero.
6562 bool canTrap() const;
300300 size_t arg_size() const;
301301 bool arg_empty() const;
302302
303 virtual void print(std::ostream &OS) const { print(OS, 0); }
304 void print(std::ostream *OS) const { if (OS) print(*OS); }
305 void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
306
307303 /// viewCFG - This function is meant for use from the debugger. You can just
308304 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
309305 /// program, displaying the CFG of the current function with the code for each
6161 ///
6262 void eraseFromParent();
6363
64 virtual void print(std::ostream &OS) const;
65 void print(std::ostream *OS) const { if (OS) print(*OS); }
66
6764 /// set/getAliasee - These methods retrive and set alias target.
6865 void setAliasee(Constant* GV);
6966 const Constant* getAliasee() const {
132132 /// replace constant initializers.
133133 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
134134
135 virtual void print(std::ostream &OS) const;
136 void print(std::ostream *OS) const { if (OS) print(*OS); }
137
138135 // Methods for support type inquiry through isa, cast, and dyn_cast:
139136 static inline bool classof(const GlobalVariable *) { return true; }
140137 static inline bool classof(const Value *V) {
2020
2121 namespace llvm {
2222
23 struct AssemblyAnnotationWriter;
2423 class PointerType;
2524 class FunctionType;
2625 class Module;
5655
5756 const std::string &getAsmString() const { return AsmString; }
5857 const std::string &getConstraintString() const { return Constraints; }
59
60 virtual void print(std::ostream &O) const { print(O, 0); }
61 void print(std::ostream *O) const { if (O) print(*O); }
62 void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
6358
6459 /// Verify - This static method can be used by the parser to check to see if
6560 /// the specified constraint string is legal for the type. This returns true
1818 #include "llvm/ADT/ilist_node.h"
1919
2020 namespace llvm {
21
22 struct AssemblyAnnotationWriter;
2321
2422 template
2523 class SymbolTableListTraits;
179177 }
180178 static bool isTrapping(unsigned op);
181179
182 virtual void print(std::ostream &OS) const { print(OS, 0); }
183 void print(std::ostream *OS) const { if (OS) print(*OS); }
184 void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
185
186180 /// Methods for support type inquiry through isa, cast, and dyn_cast:
187181 static inline bool classof(const Instruction *) { return true; }
188182 static inline bool classof(const Value *V) {
349349 /// @name Utility functions for printing and dumping Module objects
350350 /// @{
351351 public:
352 /// Print the module to an output stream
353 void print(std::ostream &OS) const { print(OS, 0); }
354 void print(std::ostream *OS) const { if (OS) print(*OS); }
355352 /// Print the module to an output stream with AssemblyAnnotationWriter.
353 void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const;
356354 void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
357 void print(std::ostream *OS, AssemblyAnnotationWriter *AAW) const {
358 if (OS) print(*OS, AAW);
359 }
360 /// Dump the module to std::cerr (for debugging).
355
356 /// Dump the module to stderr (for debugging).
361357 void dump() const;
362358 /// This function causes all the subinstructions to "let go" of all references
363359 /// that they are maintaining. This allows one to 'delete' a whole class at
384380
385381 /// An iostream inserter for modules.
386382 inline std::ostream &operator<<(std::ostream &O, const Module &M) {
387 M.print(O);
383 M.print(O, 0);
388384 return O;
389385 }
386 inline raw_ostream &operator<<(raw_ostream &O, const Module &M) {
387 M.print(O, 0);
388 return O;
389 }
390
390391
391392 inline ValueSymbolTable *
392393 ilist_traits::getSymTab(Module *M) {
3131
3232 #include "llvm/ADT/APInt.h"
3333 #include "llvm/Support/DataTypes.h"
34 #include "llvm/Support/Streams.h"
35 #include
3634
3735 namespace llvm {
3836
179177
180178 /// print - Print out the bounds to a stream...
181179 ///
182 void print(std::ostream &OS) const;
183 void print(std::ostream *OS) const { if (OS) print(*OS); }
180 void print(raw_ostream &OS) const;
184181
185182 /// dump - Allow printing from a debugger easily...
186183 ///
187184 void dump() const;
188185 };
189186
190 inline std::ostream &operator<<(std::ostream &OS, const ConstantRange &CR) {
187 inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) {
191188 CR.print(OS);
192189 return OS;
193190 }
9595 raw_ostream &operator<<(long N);
9696 raw_ostream &operator<<(unsigned long long N);
9797 raw_ostream &operator<<(long long N);
98
98 raw_ostream &operator<<(const void *P);
9999 raw_ostream &operator<<(unsigned int N) {
100100 return this->operator<<(static_cast(N));
101101 }
200200 std::ostream &OS;
201201 public:
202202 raw_os_ostream(std::ostream &O) : OS(O) {}
203
203 ~raw_os_ostream();
204
204205 /// flush_impl - The is the piece of the class that is implemented by
205206 /// subclasses. This outputs the currently buffered data and resets the
206207 /// buffer to empty.
1313 #include "llvm/AbstractTypeUser.h"
1414 #include "llvm/Support/Casting.h"
1515 #include "llvm/Support/DataTypes.h"
16 #include "llvm/Support/Streams.h"
1716 #include "llvm/ADT/GraphTraits.h"
1817 #include "llvm/ADT/iterator.h"
1918 #include
2524 class PointerType;
2625 class IntegerType;
2726 class TypeMapBase;
27 class raw_ostream;
2828
2929 /// This file contains the declaration of the Type class. For more "Type" type
3030 /// stuff, look in DerivedTypes.h.
155155 PATypeHandle *ContainedTys;
156156
157157 public:
158 void print(raw_ostream &O) const;
158159 void print(std::ostream &O) const;
159160 void print(std::ostream *O) const { if (O) print(*O); }
160161
449450 }
450451
451452 std::ostream &operator<<(std::ostream &OS, const Type &T);
453 raw_ostream &operator<<(raw_ostream &OS, const Type &T);
452454
453455 } // End llvm namespace
454456
3434 class TypeSymbolTable;
3535 template class StringMapEntry;
3636 typedef StringMapEntry ValueName;
37 class raw_ostream;
38 class AssemblyAnnotationWriter;
3739
3840 //===----------------------------------------------------------------------===//
3941 // Value Class
7577 //
7678 virtual void dump() const;
7779
78 /// print - Implement operator<< on Value...
79 ///
80 virtual void print(std::ostream &O) const = 0;
81 void print(std::ostream *O) const { if (O) print(*O); }
80 /// print - Implement operator<< on Value.
81 ///
82 void print(std::ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
83 void print(raw_ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
8284
8385 /// All values are typed, get the type of this value.
8486 ///
236238 V.print(OS);
237239 return OS;
238240 }
239
241 inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) {
242 V.print(OS);
243 return OS;
244 }
245
240246 void Use::init(Value *V, User *) {
241247 Val = V;
242248 if (V) V->addUse(*this);
33 //
44 // This file is distributed under the University of Illinois Open Source
55 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // FIXME: What does this do?
610 //
711 //===----------------------------------------------------------------------===//
812
1418 #include "llvm/Assembly/Writer.h"
1519 #include "llvm/Support/CFG.h"
1620 #include "llvm/Support/Debug.h"
17 #include "llvm/Support/Streams.h"
21 #include "llvm/Support/raw_ostream.h"
1822 using namespace llvm;
1923
2024 char LoopVR::ID = 0;
21 namespace {
2225 static RegisterPass X("loopvr", "Loop Value Ranges", true, true);
23 }
2426
2527 /// getRange - determine the range for a particular SCEV within a given Loop
2628 ConstantRange LoopVR::getRange(SCEVHandle S, Loop *L, ScalarEvolution &SE) {
219221 bool LoopVR::runOnFunction(Function &F) { Map.clear(); return false; }
220222
221223 void LoopVR::print(std::ostream &os, const Module *) const {
224 raw_os_ostream OS(os);
222225 for (std::map::const_iterator I = Map.begin(),
223226 E = Map.end(); I != E; ++I) {
224 os << *I->first << ": ";
225 I->second->print(os);
226 os << "\n";
227 OS << *I->first << ": " << *I->second << '\n';
227228 }
228229 }
229230
2727 #include "llvm/Instructions.h"
2828 #include "llvm/Support/Compiler.h"
2929 #include "llvm/Support/GraphWriter.h"
30 #include "llvm/Support/raw_ostream.h"
3031 #include "llvm/ADT/STLExtras.h"
3132 #include "llvm/Config/config.h"
3233 #include
524525 return Constants.size()-1;
525526 }
526527
528 void MachineConstantPoolValue::print(std::ostream &o) const {
529 raw_os_ostream OS(o);
530 print(OS);
531 }
527532
528533 void MachineConstantPool::print(std::ostream &OS) const {
529534 for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
2323 #include "llvm/CodeGen/MachineFrameInfo.h"
2424 #include "llvm/CodeGen/MachineModuleInfo.h"
2525 #include "llvm/CodeGen/PseudoSourceValue.h"
26 #include "llvm/Support/MathExtras.h"
2726 #include "llvm/Target/TargetRegisterInfo.h"
2827 #include "llvm/Target/TargetData.h"
2928 #include "llvm/Target/TargetLowering.h"
3029 #include "llvm/Target/TargetInstrInfo.h"
3130 #include "llvm/Target/TargetMachine.h"
31 #include "llvm/Support/MathExtras.h"
32 #include "llvm/Support/raw_ostream.h"
3233 #include "llvm/ADT/SetVector.h"
3334 #include "llvm/ADT/SmallPtrSet.h"
3435 #include "llvm/ADT/SmallSet.h"
49794980
49804981 void SDNode::dump() const { dump(0); }
49814982 void SDNode::dump(const SelectionDAG *G) const {
4982 cerr << (void*)this << ": ";
4983 print(errs(), G);
4984 }
4985
4986 void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {
4987 OS << (void*)this << ": ";
49834988
49844989 for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
4985 if (i) cerr << ",";
4990 if (i) OS << ",";
49864991 if (getValueType(i) == MVT::Other)
4987 cerr << "ch";
4992 OS << "ch";
49884993 else
4989 cerr << getValueType(i).getMVTString();
4990 }
4991 cerr << " = " << getOperationName(G);
4992
4993 cerr << " ";
4994 OS << getValueType(i).getMVTString();
4995 }
4996 OS << " = " << getOperationName(G);
4997
4998 OS << " ";
49944999 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
4995 if (i) cerr << ", ";
4996 cerr << (void*)getOperand(i).Val;
5000 if (i) OS << ", ";
5001 OS << (void*)getOperand(i).Val;
49975002 if (unsigned RN = getOperand(i).ResNo)
4998 cerr << ":" << RN;
5003 OS << ":" << RN;
49995004 }
50005005
50015006 if (!isTargetOpcode() && getOpcode() == ISD::VECTOR_SHUFFLE) {
50025007 SDNode *Mask = getOperand(2).Val;
5003 cerr << "<";
5008 OS << "<";
50045009 for (unsigned i = 0, e = Mask->getNumOperands(); i != e; ++i) {
5005 if (i) cerr << ",";
5010 if (i) OS << ",";
50065011 if (Mask->getOperand(i).getOpcode() == ISD::UNDEF)
5007 cerr << "u";
5012 OS << "u";
50085013 else
5009 cerr << cast(Mask->getOperand(i))->getValue();
5010 }
5011 cerr << ">";
5014 OS << cast(Mask->getOperand(i))->getValue();
5015 }
5016 OS << ">";
50125017 }
50135018
50145019 if (const ConstantSDNode *CSDN = dyn_cast(this)) {
5015 cerr << '<' << CSDN->getAPIntValue() << '>';
5020 OS << '<' << CSDN->getAPIntValue() << '>';
50165021 } else if (const ConstantFPSDNode *CSDN = dyn_cast(this)) {
50175022 if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle)
5018 cerr << '<' << CSDN->getValueAPF().convertToFloat() << '>';
5023 OS << '<' << CSDN->getValueAPF().convertToFloat() << '>';
50195024 else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble)
5020 cerr << '<' << CSDN->getValueAPF().convertToDouble() << '>';
5025 OS << '<' << CSDN->getValueAPF().convertToDouble() << '>';
50215026 else {
5022 cerr << "
5027 OS << "
50235028 CSDN->getValueAPF().convertToAPInt().dump();
5024 cerr << ")>";
5029 OS << ")>";
50255030 }
50265031 } else if (const GlobalAddressSDNode *GADN =
50275032 dyn_cast(this)) {
50285033 int offset = GADN->getOffset();
5029 cerr << '<';
5030 WriteAsOperand(*cerr.stream(), GADN->getGlobal());
5031 cerr << '>';
5034 OS << '<';
5035 WriteAsOperand(OS, GADN->getGlobal());
5036 OS << '>';
50325037 if (offset > 0)
5033 cerr << " + " << offset;
5038 OS << " + " << offset;
50345039 else
5035 cerr << " " << offset;
5040 OS << " " << offset;
50365041 } else if (const FrameIndexSDNode *FIDN = dyn_cast(this)) {
5037 cerr << "<" << FIDN->getIndex() << ">";
5042 OS << "<" << FIDN->getIndex() << ">";
50385043 } else if (const JumpTableSDNode *JTDN = dyn_cast(this)) {
5039 cerr << "<" << JTDN->getIndex() << ">";
5044 OS << "<" << JTDN->getIndex() << ">";
50405045 } else if (const ConstantPoolSDNode *CP = dyn_cast(this)){
50415046 int offset = CP->getOffset();
50425047 if (CP->isMachineConstantPoolEntry())
5043 cerr << "<" << *CP->getMachineCPVal() << ">";
5048 OS << "<" << *CP->getMachineCPVal() << ">";
50445049 else
5045 cerr << "<" << *CP->getConstVal() << ">";
5050 OS << "<" << *CP->getConstVal() << ">";
50465051 if (offset > 0)
5047 cerr << " + " << offset;
5052 OS << " + " << offset;
50485053 else
5049 cerr << " " << offset;
5054 OS << " " << offset;
50505055 } else if (const BasicBlockSDNode *BBDN = dyn_cast(this)) {
5051 cerr << "<";
5056 OS << "<";
50525057 const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock();
50535058 if (LBB)
5054 cerr << LBB->getName() << " ";
5055 cerr << (const void*)BBDN->getBasicBlock() << ">";
5059 OS << LBB->getName() << " ";
5060 OS << (const void*)BBDN->getBasicBlock() << ">";
50565061 } else if (const RegisterSDNode *R = dyn_cast(this)) {
50575062 if (G && R->getReg() &&
50585063 TargetRegisterInfo::isPhysicalRegister(R->getReg())) {
5059 cerr << " " << G->getTarget().getRegisterInfo()->getName(R->getReg());
5064 OS << " " << G->getTarget().getRegisterInfo()->getName(R->getReg());
50605065 } else {
5061 cerr << " #" << R->getReg();
5066 OS << " #" << R->getReg();
50625067 }
50635068 } else if (const ExternalSymbolSDNode *ES =
50645069 dyn_cast(this)) {
5065 cerr << "'" << ES->getSymbol() << "'";
5070 OS << "'" << ES->getSymbol() << "'";
50665071 } else if (const SrcValueSDNode *M = dyn_cast(this)) {
50675072 if (M->getValue())
5068 cerr << "<" << M->getValue() << ">";
5073 OS << "<" << M->getValue() << ">";
50695074 else
5070 cerr << "";
5075 OS << "";
50715076 } else if (const MemOperandSDNode *M = dyn_cast(this)) {
50725077 if (M->MO.getValue())
5073 cerr << "<" << M->MO.getValue() << ":" << M->MO.getOffset() << ">";
5078 OS << "<" << M->MO.getValue() << ":" << M->MO.getOffset() << ">";
50745079 else
5075 cerr << "MO.getOffset() << ">";
5080 OS << "MO.getOffset() << ">";
50765081 } else if (const ARG_FLAGSSDNode *N = dyn_cast(this)) {
5077 cerr << N->getArgFlags().getArgFlagsString();
5082 OS << N->getArgFlags().getArgFlagsString();
50785083 } else if (const VTSDNode *N = dyn_cast(this)) {
5079 cerr << ":" << N->getVT().getMVTString();
5084 OS << ":" << N->getVT().getMVTString();
50805085 }
50815086 else if (const LoadSDNode *LD = dyn_cast(this)) {
50825087 const Value *SrcValue = LD->getSrcValue();
50835088 int SrcOffset = LD->getSrcValueOffset();
5084 cerr << " <";
5089 OS << " <";
50855090 if (SrcValue)
5086 cerr << SrcValue;
5091 OS << SrcValue;
50875092 else
5088 cerr << "null";
5089 cerr << ":" << SrcOffset << ">";
5093 OS << "null";
5094 OS << ":" << SrcOffset << ">";
50905095
50915096 bool doExt = true;
50925097 switch (LD->getExtensionType()) {
50935098 default: doExt = false; break;
5094 case ISD::EXTLOAD:
5095 cerr << "
5096 break;
5097 case ISD::SEXTLOAD:
5098 cerr << "
5099 break;
5100 case ISD::ZEXTLOAD:
5101 cerr << "
5102 break;
5099 case ISD::EXTLOAD: OS << " break;
5100 case ISD::SEXTLOAD: OS << "
5101 case ISD::ZEXTLOAD: OS << "
51035102 }
51045103 if (doExt)
5105 cerr << LD->getMemoryVT().getMVTString() << ">";
5104 OS << LD->getMemoryVT().getMVTString() << ">";
51065105
51075106 const char *AM = getIndexedModeName(LD->getAddressingMode());
51085107 if (*AM)
5109 cerr << " " << AM;
5108 OS << " " << AM;
51105109 if (LD->isVolatile())
5111 cerr << " ";
5112 cerr << " alignment=" << LD->getAlignment();
5110 OS << " ";
5111 OS << " alignment=" << LD->getAlignment();
51135112 } else if (const StoreSDNode *ST = dyn_cast(this)) {
51145113 const Value *SrcValue = ST->getSrcValue();
51155114 int SrcOffset = ST->getSrcValueOffset();
5116 cerr << " <";
5115 OS << " <";
51175116 if (SrcValue)
5118 cerr << SrcValue;
5117 OS << SrcValue;
51195118 else
5120 cerr << "null";
5121 cerr << ":" << SrcOffset << ">";
5119 OS << "null";
5120 OS << ":" << SrcOffset << ">";
51225121
51235122 if (ST->isTruncatingStore())
5124 cerr << "
5125 << ST->getMemoryVT().getMVTString() << ">";
5123 OS << " << ST->getMemoryVT().getMVTString() << ">";
51265124
51275125 const char *AM = getIndexedModeName(ST->getAddressingMode());
51285126 if (*AM)
5129 cerr << " " << AM;
5127 OS << " " << AM;
51305128 if (ST->isVolatile())
5131 cerr << " ";
5132 cerr << " alignment=" << ST->getAlignment();
5129 OS << " ";
5130 OS << " alignment=" << ST->getAlignment();
51335131 } else if (const AtomicSDNode* AT = dyn_cast(this)) {
51345132 const Value *SrcValue = AT->getSrcValue();
51355133 int SrcOffset = AT->getSrcValueOffset();
5136 cerr << " <";
5134 OS << " <";
51375135 if (SrcValue)
5138 cerr << SrcValue;
5136 OS << SrcValue;
51395137 else
5140 cerr << "null";
5141 cerr << ":" << SrcOffset << ">";
5138 OS << "null";
5139 OS << ":" << SrcOffset << ">";
51425140 if (AT->isVolatile())
5143 cerr << " ";
5144 cerr << " alignment=" << AT->getAlignment();
5141 OS << " ";
5142 OS << " alignment=" << AT->getAlignment();
51455143 }
51465144 }
51475145
1717 #include "llvm/ADT/SmallString.h"
1818 #include "llvm/Support/Debug.h"
1919 #include "llvm/Support/MathExtras.h"
20 #include "llvm/Support/raw_ostream.h"
2021 #include
2122 #include
2223 #include
4041 return result;
4142 }
4243
43 void APInt::initSlowCase(uint32_t numBits, uint64_t val, bool isSigned)
44 {
44 void APInt::initSlowCase(uint32_t numBits, uint64_t val, bool isSigned) {
4545 pVal = getClearedMemory(getNumWords());
4646 pVal[0] = val;
4747 if (isSigned && int64_t(val) < 0)
5050 }
5151
5252 APInt::APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[])
53 : BitWidth(numBits), VAL(0) {
53 : BitWidth(numBits), VAL(0) {
5454 assert(BitWidth && "bitwidth too small");
5555 assert(bigVal && "Null pointer detected!");
5656 if (isSingleWord())
19941994 fprintf(stderr, "APInt(%db, %su %ss)", BitWidth, U.c_str(), S.c_str());
19951995 }
19961996
1997 void APInt::print(std::ostream &OS, bool isSigned) const {
1997 void APInt::print(raw_ostream &OS, bool isSigned) const {
19981998 SmallString<40> S;
19991999 this->toString(S, 10, isSigned);
20002000 OS << S.c_str();
20012001 }
2002
20032002
20042003 // This implements a variety of operations on a representation of
20052004 // arbitrary precision, two's-complement, bignum integer values.
2121 //===----------------------------------------------------------------------===//
2222
2323 #include "llvm/Support/ConstantRange.h"
24 #include "llvm/Support/Streams.h"
25 #include
24 #include "llvm/Support/raw_ostream.h"
2625 using namespace llvm;
2726
2827 /// Initialize a full (the default) or empty set for the specified type.
461460
462461 /// print - Print out the bounds to a stream...
463462 ///
464 void ConstantRange::print(std::ostream &OS) const {
463 void ConstantRange::print(raw_ostream &OS) const {
465464 OS << "[" << Lower << "," << Upper << ")";
466465 }
467466
468467 /// dump - Allow printing from a debugger easily...
469468 ///
470469 void ConstantRange::dump() const {
471 print(cerr);
472 }
470 print(errs());
471 }
9797
9898 return this->operator<<(static_cast(N));
9999 }
100
101 raw_ostream &raw_ostream::operator<<(const void *P) {
102 // FIXME: This could be much faster if it matters.
103 return *this << format("%p", P);
104 }
105
100106
101107 raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
102108 if (OutBufCur+Size > OutBufEnd)
249255 // raw_os_ostream
250256 //===----------------------------------------------------------------------===//
251257
258 raw_os_ostream::~raw_os_ostream() {
259 flush();
260 }
261
252262 /// flush_impl - The is the piece of the class that is implemented by
253263 /// subclasses. This outputs the currently buffered data and resets the
254264 /// buffer to empty.
1414 #include "llvm/ADT/FoldingSet.h"
1515 #include "llvm/GlobalValue.h"
1616 #include "llvm/Type.h"
17 #include "llvm/Support/raw_ostream.h"
1718 using namespace llvm;
1819
1920 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
7172 ID.AddInteger(PCAdjust);
7273 }
7374
74 void ARMConstantPoolValue::print(std::ostream &O) const {
75 void ARMConstantPoolValue::print(raw_ostream &O) const {
7576 if (GV)
7677 O << GV->getName();
7778 else
6868
6969 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
7070
71 virtual void print(std::ostream &O) const;
71 virtual void print(raw_ostream &O) const;
7272 };
7373
7474 }
1414 #include "llvm/ADT/FoldingSet.h"
1515 #include "llvm/GlobalValue.h"
1616 #include "llvm/Type.h"
17 #include "llvm/Support/raw_ostream.h"
1718 using namespace llvm;
1819
1920 PIC16ConstantPoolValue::PIC16ConstantPoolValue(GlobalValue *gv, unsigned id,
6970 ID.AddInteger(PCAdjust);
7071 }
7172
72 void PIC16ConstantPoolValue::print(std::ostream &O) const {
73 void PIC16ConstantPoolValue::print(raw_ostream &O) const {
7374 if (GV)
7475 O << GV->getName();
7576 else
6868
6969 virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID);
7070
71 virtual void print(std::ostream &O) const;
71 virtual void print(raw_ostream &O) const;
7272 };
7373
7474 }
921921 void dump(std::ostream &os) const {
922922 os << "{";
923923 for (const_iterator I = begin(), E = end(); I != E; ++I) {
924 os << I->second << " (" << I->first->getDFSNumIn() << "), ";
924 os << &I->second << " (" << I->first->getDFSNumIn() << "), ";
925925 }
926926 os << "}";
927927 }
2121 #include "llvm/ADT/STLExtras.h"
2222 #include "llvm/Support/Debug.h"
2323 #include "llvm/Support/Compiler.h"
24 #include "llvm/Support/raw_ostream.h"
2425 #include
2526 using namespace llvm;
2627
143144 DOUT << "RHS: " << RHS << "\n";
144145
145146 CaseRange& Pivot = *(Begin + Mid);
146 DEBUG(cerr << "Pivot ==> "
147 << cast(Pivot.Low)->getValue() << " -"
148 << cast(Pivot.High)->getValue() << "\n");
147 DEBUG(errs() << "Pivot ==> "
148 << cast(Pivot.Low)->getValue() << " -"
149 << cast(Pivot.High)->getValue() << "\n";
150 errs().flush());
149151
150152 BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,
151153 OrigBlock, Default);
3030 #include "llvm/ADT/STLExtras.h"
3131 #include "llvm/Support/CFG.h"
3232 #include "llvm/Support/MathExtras.h"
33 #include "llvm/Support/Streams.h"
3433 #include "llvm/Support/raw_ostream.h"
3534 #include
3635 #include
125124 /// PrintLLVMName - Turn the specified name into an 'LLVM name', which is either
126125 /// prefixed with % (if the string only contains simple characters) or is
127126 /// surrounded with ""'s (if it has special chars in it). Print it out.
128 static void PrintLLVMName(std::ostream &OS, const char *NameStr,
127 static void PrintLLVMName(raw_ostream &OS, const char *NameStr,
129128 unsigned NameLen, PrefixType Prefix) {
130129 assert(NameStr && "Cannot get empty name!");
131130 switch (Prefix) {
183182 /// PrintLLVMName - Turn the specified name into an 'LLVM name', which is either
184183 /// prefixed with % (if the string only contains simple characters) or is
185184 /// surrounded with ""'s (if it has special chars in it). Print it out.
186 static void PrintLLVMName(std::ostream &OS, const Value *V) {
185 static void PrintLLVMName(raw_ostream &OS, const Value *V) {
187186 PrintLLVMName(OS, V->getNameStart(), V->getNameLen(),
188187 isa(V) ? GlobalPrefix : LocalPrefix);
189188 }
438437 // AsmWriter Implementation
439438 //===----------------------------------------------------------------------===//
440439
441 static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
440 static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
442441 std::map &TypeTable,
443442 SlotTracker *Machine);
444443
578577 /// printTypeInt - The internal guts of printing out a type that has a
579578 /// potentially named portion.
580579 ///
581 static void printTypeInt(std::ostream &Out, const Type *Ty,
580 static void printTypeInt(raw_ostream &Out, const Type *Ty,
582581 std::map &TypeNames) {
583582 // Primitive types always print out their description, regardless of whether
584583 // they have been named or not.
613612 ///
614613 void llvm::WriteTypeSymbolic(std::ostream &Out, const Type *Ty,
615614 const Module *M) {
615 raw_os_ostream RO(Out);
616 WriteTypeSymbolic(RO, Ty, M);
617 }
618
619 void llvm::WriteTypeSymbolic(raw_ostream &Out, const Type *Ty, const Module *M){
616620 Out << ' ';
617621
618622 // If they want us to print out a type, but there is no context, we can't
628632
629633 // PrintEscapedString - Print each character of the specified string, escaping
630634 // it if it is not printable or if it is an escape char.
631 static void PrintEscapedString(const std::string &Str, std::ostream &Out) {
635 static void PrintEscapedString(const std::string &Str, raw_ostream &Out) {
632636 for (unsigned i = 0, e = Str.size(); i != e; ++i) {
633637 unsigned char C = Str[i];
634638 if (isprint(C) && C != '"' && C != '\\') {
674678 return pred;
675679 }
676680
677 static void WriteConstantInt(std::ostream &Out, const Constant *CV,
681 static void WriteConstantInt(raw_ostream &Out, const Constant *CV,
678682 std::map &TypeTable,
679683 SlotTracker *Machine) {
680684 if (const ConstantInt *CI = dyn_cast(CV)) {
872876 /// ostream. This can be useful when you just want to print int %reg126, not
873877 /// the whole instruction that generated it.
874878 ///
875 static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
879 static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
876880 std::map &TypeTable,
877881 SlotTracker *Machine) {
878882 Out << ' ';
935939 ///
936940 void llvm::WriteAsOperand(std::ostream &Out, const Value *V, bool PrintType,
937941 const Module *Context) {
942 raw_os_ostream OS(Out);
943 WriteAsOperand(OS, V, PrintType, Context);
944 }
945
946 void llvm::WriteAsOperand(raw_ostream &Out, const Value *V, bool PrintType,
947 const Module *Context) {
938948 std::map TypeNames;
939949 if (Context == 0) Context = getModuleFromVal(V);
940950
951961 namespace {
952962
953963 class AssemblyWriter {
954 std::ostream &Out;
964 raw_ostream &Out;
955965 SlotTracker &Machine;
956966 const Module *TheModule;
957967 std::map TypeNames;
958968 AssemblyAnnotationWriter *AnnotationWriter;
959969 public:
960 inline AssemblyWriter(std::ostream &o, SlotTracker &Mac, const Module *M,
970 inline AssemblyWriter(raw_ostream &o, SlotTracker &Mac, const Module *M,
961971 AssemblyAnnotationWriter *AAW)
962972 : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) {
963973
967977 fillTypeNameTable(M, TypeNames);
968978 }
969979
970 void write(const Module *M) { printModule(M); }
971 void write(const GlobalVariable *G) { printGlobal(G); }
972 void write(const GlobalAlias *G) { printAlias(G); }
973 void write(const Function *F) { printFunction(F); }
980 void write(const Module *M) { printModule(M); }
981
982 void write(const GlobalValue *G) {
983 if (const GlobalVariable *GV = dyn_cast(G))
984 printGlobal(GV);
985 else if (const GlobalAlias *GA = dyn_cast(G))
986 printAlias(GA);
987 else if (const Function *F = dyn_cast(G))
988 printFunction(F);
989 else
990 assert(0 && "Unknown global");
991 }
992
974993 void write(const BasicBlock *BB) { printBasicBlock(BB); }
975994 void write(const Instruction *I) { printInstruction(*I); }
976995 void write(const Type *Ty) { printType(Ty); }
11751194 printFunction(I);
11761195 }
11771196
1178 static void PrintLinkage(GlobalValue::LinkageTypes LT, std::ostream &Out) {
1197 static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
11791198 switch (LT) {
11801199 case GlobalValue::InternalLinkage: Out << "internal "; break;
11811200 case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break;
11941213
11951214
11961215 static void PrintVisibility(GlobalValue::VisibilityTypes Vis,
1197 std::ostream &Out) {
1216 raw_ostream &Out) {
11981217 switch (Vis) {
11991218 default: assert(0 && "Invalid visibility style!");
12001219 case GlobalValue::DefaultVisibility: break;
17041723 //===----------------------------------------------------------------------===//
17051724
17061725 void Module::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
1726 raw_os_ostream OS(o);
1727 print(OS, AAW);
1728 }
1729 void Module::print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const {
17071730 SlotTracker SlotTable(this);
1708 AssemblyWriter W(o, SlotTable, this, AAW);
1731 AssemblyWriter W(OS, SlotTable, this, AAW);
17091732 W.write(this);
17101733 }
17111734
1712 void GlobalVariable::print(std::ostream &o) const {
1713 SlotTracker SlotTable(getParent());
1714 AssemblyWriter W(o, SlotTable, getParent(), 0);
1715 W.write(this);
1716 }
1717
1718 void GlobalAlias::print(std::ostream &o) const {
1719 SlotTracker SlotTable(getParent());
1720 AssemblyWriter W(o, SlotTable, getParent(), 0);
1721 W.write(this);
1722 }
1723
1724 void Function::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
1725 SlotTracker SlotTable(getParent());
1726 AssemblyWriter W(o, SlotTable, getParent(), AAW);
1727
1728 W.write(this);
1729 }
1730
1731 void InlineAsm::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
1732 WriteAsOperand(o, this, true, 0);
1733 }
1734
1735 void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
1736 SlotTracker SlotTable(getParent());
1737 AssemblyWriter W(o, SlotTable,
1738 getParent() ? getParent()->getParent() : 0, AAW);
1739 W.write(this);
1740 }
1741
1742 void Instruction::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
1743 const Function *F = getParent() ? getParent()->getParent() : 0;
1744 SlotTracker SlotTable(F);
1745 AssemblyWriter W(o, SlotTable, F ? F->getParent() : 0, AAW);
1746
1747 W.write(this);
1748 }
1749
1750 void Constant::print(std::ostream &o) const {
1751 if (this == 0) { o << " constant value\n"; return; }
1752
1753 o << ' ' << getType()->getDescription() << ' ';
1754
1755 std::map TypeTable;
1756 WriteConstantInt(o, this, TypeTable, 0);
1757 }
1758
17591735 void Type::print(std::ostream &o) const {
1736 raw_os_ostream OS(o);
1737 print(OS);
1738 }
1739
1740 void Type::print(raw_ostream &o) const {
17601741 if (this == 0)
17611742 o << "";
17621743 else
17631744 o << getDescription();
17641745 }
17651746
1766 void Argument::print(std::ostream &o) const {
1767 WriteAsOperand(o, this, true, getParent() ? getParent()->getParent() : 0);
1747 void Value::print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const {
1748 if (this == 0) {
1749 OS << "printing a value\n";
1750 return;
1751 }
1752
1753 if (const Instruction *I = dyn_cast(this)) {
1754 const Function *F = I->getParent() ? I->getParent()->getParent() : 0;
1755 SlotTracker SlotTable(F);
1756 AssemblyWriter W(OS, SlotTable, F ? F->getParent() : 0, AAW);
1757 W.write(I);
1758 } else if (const BasicBlock *BB = dyn_cast(this)) {
1759 SlotTracker SlotTable(BB->getParent());
1760 AssemblyWriter W(OS, SlotTable,
1761 BB->getParent() ? BB->getParent()->getParent() : 0, AAW);
1762 W.write(BB);
1763 } else if (const GlobalValue *GV = dyn_cast(this)) {
1764 SlotTracker SlotTable(GV->getParent());
1765 AssemblyWriter W(OS, SlotTable, GV->getParent(), 0);
1766 W.write(GV);
1767 } else if (const Constant *C = dyn_cast(this)) {
1768 OS << ' ' << C->getType()->getDescription() << ' ';
1769 std::map TypeTable;
1770 WriteConstantInt(OS, C, TypeTable, 0);
1771 } else if (const Argument *A = dyn_cast(this)) {
1772 WriteAsOperand(OS, this, true,
1773 A->getParent() ? A->getParent()->getParent() : 0);
1774 } else if (isa(this)) {
1775 WriteAsOperand(OS, this, true, 0);
1776 } else {
1777 assert(0 && "Unknown value to print out!");
1778 }
1779 }
1780
1781 void Value::print(std::ostream &O, AssemblyAnnotationWriter *AAW) const {
1782 raw_os_ostream OS(O);
1783 print(OS, AAW);
17681784 }
17691785
17701786 // Value::dump - allow easy printing of Values from the debugger.
17711787 // Located here because so much of the needed functionality is here.
1772 void Value::dump() const { print(*cerr.stream()); cerr << '\n'; }
1788 void Value::dump() const { print(errs()); errs() << '\n'; }
17731789
17741790 // Type::dump - allow easy printing of Values from the debugger.
17751791 // Located here because so much of the needed functionality is here.
1776 void Type::dump() const { print(*cerr.stream()); cerr << '\n'; }
1777
1792 void Type::dump() const { print(errs()); errs() << '\n'; }
1793
1794 // Module::dump() - Allow printing from debugger
1795 void Module::dump() const { print(errs(), 0); }
1796
1797
8787 delete TypeSymTab;
8888 }
8989
90 // Module::dump() - Allow printing from debugger
91 void Module::dump() const {
92 print(*cerr.stream());
93 }
94
9590 /// Target endian information...
9691 Module::Endianness Module::getEndianness() const {
9792 std::string temp = DataLayout;
2020 #include "llvm/Support/CommandLine.h"
2121 #include "llvm/Support/ManagedStatic.h"
2222 #include "llvm/Support/MemoryBuffer.h"
23 #include "llvm/Support/raw_ostream.h"
2324 #include "llvm/System/Signals.h"
2425 #include
2526 #include
7071 std::map &EF)
7172 : FuncFreqs(FF), BlockFreqs(BF), EdgeFreqs(EF) {}
7273
73 virtual void emitFunctionAnnot(const Function *F, std::ostream &OS) {
74 virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {
7475 OS << ";;; %" << F->getName() << " called " << FuncFreqs[F]
7576 << " times.\n;;;\n";
7677 }
7778 virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
78 std::ostream &OS) {
79 raw_ostream &OS) {
7980 if (BlockFreqs.empty()) return;
8081 if (unsigned Count = BlockFreqs[BB])
8182 OS << "\t;;; Basic block executed " << Count << " times.\n";
8384 OS << "\t;;; Never executed!\n";
8485 }
8586
86 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, std::ostream &OS){
87 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
8788 if (EdgeFreqs.empty()) return;
8889
8990 // Figure out how many times each successor executed.
234235 if (FunctionsToPrint.empty() || PrintAllCode)
235236 M->print(std::cout, &PA);
236237 else
237 // Print just a subset of the functions...
238 // Print just a subset of the functions.
238239 for (std::set::iterator I = FunctionsToPrint.begin(),
239240 E = FunctionsToPrint.end(); I != E; ++I)
240241 (*I)->print(std::cout, &PA);