LLVM  15.0.0git
BlockFrequencyInfo.cpp
Go to the documentation of this file.
1 //===- BlockFrequencyInfo.cpp - Block Frequency Analysis ------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Loops should be simplified before this analysis.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/APInt.h"
15 #include "llvm/ADT/None.h"
16 #include "llvm/ADT/iterator.h"
19 #include "llvm/Analysis/LoopInfo.h"
20 #include "llvm/IR/CFG.h"
21 #include "llvm/IR/Function.h"
22 #include "llvm/IR/PassManager.h"
23 #include "llvm/InitializePasses.h"
24 #include "llvm/Pass.h"
28 #include <cassert>
29 #include <string>
30 
31 using namespace llvm;
32 
33 #define DEBUG_TYPE "block-freq"
34 
36  "view-block-freq-propagation-dags", cl::Hidden,
37  cl::desc("Pop up a window to show a dag displaying how block "
38  "frequencies propagation through the CFG."),
39  cl::values(clEnumValN(GVDT_None, "none", "do not display graphs."),
40  clEnumValN(GVDT_Fraction, "fraction",
41  "display a graph using the "
42  "fractional block frequency representation."),
43  clEnumValN(GVDT_Integer, "integer",
44  "display a graph using the raw "
45  "integer fractional block frequency representation."),
46  clEnumValN(GVDT_Count, "count", "display a graph using the real "
47  "profile count if available.")));
48 
49 namespace llvm {
51  ViewBlockFreqFuncName("view-bfi-func-name", cl::Hidden,
52  cl::desc("The option to specify "
53  "the name of the function "
54  "whose CFG will be displayed."));
55 
57  ViewHotFreqPercent("view-hot-freq-percent", cl::init(10), cl::Hidden,
58  cl::desc("An integer in percent used to specify "
59  "the hot blocks/edges to be displayed "
60  "in red: a block or edge whose frequency "
61  "is no less than the max frequency of the "
62  "function multiplied by this percent."));
63 
64 // Command line option to turn on CFG dot or text dump after profile annotation.
66  "pgo-view-counts", cl::Hidden,
67  cl::desc("A boolean option to show CFG dag or text with "
68  "block profile counts and branch probabilities "
69  "right after PGO profile annotation step. The "
70  "profile counts are computed using branch "
71  "probabilities from the runtime profile data and "
72  "block frequency propagation algorithm. To view "
73  "the raw counts from the profile, use option "
74  "-pgo-view-raw-counts instead. To limit graph "
75  "display to only one function, use filtering option "
76  "-view-bfi-func-name."),
77  cl::values(clEnumValN(PGOVCT_None, "none", "do not show."),
78  clEnumValN(PGOVCT_Graph, "graph", "show a graph."),
79  clEnumValN(PGOVCT_Text, "text", "show in text.")));
80 
82  "print-bfi", cl::init(false), cl::Hidden,
83  cl::desc("Print the block frequency info."));
84 
86  "print-bfi-func-name", cl::Hidden,
87  cl::desc("The option to specify the name of the function "
88  "whose block frequency info is printed."));
89 } // namespace llvm
90 
91 namespace llvm {
92 
93 static GVDAGType getGVDT() {
95  return GVDT_Count;
97 }
98 
99 template <>
101  using NodeRef = const BasicBlock *;
104 
106  return &G->getFunction()->front();
107  }
108 
110  return succ_begin(N);
111  }
112 
113  static ChildIteratorType child_end(const NodeRef N) { return succ_end(N); }
114 
116  return nodes_iterator(G->getFunction()->begin());
117  }
118 
120  return nodes_iterator(G->getFunction()->end());
121  }
122 };
123 
124 using BFIDOTGTraitsBase =
126 
127 template <>
129  explicit DOTGraphTraits(bool isSimple = false)
131 
132  std::string getNodeLabel(const BasicBlock *Node,
133  const BlockFrequencyInfo *Graph) {
134 
135  return BFIDOTGTraitsBase::getNodeLabel(Node, Graph, getGVDT());
136  }
137 
138  std::string getNodeAttributes(const BasicBlock *Node,
139  const BlockFrequencyInfo *Graph) {
140  return BFIDOTGTraitsBase::getNodeAttributes(Node, Graph,
142  }
143 
144  std::string getEdgeAttributes(const BasicBlock *Node, EdgeIter EI,
145  const BlockFrequencyInfo *BFI) {
146  return BFIDOTGTraitsBase::getEdgeAttributes(Node, EI, BFI, BFI->getBPI(),
148  }
149 };
150 
151 } // end namespace llvm
152 
154 
156  const BranchProbabilityInfo &BPI,
157  const LoopInfo &LI) {
158  calculate(F, BPI, LI);
159 }
160 
162  : BFI(std::move(Arg.BFI)) {}
163 
165  releaseMemory();
166  BFI = std::move(RHS.BFI);
167  return *this;
168 }
169 
170 // Explicitly define the default constructor otherwise it would be implicitly
171 // defined at the first ODR-use which is the BFI member in the
172 // LazyBlockFrequencyInfo header. The dtor needs the BlockFrequencyInfoImpl
173 // template instantiated which is not available in the header.
175 
178  // Check whether the analysis, all analyses on functions, or the function's
179  // CFG have been preserved.
180  auto PAC = PA.getChecker<BlockFrequencyAnalysis>();
181  return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
182  PAC.preservedSet<CFGAnalyses>());
183 }
184 
186  const BranchProbabilityInfo &BPI,
187  const LoopInfo &LI) {
188  if (!BFI)
189  BFI.reset(new ImplType);
190  BFI->calculate(F, BPI, LI);
192  (ViewBlockFreqFuncName.empty() ||
193  F.getName().equals(ViewBlockFreqFuncName))) {
194  view();
195  }
196  if (PrintBlockFreq &&
197  (PrintBlockFreqFuncName.empty() ||
198  F.getName().equals(PrintBlockFreqFuncName))) {
199  print(dbgs());
200  }
201 }
202 
204  return BFI ? BFI->getBlockFreq(BB) : 0;
205 }
206 
209  bool AllowSynthetic) const {
210  if (!BFI)
211  return None;
212 
213  return BFI->getBlockProfileCount(*getFunction(), BB, AllowSynthetic);
214 }
215 
218  if (!BFI)
219  return None;
220  return BFI->getProfileCountFromFreq(*getFunction(), Freq);
221 }
222 
224  assert(BFI && "Expected analysis to be available");
225  return BFI->isIrrLoopHeader(BB);
226 }
227 
229  assert(BFI && "Expected analysis to be available");
230  BFI->setBlockFreq(BB, Freq);
231 }
232 
234  const BasicBlock *ReferenceBB, uint64_t Freq,
235  SmallPtrSetImpl<BasicBlock *> &BlocksToScale) {
236  assert(BFI && "Expected analysis to be available");
237  // Use 128 bits APInt to avoid overflow.
238  APInt NewFreq(128, Freq);
239  APInt OldFreq(128, BFI->getBlockFreq(ReferenceBB).getFrequency());
240  APInt BBFreq(128, 0);
241  for (auto *BB : BlocksToScale) {
242  BBFreq = BFI->getBlockFreq(BB).getFrequency();
243  // Multiply first by NewFreq and then divide by OldFreq
244  // to minimize loss of precision.
245  BBFreq *= NewFreq;
246  // udiv is an expensive operation in the general case. If this ends up being
247  // a hot spot, one of the options proposed in
248  // https://reviews.llvm.org/D28535#650071 could be used to avoid this.
249  BBFreq = BBFreq.udiv(OldFreq);
250  BFI->setBlockFreq(BB, BBFreq.getLimitedValue());
251  }
252  BFI->setBlockFreq(ReferenceBB, Freq);
253 }
254 
255 /// Pop up a ghostview window with the current block frequency propagation
256 /// rendered using dot.
258  ViewGraph(const_cast<BlockFrequencyInfo *>(this), title);
259 }
260 
262  return BFI ? BFI->getFunction() : nullptr;
263 }
264 
266  return BFI ? &BFI->getBPI() : nullptr;
267 }
268 
270 printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const {
271  return BFI ? BFI->printBlockFreq(OS, Freq) : OS;
272 }
273 
274 raw_ostream &
276  const BasicBlock *BB) const {
277  return BFI ? BFI->printBlockFreq(OS, BB) : OS;
278 }
279 
281  return BFI ? BFI->getEntryFreq() : 0;
282 }
283 
285 
287  if (BFI)
288  BFI->print(OS);
289 }
290 
292  if (BFI)
293  BFI->verifyMatch(*Other.BFI);
294 }
295 
297  "Block Frequency Analysis", true, true)
301  "Block Frequency Analysis", true, true)
302 
304 
306  : FunctionPass(ID) {
308 }
309 
311 
313  const Module *) const {
314  BFI.print(OS);
315 }
316 
320  AU.setPreservesAll();
321 }
322 
324 
326  BranchProbabilityInfo &BPI =
327  getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI();
328  LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
329  BFI.calculate(F, BPI, LI);
330  return false;
331 }
332 
337  BFI.calculate(F, AM.getResult<BranchProbabilityAnalysis>(F),
338  AM.getResult<LoopAnalysis>(F));
339  return BFI;
340 }
341 
344  OS << "Printing analysis results of BFI for function "
345  << "'" << F.getName() << "':"
346  << "\n";
348  return PreservedAnalyses::all();
349 }
llvm::SuccIterator
Definition: CFG.h:138
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
block
we get the following basic block
Definition: README_ALTIVEC.txt:95
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::ViewHotFreqPercent
cl::opt< unsigned > ViewHotFreqPercent("view-hot-freq-percent", cl::init(10), cl::Hidden, cl::desc("An integer in percent used to specify " "the hot blocks/edges to be displayed " "in red: a block or edge whose frequency " "is no less than the max frequency of the " "function multiplied by this percent."))
Definition: MachineBlockFrequencyInfo.cpp:70
llvm::DOTGraphTraits< BlockFrequencyInfo * >::getNodeLabel
std::string getNodeLabel(const BasicBlock *Node, const BlockFrequencyInfo *Graph)
Definition: BlockFrequencyInfo.cpp:132
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition: ArchiveWriter.cpp:189
llvm::BlockFrequencyInfo::print
void print(raw_ostream &OS) const
Definition: BlockFrequencyInfo.cpp:286
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:780
llvm::succ_end
Interval::succ_iterator succ_end(Interval *I)
Definition: Interval.h:102
llvm::Function
Definition: Function.h:60
Pass.h
llvm::BlockFrequencyInfoWrapperPass
Legacy analysis pass which computes BlockFrequencyInfo.
Definition: BlockFrequencyInfo.h:138
llvm::GraphTraits< BlockFrequencyInfo * >::child_begin
static ChildIteratorType child_begin(const NodeRef N)
Definition: BlockFrequencyInfo.cpp:109
true
block Block Frequency true
Definition: BlockFrequencyInfo.cpp:301
llvm::AllAnalysesOn
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
Definition: PassManager.h:90
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
APInt.h
llvm::BlockFrequencyInfo::view
void view(StringRef="BlockFrequencyDAGs") const
Pop up a ghostview window with the current block frequency propagation rendered using dot.
Definition: BlockFrequencyInfo.cpp:257
llvm::GraphTraits< BlockFrequencyInfo * >::getEntryNode
static NodeRef getEntryNode(const BlockFrequencyInfo *G)
Definition: BlockFrequencyInfo.cpp:105
llvm::LoopInfoWrapperPass
The legacy pass manager's analysis pass to compute loop information.
Definition: LoopInfo.h:1271
llvm::BlockFrequencyInfoWrapperPass::~BlockFrequencyInfoWrapperPass
~BlockFrequencyInfoWrapperPass() override
llvm::Optional< uint64_t >
llvm::BlockFrequencyInfoWrapperPass::runOnFunction
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Definition: BlockFrequencyInfo.cpp:325
llvm::ViewGraph
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
Definition: GraphWriter.h:427
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::PGOVCT_Text
@ PGOVCT_Text
Definition: BlockFrequencyInfo.h:33
freq
block freq
Definition: BlockFrequencyInfo.cpp:300
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:186
llvm::BFIDOTGraphTraitsBase::getNodeLabel
std::string getNodeLabel(NodeRef Node, const BlockFrequencyInfoT *Graph, GVDAGType GType, int layout_order=-1)
Definition: BlockFrequencyInfoImpl.h:1853
CommandLine.h
llvm::BlockFrequencyInfo::getEntryFreq
uint64_t getEntryFreq() const
Definition: BlockFrequencyInfo.cpp:280
llvm::PGOVCT_Graph
@ PGOVCT_Graph
Definition: BlockFrequencyInfo.h:33
llvm::BranchProbabilityAnalysis
Analysis pass which computes BranchProbabilityInfo.
Definition: BranchProbabilityInfo.h:412
llvm::GVDT_Fraction
@ GVDT_Fraction
Definition: BlockFrequencyInfoImpl.h:1805
llvm::BlockFrequencyInfo
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Definition: BlockFrequencyInfo.h:37
BlockFrequencyInfoImpl.h
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::BranchProbabilityInfoWrapperPass
Legacy analysis pass which computes BranchProbabilityInfo.
Definition: BranchProbabilityInfo.h:438
llvm::BlockFrequencyInfo::getProfileCountFromFreq
Optional< uint64_t > getProfileCountFromFreq(uint64_t Freq) const
Returns the estimated profile count of Freq.
Definition: BlockFrequencyInfo.cpp:217
llvm::BranchProbabilityInfo
Analysis providing branch probability information.
Definition: BranchProbabilityInfo.h:113
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
llvm::APInt::getLimitedValue
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
Definition: APInt.h:456
llvm::BlockFrequencyInfo::setBlockFreq
void setBlockFreq(const BasicBlock *BB, uint64_t Freq)
Definition: BlockFrequencyInfo.cpp:228
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::PrintBlockFreqFuncName
cl::opt< std::string > PrintBlockFreqFuncName("print-bfi-func-name", cl::Hidden, cl::desc("The option to specify the name of the function " "whose block frequency info is printed."))
Definition: MachineBlockFrequencyInfo.cpp:78
llvm::BFIDOTGraphTraitsBase::getEdgeAttributes
std::string getEdgeAttributes(NodeRef Node, EdgeIter EI, const BlockFrequencyInfoT *BFI, const BranchProbabilityInfoT *BPI, unsigned HotPercentThreshold=0)
Definition: BlockFrequencyInfoImpl.h:1884
llvm::BlockFrequencyInfo::releaseMemory
void releaseMemory()
Definition: BlockFrequencyInfo.cpp:284
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:667
llvm::BlockFrequencyInfo::printBlockFreq
raw_ostream & printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const
Definition: BlockFrequencyInfo.cpp:270
llvm::BlockFrequencyAnalysis
Analysis pass which computes BlockFrequencyInfo.
Definition: BlockFrequencyInfo.h:112
llvm::None
const NoneType None
Definition: None.h:24
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
CFG.h
LoopInfo.h
llvm::DOTGraphTraits
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
Definition: DOTGraphTraits.h:166
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::pointer_iterator
Definition: iterator.h:344
llvm::cl::opt
Definition: CommandLine.h:1392
llvm::BlockFrequency
Definition: BlockFrequency.h:23
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:685
BranchProbabilityInfo.h
llvm::PGOViewCounts
cl::opt< PGOViewCountsType > PGOViewCounts("pgo-view-counts", cl::Hidden, cl::desc("A boolean option to show CFG dag or text with " "block profile counts and branch probabilities " "right after PGO profile annotation step. The " "profile counts are computed using branch " "probabilities from the runtime profile data and " "block frequency propagation algorithm. To view " "the raw counts from the profile, use option " "-pgo-view-raw-counts instead. To limit graph " "display to only one function, use filtering option " "-view-bfi-func-name."), cl::values(clEnumValN(PGOVCT_None, "none", "do not show."), clEnumValN(PGOVCT_Graph, "graph", "show a graph."), clEnumValN(PGOVCT_Text, "text", "show in text.")))
Definition: PGOInstrumentation.cpp:293
uint64_t
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(BlockFrequencyInfoWrapperPass, "block-freq", "Block Frequency Analysis", true, true) INITIALIZE_PASS_END(BlockFrequencyInfoWrapperPass
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::BlockFrequencyInfo::~BlockFrequencyInfo
~BlockFrequencyInfo()
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
iterator.h
ViewBlockFreqPropagationDAG
static cl::opt< GVDAGType > ViewBlockFreqPropagationDAG("view-block-freq-propagation-dags", cl::Hidden, cl::desc("Pop up a window to show a dag displaying how block " "frequencies propagation through the CFG."), cl::values(clEnumValN(GVDT_None, "none", "do not display graphs."), clEnumValN(GVDT_Fraction, "fraction", "display a graph using the " "fractional block frequency representation."), clEnumValN(GVDT_Integer, "integer", "display a graph using the raw " "integer fractional block frequency representation."), clEnumValN(GVDT_Count, "count", "display a graph using the real " "profile count if available.")))
llvm::PrintBlockFreq
static cl::opt< bool > PrintBlockFreq("print-bfi", cl::init(false), cl::Hidden, cl::desc("Print the block frequency info."))
llvm::succ_begin
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:99
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
llvm::BlockFrequencyInfo::operator=
BlockFrequencyInfo & operator=(const BlockFrequencyInfo &)=delete
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1665
llvm::PGOVCT_None
@ PGOVCT_None
Definition: BlockFrequencyInfo.h:33
llvm::BFIDOTGraphTraitsBase::EdgeIter
typename GTraits::ChildIteratorType EdgeIter
Definition: BlockFrequencyInfoImpl.h:1811
llvm::BlockFrequencyInfo::isIrrLoopHeader
bool isIrrLoopHeader(const BasicBlock *BB)
Returns true if BB is an irreducible loop header block.
Definition: BlockFrequencyInfo.cpp:223
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::GVDT_Integer
@ GVDT_Integer
Definition: BlockFrequencyInfoImpl.h:1805
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::BFIDOTGraphTraitsBase::getNodeAttributes
std::string getNodeAttributes(NodeRef Node, const BlockFrequencyInfoT *Graph, unsigned HotPercentThreshold=0)
Definition: BlockFrequencyInfoImpl.h:1823
llvm::BlockFrequencyInfo::calculate
void calculate(const Function &F, const BranchProbabilityInfo &BPI, const LoopInfo &LI)
calculate - compute block frequency info for the given function.
Definition: BlockFrequencyInfo.cpp:185
llvm::LoopInfo
Definition: LoopInfo.h:1086
None.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::CFGAnalyses
Represents analyses that only rely on functions' control flow.
Definition: PassManager.h:113
llvm::GraphTraits< BlockFrequencyInfo * >::child_end
static ChildIteratorType child_end(const NodeRef N)
Definition: BlockFrequencyInfo.cpp:113
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:660
BlockFrequencyInfo.h
llvm::AMDGPUISD::BFI
@ BFI
Definition: AMDGPUISelLowering.h:429
llvm::APInt::udiv
APInt udiv(const APInt &RHS) const
Unsigned division operation.
Definition: APInt.cpp:1589
Analysis
block Block Frequency Analysis
Definition: BlockFrequencyInfo.cpp:301
llvm::BlockFrequencyInfo::invalidate
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
Definition: BlockFrequencyInfo.cpp:176
llvm::BlockFrequencyInfo::setBlockFreqAndScale
void setBlockFreqAndScale(const BasicBlock *ReferenceBB, uint64_t Freq, SmallPtrSetImpl< BasicBlock * > &BlocksToScale)
Set the frequency of ReferenceBB to Freq and scale the frequencies of the blocks in BlocksToScale suc...
Definition: BlockFrequencyInfo.cpp:233
llvm::DOTGraphTraits< BlockFrequencyInfo * >::getNodeAttributes
std::string getNodeAttributes(const BasicBlock *Node, const BlockFrequencyInfo *Graph)
Definition: BlockFrequencyInfo.cpp:138
GraphWriter.h
std
Definition: BitVector.h:851
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
llvm::DOTGraphTraits< BlockFrequencyInfo * >::DOTGraphTraits
DOTGraphTraits(bool isSimple=false)
Definition: BlockFrequencyInfo.cpp:129
Function.h
llvm::BlockFrequencyAnalysis::run
Result run(Function &F, FunctionAnalysisManager &AM)
Run the analysis pass over a function and produce BFI.
Definition: BlockFrequencyInfo.cpp:334
llvm::GraphTraits< BlockFrequencyInfo * >::nodes_begin
static nodes_iterator nodes_begin(const BlockFrequencyInfo *G)
Definition: BlockFrequencyInfo.cpp:115
llvm::BFIDOTGraphTraitsBase
Definition: BlockFrequencyInfoImpl.h:1808
PassManager.h
llvm::DOTGraphTraits< BlockFrequencyInfo * >::getEdgeAttributes
std::string getEdgeAttributes(const BasicBlock *Node, EdgeIter EI, const BlockFrequencyInfo *BFI)
Definition: BlockFrequencyInfo.cpp:144
llvm::BlockFrequencyInfo::getBPI
const BranchProbabilityInfo * getBPI() const
Definition: BlockFrequencyInfo.cpp:265
llvm::BlockFrequencyInfoWrapperPass::print
void print(raw_ostream &OS, const Module *M) const override
print - Print out the internal state of the pass.
Definition: BlockFrequencyInfo.cpp:312
isSimple
static bool isSimple(Instruction *I)
Definition: SLPVectorizer.cpp:664
llvm::BlockFrequencyInfo::getBlockFreq
BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.
Definition: BlockFrequencyInfo.cpp:203
llvm::GVDT_Count
@ GVDT_Count
Definition: BlockFrequencyInfoImpl.h:1805
llvm::getGVDT
static GVDAGType getGVDT()
Definition: BlockFrequencyInfo.cpp:93
llvm::BlockFrequencyInfo::getFunction
const Function * getFunction() const
Definition: BlockFrequencyInfo.cpp:261
llvm::GVDT_None
@ GVDT_None
Definition: BlockFrequencyInfoImpl.h:1805
llvm::BlockFrequencyInfo::getBlockProfileCount
Optional< uint64_t > getBlockProfileCount(const BasicBlock *BB, bool AllowSynthetic=false) const
Returns the estimated profile count of BB.
Definition: BlockFrequencyInfo.cpp:208
llvm::BlockFrequencyInfoWrapperPass::releaseMemory
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition: BlockFrequencyInfo.cpp:323
N
#define N
llvm::BlockFrequencyInfo::BlockFrequencyInfo
BlockFrequencyInfo()
llvm::BlockFrequencyInfo::verifyMatch
void verifyMatch(BlockFrequencyInfo &Other) const
Definition: BlockFrequencyInfo.cpp:291
llvm::BlockFrequencyInfoImpl
Shared implementation for block frequency analysis.
Definition: BlockFrequencyInfo.h:31
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:344
llvm::PreservedAnalyses::getChecker
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition: PassManager.h:310
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
llvm::GraphTraits< BlockFrequencyInfo * >::nodes_end
static nodes_iterator nodes_end(const BlockFrequencyInfo *G)
Definition: BlockFrequencyInfo.cpp:119
llvm::initializeBlockFrequencyInfoWrapperPassPass
void initializeBlockFrequencyInfoWrapperPassPass(PassRegistry &)
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::ViewBlockFreqFuncName
cl::opt< std::string > ViewBlockFreqFuncName("view-bfi-func-name", cl::Hidden, cl::desc("The option to specify " "the name of the function " "whose CFG will be displayed."))
Definition: MachineBlockFrequencyInfo.cpp:66
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::GraphTraits
Definition: GraphTraits.h:37
llvm::const_succ_iterator
SuccIterator< const Instruction, const BasicBlock > const_succ_iterator
Definition: CFG.h:243
llvm::cl::desc
Definition: CommandLine.h:405
raw_ostream.h
llvm::BlockFrequencyPrinterPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: BlockFrequencyInfo.cpp:343
llvm::BlockFrequencyInfoWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: BlockFrequencyInfo.cpp:317
InitializePasses.h
llvm::LoopAnalysis
Analysis pass that exposes the LoopInfo for a function.
Definition: LoopInfo.h:1246
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1225
llvm::GVDAGType
GVDAGType
Definition: BlockFrequencyInfoImpl.h:1805