LLVM  14.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 static uint64_t getCallStackHash(const DILocation *DIL) {
54  uint64_t Hash = 0;
55  const DILocation *InlinedAt = DIL ? DIL->getInlinedAt() : nullptr;
56  while (InlinedAt) {
57  Hash ^= MD5Hash(std::to_string(InlinedAt->getLine()));
58  Hash ^= MD5Hash(std::to_string(InlinedAt->getColumn()));
59  const DISubprogram *SP = InlinedAt->getScope()->getSubprogram();
60  // Use linkage name for C++ if possible.
61  auto Name = SP->getLinkageName();
62  if (Name.empty())
63  Name = SP->getName();
64  Hash ^= MD5Hash(Name);
65  InlinedAt = InlinedAt->getInlinedAt();
66  }
67  return Hash;
68 }
69 
71  return getCallStackHash(Inst.getDebugLoc());
72 }
73 
74 bool PseudoProbeVerifier::shouldVerifyFunction(const Function *F) {
75  // Skip function declaration.
76  if (F->isDeclaration())
77  return false;
78  // Skip function that will not be emitted into object file. The prevailing
79  // defintion will be verified instead.
80  if (F->hasAvailableExternallyLinkage())
81  return false;
82  // Do a name matching.
83  static std::unordered_set<std::string> VerifyFuncNames(
85  return VerifyFuncNames.empty() || VerifyFuncNames.count(F->getName().str());
86 }
87 
89  if (VerifyPseudoProbe) {
91  [this](StringRef P, Any IR, const PreservedAnalyses &) {
92  this->runAfterPass(P, IR);
93  });
94  }
95 }
96 
97 // Callback to run after each transformation for the new pass manager.
99  std::string Banner =
100  "\n*** Pseudo Probe Verification After " + PassID.str() + " ***\n";
101  dbgs() << Banner;
102  if (any_isa<const Module *>(IR))
103  runAfterPass(any_cast<const Module *>(IR));
104  else if (any_isa<const Function *>(IR))
105  runAfterPass(any_cast<const Function *>(IR));
106  else if (any_isa<const LazyCallGraph::SCC *>(IR))
107  runAfterPass(any_cast<const LazyCallGraph::SCC *>(IR));
108  else if (any_isa<const Loop *>(IR))
109  runAfterPass(any_cast<const Loop *>(IR));
110  else
111  llvm_unreachable("Unknown IR unit");
112 }
113 
115  for (const Function &F : *M)
116  runAfterPass(&F);
117 }
118 
120  for (const LazyCallGraph::Node &N : *C)
121  runAfterPass(&N.getFunction());
122 }
123 
125  if (!shouldVerifyFunction(F))
126  return;
127  ProbeFactorMap ProbeFactors;
128  for (const auto &BB : *F)
129  collectProbeFactors(&BB, ProbeFactors);
130  verifyProbeFactors(F, ProbeFactors);
131 }
132 
134  const Function *F = L->getHeader()->getParent();
135  runAfterPass(F);
136 }
137 
138 void PseudoProbeVerifier::collectProbeFactors(const BasicBlock *Block,
139  ProbeFactorMap &ProbeFactors) {
140  for (const auto &I : *Block) {
141  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
143  ProbeFactors[{Probe->Id, Hash}] += Probe->Factor;
144  }
145  }
146 }
147 
148 void PseudoProbeVerifier::verifyProbeFactors(
149  const Function *F, const ProbeFactorMap &ProbeFactors) {
150  bool BannerPrinted = false;
151  auto &PrevProbeFactors = FunctionProbeFactors[F->getName()];
152  for (const auto &I : ProbeFactors) {
153  float CurProbeFactor = I.second;
154  if (PrevProbeFactors.count(I.first)) {
155  float PrevProbeFactor = PrevProbeFactors[I.first];
156  if (std::abs(CurProbeFactor - PrevProbeFactor) >
157  DistributionFactorVariance) {
158  if (!BannerPrinted) {
159  dbgs() << "Function " << F->getName() << ":\n";
160  BannerPrinted = true;
161  }
162  dbgs() << "Probe " << I.first.first << "\tprevious factor "
163  << format("%0.2f", PrevProbeFactor) << "\tcurrent factor "
164  << format("%0.2f", CurProbeFactor) << "\n";
165  }
166  }
167 
168  // Update
169  PrevProbeFactors[I.first] = I.second;
170  }
171 }
172 
174  if (NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName)) {
175  for (const auto *Operand : FuncInfo->operands()) {
176  const auto *MD = cast<MDNode>(Operand);
177  auto GUID =
178  mdconst::dyn_extract<ConstantInt>(MD->getOperand(0))->getZExtValue();
179  auto Hash =
180  mdconst::dyn_extract<ConstantInt>(MD->getOperand(1))->getZExtValue();
181  GUIDToProbeDescMap.try_emplace(GUID, PseudoProbeDescriptor(GUID, Hash));
182  }
183  }
184 }
185 
186 const PseudoProbeDescriptor *
187 PseudoProbeManager::getDesc(const Function &F) const {
188  auto I = GUIDToProbeDescMap.find(
190  return I == GUIDToProbeDescMap.end() ? nullptr : &I->second;
191 }
192 
194  return M.getNamedMetadata(PseudoProbeDescMetadataName);
195 }
196 
198  const FunctionSamples &Samples) const {
199  const auto *Desc = getDesc(F);
200  if (!Desc) {
201  LLVM_DEBUG(dbgs() << "Probe descriptor missing for Function " << F.getName()
202  << "\n");
203  return false;
204  } else {
205  if (Desc->getFunctionHash() != Samples.getFunctionHash()) {
206  LLVM_DEBUG(dbgs() << "Hash mismatch for Function " << F.getName()
207  << "\n");
208  return false;
209  }
210  }
211  return true;
212 }
213 
215  const std::string &CurModuleUniqueId)
216  : F(&Func), CurModuleUniqueId(CurModuleUniqueId) {
217  BlockProbeIds.clear();
218  CallProbeIds.clear();
219  LastProbeId = (uint32_t)PseudoProbeReservedId::Last;
220  computeProbeIdForBlocks();
221  computeProbeIdForCallsites();
222  computeCFGHash();
223 }
224 
225 // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
226 // value of each BB in the CFG. The higher 32 bits record the number of edges
227 // preceded by the number of indirect calls.
228 // This is derived from FuncPGOInstrumentation<Edge, BBInfo>::computeCFGHash().
229 void SampleProfileProber::computeCFGHash() {
230  std::vector<uint8_t> Indexes;
231  JamCRC JC;
232  for (auto &BB : *F) {
233  auto *TI = BB.getTerminator();
234  for (unsigned I = 0, E = TI->getNumSuccessors(); I != E; ++I) {
235  auto *Succ = TI->getSuccessor(I);
236  auto Index = getBlockId(Succ);
237  for (int J = 0; J < 4; J++)
238  Indexes.push_back((uint8_t)(Index >> (J * 8)));
239  }
240  }
241 
242  JC.update(Indexes);
243 
244  FunctionHash = (uint64_t)CallProbeIds.size() << 48 |
245  (uint64_t)Indexes.size() << 32 | JC.getCRC();
246  // Reserve bit 60-63 for other information purpose.
247  FunctionHash &= 0x0FFFFFFFFFFFFFFF;
248  assert(FunctionHash && "Function checksum should not be zero");
249  LLVM_DEBUG(dbgs() << "\nFunction Hash Computation for " << F->getName()
250  << ":\n"
251  << " CRC = " << JC.getCRC() << ", Edges = "
252  << Indexes.size() << ", ICSites = " << CallProbeIds.size()
253  << ", Hash = " << FunctionHash << "\n");
254 }
255 
256 void SampleProfileProber::computeProbeIdForBlocks() {
257  for (auto &BB : *F) {
258  BlockProbeIds[&BB] = ++LastProbeId;
259  }
260 }
261 
262 void SampleProfileProber::computeProbeIdForCallsites() {
263  for (auto &BB : *F) {
264  for (auto &I : BB) {
265  if (!isa<CallBase>(I))
266  continue;
267  if (isa<IntrinsicInst>(&I))
268  continue;
269  CallProbeIds[&I] = ++LastProbeId;
270  }
271  }
272 }
273 
274 uint32_t SampleProfileProber::getBlockId(const BasicBlock *BB) const {
275  auto I = BlockProbeIds.find(const_cast<BasicBlock *>(BB));
276  return I == BlockProbeIds.end() ? 0 : I->second;
277 }
278 
279 uint32_t SampleProfileProber::getCallsiteId(const Instruction *Call) const {
280  auto Iter = CallProbeIds.find(const_cast<Instruction *>(Call));
281  return Iter == CallProbeIds.end() ? 0 : Iter->second;
282 }
283 
285  Module *M = F.getParent();
286  MDBuilder MDB(F.getContext());
287  // Compute a GUID without considering the function's linkage type. This is
288  // fine since function name is the only key in the profile database.
289  uint64_t Guid = Function::getGUID(F.getName());
290 
291  // Assign an artificial debug line to a probe that doesn't come with a real
292  // line. A probe not having a debug line will get an incomplete inline
293  // context. This will cause samples collected on the probe to be counted
294  // into the base profile instead of a context profile. The line number
295  // itself is not important though.
296  auto AssignDebugLoc = [&](Instruction *I) {
297  assert((isa<PseudoProbeInst>(I) || isa<CallBase>(I)) &&
298  "Expecting pseudo probe or call instructions");
299  if (!I->getDebugLoc()) {
300  if (auto *SP = F.getSubprogram()) {
301  auto DIL = DILocation::get(SP->getContext(), 0, 0, SP);
302  I->setDebugLoc(DIL);
303  ArtificialDbgLine++;
304  LLVM_DEBUG({
305  dbgs() << "\nIn Function " << F.getName()
306  << " Probe gets an artificial debug line\n";
307  I->dump();
308  });
309  }
310  }
311  };
312 
313  // Probe basic blocks.
314  for (auto &I : BlockProbeIds) {
315  BasicBlock *BB = I.first;
316  uint32_t Index = I.second;
317  // Insert a probe before an instruction with a valid debug line number which
318  // will be assigned to the probe. The line number will be used later to
319  // model the inline context when the probe is inlined into other functions.
320  // Debug instructions, phi nodes and lifetime markers do not have an valid
321  // line number. Real instructions generated by optimizations may not come
322  // with a line number either.
323  auto HasValidDbgLine = [](Instruction *J) {
324  return !isa<PHINode>(J) && !isa<DbgInfoIntrinsic>(J) &&
325  !J->isLifetimeStartOrEnd() && J->getDebugLoc();
326  };
327 
328  Instruction *J = &*BB->getFirstInsertionPt();
329  while (J != BB->getTerminator() && !HasValidDbgLine(J)) {
330  J = J->getNextNode();
331  }
332 
333  IRBuilder<> Builder(J);
334  assert(Builder.GetInsertPoint() != BB->end() &&
335  "Cannot get the probing point");
336  Function *ProbeFn =
337  llvm::Intrinsic::getDeclaration(M, Intrinsic::pseudoprobe);
338  Value *Args[] = {Builder.getInt64(Guid), Builder.getInt64(Index),
339  Builder.getInt32(0),
341  auto *Probe = Builder.CreateCall(ProbeFn, Args);
342  AssignDebugLoc(Probe);
343  }
344 
345  // Probe both direct calls and indirect calls. Direct calls are probed so that
346  // their probe ID can be used as an call site identifier to represent a
347  // calling context.
348  for (auto &I : CallProbeIds) {
349  auto *Call = I.first;
350  uint32_t Index = I.second;
351  uint32_t Type = cast<CallBase>(Call)->getCalledFunction()
354  AssignDebugLoc(Call);
355  // Levarge the 32-bit discriminator field of debug data to store the ID and
356  // type of a callsite probe. This gets rid of the dependency on plumbing a
357  // customized metadata through the codegen pipeline.
360  if (auto DIL = Call->getDebugLoc()) {
361  DIL = DIL->cloneWithDiscriminator(V);
362  Call->setDebugLoc(DIL);
363  }
364  }
365 
366  // Create module-level metadata that contains function info necessary to
367  // synthesize probe-based sample counts, which are
368  // - FunctionGUID
369  // - FunctionHash.
370  // - FunctionName
371  auto Hash = getFunctionHash();
372  auto *MD = MDB.createPseudoProbeDesc(Guid, Hash, &F);
373  auto *NMD = M->getNamedMetadata(PseudoProbeDescMetadataName);
374  assert(NMD && "llvm.pseudo_probe_desc should be pre-created");
375  NMD->addOperand(MD);
376 
377  // Preserve a comdat group to hold all probes materialized later. This
378  // allows that when the function is considered dead and removed, the
379  // materialized probes are disposed too.
380  // Imported functions are defined in another module. They do not need
381  // the following handling since same care will be taken for them in their
382  // original module. The pseudo probes inserted into an imported functions
383  // above will naturally not be emitted since the imported function is free
384  // from object emission. However they will be emitted together with the
385  // inliner functions that the imported function is inlined into. We are not
386  // creating a comdat group for an import function since it's useless anyway.
387  if (!F.isDeclarationForLinker()) {
388  if (TM) {
389  auto Triple = TM->getTargetTriple();
390  if (Triple.supportsCOMDAT() && TM->getFunctionSections())
392  }
393  }
394 }
395 
397  ModuleAnalysisManager &AM) {
398  auto ModuleId = getUniqueModuleId(&M);
399  // Create the pseudo probe desc metadata beforehand.
400  // Note that modules with only data but no functions will require this to
401  // be set up so that they will be known as probed later.
402  M.getOrInsertNamedMetadata(PseudoProbeDescMetadataName);
403 
404  for (auto &F : M) {
405  if (F.isDeclaration())
406  continue;
407  SampleProfileProber ProbeManager(F, ModuleId);
408  ProbeManager.instrumentOneFunc(F, TM);
409  }
410 
411  return PreservedAnalyses::none();
412 }
413 
414 void PseudoProbeUpdatePass::runOnFunction(Function &F,
417  auto BBProfileCount = [&BFI](BasicBlock *BB) {
418  return BFI.getBlockProfileCount(BB)
419  ? BFI.getBlockProfileCount(BB).getValue()
420  : 0;
421  };
422 
423  // Collect the sum of execution weight for each probe.
424  ProbeFactorMap ProbeFactors;
425  for (auto &Block : F) {
426  for (auto &I : Block) {
427  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
429  ProbeFactors[{Probe->Id, Hash}] += BBProfileCount(&Block);
430  }
431  }
432  }
433 
434  // Fix up over-counted probes.
435  for (auto &Block : F) {
436  for (auto &I : Block) {
437  if (Optional<PseudoProbe> Probe = extractProbe(I)) {
439  float Sum = ProbeFactors[{Probe->Id, Hash}];
440  if (Sum != 0)
441  setProbeDistributionFactor(I, BBProfileCount(&Block) / Sum);
442  }
443  }
444  }
445 }
446 
448  ModuleAnalysisManager &AM) {
449  if (UpdatePseudoProbe) {
450  for (auto &F : M) {
451  if (F.isDeclaration())
452  continue;
455  runOnFunction(F, FAM);
456  }
457  }
458  return PreservedAnalyses::none();
459 }
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:31
llvm
---------------------— PointerInfo ------------------------------------—
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::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1396
llvm::PseudoProbeDwarfDiscriminator::FullDistributionFactor
constexpr static uint8_t FullDistributionFactor
Definition: PseudoProbe.h:71
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:1379
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:779
DebugInfoMetadata.h
llvm::Function
Definition: Function.h:61
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:530
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:197
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
FAM
FunctionAnalysisManager FAM
Definition: PassBuilderBindings.cpp:59
llvm::DIScope::getName
StringRef getName() const
Definition: DebugInfoMetadata.cpp:261
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1580
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:45
PIC
PassInstrumentationCallbacks PIC
Definition: PassBuilderBindings.cpp:55
llvm::Optional
Definition: APInt.h:33
llvm::SampleProfileProber
Sample profile pseudo prober.
Definition: SampleProfileProbe.h:99
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:1208
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:44
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: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:447
GlobalValue.h
llvm::LazyCallGraph::SCC
An SCC of the call graph.
Definition: LazyCallGraph.h:422
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:815
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:744
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:245
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:98
getCallStackHash
static uint64_t getCallStackHash(const DILocation *DIL)
Definition: SampleProfileProbe.cpp:53
BasicBlock.h
llvm::cl::opt< bool >
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
uint64_t
llvm::sampleprof::FunctionSamples
Representation of the samples collected for a function.
Definition: SampleProf.h:684
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
llvm::sampleprof::FunctionSamples::getFunctionHash
uint64_t getFunctionHash() const
Definition: SampleProf.h:922
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:79
llvm::PseudoProbeDescriptor
Definition: SampleProfileProbe.h:44
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:318
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::SampleProfileProber::SampleProfileProber
SampleProfileProber(Function &F, const std::string &CurModuleUniqueId)
Definition: SampleProfileProbe.cpp:214
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:136
uint32_t
llvm::PseudoProbeManager::PseudoProbeManager
PseudoProbeManager(const Module &M)
Definition: SampleProfileProbe.cpp:173
llvm::SampleProfileProbePass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: SampleProfileProbe.cpp:396
llvm::PseudoProbeVerifier::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: SampleProfileProbe.cpp:88
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:421
Constant.h
llvm::Any
Definition: Any.h:26
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
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::ProbeFactorMap
std::unordered_map< std::pair< uint64_t, uint64_t >, float, pair_hash< uint64_t, uint64_t > > ProbeFactorMap
Definition: SampleProfileProbe.h:39
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:244
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:70
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:926
llvm::Instruction::getDebugLoc
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:370
llvm::SampleProfileProber::instrumentOneFunc
void instrumentOneFunc(Function &F, TargetMachine *TM)
Definition: SampleProfileProbe.cpp:284
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:63
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1820
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
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:936
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:389
llvm::cl::desc
Definition: CommandLine.h:414
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:1284
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:193
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:122
llvm::PseudoProbeType::DirectCall
@ DirectCall
llvm::cl::list
Definition: CommandLine.h:1642