Duncan P. N. Exon Smith | e9139c6 | 2014-04-11 23:20:58 +0000 | [diff] [blame] | 1 | //===- MachineBlockFrequencyInfo.cpp - MBB Frequency Analysis -------------===// |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Loops should be simplified before this analysis. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Jakub Staszak | f55c1c8 | 2011-07-25 19:25:40 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/DenseMap.h" |
| 16 | #include "llvm/ADT/None.h" |
| 17 | #include "llvm/ADT/iterator.h" |
Duncan P. N. Exon Smith | e9139c6 | 2014-04-11 23:20:58 +0000 | [diff] [blame] | 18 | #include "llvm/Analysis/BlockFrequencyInfoImpl.h" |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineBasicBlock.h" |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" |
Duncan P. N. Exon Smith | 9a11d66 | 2014-04-21 17:57:07 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineFunction.h" |
| 22 | #include "llvm/CodeGen/MachineLoopInfo.h" |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 23 | #include "llvm/Pass.h" |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 24 | #include "llvm/Support/CommandLine.h" |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 25 | #include "llvm/Support/GraphWriter.h" |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 26 | #include <string> |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 27 | |
| 28 | using namespace llvm; |
| 29 | |
Matthias Braun | 94c4904 | 2017-05-25 21:26:32 +0000 | [diff] [blame] | 30 | #define DEBUG_TYPE "machine-block-freq" |
Chandler Carruth | 8677f2f | 2014-04-22 02:02:50 +0000 | [diff] [blame] | 31 | |
Xinliang David Li | 3071cc9 | 2016-06-21 23:36:12 +0000 | [diff] [blame] | 32 | static cl::opt<GVDAGType> ViewMachineBlockFreqPropagationDAG( |
| 33 | "view-machine-block-freq-propagation-dags", cl::Hidden, |
| 34 | cl::desc("Pop up a window to show a dag displaying how machine block " |
| 35 | "frequencies propagate through the CFG."), |
| 36 | cl::values(clEnumValN(GVDT_None, "none", "do not display graphs."), |
| 37 | clEnumValN(GVDT_Fraction, "fraction", |
| 38 | "display a graph using the " |
| 39 | "fractional block frequency representation."), |
| 40 | clEnumValN(GVDT_Integer, "integer", |
| 41 | "display a graph using the raw " |
| 42 | "integer fractional block frequency representation."), |
Xinliang David Li | 9e588d8 | 2016-06-22 19:26:44 +0000 | [diff] [blame] | 43 | clEnumValN(GVDT_Count, "count", "display a graph using the real " |
Mehdi Amini | 3ffe113 | 2016-10-08 19:41:06 +0000 | [diff] [blame] | 44 | "profile count if available."))); |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 45 | |
Xinliang David Li | 828b398 | 2017-01-29 01:57:02 +0000 | [diff] [blame] | 46 | // Similar option above, but used to control BFI display only after MBP pass |
| 47 | cl::opt<GVDAGType> ViewBlockLayoutWithBFI( |
| 48 | "view-block-layout-with-bfi", cl::Hidden, |
| 49 | cl::desc( |
| 50 | "Pop up a window to show a dag displaying MBP layout and associated " |
| 51 | "block frequencies of the CFG."), |
| 52 | cl::values(clEnumValN(GVDT_None, "none", "do not display graphs."), |
| 53 | clEnumValN(GVDT_Fraction, "fraction", |
| 54 | "display a graph using the " |
| 55 | "fractional block frequency representation."), |
| 56 | clEnumValN(GVDT_Integer, "integer", |
| 57 | "display a graph using the raw " |
| 58 | "integer fractional block frequency representation."), |
| 59 | clEnumValN(GVDT_Count, "count", |
| 60 | "display a graph using the real " |
| 61 | "profile count if available."))); |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 62 | |
Xinliang David Li | 050d2a7 | 2017-02-02 21:29:17 +0000 | [diff] [blame] | 63 | // Command line option to specify the name of the function for CFG dump |
| 64 | // Defined in Analysis/BlockFrequencyInfo.cpp: -view-bfi-func-name= |
Xinliang David Li | f2c927d | 2016-06-28 04:07:03 +0000 | [diff] [blame] | 65 | extern cl::opt<std::string> ViewBlockFreqFuncName; |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 66 | |
Xinliang David Li | 050d2a7 | 2017-02-02 21:29:17 +0000 | [diff] [blame] | 67 | // Command line option to specify hot frequency threshold. |
| 68 | // Defined in Analysis/BlockFrequencyInfo.cpp: -view-hot-freq-perc= |
Simon Pilgrim | 970b0c8 | 2016-06-28 12:34:44 +0000 | [diff] [blame] | 69 | extern cl::opt<unsigned> ViewHotFreqPercent; |
Xinliang David Li | 06dbef9 | 2016-06-22 02:12:54 +0000 | [diff] [blame] | 70 | |
Hiroshi Yamauchi | 1020c41 | 2017-08-26 00:31:00 +0000 | [diff] [blame] | 71 | static cl::opt<bool> PrintMachineBlockFreq( |
| 72 | "print-machine-bfi", cl::init(false), cl::Hidden, |
| 73 | cl::desc("Print the machine block frequency info.")); |
| 74 | |
| 75 | // Command line option to specify the name of the function for block frequency |
| 76 | // dump. Defined in Analysis/BlockFrequencyInfo.cpp. |
| 77 | extern cl::opt<std::string> PrintBlockFreqFuncName; |
| 78 | |
Xinliang David Li | 828b398 | 2017-01-29 01:57:02 +0000 | [diff] [blame] | 79 | static GVDAGType getGVDT() { |
| 80 | if (ViewBlockLayoutWithBFI != GVDT_None) |
| 81 | return ViewBlockLayoutWithBFI; |
| 82 | |
| 83 | return ViewMachineBlockFreqPropagationDAG; |
| 84 | } |
| 85 | |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 86 | namespace llvm { |
| 87 | |
Xinliang David Li | 3071cc9 | 2016-06-21 23:36:12 +0000 | [diff] [blame] | 88 | template <> struct GraphTraits<MachineBlockFrequencyInfo *> { |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 89 | using NodeRef = const MachineBasicBlock *; |
| 90 | using ChildIteratorType = MachineBasicBlock::const_succ_iterator; |
| 91 | using nodes_iterator = pointer_iterator<MachineFunction::const_iterator>; |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 92 | |
Tim Shen | b62ba77 | 2016-08-31 16:48:13 +0000 | [diff] [blame] | 93 | static NodeRef getEntryNode(const MachineBlockFrequencyInfo *G) { |
Duncan P. N. Exon Smith | b1510c2 | 2015-10-09 19:23:20 +0000 | [diff] [blame] | 94 | return &G->getFunction()->front(); |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 95 | } |
Michael Gottesman | 3916f6c | 2013-12-03 20:21:17 +0000 | [diff] [blame] | 96 | |
Tim Shen | 22fca38 | 2016-08-22 21:09:30 +0000 | [diff] [blame] | 97 | static ChildIteratorType child_begin(const NodeRef N) { |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 98 | return N->succ_begin(); |
| 99 | } |
Michael Gottesman | 3916f6c | 2013-12-03 20:21:17 +0000 | [diff] [blame] | 100 | |
Tim Shen | 22fca38 | 2016-08-22 21:09:30 +0000 | [diff] [blame] | 101 | static ChildIteratorType child_end(const NodeRef N) { return N->succ_end(); } |
Michael Gottesman | 3916f6c | 2013-12-03 20:21:17 +0000 | [diff] [blame] | 102 | |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 103 | static nodes_iterator nodes_begin(const MachineBlockFrequencyInfo *G) { |
Tim Shen | f6e737e | 2016-08-19 21:20:13 +0000 | [diff] [blame] | 104 | return nodes_iterator(G->getFunction()->begin()); |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 105 | } |
Michael Gottesman | 3916f6c | 2013-12-03 20:21:17 +0000 | [diff] [blame] | 106 | |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 107 | static nodes_iterator nodes_end(const MachineBlockFrequencyInfo *G) { |
Tim Shen | f6e737e | 2016-08-19 21:20:13 +0000 | [diff] [blame] | 108 | return nodes_iterator(G->getFunction()->end()); |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 109 | } |
| 110 | }; |
| 111 | |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 112 | using MBFIDOTGraphTraitsBase = |
| 113 | BFIDOTGraphTraitsBase<MachineBlockFrequencyInfo, |
| 114 | MachineBranchProbabilityInfo>; |
| 115 | |
Xinliang David Li | 3071cc9 | 2016-06-21 23:36:12 +0000 | [diff] [blame] | 116 | template <> |
| 117 | struct DOTGraphTraits<MachineBlockFrequencyInfo *> |
Xinliang David Li | 6fff479 | 2016-06-28 03:41:29 +0000 | [diff] [blame] | 118 | : public MBFIDOTGraphTraitsBase { |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 119 | const MachineFunction *CurFunc = nullptr; |
Xinliang David Li | 828b398 | 2017-01-29 01:57:02 +0000 | [diff] [blame] | 120 | DenseMap<const MachineBasicBlock *, int> LayoutOrderMap; |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 121 | |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 122 | explicit DOTGraphTraits(bool isSimple = false) |
| 123 | : MBFIDOTGraphTraitsBase(isSimple) {} |
| 124 | |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 125 | std::string getNodeLabel(const MachineBasicBlock *Node, |
| 126 | const MachineBlockFrequencyInfo *Graph) { |
Xinliang David Li | 828b398 | 2017-01-29 01:57:02 +0000 | [diff] [blame] | 127 | int layout_order = -1; |
| 128 | // Attach additional ordering information if 'isSimple' is false. |
| 129 | if (!isSimple()) { |
| 130 | const MachineFunction *F = Node->getParent(); |
| 131 | if (!CurFunc || F != CurFunc) { |
| 132 | if (CurFunc) |
| 133 | LayoutOrderMap.clear(); |
| 134 | |
| 135 | CurFunc = F; |
| 136 | int O = 0; |
| 137 | for (auto MBI = F->begin(); MBI != F->end(); ++MBI, ++O) { |
| 138 | LayoutOrderMap[&*MBI] = O; |
| 139 | } |
| 140 | } |
| 141 | layout_order = LayoutOrderMap[Node]; |
| 142 | } |
| 143 | return MBFIDOTGraphTraitsBase::getNodeLabel(Node, Graph, getGVDT(), |
| 144 | layout_order); |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 145 | } |
Xinliang David Li | 6fff479 | 2016-06-28 03:41:29 +0000 | [diff] [blame] | 146 | |
Xinliang David Li | cc075cf | 2016-06-28 06:58:21 +0000 | [diff] [blame] | 147 | std::string getNodeAttributes(const MachineBasicBlock *Node, |
| 148 | const MachineBlockFrequencyInfo *Graph) { |
| 149 | return MBFIDOTGraphTraitsBase::getNodeAttributes(Node, Graph, |
| 150 | ViewHotFreqPercent); |
| 151 | } |
| 152 | |
Xinliang David Li | 6fff479 | 2016-06-28 03:41:29 +0000 | [diff] [blame] | 153 | std::string getEdgeAttributes(const MachineBasicBlock *Node, EdgeIter EI, |
| 154 | const MachineBlockFrequencyInfo *MBFI) { |
Xinliang David Li | cc075cf | 2016-06-28 06:58:21 +0000 | [diff] [blame] | 155 | return MBFIDOTGraphTraitsBase::getEdgeAttributes( |
| 156 | Node, EI, MBFI, MBFI->getMBPI(), ViewHotFreqPercent); |
Xinliang David Li | 27717d0 | 2016-06-22 16:04:51 +0000 | [diff] [blame] | 157 | } |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 160 | } // end namespace llvm |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 161 | |
Matthias Braun | 94c4904 | 2017-05-25 21:26:32 +0000 | [diff] [blame] | 162 | INITIALIZE_PASS_BEGIN(MachineBlockFrequencyInfo, DEBUG_TYPE, |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 163 | "Machine Block Frequency Analysis", true, true) |
| 164 | INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfo) |
Duncan P. N. Exon Smith | 9a11d66 | 2014-04-21 17:57:07 +0000 | [diff] [blame] | 165 | INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) |
Matthias Braun | 94c4904 | 2017-05-25 21:26:32 +0000 | [diff] [blame] | 166 | INITIALIZE_PASS_END(MachineBlockFrequencyInfo, DEBUG_TYPE, |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 167 | "Machine Block Frequency Analysis", true, true) |
| 168 | |
Jakub Staszak | f55c1c8 | 2011-07-25 19:25:40 +0000 | [diff] [blame] | 169 | char MachineBlockFrequencyInfo::ID = 0; |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 170 | |
Xinliang David Li | 3071cc9 | 2016-06-21 23:36:12 +0000 | [diff] [blame] | 171 | MachineBlockFrequencyInfo::MachineBlockFrequencyInfo() |
| 172 | : MachineFunctionPass(ID) { |
Jakub Staszak | f55c1c8 | 2011-07-25 19:25:40 +0000 | [diff] [blame] | 173 | initializeMachineBlockFrequencyInfoPass(*PassRegistry::getPassRegistry()); |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Eugene Zelenko | 2de563a | 2017-08-24 21:21:39 +0000 | [diff] [blame] | 176 | MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo() = default; |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 177 | |
Jakub Staszak | f55c1c8 | 2011-07-25 19:25:40 +0000 | [diff] [blame] | 178 | void MachineBlockFrequencyInfo::getAnalysisUsage(AnalysisUsage &AU) const { |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 179 | AU.addRequired<MachineBranchProbabilityInfo>(); |
Duncan P. N. Exon Smith | 9a11d66 | 2014-04-21 17:57:07 +0000 | [diff] [blame] | 180 | AU.addRequired<MachineLoopInfo>(); |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 181 | AU.setPreservesAll(); |
Jakub Staszak | 9d81c97 | 2011-07-21 22:59:09 +0000 | [diff] [blame] | 182 | MachineFunctionPass::getAnalysisUsage(AU); |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Adam Nemet | 1174583 | 2017-02-14 17:21:09 +0000 | [diff] [blame] | 185 | void MachineBlockFrequencyInfo::calculate( |
| 186 | const MachineFunction &F, const MachineBranchProbabilityInfo &MBPI, |
| 187 | const MachineLoopInfo &MLI) { |
Duncan P. N. Exon Smith | 27e1ca8 | 2014-03-25 18:01:38 +0000 | [diff] [blame] | 188 | if (!MBFI) |
| 189 | MBFI.reset(new ImplType); |
Cong Hou | 2fa118d | 2015-07-15 19:58:26 +0000 | [diff] [blame] | 190 | MBFI->calculate(F, MBPI, MLI); |
Xinliang David Li | 06dbef9 | 2016-06-22 02:12:54 +0000 | [diff] [blame] | 191 | if (ViewMachineBlockFreqPropagationDAG != GVDT_None && |
Xinliang David Li | f2c927d | 2016-06-28 04:07:03 +0000 | [diff] [blame] | 192 | (ViewBlockFreqFuncName.empty() || |
| 193 | F.getName().equals(ViewBlockFreqFuncName))) { |
Xinliang David Li | 210c690 | 2017-02-15 19:21:04 +0000 | [diff] [blame] | 194 | view("MachineBlockFrequencyDAGS." + F.getName()); |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 195 | } |
Hiroshi Yamauchi | 1020c41 | 2017-08-26 00:31:00 +0000 | [diff] [blame] | 196 | if (PrintMachineBlockFreq && |
| 197 | (PrintBlockFreqFuncName.empty() || |
| 198 | F.getName().equals(PrintBlockFreqFuncName))) { |
| 199 | MBFI->print(dbgs()); |
| 200 | } |
Adam Nemet | 1174583 | 2017-02-14 17:21:09 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) { |
| 204 | MachineBranchProbabilityInfo &MBPI = |
| 205 | getAnalysis<MachineBranchProbabilityInfo>(); |
| 206 | MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>(); |
| 207 | calculate(F, MBPI, MLI); |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 208 | return false; |
| 209 | } |
| 210 | |
Duncan P. N. Exon Smith | 27e1ca8 | 2014-03-25 18:01:38 +0000 | [diff] [blame] | 211 | void MachineBlockFrequencyInfo::releaseMemory() { MBFI.reset(); } |
| 212 | |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 213 | /// Pop up a ghostview window with the current block frequency propagation |
| 214 | /// rendered using dot. |
Xinliang David Li | 210c690 | 2017-02-15 19:21:04 +0000 | [diff] [blame] | 215 | void MachineBlockFrequencyInfo::view(const Twine &Name, bool isSimple) const { |
| 216 | // This code is only for debugging. |
| 217 | ViewGraph(const_cast<MachineBlockFrequencyInfo *>(this), Name, isSimple); |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Xinliang David Li | 3071cc9 | 2016-06-21 23:36:12 +0000 | [diff] [blame] | 220 | BlockFrequency |
| 221 | MachineBlockFrequencyInfo::getBlockFreq(const MachineBasicBlock *MBB) const { |
Duncan P. N. Exon Smith | 27e1ca8 | 2014-03-25 18:01:38 +0000 | [diff] [blame] | 222 | return MBFI ? MBFI->getBlockFreq(MBB) : 0; |
Jakub Staszak | 59a9dab | 2011-07-16 20:23:20 +0000 | [diff] [blame] | 223 | } |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 224 | |
Xinliang David Li | 9e588d8 | 2016-06-22 19:26:44 +0000 | [diff] [blame] | 225 | Optional<uint64_t> MachineBlockFrequencyInfo::getBlockProfileCount( |
| 226 | const MachineBasicBlock *MBB) const { |
Matthias Braun | d318139 | 2017-12-15 22:22:58 +0000 | [diff] [blame] | 227 | const Function &F = MBFI->getFunction()->getFunction(); |
| 228 | return MBFI ? MBFI->getBlockProfileCount(F, MBB) : None; |
Xinliang David Li | 9e588d8 | 2016-06-22 19:26:44 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Sean Silva | e9e0746 | 2016-08-02 02:15:45 +0000 | [diff] [blame] | 231 | Optional<uint64_t> |
| 232 | MachineBlockFrequencyInfo::getProfileCountFromFreq(uint64_t Freq) const { |
Matthias Braun | d318139 | 2017-12-15 22:22:58 +0000 | [diff] [blame] | 233 | const Function &F = MBFI->getFunction()->getFunction(); |
| 234 | return MBFI ? MBFI->getProfileCountFromFreq(F, Freq) : None; |
Sean Silva | e9e0746 | 2016-08-02 02:15:45 +0000 | [diff] [blame] | 235 | } |
| 236 | |
Hiroshi Yamauchi | dd33e17 | 2017-11-02 22:26:51 +0000 | [diff] [blame] | 237 | bool |
| 238 | MachineBlockFrequencyInfo::isIrrLoopHeader(const MachineBasicBlock *MBB) { |
| 239 | assert(MBFI && "Expected analysis to be available"); |
| 240 | return MBFI->isIrrLoopHeader(MBB); |
| 241 | } |
| 242 | |
Duncan P. N. Exon Smith | 8451e1b | 2014-03-25 18:01:32 +0000 | [diff] [blame] | 243 | const MachineFunction *MachineBlockFrequencyInfo::getFunction() const { |
Duncan P. N. Exon Smith | 9a11d66 | 2014-04-21 17:57:07 +0000 | [diff] [blame] | 244 | return MBFI ? MBFI->getFunction() : nullptr; |
Michael Gottesman | eae8ef4 | 2013-12-03 00:49:33 +0000 | [diff] [blame] | 245 | } |
Michael Gottesman | a73959a | 2013-12-14 00:06:03 +0000 | [diff] [blame] | 246 | |
Xinliang David Li | 2aa8ecf | 2016-06-28 00:15:45 +0000 | [diff] [blame] | 247 | const MachineBranchProbabilityInfo *MachineBlockFrequencyInfo::getMBPI() const { |
| 248 | return MBFI ? &MBFI->getBPI() : nullptr; |
| 249 | } |
| 250 | |
Michael Gottesman | a73959a | 2013-12-14 00:06:03 +0000 | [diff] [blame] | 251 | raw_ostream & |
| 252 | MachineBlockFrequencyInfo::printBlockFreq(raw_ostream &OS, |
| 253 | const BlockFrequency Freq) const { |
Duncan P. N. Exon Smith | 27e1ca8 | 2014-03-25 18:01:38 +0000 | [diff] [blame] | 254 | return MBFI ? MBFI->printBlockFreq(OS, Freq) : OS; |
Michael Gottesman | a73959a | 2013-12-14 00:06:03 +0000 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | raw_ostream & |
| 258 | MachineBlockFrequencyInfo::printBlockFreq(raw_ostream &OS, |
| 259 | const MachineBasicBlock *MBB) const { |
Duncan P. N. Exon Smith | 27e1ca8 | 2014-03-25 18:01:38 +0000 | [diff] [blame] | 260 | return MBFI ? MBFI->printBlockFreq(OS, MBB) : OS; |
Michael Gottesman | a73959a | 2013-12-14 00:06:03 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Michael Gottesman | 523823b | 2013-12-14 02:37:38 +0000 | [diff] [blame] | 263 | uint64_t MachineBlockFrequencyInfo::getEntryFreq() const { |
Duncan P. N. Exon Smith | 27e1ca8 | 2014-03-25 18:01:38 +0000 | [diff] [blame] | 264 | return MBFI ? MBFI->getEntryFreq() : 0; |
Michael Gottesman | a73959a | 2013-12-14 00:06:03 +0000 | [diff] [blame] | 265 | } |