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