Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
MIRSampleProfile.cpp
Go to the documentation of this file.
1//===-------- MIRSampleProfile.cpp: MIRSampleFDO (For FSAFDO) -------------===//
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 file provides the implementation of the MIRSampleProfile loader, mainly
10// for flow sensitive SampleFDO.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/CodeGen/MIRSampleProfile.h"
15#include "llvm/ADT/DenseMap.h"
16#include "llvm/ADT/DenseSet.h"
17#include "llvm/Analysis/BlockFrequencyInfoImpl.h"
18#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
19#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
20#include "llvm/CodeGen/MachineDominators.h"
21#include "llvm/CodeGen/MachineInstr.h"
22#include "llvm/CodeGen/MachineLoopInfo.h"
23#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
24#include "llvm/CodeGen/MachinePostDominators.h"
25#include "llvm/CodeGen/Passes.h"
26#include "llvm/IR/Function.h"
27#include "llvm/IR/PseudoProbe.h"
28#include "llvm/InitializePasses.h"
29#include "llvm/Support/CommandLine.h"
30#include "llvm/Support/Debug.h"
31#include "llvm/Support/VirtualFileSystem.h"
32#include "llvm/Support/raw_ostream.h"
33#include "llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h"
34#include "llvm/Transforms/Utils/SampleProfileLoaderBaseUtil.h"
35#include <optional>
36
37using namespacellvm;
38using namespacesampleprof;
39using namespacellvm::sampleprofutil;
40usingProfileCount =Function::ProfileCount;
41
42#define DEBUG_TYPE "fs-profile-loader"
43
44staticcl::opt<bool>ShowFSBranchProb(
45"show-fs-branchprob",cl::Hidden,cl::init(false),
46cl::desc("Print setting flow sensitive branch probabilities"));
47staticcl::opt<unsigned>FSProfileDebugProbDiffThreshold(
48"fs-profile-debug-prob-diff-threshold",cl::init(10),
49cl::desc(
50"Only show debug message if the branch probability is greater than "
51"this value (in percentage)."));
52
53staticcl::opt<unsigned>FSProfileDebugBWThreshold(
54"fs-profile-debug-bw-threshold",cl::init(10000),
55cl::desc("Only show debug message if the source branch weight is greater "
56" than this value."));
57
58staticcl::opt<bool>ViewBFIBefore("fs-viewbfi-before",cl::Hidden,
59cl::init(false),
60cl::desc("View BFI before MIR loader"));
61staticcl::opt<bool>ViewBFIAfter("fs-viewbfi-after",cl::Hidden,
62cl::init(false),
63cl::desc("View BFI after MIR loader"));
64
65namespacellvm {
66externcl::opt<bool>ImprovedFSDiscriminator;
67}
68charMIRProfileLoaderPass::ID = 0;
69
70INITIALIZE_PASS_BEGIN(MIRProfileLoaderPass,DEBUG_TYPE,
71"Load MIR Sample Profile",
72/* cfg = */false,/* is_analysis = */false)
73INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfoWrapperPass)
74INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
75INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTreeWrapperPass)
76INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
77INITIALIZE_PASS_DEPENDENCY(MachineOptimizationRemarkEmitterPass)
78INITIALIZE_PASS_END(MIRProfileLoaderPass,DEBUG_TYPE, "Load MIR SampleProfile",
79/* cfg = */false,/* is_analysis = */false)
80
81char &llvm::MIRProfileLoaderPassID =MIRProfileLoaderPass::ID;
82
83FunctionPass *
84llvm::createMIRProfileLoaderPass(std::string File,std::string RemappingFile,
85FSDiscriminatorPassP,
86IntrusiveRefCntPtr<vfs::FileSystem> FS) {
87returnnewMIRProfileLoaderPass(File, RemappingFile,P, std::move(FS));
88}
89
90namespacellvm {
91
92// Internal option used to control BFI display only after MBP pass.
93// Defined in CodeGen/MachineBlockFrequencyInfo.cpp:
94// -view-block-layout-with-bfi={none | fraction | integer | count}
95externcl::opt<GVDAGType>ViewBlockLayoutWithBFI;
96
97// Command line option to specify the name of the function for CFG dump
98// Defined in Analysis/BlockFrequencyInfo.cpp: -view-bfi-func-name=
99externcl::opt<std::string>ViewBlockFreqFuncName;
100
101std::optional<PseudoProbe>extractProbe(constMachineInstr &MI) {
102if (MI.isPseudoProbe()) {
103PseudoProbe Probe;
104 Probe.Id =MI.getOperand(1).getImm();
105 Probe.Type =MI.getOperand(2).getImm();
106 Probe.Attr =MI.getOperand(3).getImm();
107 Probe.Factor = 1;
108DILocation *DebugLoc =MI.getDebugLoc();
109 Probe.Discriminator =DebugLoc ?DebugLoc->getDiscriminator() : 0;
110return Probe;
111 }
112
113// Ignore callsite probes since they do not have FS discriminators.
114return std::nullopt;
115}
116
117namespaceafdo_detail {
118template <>structIRTraits<MachineBasicBlock> {
119usingInstructionT =MachineInstr;
120usingBasicBlockT =MachineBasicBlock;
121usingFunctionT =MachineFunction;
122usingBlockFrequencyInfoT =MachineBlockFrequencyInfo;
123usingLoopT =MachineLoop;
124usingLoopInfoPtrT =MachineLoopInfo *;
125usingDominatorTreePtrT =MachineDominatorTree *;
126usingPostDominatorTreePtrT =MachinePostDominatorTree *;
127usingPostDominatorTreeT =MachinePostDominatorTree;
128usingOptRemarkEmitterT =MachineOptimizationRemarkEmitter;
129usingOptRemarkAnalysisT =MachineOptimizationRemarkAnalysis;
130usingPredRangeT =
131iterator_range<SmallVectorImpl<MachineBasicBlock *>::iterator>;
132usingSuccRangeT =
133iterator_range<SmallVectorImpl<MachineBasicBlock *>::iterator>;
134staticFunction &getFunction(MachineFunction &F) {returnF.getFunction(); }
135staticconstMachineBasicBlock *getEntryBB(constMachineFunction *F) {
136returnGraphTraits<const MachineFunction *>::getEntryNode(F);
137 }
138staticPredRangeTgetPredecessors(MachineBasicBlock *BB) {
139return BB->predecessors();
140 }
141staticSuccRangeTgetSuccessors(MachineBasicBlock *BB) {
142return BB->successors();
143 }
144};
145}// namespace afdo_detail
146
147classMIRProfileLoader final
148 :publicSampleProfileLoaderBaseImpl<MachineFunction> {
149public:
150voidsetInitVals(MachineDominatorTree *MDT,MachinePostDominatorTree *MPDT,
151MachineLoopInfo *MLI,MachineBlockFrequencyInfo *MBFI,
152MachineOptimizationRemarkEmitter *MORE) {
153DT = MDT;
154PDT = MPDT;
155LI = MLI;
156BFI = MBFI;
157ORE =MORE;
158 }
159voidsetFSPass(FSDiscriminatorPassPass) {
160P =Pass;
161LowBit =getFSPassBitBegin(P);
162HighBit =getFSPassBitEnd(P);
163assert(LowBit <HighBit &&"HighBit needs to be greater than Lowbit");
164 }
165
166MIRProfileLoader(StringRefName,StringRef RemapName,
167IntrusiveRefCntPtr<vfs::FileSystem>FS)
168 :SampleProfileLoaderBaseImpl(std::string(Name),std::string(RemapName),
169std::move(FS)) {}
170
171voidsetBranchProbs(MachineFunction &F);
172boolrunOnFunction(MachineFunction &F);
173booldoInitialization(Module &M);
174boolisValid() const{returnProfileIsValid; }
175
176protected:
177friendclassSampleCoverageTracker;
178
179 /// Hold the information of the basic block frequency.
180MachineBlockFrequencyInfo *BFI;
181
182 /// PassNum is the sequence number this pass is called, start from 1.
183FSDiscriminatorPassP;
184
185// LowBit in the FS discriminator used by this instance. Note the number is
186// 0-based. Base discrimnator use bit 0 to bit 11.
187unsignedLowBit;
188// HighwBit in the FS discriminator used by this instance. Note the number
189// is 0-based.
190unsignedHighBit;
191
192boolProfileIsValid =true;
193ErrorOr<uint64_t>getInstWeight(constMachineInstr &MI) override{
194if (FunctionSamples::ProfileIsProbeBased)
195returngetProbeWeight(MI);
196if (ImprovedFSDiscriminator &&MI.isMetaInstruction())
197return std::error_code();
198returngetInstWeightImpl(MI);
199 }
200};
201
202template <>
203voidSampleProfileLoaderBaseImpl<MachineFunction>::computeDominanceAndLoopInfo(
204MachineFunction &F) {}
205
206voidMIRProfileLoader::setBranchProbs(MachineFunction &F) {
207LLVM_DEBUG(dbgs() <<"\nPropagation complete. Setting branch probs\n");
208for (auto &BI :F) {
209MachineBasicBlock *BB = &BI;
210if (BB->succ_size() < 2)
211continue;
212constMachineBasicBlock *EC =EquivalenceClass[BB];
213uint64_t BBWeight =BlockWeights[EC];
214uint64_t SumEdgeWeight = 0;
215for (MachineBasicBlock *Succ : BB->successors()) {
216EdgeE = std::make_pair(BB, Succ);
217 SumEdgeWeight +=EdgeWeights[E];
218 }
219
220if (BBWeight != SumEdgeWeight) {
221LLVM_DEBUG(dbgs() <<"BBweight is not equal to SumEdgeWeight: BBWWeight="
222 << BBWeight <<" SumEdgeWeight= " << SumEdgeWeight
223 <<"\n");
224 BBWeight = SumEdgeWeight;
225 }
226if (BBWeight == 0) {
227LLVM_DEBUG(dbgs() <<"SKIPPED. All branch weights are zero.\n");
228continue;
229 }
230
231#ifndef NDEBUG
232uint64_t BBWeightOrig = BBWeight;
233#endif
234uint32_t MaxWeight = std::numeric_limits<uint32_t>::max();
235uint32_t Factor = 1;
236if (BBWeight > MaxWeight) {
237 Factor = BBWeight / MaxWeight + 1;
238 BBWeight /= Factor;
239LLVM_DEBUG(dbgs() <<"Scaling weights by " << Factor <<"\n");
240 }
241
242for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
243 SE = BB->succ_end();
244 SI != SE; ++SI) {
245MachineBasicBlock *Succ = *SI;
246EdgeE = std::make_pair(BB, Succ);
247uint64_t EdgeWeight =EdgeWeights[E];
248 EdgeWeight /= Factor;
249
250assert(BBWeight >= EdgeWeight &&
251"BBweight is larger than EdgeWeight -- should not happen.\n");
252
253BranchProbability OldProb =BFI->getMBPI()->getEdgeProbability(BB, SI);
254BranchProbability NewProb(EdgeWeight, BBWeight);
255if (OldProb == NewProb)
256continue;
257 BB->setSuccProbability(SI, NewProb);
258#ifndef NDEBUG
259if (!ShowFSBranchProb)
260continue;
261bool Show =false;
262BranchProbability Diff;
263if (OldProb > NewProb)
264 Diff = OldProb - NewProb;
265else
266 Diff = NewProb - OldProb;
267 Show = (Diff >=BranchProbability(FSProfileDebugProbDiffThreshold, 100));
268 Show &= (BBWeightOrig >=FSProfileDebugBWThreshold);
269
270auto DIL = BB->findBranchDebugLoc();
271auto SuccDIL = Succ->findBranchDebugLoc();
272if (Show) {
273dbgs() <<"Set branch fs prob: MBB (" << BB->getNumber() <<" -> "
274 << Succ->getNumber() <<"): ";
275if (DIL)
276dbgs() << DIL->getFilename() <<":" << DIL->getLine() <<":"
277 << DIL->getColumn();
278if (SuccDIL)
279dbgs() <<"-->" << SuccDIL->getFilename() <<":" << SuccDIL->getLine()
280 <<":" << SuccDIL->getColumn();
281dbgs() <<" W=" << BBWeightOrig <<" " << OldProb <<" --> " << NewProb
282 <<"\n";
283 }
284#endif
285 }
286 }
287}
288
289boolMIRProfileLoader::doInitialization(Module &M) {
290auto &Ctx = M.getContext();
291
292auto ReaderOrErr =sampleprof::SampleProfileReader::create(
293Filename, Ctx, *FS,P,RemappingFilename);
294if (std::error_code EC = ReaderOrErr.getError()) {
295 std::string Msg ="Could not open profile: " + EC.message();
296 Ctx.diagnose(DiagnosticInfoSampleProfile(Filename, Msg));
297returnfalse;
298 }
299
300Reader = std::move(ReaderOrErr.get());
301Reader->setModule(&M);
302ProfileIsValid = (Reader->read() ==sampleprof_error::success);
303
304// Load pseudo probe descriptors for probe-based function samples.
305if (Reader->profileIsProbeBased()) {
306ProbeManager = std::make_unique<PseudoProbeManager>(M);
307if (!ProbeManager->moduleIsProbed(M)) {
308returnfalse;
309 }
310 }
311
312returntrue;
313}
314
315boolMIRProfileLoader::runOnFunction(MachineFunction &MF) {
316// Do not load non-FS profiles. A line or probe can get a zero-valued
317// discriminator at certain pass which could result in accidentally loading
318// the corresponding base counter in the non-FS profile, while a non-zero
319// discriminator would end up getting zero samples. This could in turn undo
320// the sample distribution effort done by previous BFI maintenance and the
321// probe distribution factor work for pseudo probes.
322if (!Reader->profileIsFS())
323returnfalse;
324
325Function &Func = MF.getFunction();
326clearFunctionData(false);
327Samples =Reader->getSamplesFor(Func);
328if (!Samples ||Samples->empty())
329returnfalse;
330
331if (FunctionSamples::ProfileIsProbeBased) {
332if (!ProbeManager->profileIsValid(MF.getFunction(), *Samples))
333returnfalse;
334 }else {
335if (getFunctionLoc(MF) == 0)
336returnfalse;
337 }
338
339DenseSet<GlobalValue::GUID> InlinedGUIDs;
340bool Changed =computeAndPropagateWeights(MF, InlinedGUIDs);
341
342// Set the new BPI, BFI.
343setBranchProbs(MF);
344
345return Changed;
346}
347
348}// namespace llvm
349
350MIRProfileLoaderPass::MIRProfileLoaderPass(
351 std::string FileName, std::string RemappingFileName,FSDiscriminatorPassP,
352IntrusiveRefCntPtr<vfs::FileSystem> FS)
353 :MachineFunctionPass(ID), ProfileFileName(FileName),P(P) {
354 LowBit =getFSPassBitBegin(P);
355 HighBit =getFSPassBitEnd(P);
356
357auto VFS = FS ? std::move(FS) :vfs::getRealFileSystem();
358 MIRSampleLoader = std::make_unique<MIRProfileLoader>(
359 FileName, RemappingFileName, std::move(VFS));
360assert(LowBit < HighBit &&"HighBit needs to be greater than Lowbit");
361}
362
363bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) {
364if (!MIRSampleLoader->isValid())
365returnfalse;
366
367LLVM_DEBUG(dbgs() <<"MIRProfileLoader pass working on Func: "
368 << MF.getFunction().getName() <<"\n");
369 MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
370auto *MDT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
371auto *MPDT =
372 &getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree();
373
374 MF.RenumberBlocks();
375 MDT->updateBlockNumbers();
376 MPDT->updateBlockNumbers();
377
378 MIRSampleLoader->setInitVals(
379 MDT, MPDT, &getAnalysis<MachineLoopInfoWrapperPass>().getLI(), MBFI,
380 &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE());
381
382if (ViewBFIBefore &&ViewBlockLayoutWithBFI !=GVDT_None &&
383 (ViewBlockFreqFuncName.empty() ||
384 MF.getFunction().getName() ==ViewBlockFreqFuncName)) {
385 MBFI->view("MIR_Prof_loader_b." + MF.getName(),false);
386 }
387
388bool Changed = MIRSampleLoader->runOnFunction(MF);
389if (Changed)
390 MBFI->calculate(MF, *MBFI->getMBPI(),
391 *&getAnalysis<MachineLoopInfoWrapperPass>().getLI());
392
393if (ViewBFIAfter &&ViewBlockLayoutWithBFI !=GVDT_None &&
394 (ViewBlockFreqFuncName.empty() ||
395 MF.getFunction().getName() ==ViewBlockFreqFuncName)) {
396 MBFI->view("MIR_prof_loader_a." + MF.getName(),false);
397 }
398
399return Changed;
400}
401
402bool MIRProfileLoaderPass::doInitialization(Module &M) {
403LLVM_DEBUG(dbgs() <<"MIRProfileLoader pass working on Module " <<M.getName()
404 <<"\n");
405
406 MIRSampleLoader->setFSPass(P);
407return MIRSampleLoader->doInitialization(M);
408}
409
410void MIRProfileLoaderPass::getAnalysisUsage(AnalysisUsage &AU) const{
411 AU.setPreservesAll();
412 AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
413 AU.addRequired<MachineDominatorTreeWrapperPass>();
414 AU.addRequired<MachinePostDominatorTreeWrapperPass>();
415 AU.addRequiredTransitive<MachineLoopInfoWrapperPass>();
416 AU.addRequired<MachineOptimizationRemarkEmitterPass>();
417MachineFunctionPass::getAnalysisUsage(AU);
418}
BlockFrequencyInfoImpl.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Passes.h
CommandLine.h
Debug.h
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
DenseMap.h
This file defines the DenseMap class.
DenseSet.h
This file defines the DenseSet and SmallDenseSet classes.
Name
std::string Name
Definition:ELFObjHandler.cpp:77
MI
IRTranslator LLVM IR MI
Definition:IRTranslator.cpp:112
Function.h
InitializePasses.h
SpecialSubKind::string
@ string
F
#define F(x, y, z)
Definition:MD5.cpp:55
Profile
Load MIR Sample Profile
Definition:MIRSampleProfile.cpp:78
ShowFSBranchProb
static cl::opt< bool > ShowFSBranchProb("show-fs-branchprob", cl::Hidden, cl::init(false), cl::desc("Print setting flow sensitive branch probabilities"))
ViewBFIAfter
static cl::opt< bool > ViewBFIAfter("fs-viewbfi-after", cl::Hidden, cl::init(false), cl::desc("View BFI after MIR loader"))
FSProfileDebugBWThreshold
static cl::opt< unsigned > FSProfileDebugBWThreshold("fs-profile-debug-bw-threshold", cl::init(10000), cl::desc("Only show debug message if the source branch weight is greater " " than this value."))
FSProfileDebugProbDiffThreshold
static cl::opt< unsigned > FSProfileDebugProbDiffThreshold("fs-profile-debug-prob-diff-threshold", cl::init(10), cl::desc("Only show debug message if the branch probability is greater than " "this value (in percentage)."))
DEBUG_TYPE
#define DEBUG_TYPE
Definition:MIRSampleProfile.cpp:42
ViewBFIBefore
static cl::opt< bool > ViewBFIBefore("fs-viewbfi-before", cl::Hidden, cl::init(false), cl::desc("View BFI before MIR loader"))
MIRSampleProfile.h
MachineBlockFrequencyInfo.h
MachineBranchProbabilityInfo.h
MachineDominators.h
MachineInstr.h
MachineLoopInfo.h
MachineOptimizationRemarkEmitter.h
===- MachineOptimizationRemarkEmitter.h - Opt Diagnostics -*- C++ -*-—===//
MachinePostDominators.h
P
#define P(N)
INITIALIZE_PASS_DEPENDENCY
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition:PassSupport.h:55
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:52
PseudoProbe.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SampleProfileLoaderBaseImpl.h
This file provides the interface for the sampled PGO profile loader base implementation.
SampleProfileLoaderBaseUtil.h
This file provides the utility functions for the sampled PGO loader base implementation.
VirtualFileSystem.h
Defines the virtual file system interface vfs::FileSystem.
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition:PassAnalysisSupport.h:75
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition:PassAnalysisSupport.h:130
llvm::AnalysisUsage::addRequiredTransitive
AnalysisUsage & addRequiredTransitive()
Definition:PassAnalysisSupport.h:81
llvm::BranchProbability
Definition:BranchProbability.h:30
llvm::DILocation
Debug location.
Definition:DebugInfoMetadata.h:1988
llvm::DebugLoc
A debug info location.
Definition:DebugLoc.h:33
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition:DenseSet.h:278
llvm::DiagnosticInfoSampleProfile
Diagnostic information for the sample profiler.
Definition:DiagnosticInfo.h:257
llvm::ErrorOr
Represents either an error or a value T.
Definition:ErrorOr.h:56
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition:Pass.h:310
llvm::Function::ProfileCount
Class to represent profile counts.
Definition:Function.h:292
llvm::Function
Definition:Function.h:63
llvm::IntrusiveRefCntPtr
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
Definition:IntrusiveRefCntPtr.h:173
llvm::MIRProfileLoaderPass
Definition:MIRSampleProfile.h:37
llvm::MIRProfileLoaderPass::ID
static char ID
Definition:MIRSampleProfile.h:45
llvm::MIRProfileLoaderPass::MIRProfileLoaderPass
MIRProfileLoaderPass(std::string FileName="", std::string RemappingFileName="", FSDiscriminatorPass P=FSDiscriminatorPass::Pass1, IntrusiveRefCntPtr< vfs::FileSystem > FS=nullptr)
FS bits will only use the '1' bits in the Mask.
Definition:MIRSampleProfile.cpp:350
llvm::MIRProfileLoader
Definition:MIRSampleProfile.cpp:148
llvm::MIRProfileLoader::MIRProfileLoader
MIRProfileLoader(StringRef Name, StringRef RemapName, IntrusiveRefCntPtr< vfs::FileSystem > FS)
Definition:MIRSampleProfile.cpp:166
llvm::MIRProfileLoader::isValid
bool isValid() const
Definition:MIRSampleProfile.cpp:174
llvm::MIRProfileLoader::setBranchProbs
void setBranchProbs(MachineFunction &F)
Definition:MIRSampleProfile.cpp:206
llvm::MIRProfileLoader::getInstWeight
ErrorOr< uint64_t > getInstWeight(const MachineInstr &MI) override
Definition:MIRSampleProfile.cpp:193
llvm::MIRProfileLoader::runOnFunction
bool runOnFunction(MachineFunction &F)
Definition:MIRSampleProfile.cpp:315
llvm::MIRProfileLoader::HighBit
unsigned HighBit
Definition:MIRSampleProfile.cpp:190
llvm::MIRProfileLoader::BFI
MachineBlockFrequencyInfo * BFI
Hold the information of the basic block frequency.
Definition:MIRSampleProfile.cpp:180
llvm::MIRProfileLoader::P
FSDiscriminatorPass P
PassNum is the sequence number this pass is called, start from 1.
Definition:MIRSampleProfile.cpp:183
llvm::MIRProfileLoader::doInitialization
bool doInitialization(Module &M)
Definition:MIRSampleProfile.cpp:289
llvm::MIRProfileLoader::LowBit
unsigned LowBit
Definition:MIRSampleProfile.cpp:187
llvm::MIRProfileLoader::setInitVals
void setInitVals(MachineDominatorTree *MDT, MachinePostDominatorTree *MPDT, MachineLoopInfo *MLI, MachineBlockFrequencyInfo *MBFI, MachineOptimizationRemarkEmitter *MORE)
Definition:MIRSampleProfile.cpp:150
llvm::MIRProfileLoader::ProfileIsValid
bool ProfileIsValid
Definition:MIRSampleProfile.cpp:192
llvm::MIRProfileLoader::setFSPass
void setFSPass(FSDiscriminatorPass Pass)
Definition:MIRSampleProfile.cpp:159
llvm::MachineBasicBlock
Definition:MachineBasicBlock.h:125
llvm::MachineBasicBlock::getNumber
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Definition:MachineBasicBlock.h:1217
llvm::MachineBasicBlock::succ_end
succ_iterator succ_end()
Definition:MachineBasicBlock.h:423
llvm::MachineBasicBlock::setSuccProbability
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
Definition:MachineBasicBlock.cpp:1598
llvm::MachineBasicBlock::succ_begin
succ_iterator succ_begin()
Definition:MachineBasicBlock.h:421
llvm::MachineBasicBlock::succ_size
unsigned succ_size() const
Definition:MachineBasicBlock.h:433
llvm::MachineBasicBlock::succ_iterator
SmallVectorImpl< MachineBasicBlock * >::iterator succ_iterator
Definition:MachineBasicBlock.h:394
llvm::MachineBasicBlock::findBranchDebugLoc
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
Definition:MachineBasicBlock.cpp:1559
llvm::MachineBasicBlock::successors
iterator_range< succ_iterator > successors()
Definition:MachineBasicBlock.h:444
llvm::MachineBasicBlock::predecessors
iterator_range< pred_iterator > predecessors()
Definition:MachineBasicBlock.h:438
llvm::MachineBlockFrequencyInfoWrapperPass
Definition:MachineBlockFrequencyInfo.h:137
llvm::MachineBlockFrequencyInfo
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
Definition:MachineBlockFrequencyInfo.h:34
llvm::MachineBlockFrequencyInfo::view
void view(const Twine &Name, bool isSimple=true) const
Pop up a ghostview window with the current block frequency propagation rendered using dot.
Definition:MachineBlockFrequencyInfo.cpp:262
llvm::MachineBlockFrequencyInfo::getMBPI
const MachineBranchProbabilityInfo * getMBPI() const
Definition:MachineBlockFrequencyInfo.cpp:311
llvm::MachineBlockFrequencyInfo::calculate
void calculate(const MachineFunction &F, const MachineBranchProbabilityInfo &MBPI, const MachineLoopInfo &MLI)
calculate - compute block frequency info for the given function.
Definition:MachineBlockFrequencyInfo.cpp:231
llvm::MachineBranchProbabilityInfo::getEdgeProbability
BranchProbability getEdgeProbability(const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const
Definition:MachineBranchProbabilityInfo.cpp:88
llvm::MachineDominatorTreeWrapperPass
Analysis pass which computes a MachineDominatorTree.
Definition:MachineDominators.h:131
llvm::MachineDominatorTree
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Definition:MachineDominators.h:75
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition:MachineFunctionPass.h:30
llvm::MachineFunctionPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition:MachineFunctionPass.cpp:169
llvm::MachineFunction
Definition:MachineFunction.h:267
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition:MachineFunction.cpp:645
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition:MachineFunction.h:704
llvm::MachineFunction::RenumberBlocks
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
Definition:MachineFunction.cpp:343
llvm::MachineInstr
Representation of each machine instruction.
Definition:MachineInstr.h:71
llvm::MachineLoopInfoWrapperPass
Definition:MachineLoopInfo.h:156
llvm::MachineLoopInfo
Definition:MachineLoopInfo.h:105
llvm::MachineLoop
Definition:MachineLoopInfo.h:46
llvm::MachineOptimizationRemarkAnalysis
Diagnostic information for optimization analysis remarks.
Definition:MachineOptimizationRemarkEmitter.h:111
llvm::MachineOptimizationRemarkEmitterPass
The analysis pass.
Definition:MachineOptimizationRemarkEmitter.h:239
llvm::MachineOptimizationRemarkEmitter
The optimization diagnostic interface.
Definition:MachineOptimizationRemarkEmitter.h:153
llvm::MachinePostDominatorTreeWrapperPass
Definition:MachinePostDominators.h:90
llvm::MachinePostDominatorTree
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
Definition:MachinePostDominators.h:46
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition:Pass.h:94
llvm::SampleProfileLoaderBaseImpl
Definition:SampleProfileLoaderBaseImpl.h:175
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::computeAndPropagateWeights
bool computeAndPropagateWeights(FunctionT &F, const DenseSet< GlobalValue::GUID > &InlinedGUIDs)
Generate branch weight metadata for all branches in F.
Definition:SampleProfileLoaderBaseImpl.h:1027
llvm::SampleProfileLoaderBaseImpl::computeDominanceAndLoopInfo
void computeDominanceAndLoopInfo(FunctionT &F)
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::FS
IntrusiveRefCntPtr< vfs::FileSystem > FS
VirtualFileSystem to load profile files from.
Definition:SampleProfileLoaderBaseImpl.h:326
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::EdgeWeights
EdgeWeightMap EdgeWeights
Map edges to their computed weights.
Definition:SampleProfileLoaderBaseImpl.h:275
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::ORE
OptRemarkEmitterT * ORE
Optimization Remark Emitter used to emit diagnostic remarks.
Definition:SampleProfileLoaderBaseImpl.h:332
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::getFunctionLoc
unsigned getFunctionLoc(FunctionT &Func)
Get the line number for the function header.
Definition:SampleProfileLoaderBaseImpl.h:1139
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::getInstWeightImpl
ErrorOr< uint64_t > getInstWeightImpl(const InstructionT &Inst)
Definition:SampleProfileLoaderBaseImpl.h:410
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::EquivalenceClass
EquivalenceClassMap EquivalenceClass
Equivalence classes for block weights.
Definition:SampleProfileLoaderBaseImpl.h:289
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::Reader
std::unique_ptr< SampleProfileReader > Reader
Profile reader object.
Definition:SampleProfileLoaderBaseImpl.h:306
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::DT
DominatorTreePtrT DT
Dominance, post-dominance and loop information.
Definition:SampleProfileLoaderBaseImpl.h:292
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::ProbeManager
std::unique_ptr< PseudoProbeManager > ProbeManager
Definition:SampleProfileLoaderBaseImpl.h:314
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::Filename
std::string Filename
Name of the profile file to load.
Definition:SampleProfileLoaderBaseImpl.h:320
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::PDT
PostDominatorTreePtrT PDT
Definition:SampleProfileLoaderBaseImpl.h:293
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::getProbeWeight
virtual ErrorOr< uint64_t > getProbeWeight(const InstructionT &Inst)
Definition:SampleProfileLoaderBaseImpl.h:454
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::RemappingFilename
std::string RemappingFilename
Name of the profile remapping file to load.
Definition:SampleProfileLoaderBaseImpl.h:323
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::Samples
FunctionSamples * Samples
Samples collected for the body of this function.
Definition:SampleProfileLoaderBaseImpl.h:317
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::Edge
std::pair< const BasicBlockT *, const BasicBlockT * > Edge
Definition:SampleProfileLoaderBaseImpl.h:207
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::LI
LoopInfoPtrT LI
Definition:SampleProfileLoaderBaseImpl.h:294
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::clearFunctionData
void clearFunctionData(bool ResetDT=true)
Clear all the per-function data used to load samples and propagate weights.
Definition:SampleProfileLoaderBaseImpl.h:337
llvm::SampleProfileLoaderBaseImpl< MachineFunction >::BlockWeights
BlockWeightMap BlockWeights
Map basic blocks to their computed weights.
Definition:SampleProfileLoaderBaseImpl.h:269
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition:Value.cpp:309
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition:iterator_range.h:42
llvm::sampleprof::FunctionSamples::empty
bool empty() const
Definition:SampleProf.h:931
llvm::sampleprof::FunctionSamples::ProfileIsProbeBased
static bool ProfileIsProbeBased
Definition:SampleProf.h:1186
llvm::sampleprof::SampleProfileReader::create
static ErrorOr< std::unique_ptr< SampleProfileReader > > create(StringRef Filename, LLVMContext &C, vfs::FileSystem &FS, FSDiscriminatorPass P=FSDiscriminatorPass::Base, StringRef RemapFilename="")
Create a sample profile reader appropriate to the file format.
Definition:SampleProfReader.cpp:1905
llvm::sampleprofutil::SampleCoverageTracker
Definition:SampleProfileLoaderBaseUtil.h:35
uint32_t
uint64_t
unsigned
false
Definition:StackSlotColoring.cpp:193
llvm::ARM::ProfileKind::M
@ M
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm::sampleprof::FSDiscriminatorPass
FSDiscriminatorPass
Definition:Discriminator.h:57
llvm::sampleprofutil
Definition:SampleProfileLoaderBaseUtil.h:33
llvm::vfs::getRealFileSystem
IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
Definition:VirtualFileSystem.cpp:399
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::getFSPassBitBegin
static unsigned getFSPassBitBegin(sampleprof::FSDiscriminatorPass P)
Definition:Discriminator.h:94
llvm::MIRProfileLoaderPassID
char & MIRProfileLoaderPassID
This pass reads flow sensitive profile.
Definition:MIRSampleProfile.cpp:81
llvm::getFSPassBitEnd
static unsigned getFSPassBitEnd(sampleprof::FSDiscriminatorPass P)
Definition:Discriminator.h:87
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::sampleprof_error::success
@ success
llvm::extractProbe
std::optional< PseudoProbe > extractProbe(const Instruction &Inst)
Definition:PseudoProbe.cpp:56
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::ViewBlockLayoutWithBFI
cl::opt< GVDAGType > ViewBlockLayoutWithBFI("view-block-layout-with-bfi", cl::Hidden, cl::desc("Pop up a window to show a dag displaying MBP layout and associated " "block frequencies of 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.")))
Definition:MachineBlockPlacement.cpp:235
llvm::ImprovedFSDiscriminator
cl::opt< bool > ImprovedFSDiscriminator("improved-fs-discriminator", cl::Hidden, cl::init(false), cl::desc("New FS discriminators encoding (incompatible with the original " "encoding)"))
Definition:MIRSampleProfile.cpp:66
llvm::createMIRProfileLoaderPass
FunctionPass * createMIRProfileLoaderPass(std::string File, std::string RemappingFile, sampleprof::FSDiscriminatorPass P, IntrusiveRefCntPtr< vfs::FileSystem > FS)
Read Flow Sensitive Profile.
Definition:MIRSampleProfile.cpp:84
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
llvm::GVDT_None
@ GVDT_None
Definition:BlockFrequencyInfoImpl.h:1796
std
Implement std::hash so that hash_code can be used in STL containers.
Definition:BitVector.h:858
raw_ostream.h
MORE
#define MORE()
Definition:regcomp.c:252
llvm::GraphTraits
Definition:GraphTraits.h:38
llvm::PseudoProbe
Definition:PseudoProbe.h:117
llvm::PseudoProbe::Attr
uint32_t Attr
Definition:PseudoProbe.h:120
llvm::PseudoProbe::Id
uint32_t Id
Definition:PseudoProbe.h:118
llvm::PseudoProbe::Type
uint32_t Type
Definition:PseudoProbe.h:119
llvm::PseudoProbe::Factor
float Factor
Definition:PseudoProbe.h:125
llvm::PseudoProbe::Discriminator
uint32_t Discriminator
Definition:PseudoProbe.h:121
llvm::afdo_detail::IRTraits< MachineBasicBlock >::getPredecessors
static PredRangeT getPredecessors(MachineBasicBlock *BB)
Definition:MIRSampleProfile.cpp:138
llvm::afdo_detail::IRTraits< MachineBasicBlock >::getSuccessors
static SuccRangeT getSuccessors(MachineBasicBlock *BB)
Definition:MIRSampleProfile.cpp:141
llvm::afdo_detail::IRTraits< MachineBasicBlock >::getEntryBB
static const MachineBasicBlock * getEntryBB(const MachineFunction *F)
Definition:MIRSampleProfile.cpp:135
llvm::afdo_detail::IRTraits< MachineBasicBlock >::getFunction
static Function & getFunction(MachineFunction &F)
Definition:MIRSampleProfile.cpp:134
llvm::afdo_detail::IRTraits
Definition:SampleProfileLoaderBaseImpl.h:60
llvm::cl::desc
Definition:CommandLine.h:409

Generated on Thu Jul 17 2025 11:34:55 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp