|
31 | 31 | #include "llvm/Support/FormatVariadic.h"
|
32 | 32 |
|
33 | 33 | namespace llvm {
|
| 34 | +class ModuleSlotTracker; |
| 35 | + |
34 | 36 | template <class GraphType> struct GraphTraits;
|
35 | 37 | class CFGViewerPass : public PassInfoMixin<CFGViewerPass> {
|
36 | 38 | public:
|
@@ -61,28 +63,27 @@ class DOTFuncInfo {
|
61 | 63 | const Function *F;
|
62 | 64 | const BlockFrequencyInfo *BFI;
|
63 | 65 | const BranchProbabilityInfo *BPI;
|
| 66 | + std::unique_ptr<ModuleSlotTracker> MSTStorage; |
64 | 67 | uint64_t MaxFreq;
|
65 | 68 | bool ShowHeat;
|
66 | 69 | bool EdgeWeights;
|
67 | 70 | bool RawWeights;
|
68 | 71 |
|
69 | 72 | public:
|
70 | 73 | DOTFuncInfo(const Function *F) : DOTFuncInfo(F, nullptr, nullptr, 0) {}
|
| 74 | + ~DOTFuncInfo(); |
71 | 75 |
|
72 | 76 | DOTFuncInfo(const Function *F, const BlockFrequencyInfo *BFI,
|
73 |
| - const BranchProbabilityInfo *BPI, uint64_t MaxFreq) |
74 |
| - : F(F), BFI(BFI), BPI(BPI), MaxFreq(MaxFreq) { |
75 |
| - ShowHeat = false; |
76 |
| - EdgeWeights = !!BPI; // Print EdgeWeights when BPI is available. |
77 |
| - RawWeights = !!BFI; // Print RawWeights when BFI is available. |
78 |
| - } |
| 77 | + const BranchProbabilityInfo *BPI, uint64_t MaxFreq); |
79 | 78 |
|
80 | 79 | const BlockFrequencyInfo *getBFI() const { return BFI; }
|
81 | 80 |
|
82 | 81 | const BranchProbabilityInfo *getBPI() const { return BPI; }
|
83 | 82 |
|
84 | 83 | const Function *getFunction() const { return this->F; }
|
85 | 84 |
|
| 85 | + ModuleSlotTracker *getModuleSlotTracker(); |
| 86 | + |
86 | 87 | uint64_t getMaxFreq() const { return MaxFreq; }
|
87 | 88 |
|
88 | 89 | uint64_t getFreq(const BasicBlock *BB) const {
|
@@ -203,22 +204,12 @@ struct DOTGraphTraits<DOTFuncInfo *> : public DefaultDOTGraphTraits {
|
203 | 204 | return SimpleNodeLabelString(Node);
|
204 | 205 | }
|
205 | 206 |
|
206 |
| - static void printBasicBlock(raw_string_ostream &OS, const BasicBlock &Node) { |
207 |
| - // Prepend label name |
208 |
| - Node.printAsOperand(OS, false); |
209 |
| - OS << ":\n"; |
210 |
| - for (const Instruction &Inst : Node) |
211 |
| - OS << Inst << "\n"; |
212 |
| - } |
213 |
| - |
214 | 207 | static std::string getCompleteNodeLabel(
|
215 | 208 | const BasicBlock *Node, DOTFuncInfo *,
|
216 | 209 | function_ref<void(raw_string_ostream &, const BasicBlock &)>
|
217 |
| - HandleBasicBlock = printBasicBlock, |
218 |
| - function_ref<void(std::string &, unsigned &, unsigned)> |
219 |
| - HandleComment = eraseComment) { |
220 |
| - return CompleteNodeLabelString(Node, HandleBasicBlock, HandleComment); |
221 |
| - } |
| 210 | + HandleBasicBlock = {}, |
| 211 | + function_ref<void(std::string &, unsigned &, unsigned)> HandleComment = |
| 212 | + eraseComment); |
222 | 213 |
|
223 | 214 | std::string getNodeLabel(const BasicBlock *Node, DOTFuncInfo *CFGInfo) {
|
224 | 215 |
|
@@ -337,6 +328,6 @@ struct DOTGraphTraits<DOTFuncInfo *> : public DefaultDOTGraphTraits {
|
337 | 328 | bool isNodeHidden(const BasicBlock *Node, const DOTFuncInfo *CFGInfo);
|
338 | 329 | void computeDeoptOrUnreachablePaths(const Function *F);
|
339 | 330 | };
|
340 |
| -} // End llvm namespace |
| 331 | +} // namespace llvm |
341 | 332 |
|
342 | 333 | #endif
|
0 commit comments