llvm.org GIT mirror llvm / a11a6a0
AsmPrinter has a formatted stream, pass it down through AsmAnnotationWriter git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112903 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
2 changed file(s) with 18 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
3131
3232 /// emitFunctionAnnot - This may be implemented to emit a string right before
3333 /// the start of a function.
34 virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {}
34 virtual void emitFunctionAnnot(const Function *F,
35 formatted_raw_ostream &OS) {}
3536
3637 /// emitBasicBlockStartAnnot - This may be implemented to emit a string right
37 /// after the basic block label, but before the first instruction in the block.
38 virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, raw_ostream &OS){
38 /// after the basic block label, but before the first instruction in the
39 /// block.
40 virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
41 formatted_raw_ostream &OS){
3942 }
4043
4144 /// emitBasicBlockEndAnnot - This may be implemented to emit a string right
4245 /// after the basic block.
43 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS){
46 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB,
47 formatted_raw_ostream &OS){
4448 }
4549
4650 /// emitInstructionAnnot - This may be implemented to emit a string right
4751 /// before an instruction is emitted.
48 virtual void emitInstructionAnnot(const Instruction *I, raw_ostream &OS) {}
52 virtual void emitInstructionAnnot(const Instruction *I,
53 formatted_raw_ostream &OS) {}
4954
5055 /// printInfoComment - This may be implemented to emit a comment to the
5156 /// right of an instruction or global value.
2222 #include "llvm/Analysis/Passes.h"
2323 #include "llvm/Bitcode/ReaderWriter.h"
2424 #include "llvm/Support/CommandLine.h"
25 #include "llvm/Support/FormattedStream.h"
2526 #include "llvm/Support/ManagedStatic.h"
2627 #include "llvm/Support/MemoryBuffer.h"
2728 #include "llvm/Support/PrettyStackTrace.h"
7475 class ProfileAnnotator : public AssemblyAnnotationWriter {
7576 ProfileInfo Π
7677 public:
77 ProfileAnnotator(ProfileInfo& pi) : PI(pi) {}
78
79 virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {
78 ProfileAnnotator(ProfileInfo &pi) : PI(pi) {}
79
80 virtual void emitFunctionAnnot(const Function *F,
81 formatted_raw_ostream &OS) {
8082 double w = PI.getExecutionCount(F);
8183 if (w != ProfileInfo::MissingValue) {
8284 OS << ";;; %" << F->getName() << " called "<<(unsigned)w
8486 }
8587 }
8688 virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
87 raw_ostream &OS) {
89 formatted_raw_ostream &OS) {
8890 double w = PI.getExecutionCount(BB);
8991 if (w != ProfileInfo::MissingValue) {
9092 if (w != 0) {
9597 }
9698 }
9799
98 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
100 virtual void emitBasicBlockEndAnnot(const BasicBlock *BB,
101 formatted_raw_ostream &OS) {
99102 // Figure out how many times each successor executed.
100103 std::vector > SuccCounts;
101104