Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
BranchProbabilityInfo.h
Go to the documentation of this file.
1//===- BranchProbabilityInfo.h - Branch Probability Analysis ----*- C++ -*-===//
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// This pass is used to evaluate branch probabilties.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_ANALYSIS_BRANCHPROBABILITYINFO_H
14#define LLVM_ANALYSIS_BRANCHPROBABILITYINFO_H
15
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/ADT/DenseMapInfo.h"
18#include "llvm/ADT/DenseSet.h"
19#include "llvm/IR/BasicBlock.h"
20#include "llvm/IR/CFG.h"
21#include "llvm/IR/PassManager.h"
22#include "llvm/IR/ValueHandle.h"
23#include "llvm/Pass.h"
24#include "llvm/Support/BranchProbability.h"
25#include <cassert>
26#include <cstdint>
27#include <memory>
28#include <utility>
29
30namespacellvm {
31
32classFunction;
33classLoop;
34classLoopInfo;
35classraw_ostream;
36classDominatorTree;
37classPostDominatorTree;
38classTargetLibraryInfo;
39classValue;
40
41/// Analysis providing branch probability information.
42///
43/// This is a function analysis which provides information on the relative
44/// probabilities of each "edge" in the function's CFG where such an edge is
45/// defined by a pair (PredBlock and an index in the successors). The
46/// probability of an edge from one block is always relative to the
47/// probabilities of other edges from the block. The probabilites of all edges
48/// from a block sum to exactly one (100%).
49/// We use a pair (PredBlock and an index in the successors) to uniquely
50/// identify an edge, since we can have multiple edges from Src to Dst.
51/// As an example, we can have a switch which jumps to Dst with value 0 and
52/// value 10.
53///
54/// Process of computing branch probabilities can be logically viewed as three
55/// step process:
56///
57/// First, if there is a profile information associated with the branch then
58/// it is trivially translated to branch probabilities. There is one exception
59/// from this rule though. Probabilities for edges leading to "unreachable"
60/// blocks (blocks with the estimated weight not greater than
61/// UNREACHABLE_WEIGHT) are evaluated according to static estimation and
62/// override profile information. If no branch probabilities were calculated
63/// on this step then take the next one.
64///
65/// Second, estimate absolute execution weights for each block based on
66/// statically known information. Roots of such information are "cold",
67/// "unreachable", "noreturn" and "unwind" blocks. Those blocks get their
68/// weights set to BlockExecWeight::COLD, BlockExecWeight::UNREACHABLE,
69/// BlockExecWeight::NORETURN and BlockExecWeight::UNWIND respectively. Then the
70/// weights are propagated to the other blocks up the domination line. In
71/// addition, if all successors have estimated weights set then maximum of these
72/// weights assigned to the block itself (while this is not ideal heuristic in
73/// theory it's simple and works reasonably well in most cases) and the process
74/// repeats. Once the process of weights propagation converges branch
75/// probabilities are set for all such branches that have at least one successor
76/// with the weight set. Default execution weight (BlockExecWeight::DEFAULT) is
77/// used for any successors which doesn't have its weight set. For loop back
78/// branches we use their weights scaled by loop trip count equal to
79/// 'LBH_TAKEN_WEIGHT/LBH_NOTTAKEN_WEIGHT'.
80///
81/// Here is a simple example demonstrating how the described algorithm works.
82///
83/// BB1
84/// / \
85/// v v
86/// BB2 BB3
87/// / \
88/// v v
89/// ColdBB UnreachBB
90///
91/// Initially, ColdBB is associated with COLD_WEIGHT and UnreachBB with
92/// UNREACHABLE_WEIGHT. COLD_WEIGHT is set to BB2 as maximum between its
93/// successors. BB1 and BB3 has no explicit estimated weights and assumed to
94/// have DEFAULT_WEIGHT. Based on assigned weights branches will have the
95/// following probabilities:
96/// P(BB1->BB2) = COLD_WEIGHT/(COLD_WEIGHT + DEFAULT_WEIGHT) =
97/// 0xffff / (0xffff + 0xfffff) = 0.0588(5.9%)
98/// P(BB1->BB3) = DEFAULT_WEIGHT_WEIGHT/(COLD_WEIGHT + DEFAULT_WEIGHT) =
99/// 0xfffff / (0xffff + 0xfffff) = 0.941(94.1%)
100/// P(BB2->ColdBB) = COLD_WEIGHT/(COLD_WEIGHT + UNREACHABLE_WEIGHT) = 1(100%)
101/// P(BB2->UnreachBB) =
102/// UNREACHABLE_WEIGHT/(COLD_WEIGHT+UNREACHABLE_WEIGHT) = 0(0%)
103///
104/// If no branch probabilities were calculated on this step then take the next
105/// one.
106///
107/// Third, apply different kinds of local heuristics for each individual
108/// branch until first match. For example probability of a pointer to be null is
109/// estimated as PH_TAKEN_WEIGHT/(PH_TAKEN_WEIGHT + PH_NONTAKEN_WEIGHT). If
110/// no local heuristic has been matched then branch is left with no explicit
111/// probability set and assumed to have default probability.
112classBranchProbabilityInfo {
113public:
114BranchProbabilityInfo() =default;
115
116BranchProbabilityInfo(constFunction &F,constLoopInfo &LI,
117constTargetLibraryInfo *TLI =nullptr,
118DominatorTree *DT =nullptr,
119PostDominatorTree *PDT =nullptr) {
120calculate(F, LI, TLI, DT, PDT);
121 }
122
123BranchProbabilityInfo(BranchProbabilityInfo &&Arg)
124 : Handles(std::move(Arg.Handles)), Probs(std::move(Arg.Probs)),
125 LastF(Arg.LastF),
126 EstimatedBlockWeight(std::move(Arg.EstimatedBlockWeight)) {
127for (auto &Handle : Handles)
128 Handle.setBPI(this);
129 }
130
131BranchProbabilityInfo(constBranchProbabilityInfo &) =delete;
132BranchProbabilityInfo &operator=(constBranchProbabilityInfo &) =delete;
133
134BranchProbabilityInfo &operator=(BranchProbabilityInfo &&RHS) {
135releaseMemory();
136 Handles = std::move(RHS.Handles);
137 Probs = std::move(RHS.Probs);
138 EstimatedBlockWeight = std::move(RHS.EstimatedBlockWeight);
139for (auto &Handle : Handles)
140 Handle.setBPI(this);
141return *this;
142 }
143
144boolinvalidate(Function &,constPreservedAnalyses &PA,
145FunctionAnalysisManager::Invalidator &);
146
147voidreleaseMemory();
148
149voidprint(raw_ostream &OS)const;
150
151 /// Get an edge's probability, relative to other out-edges of the Src.
152 ///
153 /// This routine provides access to the fractional probability between zero
154 /// (0%) and one (100%) of this edge executing, relative to other edges
155 /// leaving the 'Src' block. The returned probability is never zero, and can
156 /// only be one if the source block has only one successor.
157BranchProbabilitygetEdgeProbability(constBasicBlock *Src,
158unsigned IndexInSuccessors)const;
159
160 /// Get the probability of going from Src to Dst.
161 ///
162 /// It returns the sum of all probabilities for edges from Src to Dst.
163BranchProbabilitygetEdgeProbability(constBasicBlock *Src,
164constBasicBlock *Dst)const;
165
166BranchProbabilitygetEdgeProbability(constBasicBlock *Src,
167const_succ_iterator Dst)const;
168
169 /// Test if an edge is hot relative to other out-edges of the Src.
170 ///
171 /// Check whether this edge out of the source block is 'hot'. We define hot
172 /// as having a relative probability > 80%.
173boolisEdgeHot(constBasicBlock *Src,constBasicBlock *Dst)const;
174
175 /// Print an edge's probability.
176 ///
177 /// Retrieves an edge's probability similarly to \see getEdgeProbability, but
178 /// then prints that probability to the provided stream. That stream is then
179 /// returned.
180raw_ostream &printEdgeProbability(raw_ostream &OS,constBasicBlock *Src,
181constBasicBlock *Dst)const;
182
183public:
184 /// Set the raw probabilities for all edges from the given block.
185 ///
186 /// This allows a pass to explicitly set edge probabilities for a block. It
187 /// can be used when updating the CFG to update the branch probability
188 /// information.
189voidsetEdgeProbability(constBasicBlock *Src,
190constSmallVectorImpl<BranchProbability> &Probs);
191
192 /// Copy outgoing edge probabilities from \p Src to \p Dst.
193 ///
194 /// This allows to keep probabilities unset for the destination if they were
195 /// unset for source.
196voidcopyEdgeProbabilities(BasicBlock *Src,BasicBlock *Dst);
197
198 /// Swap outgoing edges probabilities for \p Src with branch terminator
199voidswapSuccEdgesProbabilities(constBasicBlock *Src);
200
201staticBranchProbabilitygetBranchProbStackProtector(bool IsLikely) {
202staticconstBranchProbability LikelyProb((1u << 20) - 1, 1u << 20);
203return IsLikely ? LikelyProb : LikelyProb.getCompl();
204 }
205
206voidcalculate(constFunction &F,constLoopInfo &LI,
207constTargetLibraryInfo *TLI,DominatorTree *DT,
208PostDominatorTree *PDT);
209
210 /// Forget analysis results for the given basic block.
211voideraseBlock(constBasicBlock *BB);
212
213// Data structure to track SCCs for handling irreducible loops.
214classSccInfo {
215// Enum of types to classify basic blocks in SCC. Basic block belonging to
216// SCC is 'Inner' until it is either 'Header' or 'Exiting'. Note that a
217// basic block can be 'Header' and 'Exiting' at the same time.
218enum SccBlockType {
219 Inner = 0x0,
220 Header = 0x1,
221 Exiting = 0x2,
222 };
223// Map of basic blocks to SCC IDs they belong to. If basic block doesn't
224// belong to any SCC it is not in the map.
225usingSccMap =DenseMap<const BasicBlock *, int>;
226// Each basic block in SCC is attributed with one or several types from
227// SccBlockType. Map value has uint32_t type (instead of SccBlockType)
228// since basic block may be for example "Header" and "Exiting" at the same
229// time and we need to be able to keep more than one value from
230// SccBlockType.
231usingSccBlockTypeMap =DenseMap<const BasicBlock *, uint32_t>;
232// Vector containing classification of basic blocks for all SCCs where i'th
233// vector element corresponds to SCC with ID equal to i.
234usingSccBlockTypeMaps = std::vector<SccBlockTypeMap>;
235
236SccMap SccNums;
237 SccBlockTypeMaps SccBlocks;
238
239public:
240explicitSccInfo(constFunction &F);
241
242 /// If \p BB belongs to some SCC then ID of that SCC is returned, otherwise
243 /// -1 is returned. If \p BB belongs to more than one SCC at the same time
244 /// result is undefined.
245intgetSCCNum(constBasicBlock *BB)const;
246 /// Returns true if \p BB is a 'header' block in SCC with \p SccNum ID,
247 /// false otherwise.
248boolisSCCHeader(constBasicBlock *BB,int SccNum) const{
249return getSccBlockType(BB, SccNum) & Header;
250 }
251 /// Returns true if \p BB is an 'exiting' block in SCC with \p SccNum ID,
252 /// false otherwise.
253boolisSCCExitingBlock(constBasicBlock *BB,int SccNum) const{
254return getSccBlockType(BB, SccNum) & Exiting;
255 }
256 /// Fills in \p Enters vector with all such blocks that don't belong to
257 /// SCC with \p SccNum ID but there is an edge to a block belonging to the
258 /// SCC.
259voidgetSccEnterBlocks(int SccNum,
260SmallVectorImpl<BasicBlock *> &Enters)const;
261 /// Fills in \p Exits vector with all such blocks that don't belong to
262 /// SCC with \p SccNum ID but there is an edge from a block belonging to the
263 /// SCC.
264voidgetSccExitBlocks(int SccNum,
265SmallVectorImpl<BasicBlock *> &Exits)const;
266
267private:
268 /// Returns \p BB's type according to classification given by SccBlockType
269 /// enum. Please note that \p BB must belong to SSC with \p SccNum ID.
270uint32_t getSccBlockType(constBasicBlock *BB,int SccNum)const;
271 /// Calculates \p BB's type and stores it in internal data structures for
272 /// future use. Please note that \p BB must belong to SSC with \p SccNum ID.
273void calculateSccBlockType(constBasicBlock *BB,int SccNum);
274 };
275
276private:
277// We need to store CallbackVH's in order to correctly handle basic block
278// removal.
279classBasicBlockCallbackVH final :publicCallbackVH {
280BranchProbabilityInfo *BPI;
281
282void deleted() override{
283assert(BPI !=nullptr);
284 BPI->eraseBlock(cast<BasicBlock>(getValPtr()));
285 }
286
287public:
288void setBPI(BranchProbabilityInfo *BPI) { this->BPI = BPI; }
289
290 BasicBlockCallbackVH(constValue *V,BranchProbabilityInfo *BPI =nullptr)
291 :CallbackVH(const_cast<Value *>(V)), BPI(BPI) {}
292 };
293
294 /// Pair of Loop and SCC ID number. Used to unify handling of normal and
295 /// SCC based loop representations.
296usingLoopData = std::pair<Loop *, int>;
297 /// Helper class to keep basic block along with its loop data information.
298classLoopBlock {
299public:
300explicit LoopBlock(const BasicBlock *BB,const LoopInfo &LI,
301const SccInfo &SccI);
302
303constBasicBlock *getBlock() const{return BB; }
304BasicBlock *getBlock() {returnconst_cast<BasicBlock *>(BB); }
305 LoopData getLoopData() const{returnLD; }
306 Loop *getLoop() const{returnLD.first; }
307int getSccNum() const{returnLD.second; }
308
309bool belongsToLoop() const{return getLoop() || getSccNum() != -1; }
310bool belongsToSameLoop(const LoopBlock &LB) const{
311return (LB.getLoop() && getLoop() == LB.getLoop()) ||
312 (LB.getSccNum() != -1 && getSccNum() == LB.getSccNum());
313 }
314
315private:
316constBasicBlock *const BB =nullptr;
317 LoopDataLD = {nullptr, -1};
318 };
319
320// Pair of LoopBlocks representing an edge from first to second block.
321usingLoopEdge = std::pair<const LoopBlock &, const LoopBlock &>;
322
323 DenseSet<BasicBlockCallbackVH, DenseMapInfo<Value*>> Handles;
324
325// Since we allow duplicate edges from one basic block to another, we use
326// a pair (PredBlock and an index in the successors) to specify an edge.
327usingEdge = std::pair<const BasicBlock *, unsigned>;
328
329 DenseMap<Edge, BranchProbability> Probs;
330
331 /// Track the last function we run over for printing.
332constFunction *LastF =nullptr;
333
334const LoopInfo *LI =nullptr;
335
336 /// Keeps information about all SCCs in a function.
337 std::unique_ptr<const SccInfo> SccI;
338
339 /// Keeps mapping of a basic block to its estimated weight.
340 SmallDenseMap<const BasicBlock *, uint32_t> EstimatedBlockWeight;
341
342 /// Keeps mapping of a loop to estimated weight to enter the loop.
343 SmallDenseMap<LoopData, uint32_t> EstimatedLoopWeight;
344
345 /// Helper to construct LoopBlock for \p BB.
346 LoopBlock getLoopBlock(const BasicBlock *BB) const{
347return LoopBlock(BB, *LI, *SccI);
348 }
349
350 /// Returns true if destination block belongs to some loop and source block is
351 /// either doesn't belong to any loop or belongs to a loop which is not inner
352 /// relative to the destination block.
353bool isLoopEnteringEdge(const LoopEdge &Edge)const;
354 /// Returns true if source block belongs to some loop and destination block is
355 /// either doesn't belong to any loop or belongs to a loop which is not inner
356 /// relative to the source block.
357bool isLoopExitingEdge(const LoopEdge &Edge)const;
358 /// Returns true if \p Edge is either enters to or exits from some loop, false
359 /// in all other cases.
360bool isLoopEnteringExitingEdge(const LoopEdge &Edge)const;
361 /// Returns true if source and destination blocks belongs to the same loop and
362 /// destination block is loop header.
363bool isLoopBackEdge(const LoopEdge &Edge)const;
364// Fills in \p Enters vector with all "enter" blocks to a loop \LB belongs to.
365void getLoopEnterBlocks(const LoopBlock &LB,
366 SmallVectorImpl<BasicBlock *> &Enters)const;
367// Fills in \p Exits vector with all "exit" blocks from a loop \LB belongs to.
368void getLoopExitBlocks(const LoopBlock &LB,
369 SmallVectorImpl<BasicBlock *> &Exits)const;
370
371 /// Returns estimated weight for \p BB. std::nullopt if \p BB has no estimated
372 /// weight.
373 std::optional<uint32_t> getEstimatedBlockWeight(const BasicBlock *BB)const;
374
375 /// Returns estimated weight to enter \p L. In other words it is weight of
376 /// loop's header block not scaled by trip count. Returns std::nullopt if \p L
377 /// has no no estimated weight.
378 std::optional<uint32_t> getEstimatedLoopWeight(const LoopData &L)const;
379
380 /// Return estimated weight for \p Edge. Returns std::nullopt if estimated
381 /// weight is unknown.
382 std::optional<uint32_t> getEstimatedEdgeWeight(const LoopEdge &Edge)const;
383
384 /// Iterates over all edges leading from \p SrcBB to \p Successors and
385 /// returns maximum of all estimated weights. If at least one edge has unknown
386 /// estimated weight std::nullopt is returned.
387template <class IterT>
388 std::optional<uint32_t>
389 getMaxEstimatedEdgeWeight(const LoopBlock &SrcBB,
390 iterator_range<IterT> Successors)const;
391
392 /// If \p LoopBB has no estimated weight then set it to \p BBWeight and
393 /// return true. Otherwise \p BB's weight remains unchanged and false is
394 /// returned. In addition all blocks/loops that might need their weight to be
395 /// re-estimated are put into BlockWorkList/LoopWorkList.
396bool updateEstimatedBlockWeight(LoopBlock &LoopBB,uint32_t BBWeight,
397 SmallVectorImpl<BasicBlock *> &BlockWorkList,
398 SmallVectorImpl<LoopBlock> &LoopWorkList);
399
400 /// Starting from \p LoopBB (including \p LoopBB itself) propagate \p BBWeight
401 /// up the domination tree.
402void propagateEstimatedBlockWeight(const LoopBlock &LoopBB, DominatorTree *DT,
403 PostDominatorTree *PDT,uint32_t BBWeight,
404 SmallVectorImpl<BasicBlock *> &WorkList,
405 SmallVectorImpl<LoopBlock> &LoopWorkList);
406
407 /// Returns block's weight encoded in the IR.
408 std::optional<uint32_t> getInitialEstimatedBlockWeight(const BasicBlock *BB);
409
410// Computes estimated weights for all blocks in \p F.
411void computeEestimateBlockWeight(const Function &F, DominatorTree *DT,
412 PostDominatorTree *PDT);
413
414 /// Based on computed weights by \p computeEstimatedBlockWeight set
415 /// probabilities on branches.
416bool calcEstimatedHeuristics(const BasicBlock *BB);
417bool calcMetadataWeights(const BasicBlock *BB);
418bool calcPointerHeuristics(const BasicBlock *BB);
419bool calcZeroHeuristics(const BasicBlock *BB,const TargetLibraryInfo *TLI);
420bool calcFloatingPointHeuristics(const BasicBlock *BB);
421};
422
423/// Analysis pass which computes \c BranchProbabilityInfo.
424classBranchProbabilityAnalysis
425 :publicAnalysisInfoMixin<BranchProbabilityAnalysis> {
426friendAnalysisInfoMixin<BranchProbabilityAnalysis>;
427
428staticAnalysisKey Key;
429
430public:
431 /// Provide the result type for this analysis pass.
432usingResult =BranchProbabilityInfo;
433
434 /// Run the analysis pass over a function and produce BPI.
435BranchProbabilityInforun(Function &F,FunctionAnalysisManager &AM);
436};
437
438/// Printer pass for the \c BranchProbabilityAnalysis results.
439classBranchProbabilityPrinterPass
440 :publicPassInfoMixin<BranchProbabilityPrinterPass> {
441raw_ostream &OS;
442
443public:
444explicitBranchProbabilityPrinterPass(raw_ostream &OS) :OS(OS) {}
445
446PreservedAnalysesrun(Function &F,FunctionAnalysisManager &AM);
447
448staticboolisRequired() {returntrue; }
449};
450
451/// Legacy analysis pass which computes \c BranchProbabilityInfo.
452classBranchProbabilityInfoWrapperPass :publicFunctionPass {
453BranchProbabilityInfo BPI;
454
455public:
456staticcharID;
457
458BranchProbabilityInfoWrapperPass();
459
460BranchProbabilityInfo &getBPI() {return BPI; }
461constBranchProbabilityInfo &getBPI() const{return BPI; }
462
463voidgetAnalysisUsage(AnalysisUsage &AU)const override;
464boolrunOnFunction(Function &F)override;
465voidreleaseMemory()override;
466voidprint(raw_ostream &OS,constModule *M =nullptr)const override;
467};
468
469}// end namespace llvm
470
471#endif// LLVM_ANALYSIS_BRANCHPROBABILITYINFO_H
BranchProbability.h
DenseMapInfo.h
This file defines DenseMapInfo traits for DenseMap.
DenseMap.h
This file defines the DenseMap class.
DenseSet.h
This file defines the DenseSet and SmallDenseSet classes.
BasicBlock.h
CFG.h
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
PassManager.h
This header defines various interfaces for pass management in LLVM.
F
#define F(x, y, z)
Definition:MD5.cpp:55
Pass.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
ValueHandle.h
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition:PassManager.h:292
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BranchProbabilityAnalysis
Analysis pass which computes BranchProbabilityInfo.
Definition:BranchProbabilityInfo.h:425
llvm::BranchProbabilityAnalysis::run
BranchProbabilityInfo run(Function &F, FunctionAnalysisManager &AM)
Run the analysis pass over a function and produce BPI.
Definition:BranchProbabilityInfo.cpp:1316
llvm::BranchProbabilityInfoWrapperPass
Legacy analysis pass which computes BranchProbabilityInfo.
Definition:BranchProbabilityInfo.h:452
llvm::BranchProbabilityInfoWrapperPass::releaseMemory
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition:BranchProbabilityInfo.cpp:1307
llvm::BranchProbabilityInfoWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition:BranchProbabilityInfo.cpp:1283
llvm::BranchProbabilityInfoWrapperPass::ID
static char ID
Definition:BranchProbabilityInfo.h:456
llvm::BranchProbabilityInfoWrapperPass::getBPI
const BranchProbabilityInfo & getBPI() const
Definition:BranchProbabilityInfo.h:461
llvm::BranchProbabilityInfoWrapperPass::BranchProbabilityInfoWrapperPass
BranchProbabilityInfoWrapperPass()
Definition:BranchProbabilityInfo.cpp:71
llvm::BranchProbabilityInfoWrapperPass::runOnFunction
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Definition:BranchProbabilityInfo.cpp:1296
llvm::BranchProbabilityInfoWrapperPass::print
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Definition:BranchProbabilityInfo.cpp:1309
llvm::BranchProbabilityInfoWrapperPass::getBPI
BranchProbabilityInfo & getBPI()
Definition:BranchProbabilityInfo.h:460
llvm::BranchProbabilityInfo::SccInfo
Definition:BranchProbabilityInfo.h:214
llvm::BranchProbabilityInfo::SccInfo::isSCCHeader
bool isSCCHeader(const BasicBlock *BB, int SccNum) const
Returns true if BB is a 'header' block in SCC with SccNum ID, false otherwise.
Definition:BranchProbabilityInfo.h:248
llvm::BranchProbabilityInfo::SccInfo::getSccEnterBlocks
void getSccEnterBlocks(int SccNum, SmallVectorImpl< BasicBlock * > &Enters) const
Fills in Enters vector with all such blocks that don't belong to SCC with SccNum ID but there is an e...
Definition:BranchProbabilityInfo.cpp:246
llvm::BranchProbabilityInfo::SccInfo::isSCCExitingBlock
bool isSCCExitingBlock(const BasicBlock *BB, int SccNum) const
Returns true if BB is an 'exiting' block in SCC with SccNum ID, false otherwise.
Definition:BranchProbabilityInfo.h:253
llvm::BranchProbabilityInfo::SccInfo::getSccExitBlocks
void getSccExitBlocks(int SccNum, SmallVectorImpl< BasicBlock * > &Exits) const
Fills in Exits vector with all such blocks that don't belong to SCC with SccNum ID but there is an ed...
Definition:BranchProbabilityInfo.cpp:258
llvm::BranchProbabilityInfo::SccInfo::getSCCNum
int getSCCNum(const BasicBlock *BB) const
If BB belongs to some SCC then ID of that SCC is returned, otherwise -1 is returned.
Definition:BranchProbabilityInfo.cpp:239
llvm::BranchProbabilityInfo
Analysis providing branch probability information.
Definition:BranchProbabilityInfo.h:112
llvm::BranchProbabilityInfo::eraseBlock
void eraseBlock(const BasicBlock *BB)
Forget analysis results for the given basic block.
Definition:BranchProbabilityInfo.cpp:1202
llvm::BranchProbabilityInfo::setEdgeProbability
void setEdgeProbability(const BasicBlock *Src, const SmallVectorImpl< BranchProbability > &Probs)
Set the raw probabilities for all edges from the given block.
Definition:BranchProbabilityInfo.cpp:1131
llvm::BranchProbabilityInfo::BranchProbabilityInfo
BranchProbabilityInfo(const BranchProbabilityInfo &)=delete
llvm::BranchProbabilityInfo::invalidate
bool invalidate(Function &, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Definition:BranchProbabilityInfo.cpp:1062
llvm::BranchProbabilityInfo::getEdgeProbability
BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
Definition:BranchProbabilityInfo.cpp:1094
llvm::BranchProbabilityInfo::getBranchProbStackProtector
static BranchProbability getBranchProbStackProtector(bool IsLikely)
Definition:BranchProbabilityInfo.h:201
llvm::BranchProbabilityInfo::calculate
void calculate(const Function &F, const LoopInfo &LI, const TargetLibraryInfo *TLI, DominatorTree *DT, PostDominatorTree *PDT)
Definition:BranchProbabilityInfo.cpp:1224
llvm::BranchProbabilityInfo::operator=
BranchProbabilityInfo & operator=(BranchProbabilityInfo &&RHS)
Definition:BranchProbabilityInfo.h:134
llvm::BranchProbabilityInfo::BranchProbabilityInfo
BranchProbabilityInfo()=default
llvm::BranchProbabilityInfo::releaseMemory
void releaseMemory()
Definition:BranchProbabilityInfo.cpp:1057
llvm::BranchProbabilityInfo::isEdgeHot
bool isEdgeHot(const BasicBlock *Src, const BasicBlock *Dst) const
Test if an edge is hot relative to other out-edges of the Src.
Definition:BranchProbabilityInfo.cpp:1083
llvm::BranchProbabilityInfo::swapSuccEdgesProbabilities
void swapSuccEdgesProbabilities(const BasicBlock *Src)
Swap outgoing edges probabilities for Src with branch terminator.
Definition:BranchProbabilityInfo.cpp:1177
llvm::BranchProbabilityInfo::BranchProbabilityInfo
BranchProbabilityInfo(BranchProbabilityInfo &&Arg)
Definition:BranchProbabilityInfo.h:123
llvm::BranchProbabilityInfo::print
void print(raw_ostream &OS) const
Definition:BranchProbabilityInfo.cpp:1071
llvm::BranchProbabilityInfo::BranchProbabilityInfo
BranchProbabilityInfo(const Function &F, const LoopInfo &LI, const TargetLibraryInfo *TLI=nullptr, DominatorTree *DT=nullptr, PostDominatorTree *PDT=nullptr)
Definition:BranchProbabilityInfo.h:116
llvm::BranchProbabilityInfo::operator=
BranchProbabilityInfo & operator=(const BranchProbabilityInfo &)=delete
llvm::BranchProbabilityInfo::printEdgeProbability
raw_ostream & printEdgeProbability(raw_ostream &OS, const BasicBlock *Src, const BasicBlock *Dst) const
Print an edge's probability.
Definition:BranchProbabilityInfo.cpp:1188
llvm::BranchProbabilityInfo::copyEdgeProbabilities
void copyEdgeProbabilities(BasicBlock *Src, BasicBlock *Dst)
Copy outgoing edge probabilities from Src to Dst.
Definition:BranchProbabilityInfo.cpp:1158
llvm::BranchProbabilityPrinterPass
Printer pass for the BranchProbabilityAnalysis results.
Definition:BranchProbabilityInfo.h:440
llvm::BranchProbabilityPrinterPass::BranchProbabilityPrinterPass
BranchProbabilityPrinterPass(raw_ostream &OS)
Definition:BranchProbabilityInfo.h:444
llvm::BranchProbabilityPrinterPass::isRequired
static bool isRequired()
Definition:BranchProbabilityInfo.h:448
llvm::BranchProbabilityPrinterPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition:BranchProbabilityInfo.cpp:1327
llvm::BranchProbability
Definition:BranchProbability.h:30
llvm::BranchProbability::getCompl
BranchProbability getCompl() const
Definition:BranchProbability.h:69
llvm::CallbackVH
Value handle with callbacks on RAUW and destruction.
Definition:ValueHandle.h:383
llvm::CallbackVH::CallbackVH
CallbackVH()
Definition:ValueHandle.h:395
llvm::DenseMap< const BasicBlock *, int >
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition:Dominators.h:162
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition:Pass.h:310
llvm::Function
Definition:Function.h:63
llvm::LoopInfo
Definition:LoopInfo.h:407
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::PostDominatorTree
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
Definition:PostDominators.h:28
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SuccIterator
Definition:CFG.h:141
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition:TargetLibraryInfo.h:280
llvm::ValueHandleBase::getValPtr
Value * getValPtr() const
Definition:ValueHandle.h:99
llvm::ValueHandleBase::Value
friend class Value
Definition:ValueHandle.h:30
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
uint32_t
llvm::ARM_MB::LD
@ LD
Definition:ARMBaseInfo.h:72
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition:ISDOpcodes.h:71
llvm::M68k::MemAddrModeKind::V
@ V
llvm::TargetStackID::Value
Value
Definition:TargetFrameLowering.h:29
llvm::codeview::PublicSymFlags::Function
@ Function
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
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:1873
std
Implement std::hash so that hash_code can be used in STL containers.
Definition:BitVector.h:858
llvm::AnalysisInfoMixin
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition:PassManager.h:92
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition:Analysis.h:28
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition:PassManager.h:69

Generated on Thu Jul 17 2025 08:26:07 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp