LLVM  15.0.0git
SampleProfileProbe.cpp
Go to the documentation of this file.
1 //===- SampleProfileProbe.cpp - Pseudo probe Instrumentation -------------===//
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 implements the SampleProfileProber transformation.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/Statistic.h"
16 #include "llvm/Analysis/LoopInfo.h"
17 #include "llvm/IR/BasicBlock.h"
18 #include "llvm/IR/Constants.h"
20 #include "llvm/IR/IRBuilder.h"
21 #include "llvm/IR/Instruction.h"
22 #include "llvm/IR/IntrinsicInst.h"
23 #include "llvm/IR/MDBuilder.h"
24 #include "llvm/IR/PseudoProbe.h"
26 #include "llvm/Support/CRC.h"
31 #include <unordered_set>
32 #include <vector>
33 
34 using namespace llvm;
35 #define DEBUG_TYPE "sample-profile-probe"
36 
37 STATISTIC(ArtificialDbgLine,
38  "Number of probes that have an artificial debug line");
39 
40 static cl::opt<bool>
41  VerifyPseudoProbe("verify-pseudo-probe", cl::init(false), cl::Hidden,
42  cl::desc("Do pseudo probe verification"));
43 
45  "verify-pseudo-probe-funcs", cl::Hidden,
46  cl::desc("The option to specify the name of the functions to verify."));
47 
48 static cl::opt<bool>
49  UpdatePseudoProbe("update-pseudo-probe", cl::init(true), cl::Hidden,
50  cl::desc("Update pseudo probe distribution factor"));
51 
52 static uint64_t getCallStackHash(const DILocation *DIL) {
53  uint64_t Hash = 0;
54  const DILocation *InlinedAt = DIL ? DIL->getInlinedAt() : nullptr;
55  while (InlinedAt) {
56  Hash ^= MD5Hash(std::to_string(InlinedAt->getLine()));
57  Hash ^= MD5Hash(std::to_string(InlinedAt->getColumn()));
58  const DISubprogram *SP = InlinedAt->getScope()->getSubprogram();
59  // Use linkage name for C++ if possible.
60  auto Name = SP->getLinkageName();
61  if (Name.empty())
62  Name = SP->getName();
63  Hash ^= MD5Hash(Name);
64  InlinedAt = InlinedAt->getInlinedAt();
65  }
66  return Hash;
67 }
68 
70  return getCallStackHash(Inst.getDebugLoc());
71 }
72 
73 bool PseudoProbeVerifier::shouldVerifyFunction(const Function *F) {
74  // Skip function declaration.
75  if (F->isDeclaration())
76  return false;
77  // Skip function that will not be emitted into object file. The prevailing
78  // defintion will be verified instead.
79  if (F->hasAvailableExternallyLinkage())
80  return false;
81  // Do a name matching.
82  static std::unordered_set<std::string> VerifyFuncNames(
84  return VerifyFuncNames.empty() || VerifyFuncNames.count(F->getName().str());
85 }
86 
88  if (VerifyPseudoProbe) {
90  [this](StringRef P, Any IR, const PreservedAnalyses &) {
91  this->runAfterPass(P, IR);
92  });
93  }
94 }
95 
96 // Callback to run after each transformation for the new pass manager.
98  std::string Banner =
99  "\n*** Pseudo Probe Verification After " + PassID.str() + " ***\n";
100  dbgs() << Banner;
101  if (any_isa<const Module *>(IR))
102  runAfterPass(any_cast<const Module *>(IR));
103  else if (any_isa<const Function *>(IR))
104  runAfterPass(any_cast<const Function *>(IR));
105  else if (any_isa<const LazyCallGraph::SCC *>(IR))
106  runAfterPass(any_cast<const LazyCallGraph::SCC *>(IR));
107  else if (any_isa<const Loop *>(IR))
108  runAfterPass(any_cast<const Loop *>(IR));
109  else
110  llvm_unreachable("Unknown IR unit");
111 }
112 
114  for (const Function &F : *M)
115  runAfterPass(&F);
116 }
117 
119  for (const LazyCallGraph::Node &N : *C)
120  runAfterPass(&N.getFunction());
121 }
122 
124  if (!shouldVerifyFunction(F))
125  return;
126  ProbeFactorMap ProbeFactors;
127  for (const auto &BB : *F)
128  collectProbeFactors(&BB, ProbeFactors);
129  verifyProbeFactors(F, ProbeFactors);
130 }
131 
133  const Function *F = L->getHeader()->getParent();
134  runAfterPass(F);
135 }
136 
137 void PseudoProbeVerifier::collectProbeFactors(const BasicBlock *Block,
138  ProbeFactorMap &ProbeFactors) {
139  for (const auto &I : *Block) {
140  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
142  ProbeFactors[{Probe->Id, Hash}] += Probe->Factor;
143  }
144  }
145 }
146 
147 void PseudoProbeVerifier::verifyProbeFactors(
148  const Function *F, const ProbeFactorMap &ProbeFactors) {
149  bool BannerPrinted = false;
150  auto &PrevProbeFactors = FunctionProbeFactors[F->getName()];
151  for (const auto &I : ProbeFactors) {
152  float CurProbeFactor = I.second;
153  if (PrevProbeFactors.count(I.first)) {
154  float PrevProbeFactor = PrevProbeFactors[I.first];
155  if (std::abs(CurProbeFactor - PrevProbeFactor) >
156  DistributionFactorVariance) {
157  if (!BannerPrinted) {
158  dbgs() << "Function " << F->getName() << ":\n";
159  BannerPrinted = true;
160  }
161  dbgs() << "Probe " << I.first.first << "\tprevious factor "
162  << format("%0.2f", PrevProbeFactor) << "\tcurrent factor "
163  << format("%0.2f", CurProbeFactor) << "\n";
164  }
165  }
166 
167  // Update
168  PrevProbeFactors[I.first] = I.second;
169  }
170 }
171 
173  if (NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName)) {
174  for (const auto *Operand : FuncInfo->operands()) {
175  const auto *MD = cast<MDNode>(Operand);
176  auto GUID =
177  mdconst::dyn_extract<ConstantInt>(MD->getOperand(0))->getZExtValue();
178  auto Hash =
179  mdconst::dyn_extract<ConstantInt>(MD->getOperand(1))->getZExtValue();
180  GUIDToProbeDescMap.try_emplace(GUID, PseudoProbeDescriptor(GUID, Hash));
181  }
182  }
183 }
184 
185 const PseudoProbeDescriptor *
186 PseudoProbeManager::getDesc(const Function &F) const {
187  auto I = GUIDToProbeDescMap.find(
189  return I == GUIDToProbeDescMap.end() ? nullptr : &I->second;
190 }
191 
193  return M.getNamedMetadata(PseudoProbeDescMetadataName);
194 }
195 
197  const FunctionSamples &Samples) const {
198  const auto *Desc = getDesc(F);
199  if (!Desc) {
200  LLVM_DEBUG(dbgs() << "Probe descriptor missing for Function " << F.getName()
201  << "\n");
202  return false;
203  } else {
204  if (Desc->getFunctionHash() != Samples.getFunctionHash()) {
205  LLVM_DEBUG(dbgs() << "Hash mismatch for Function " << F.getName()
206  << "\n");
207  return false;
208  }
209  }
210  return true;
211 }
212 
214  const std::string &CurModuleUniqueId)
215  : F(&Func), CurModuleUniqueId(CurModuleUniqueId) {
216  BlockProbeIds.clear();
217  CallProbeIds.clear();
218  LastProbeId = (uint32_t)PseudoProbeReservedId::Last;
219  computeProbeIdForBlocks();
220  computeProbeIdForCallsites();
221  computeCFGHash();
222 }
223 
224 // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
225 // value of each BB in the CFG. The higher 32 bits record the number of edges
226 // preceded by the number of indirect calls.
227 // This is derived from FuncPGOInstrumentation<Edge, BBInfo>::computeCFGHash().
228 void SampleProfileProber::computeCFGHash() {
229  std::vector<uint8_t> Indexes;
230  JamCRC JC;
231  for (auto &BB : *F) {
232  auto *TI = BB.getTerminator();
233  for (unsigned I = 0, E = TI->getNumSuccessors(); I != E; ++I) {
234  auto *Succ = TI->getSuccessor(I);
235  auto Index = getBlockId(Succ);
236  for (int J = 0; J < 4; J++)
237  Indexes.push_back((uint8_t)(Index >> (J * 8)));
238  }
239  }
240 
241  JC.update(Indexes);
242 
243  FunctionHash = (uint64_t)CallProbeIds.size() << 48 |
244  (uint64_t)Indexes.size() << 32 | JC.getCRC();
245  // Reserve bit 60-63 for other information purpose.
246  FunctionHash &= 0x0FFFFFFFFFFFFFFF;
247  assert(FunctionHash && "Function checksum should not be zero");
248  LLVM_DEBUG(dbgs() << "\nFunction Hash Computation for " << F->getName()
249  << ":\n"
250  << " CRC = " << JC.getCRC() << ", Edges = "
251  << Indexes.size() << ", ICSites = " << CallProbeIds.size()
252  << ", Hash = " << FunctionHash << "\n");
253 }
254 
255 void SampleProfileProber::computeProbeIdForBlocks() {
256  for (auto &BB : *F) {
257  BlockProbeIds[&BB] = ++LastProbeId;
258  }
259 }
260 
261 void SampleProfileProber::computeProbeIdForCallsites() {
262  for (auto &BB : *F) {
263  for (auto &I : BB) {
264  if (!isa<CallBase>(I))
265  continue;
266  if (isa<IntrinsicInst>(&I))
267  continue;
268  CallProbeIds[&I] = ++LastProbeId;
269  }
270  }
271 }
272 
273 uint32_t SampleProfileProber::getBlockId(const BasicBlock *BB) const {
274  auto I = BlockProbeIds.find(const_cast<BasicBlock *>(BB));
275  return I == BlockProbeIds.end() ? 0 : I->second;
276 }
277 
278 uint32_t SampleProfileProber::getCallsiteId(const Instruction *Call) const {
279  auto Iter = CallProbeIds.find(const_cast<Instruction *>(Call));
280  return Iter == CallProbeIds.end() ? 0 : Iter->second;
281 }
282 
284  Module *M = F.getParent();
285  MDBuilder MDB(F.getContext());
286  // Compute a GUID without considering the function's linkage type. This is
287  // fine since function name is the only key in the profile database.
288  uint64_t Guid = Function::getGUID(F.getName());
289 
290  // Assign an artificial debug line to a probe that doesn't come with a real
291  // line. A probe not having a debug line will get an incomplete inline
292  // context. This will cause samples collected on the probe to be counted
293  // into the base profile instead of a context profile. The line number
294  // itself is not important though.
295  auto AssignDebugLoc = [&](Instruction *I) {
296  assert((isa<PseudoProbeInst>(I) || isa<CallBase>(I)) &&
297  "Expecting pseudo probe or call instructions");
298  if (!I->getDebugLoc()) {
299  if (auto *SP = F.getSubprogram()) {
300  auto DIL = DILocation::get(SP->getContext(), 0, 0, SP);
301  I->setDebugLoc(DIL);
302  ArtificialDbgLine++;
303  LLVM_DEBUG({
304  dbgs() << "\nIn Function " << F.getName()
305  << " Probe gets an artificial debug line\n";
306  I->dump();
307  });
308  }
309  }
310  };
311 
312  // Probe basic blocks.
313  for (auto &I : BlockProbeIds) {
314  BasicBlock *BB = I.first;
315  uint32_t Index = I.second;
316  // Insert a probe before an instruction with a valid debug line number which
317  // will be assigned to the probe. The line number will be used later to
318  // model the inline context when the probe is inlined into other functions.
319  // Debug instructions, phi nodes and lifetime markers do not have an valid
320  // line number. Real instructions generated by optimizations may not come
321  // with a line number either.
322  auto HasValidDbgLine = [](Instruction *J) {
323  return !isa<PHINode>(J) && !isa<DbgInfoIntrinsic>(J) &&
324  !J->isLifetimeStartOrEnd() && J->getDebugLoc();
325  };
326 
327  Instruction *J = &*BB->getFirstInsertionPt();
328  while (J != BB->getTerminator() && !HasValidDbgLine(J)) {
329  J = J->getNextNode();
330  }
331 
332  IRBuilder<> Builder(J);
333  assert(Builder.GetInsertPoint() != BB->end() &&
334  "Cannot get the probing point");
335  Function *ProbeFn =
336  llvm::Intrinsic::getDeclaration(M, Intrinsic::pseudoprobe);
337  Value *Args[] = {Builder.getInt64(Guid), Builder.getInt64(Index),
338  Builder.getInt32(0),
340  auto *Probe = Builder.CreateCall(ProbeFn, Args);
341  AssignDebugLoc(Probe);
342  }
343 
344  // Probe both direct calls and indirect calls. Direct calls are probed so that
345  // their probe ID can be used as an call site identifier to represent a
346  // calling context.
347  for (auto &I : CallProbeIds) {
348  auto *Call = I.first;
349  uint32_t Index = I.second;
350  uint32_t Type = cast<CallBase>(Call)->getCalledFunction()
353  AssignDebugLoc(Call);
354  // Levarge the 32-bit discriminator field of debug data to store the ID and
355  // type of a callsite probe. This gets rid of the dependency on plumbing a
356  // customized metadata through the codegen pipeline.
359  if (auto DIL = Call->getDebugLoc()) {
360  DIL = DIL->cloneWithDiscriminator(V);
361  Call->setDebugLoc(DIL);
362  }
363  }
364 
365  // Create module-level metadata that contains function info necessary to
366  // synthesize probe-based sample counts, which are
367  // - FunctionGUID
368  // - FunctionHash.
369  // - FunctionName
370  auto Hash = getFunctionHash();
371  auto *MD = MDB.createPseudoProbeDesc(Guid, Hash, &F);
372  auto *NMD = M->getNamedMetadata(PseudoProbeDescMetadataName);
373  assert(NMD && "llvm.pseudo_probe_desc should be pre-created");
374  NMD->addOperand(MD);
375 
376  // Preserve a comdat group to hold all probes materialized later. This
377  // allows that when the function is considered dead and removed, the
378  // materialized probes are disposed too.
379  // Imported functions are defined in another module. They do not need
380  // the following handling since same care will be taken for them in their
381  // original module. The pseudo probes inserted into an imported functions
382  // above will naturally not be emitted since the imported function is free
383  // from object emission. However they will be emitted together with the
384  // inliner functions that the imported function is inlined into. We are not
385  // creating a comdat group for an import function since it's useless anyway.
386  if (!F.isDeclarationForLinker()) {
387  if (TM) {
388  auto Triple = TM->getTargetTriple();
389  if (Triple.supportsCOMDAT() && TM->getFunctionSections())
391  }
392  }
393 }
394 
396  ModuleAnalysisManager &AM) {
397  auto ModuleId = getUniqueModuleId(&M);
398  // Create the pseudo probe desc metadata beforehand.
399  // Note that modules with only data but no functions will require this to
400  // be set up so that they will be known as probed later.
401  M.getOrInsertNamedMetadata(PseudoProbeDescMetadataName);
402 
403  for (auto &F : M) {
404  if (F.isDeclaration())
405  continue;
406  SampleProfileProber ProbeManager(F, ModuleId);
407  ProbeManager.instrumentOneFunc(F, TM);
408  }
409 
410  return PreservedAnalyses::none();
411 }
412 
413 void PseudoProbeUpdatePass::runOnFunction(Function &F,
416  auto BBProfileCount = [&BFI](BasicBlock *BB) {
417  return BFI.getBlockProfileCount(BB).value_or(0);
418  };
419 
420  // Collect the sum of execution weight for each probe.
421  ProbeFactorMap ProbeFactors;
422  for (auto &Block : F) {
423  for (auto &I : Block) {
424  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
426  ProbeFactors[{Probe->Id, Hash}] += BBProfileCount(&Block);
427  }
428  }
429  }
430 
431  // Fix up over-counted probes.
432  for (auto &Block : F) {
433  for (auto &I : Block) {
434  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
436  float Sum = ProbeFactors[{Probe->Id, Hash}];
437  if (Sum != 0)
438  setProbeDistributionFactor(I, BBProfileCount(&Block) / Sum);
439  }
440  }
441  }
442 }
443 
445  ModuleAnalysisManager &AM) {
446  if (UpdatePseudoProbe) {
447  for (auto &F : M) {
448  if (F.isDeclaration())
449  continue;
452  runOnFunction(F, FAM);
453  }
454  }
455  return PreservedAnalyses::none();
456 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
Instrumentation.h
llvm::PseudoProbeFullDistributionFactor
constexpr static uint64_t PseudoProbeFullDistributionFactor
Definition: PseudoProbe.h:30
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1572
llvm::PseudoProbeDwarfDiscriminator::FullDistributionFactor
constexpr static uint8_t FullDistributionFactor
Definition: PseudoProbe.h:70
llvm::JamCRC::update
void update(ArrayRef< uint8_t > Data)
Definition: CRC.cpp:103
llvm::Intrinsic::getDeclaration
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:1419
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:104
IntrinsicInst.h
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
DebugInfoMetadata.h
llvm::Function
Definition: Function.h:60
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:546
llvm::PseudoProbeReservedId::Last
@ Last
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::MDBuilder::createPseudoProbeDesc
MDNode * createPseudoProbeDesc(uint64_t GUID, uint64_t Hash, Function *F)
Return metadata containing the pseudo probe descriptor for a function.
Definition: MDBuilder.cpp:317
llvm::PseudoProbeManager::profileIsValid
bool profileIsValid(const Function &F, const FunctionSamples &Samples) const
Definition: SampleProfileProbe.cpp:196
llvm::ilist_node_with_parent::getNextNode
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
Definition: ilist_node.h:289
Statistic.h
llvm::IRBuilder<>
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
FAM
FunctionAnalysisManager FAM
Definition: PassBuilderBindings.cpp:59
llvm::DIScope::getName
StringRef getName() const
Definition: DebugInfoMetadata.cpp:264
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1557
llvm::PreservedAnalyses::none
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: PassManager.h:155
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
PIC
PassInstrumentationCallbacks PIC
Definition: PassBuilderBindings.cpp:55
llvm::Optional
Definition: APInt.h:33
llvm::SampleProfileProber
Sample profile pseudo prober.
Definition: SampleProfileProbe.h:101
llvm::JamCRC
Definition: CRC.h:45
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1384
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::PseudoProbeDwarfDiscriminator::packProbeData
static uint32_t packProbeData(uint32_t Index, uint32_t Type, uint32_t Flags, uint32_t Factor)
Definition: PseudoProbe.h:43
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
llvm::PseudoProbeType::IndirectCall
@ IndirectCall
Instruction.h
CommandLine.h
llvm::BlockFrequencyInfo
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Definition: BlockFrequencyInfo.h:37
llvm::PseudoProbeUpdatePass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: SampleProfileProbe.cpp:444
TargetMachine.h
llvm::LazyCallGraph::SCC
An SCC of the call graph.
Definition: LazyCallGraph.h:419
Constants.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::PseudoProbeDescMetadataName
constexpr const char * PseudoProbeDescMetadataName
Definition: PseudoProbe.h:25
CRC.h
llvm::Triple::supportsCOMDAT
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition: Triple.h:916
SampleProf.h
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::Instruction
Definition: Instruction.h:42
MDBuilder.h
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::setProbeDistributionFactor
void setProbeDistributionFactor(Instruction &Inst, float Factor)
Definition: PseudoProbe.cpp:65
IR
Statically lint checks LLVM IR
Definition: Lint.cpp:746
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:249
llvm::BlockFrequencyAnalysis
Analysis pass which computes BlockFrequencyInfo.
Definition: BlockFrequencyInfo.h:112
LoopInfo.h
llvm::PseudoProbeVerifier::runAfterPass
void runAfterPass(StringRef PassID, Any IR)
Definition: SampleProfileProbe.cpp:97
getCallStackHash
static uint64_t getCallStackHash(const DILocation *DIL)
Definition: SampleProfileProbe.cpp:52
BasicBlock.h
llvm::cl::opt< bool >
uint64_t
llvm::sampleprof::FunctionSamples
Representation of the samples collected for a function.
Definition: SampleProf.h:710
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
llvm::sampleprof::FunctionSamples::getFunctionHash
uint64_t getFunctionHash() const
Definition: SampleProf.h:1008
IRBuilder.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::PseudoProbeDescriptor
Definition: SampleProfileProbe.h:46
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
SampleProfileProbe.h
llvm::LazyCallGraph::Node
A node in the call graph.
Definition: LazyCallGraph.h:315
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::SampleProfileProber::SampleProfileProber
SampleProfileProber(Function &F, const std::string &CurModuleUniqueId)
Definition: SampleProfileProbe.cpp:213
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
uint32_t
llvm::PseudoProbeManager::PseudoProbeManager
PseudoProbeManager(const Module &M)
Definition: SampleProfileProbe.cpp:172
llvm::SampleProfileProbePass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: SampleProfileProbe.cpp:395
llvm::PseudoProbeVerifier::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: SampleProfileProbe.cpp:87
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
BlockFrequencyInfo.h
llvm::AMDGPUISD::BFI
@ BFI
Definition: AMDGPUISelLowering.h:429
llvm::Any
Definition: Any.h:28
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::JamCRC::getCRC
uint32_t getCRC() const
Definition: CRC.h:52
llvm::GlobalValue::getGUID
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:559
llvm::getOrCreateFunctionComdat
Comdat * getOrCreateFunctionComdat(Function &F, Triple &T)
Definition: Instrumentation.cpp:76
llvm::LoopBase::getHeader
BlockT * getHeader() const
Definition: LoopInfo.h:104
llvm::ProbeFactorMap
std::unordered_map< std::pair< uint64_t, uint64_t >, float, pair_hash< uint64_t, uint64_t > > ProbeFactorMap
Definition: SampleProfileProbe.h:41
llvm::getUniqueModuleId
std::string getUniqueModuleId(Module *M)
Produce a unique identifier for this module by taking the MD5 sum of the names of the module's strong...
Definition: ModuleUtils.cpp:207
PseudoProbe.h
VerifyPseudoProbeFuncList
static cl::list< std::string > VerifyPseudoProbeFuncList("verify-pseudo-probe-funcs", cl::Hidden, cl::desc("The option to specify the name of the functions to verify."))
llvm::extractProbe
Optional< PseudoProbe > extractProbe(const Instruction &Inst)
Definition: PseudoProbe.cpp:48
llvm::MDBuilder
Definition: MDBuilder.h:35
llvm::PassInstrumentationCallbacks::registerAfterPassCallback
void registerAfterPassCallback(CallableT C)
Definition: PassInstrumentation.h:110
computeCallStackHash
static uint64_t computeCallStackHash(const Instruction &Inst)
Definition: SampleProfileProbe.cpp:69
llvm::sampleprof::FunctionSamples::getCanonicalFnName
static StringRef getCanonicalFnName(const Function &F)
Return the canonical name for a function, taking into account suffix elision policy attributes.
Definition: SampleProf.h:1012
llvm::Instruction::getDebugLoc
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:367
llvm::SampleProfileProber::instrumentOneFunc
void instrumentOneFunc(Function &F, TargetMachine *TM)
Definition: SampleProfileProbe.cpp:283
llvm::PassInstrumentationCallbacks
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Definition: PassInstrumentation.h:66
ModuleUtils.h
N
#define N
llvm::to_string
std::string to_string(const T &Value)
Definition: ScopedPrinter.h:85
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1803
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::InnerAnalysisManagerProxy
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:937
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::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::cl::desc
Definition: CommandLine.h:405
UpdatePseudoProbe
static cl::opt< bool > UpdatePseudoProbe("update-pseudo-probe", cl::init(true), cl::Hidden, cl::desc("Update pseudo probe distribution factor"))
llvm::abs
APFloat abs(APFloat X)
Returns the absolute value of the argument.
Definition: APFloat.h:1282
VerifyPseudoProbe
static cl::opt< bool > VerifyPseudoProbe("verify-pseudo-probe", cl::init(false), cl::Hidden, cl::desc("Do pseudo probe verification"))
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::PseudoProbeManager::moduleIsProbed
bool moduleIsProbed(const Module &M) const
Definition: SampleProfileProbe.cpp:192
llvm::MD5Hash
uint64_t MD5Hash(StringRef Str)
Helper to compute and return lower 64 bits of the given string's MD5 hash.
Definition: MD5.h:109
llvm::PseudoProbeType::DirectCall
@ DirectCall
llvm::cl::list
Definition: CommandLine.h:1601