LLVM  13.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"
17 #include "llvm/IR/BasicBlock.h"
18 #include "llvm/IR/CFG.h"
19 #include "llvm/IR/Constant.h"
20 #include "llvm/IR/Constants.h"
22 #include "llvm/IR/GlobalValue.h"
23 #include "llvm/IR/GlobalVariable.h"
24 #include "llvm/IR/IRBuilder.h"
25 #include "llvm/IR/Instruction.h"
26 #include "llvm/IR/MDBuilder.h"
28 #include "llvm/Support/CRC.h"
32 #include <unordered_set>
33 #include <vector>
34 
35 using namespace llvm;
36 #define DEBUG_TYPE "sample-profile-probe"
37 
38 STATISTIC(ArtificialDbgLine,
39  "Number of probes that have an artificial debug line");
40 
41 static cl::opt<bool>
42  VerifyPseudoProbe("verify-pseudo-probe", cl::init(false), cl::Hidden,
43  cl::desc("Do pseudo probe verification"));
44 
46  "verify-pseudo-probe-funcs", cl::Hidden,
47  cl::desc("The option to specify the name of the functions to verify."));
48 
49 static cl::opt<bool>
50  UpdatePseudoProbe("update-pseudo-probe", cl::init(true), cl::Hidden,
51  cl::desc("Update pseudo probe distribution factor"));
52 
53 bool PseudoProbeVerifier::shouldVerifyFunction(const Function *F) {
54  // Skip function declaration.
55  if (F->isDeclaration())
56  return false;
57  // Skip function that will not be emitted into object file. The prevailing
58  // defintion will be verified instead.
59  if (F->hasAvailableExternallyLinkage())
60  return false;
61  // Do a name matching.
62  static std::unordered_set<std::string> VerifyFuncNames(
64  return VerifyFuncNames.empty() || VerifyFuncNames.count(F->getName().str());
65 }
66 
68  if (VerifyPseudoProbe) {
70  [this](StringRef P, Any IR, const PreservedAnalyses &) {
71  this->runAfterPass(P, IR);
72  });
73  }
74 }
75 
76 // Callback to run after each transformation for the new pass manager.
78  std::string Banner =
79  "\n*** Pseudo Probe Verification After " + PassID.str() + " ***\n";
80  dbgs() << Banner;
81  if (any_isa<const Module *>(IR))
82  runAfterPass(any_cast<const Module *>(IR));
83  else if (any_isa<const Function *>(IR))
84  runAfterPass(any_cast<const Function *>(IR));
85  else if (any_isa<const LazyCallGraph::SCC *>(IR))
86  runAfterPass(any_cast<const LazyCallGraph::SCC *>(IR));
87  else if (any_isa<const Loop *>(IR))
88  runAfterPass(any_cast<const Loop *>(IR));
89  else
90  llvm_unreachable("Unknown IR unit");
91 }
92 
94  for (const Function &F : *M)
95  runAfterPass(&F);
96 }
97 
99  for (const LazyCallGraph::Node &N : *C)
100  runAfterPass(&N.getFunction());
101 }
102 
104  if (!shouldVerifyFunction(F))
105  return;
106  ProbeFactorMap ProbeFactors;
107  for (const auto &BB : *F)
108  collectProbeFactors(&BB, ProbeFactors);
109  verifyProbeFactors(F, ProbeFactors);
110 }
111 
113  const Function *F = L->getHeader()->getParent();
114  runAfterPass(F);
115 }
116 
117 void PseudoProbeVerifier::collectProbeFactors(const BasicBlock *Block,
118  ProbeFactorMap &ProbeFactors) {
119  for (const auto &I : *Block) {
120  if (Optional<PseudoProbe> Probe = extractProbe(I))
121  ProbeFactors[Probe->Id] += Probe->Factor;
122  }
123 }
124 
125 void PseudoProbeVerifier::verifyProbeFactors(
126  const Function *F, const ProbeFactorMap &ProbeFactors) {
127  bool BannerPrinted = false;
128  auto &PrevProbeFactors = FunctionProbeFactors[F->getName()];
129  for (const auto &I : ProbeFactors) {
130  float CurProbeFactor = I.second;
131  if (PrevProbeFactors.count(I.first)) {
132  float PrevProbeFactor = PrevProbeFactors[I.first];
133  if (std::abs(CurProbeFactor - PrevProbeFactor) >
134  DistributionFactorVariance) {
135  if (!BannerPrinted) {
136  dbgs() << "Function " << F->getName() << ":\n";
137  BannerPrinted = true;
138  }
139  dbgs() << "Probe " << I.first << "\tprevious factor "
140  << format("%0.2f", PrevProbeFactor) << "\tcurrent factor "
141  << format("%0.2f", CurProbeFactor) << "\n";
142  }
143  }
144 
145  // Update
146  PrevProbeFactors[I.first] = I.second;
147  }
148 }
149 
151  if (NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName)) {
152  for (const auto *Operand : FuncInfo->operands()) {
153  const auto *MD = cast<MDNode>(Operand);
154  auto GUID =
155  mdconst::dyn_extract<ConstantInt>(MD->getOperand(0))->getZExtValue();
156  auto Hash =
157  mdconst::dyn_extract<ConstantInt>(MD->getOperand(1))->getZExtValue();
158  GUIDToProbeDescMap.try_emplace(GUID, PseudoProbeDescriptor(GUID, Hash));
159  }
160  }
161 }
162 
163 const PseudoProbeDescriptor *
164 PseudoProbeManager::getDesc(const Function &F) const {
165  auto I = GUIDToProbeDescMap.find(
167  return I == GUIDToProbeDescMap.end() ? nullptr : &I->second;
168 }
169 
171  return M.getNamedMetadata(PseudoProbeDescMetadataName);
172 }
173 
175  const FunctionSamples &Samples) const {
176  const auto *Desc = getDesc(F);
177  if (!Desc) {
178  LLVM_DEBUG(dbgs() << "Probe descriptor missing for Function " << F.getName()
179  << "\n");
180  return false;
181  } else {
182  if (Desc->getFunctionHash() != Samples.getFunctionHash()) {
183  LLVM_DEBUG(dbgs() << "Hash mismatch for Function " << F.getName()
184  << "\n");
185  return false;
186  }
187  }
188  return true;
189 }
190 
192  const std::string &CurModuleUniqueId)
193  : F(&Func), CurModuleUniqueId(CurModuleUniqueId) {
194  BlockProbeIds.clear();
195  CallProbeIds.clear();
196  LastProbeId = (uint32_t)PseudoProbeReservedId::Last;
197  computeProbeIdForBlocks();
198  computeProbeIdForCallsites();
199  computeCFGHash();
200 }
201 
202 // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
203 // value of each BB in the CFG. The higher 32 bits record the number of edges
204 // preceded by the number of indirect calls.
205 // This is derived from FuncPGOInstrumentation<Edge, BBInfo>::computeCFGHash().
206 void SampleProfileProber::computeCFGHash() {
207  std::vector<uint8_t> Indexes;
208  JamCRC JC;
209  for (auto &BB : *F) {
210  auto *TI = BB.getTerminator();
211  for (unsigned I = 0, E = TI->getNumSuccessors(); I != E; ++I) {
212  auto *Succ = TI->getSuccessor(I);
213  auto Index = getBlockId(Succ);
214  for (int J = 0; J < 4; J++)
215  Indexes.push_back((uint8_t)(Index >> (J * 8)));
216  }
217  }
218 
219  JC.update(Indexes);
220 
221  FunctionHash = (uint64_t)CallProbeIds.size() << 48 |
222  (uint64_t)Indexes.size() << 32 | JC.getCRC();
223  // Reserve bit 60-63 for other information purpose.
224  FunctionHash &= 0x0FFFFFFFFFFFFFFF;
225  assert(FunctionHash && "Function checksum should not be zero");
226  LLVM_DEBUG(dbgs() << "\nFunction Hash Computation for " << F->getName()
227  << ":\n"
228  << " CRC = " << JC.getCRC() << ", Edges = "
229  << Indexes.size() << ", ICSites = " << CallProbeIds.size()
230  << ", Hash = " << FunctionHash << "\n");
231 }
232 
233 void SampleProfileProber::computeProbeIdForBlocks() {
234  for (auto &BB : *F) {
235  BlockProbeIds[&BB] = ++LastProbeId;
236  }
237 }
238 
239 void SampleProfileProber::computeProbeIdForCallsites() {
240  for (auto &BB : *F) {
241  for (auto &I : BB) {
242  if (!isa<CallBase>(I))
243  continue;
244  if (isa<IntrinsicInst>(&I))
245  continue;
246  CallProbeIds[&I] = ++LastProbeId;
247  }
248  }
249 }
250 
251 uint32_t SampleProfileProber::getBlockId(const BasicBlock *BB) const {
252  auto I = BlockProbeIds.find(const_cast<BasicBlock *>(BB));
253  return I == BlockProbeIds.end() ? 0 : I->second;
254 }
255 
256 uint32_t SampleProfileProber::getCallsiteId(const Instruction *Call) const {
257  auto Iter = CallProbeIds.find(const_cast<Instruction *>(Call));
258  return Iter == CallProbeIds.end() ? 0 : Iter->second;
259 }
260 
262  Module *M = F.getParent();
263  MDBuilder MDB(F.getContext());
264  // Compute a GUID without considering the function's linkage type. This is
265  // fine since function name is the only key in the profile database.
266  uint64_t Guid = Function::getGUID(F.getName());
267 
268  // Assign an artificial debug line to a probe that doesn't come with a real
269  // line. A probe not having a debug line will get an incomplete inline
270  // context. This will cause samples collected on the probe to be counted
271  // into the base profile instead of a context profile. The line number
272  // itself is not important though.
273  auto AssignDebugLoc = [&](Instruction *I) {
274  assert((isa<PseudoProbeInst>(I) || isa<CallBase>(I)) &&
275  "Expecting pseudo probe or call instructions");
276  if (!I->getDebugLoc()) {
277  if (auto *SP = F.getSubprogram()) {
278  auto DIL = DILocation::get(SP->getContext(), 0, 0, SP);
279  I->setDebugLoc(DIL);
280  ArtificialDbgLine++;
281  LLVM_DEBUG({
282  dbgs() << "\nIn Function " << F.getName()
283  << " Probe gets an artificial debug line\n";
284  I->dump();
285  });
286  }
287  }
288  };
289 
290  // Probe basic blocks.
291  for (auto &I : BlockProbeIds) {
292  BasicBlock *BB = I.first;
293  uint32_t Index = I.second;
294  // Insert a probe before an instruction with a valid debug line number which
295  // will be assigned to the probe. The line number will be used later to
296  // model the inline context when the probe is inlined into other functions.
297  // Debug instructions, phi nodes and lifetime markers do not have an valid
298  // line number. Real instructions generated by optimizations may not come
299  // with a line number either.
300  auto HasValidDbgLine = [](Instruction *J) {
301  return !isa<PHINode>(J) && !isa<DbgInfoIntrinsic>(J) &&
302  !J->isLifetimeStartOrEnd() && J->getDebugLoc();
303  };
304 
305  Instruction *J = &*BB->getFirstInsertionPt();
306  while (J != BB->getTerminator() && !HasValidDbgLine(J)) {
307  J = J->getNextNode();
308  }
309 
310  IRBuilder<> Builder(J);
311  assert(Builder.GetInsertPoint() != BB->end() &&
312  "Cannot get the probing point");
313  Function *ProbeFn =
314  llvm::Intrinsic::getDeclaration(M, Intrinsic::pseudoprobe);
315  Value *Args[] = {Builder.getInt64(Guid), Builder.getInt64(Index),
316  Builder.getInt32(0),
318  auto *Probe = Builder.CreateCall(ProbeFn, Args);
319  AssignDebugLoc(Probe);
320  }
321 
322  // Probe both direct calls and indirect calls. Direct calls are probed so that
323  // their probe ID can be used as an call site identifier to represent a
324  // calling context.
325  for (auto &I : CallProbeIds) {
326  auto *Call = I.first;
327  uint32_t Index = I.second;
328  uint32_t Type = cast<CallBase>(Call)->getCalledFunction()
331  AssignDebugLoc(Call);
332  // Levarge the 32-bit discriminator field of debug data to store the ID and
333  // type of a callsite probe. This gets rid of the dependency on plumbing a
334  // customized metadata through the codegen pipeline.
337  if (auto DIL = Call->getDebugLoc()) {
338  DIL = DIL->cloneWithDiscriminator(V);
339  Call->setDebugLoc(DIL);
340  }
341  }
342 
343  // Create module-level metadata that contains function info necessary to
344  // synthesize probe-based sample counts, which are
345  // - FunctionGUID
346  // - FunctionHash.
347  // - FunctionName
348  auto Hash = getFunctionHash();
349  auto *MD = MDB.createPseudoProbeDesc(Guid, Hash, &F);
350  auto *NMD = M->getNamedMetadata(PseudoProbeDescMetadataName);
351  assert(NMD && "llvm.pseudo_probe_desc should be pre-created");
352  NMD->addOperand(MD);
353 
354  // Preserve a comdat group to hold all probes materialized later. This
355  // allows that when the function is considered dead and removed, the
356  // materialized probes are disposed too.
357  // Imported functions are defined in another module. They do not need
358  // the following handling since same care will be taken for them in their
359  // original module. The pseudo probes inserted into an imported functions
360  // above will naturally not be emitted since the imported function is free
361  // from object emission. However they will be emitted together with the
362  // inliner functions that the imported function is inlined into. We are not
363  // creating a comdat group for an import function since it's useless anyway.
364  if (!F.isDeclarationForLinker()) {
365  if (TM) {
366  auto Triple = TM->getTargetTriple();
367  if (Triple.supportsCOMDAT() && TM->getFunctionSections())
369  }
370  }
371 }
372 
374  ModuleAnalysisManager &AM) {
375  auto ModuleId = getUniqueModuleId(&M);
376  // Create the pseudo probe desc metadata beforehand.
377  // Note that modules with only data but no functions will require this to
378  // be set up so that they will be known as probed later.
379  M.getOrInsertNamedMetadata(PseudoProbeDescMetadataName);
380 
381  for (auto &F : M) {
382  if (F.isDeclaration())
383  continue;
384  SampleProfileProber ProbeManager(F, ModuleId);
385  ProbeManager.instrumentOneFunc(F, TM);
386  }
387 
388  return PreservedAnalyses::none();
389 }
390 
391 void PseudoProbeUpdatePass::runOnFunction(Function &F,
394  auto BBProfileCount = [&BFI](BasicBlock *BB) {
395  return BFI.getBlockProfileCount(BB)
396  ? BFI.getBlockProfileCount(BB).getValue()
397  : 0;
398  };
399 
400  // Collect the sum of execution weight for each probe.
401  ProbeFactorMap ProbeFactors;
402  for (auto &Block : F) {
403  for (auto &I : Block) {
404  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
405  // Do not count dangling probes since they are logically deleted and the
406  // current block that a dangling probe resides in doesn't reflect the
407  // execution count of the probe. The original samples of the probe will
408  // be distributed among the rest probes if there are any, this is
409  // less-than-deal but at least we don't lose any samples.
410  if (!Probe->isDangling())
411  ProbeFactors[Probe->Id] += BBProfileCount(&Block);
412  }
413  }
414  }
415 
416  // Fix up over-counted probes.
417  for (auto &Block : F) {
418  for (auto &I : Block) {
419  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
420  // Ignore danling probes since they are logically deleted and should do
421  // not consume any profile samples in the subsequent profile annotation.
422  if (!Probe->isDangling()) {
423  float Sum = ProbeFactors[Probe->Id];
424  if (Sum != 0)
425  setProbeDistributionFactor(I, BBProfileCount(&Block) / Sum);
426  }
427  }
428  }
429  }
430 }
431 
433  ModuleAnalysisManager &AM) {
434  if (UpdatePseudoProbe) {
435  for (auto &F : M) {
436  if (F.isDeclaration())
437  continue;
440  runOnFunction(F, FAM);
441  }
442  }
443  return PreservedAnalyses::none();
444 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
Instrumentation.h
llvm::PseudoProbeFullDistributionFactor
constexpr static uint64_t PseudoProbeFullDistributionFactor
Definition: PseudoProbe.h:36
llvm
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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::SystemZISD::TM
@ TM
Definition: SystemZISelLowering.h:65
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1379
llvm::PseudoProbeDwarfDiscriminator::FullDistributionFactor
constexpr static uint8_t FullDistributionFactor
Definition: PseudoProbe.h:76
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:1254
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:107
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:785
DebugInfoMetadata.h
llvm::Function
Definition: Function.h:61
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:529
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:309
llvm::PseudoProbeManager::profileIsValid
bool profileIsValid(const Function &F, const FunctionSamples &Samples) const
Definition: SampleProfileProbe.cpp:174
llvm::ilist_node_with_parent::getNextNode
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
Definition: ilist_node.h:288
Statistic.h
llvm::IRBuilder<>
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::PreservedAnalyses::none
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: PassManager.h:158
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::Optional
Definition: APInt.h:33
llvm::SampleProfileProber
Sample profile pseudo prober.
Definition: SampleProfileProbe.h:96
llvm::JamCRC
Definition: CRC.h:45
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:122
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1194
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::PseudoProbeDwarfDiscriminator::packProbeData
static uint32_t packProbeData(uint32_t Index, uint32_t Type, uint32_t Flags, uint32_t Factor)
Definition: PseudoProbe.h:49
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
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:432
GlobalValue.h
llvm::LazyCallGraph::SCC
An SCC of the call graph.
Definition: LazyCallGraph.h:421
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:26
TargetLibraryInfo.h
CRC.h
llvm::Triple::supportsCOMDAT
bool supportsCOMDAT() const
Tests whether the target supports comdat.
Definition: Triple.h:806
SampleProf.h
llvm::Instruction
Definition: Instruction.h:45
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:742
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:248
llvm::BlockFrequencyAnalysis
Analysis pass which computes BlockFrequencyInfo.
Definition: BlockFrequencyInfo.h:112
CFG.h
llvm::PseudoProbeVerifier::runAfterPass
void runAfterPass(StringRef PassID, Any IR)
Definition: SampleProfileProbe.cpp:77
BasicBlock.h
llvm::cl::opt< bool >
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::sampleprof::FunctionSamples
Representation of the samples collected for a function.
Definition: SampleProf.h:516
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:440
llvm::sampleprof::FunctionSamples::getFunctionHash
uint64_t getFunctionHash() const
Definition: SampleProf.h:766
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:41
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
SampleProfileProbe.h
llvm::LazyCallGraph::Node
A node in the call graph.
Definition: LazyCallGraph.h:317
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:643
llvm::SampleProfileProber::SampleProfileProber
SampleProfileProber(Function &F, const std::string &CurModuleUniqueId)
Definition: SampleProfileProbe.cpp:191
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
uint32_t
llvm::PseudoProbeManager::PseudoProbeManager
PseudoProbeManager(const Module &M)
Definition: SampleProfileProbe.cpp:150
llvm::SampleProfileProbePass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: SampleProfileProbe.cpp:373
llvm::PseudoProbeVerifier::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: SampleProfileProbe.cpp:67
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:419
Constant.h
llvm::Any
Definition: Any.h:26
llvm::JamCRC::getCRC
uint32_t getCRC() const
Definition: CRC.h:52
GlobalVariable.h
llvm::GlobalValue::getGUID
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:511
llvm::getOrCreateFunctionComdat
Comdat * getOrCreateFunctionComdat(Function &F, Triple &T)
Definition: Instrumentation.cpp:76
llvm::LoopBase::getHeader
BlockT * getHeader() const
Definition: LoopInfo.h:104
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:263
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:107
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:770
llvm::SampleProfileProber::instrumentOneFunc
void instrumentOneFunc(Function &F, TargetMachine *TM)
Definition: SampleProfileProbe.cpp:261
llvm::PassInstrumentationCallbacks
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Definition: PassInstrumentation.h:65
ModuleUtils.h
N
#define N
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:43
llvm::InnerAnalysisManagerProxy
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:969
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:379
llvm::cl::desc
Definition: CommandLine.h:411
llvm::ProbeFactorMap
std::unordered_map< uint64_t, float > ProbeFactorMap
Definition: SampleProfileProbe.h:36
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:1272
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:75
llvm::PseudoProbeManager::moduleIsProbed
bool moduleIsProbed(const Module &M) const
Definition: SampleProfileProbe.cpp:170
llvm::PseudoProbeType::DirectCall
@ DirectCall
llvm::cl::list
Definition: CommandLine.h:1627