[PATCH] D146657: [Pseudo Probe] use the name from debug info to compute probe GUID

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 13:17:45 PDT 2023


wlei created this revision.
Herald added subscribers: ormris, hoy, wenlei, hiraditya.
Herald added a project: All.
wlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146657

Files:
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp


Index: llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
+++ llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
@@ -286,9 +286,15 @@
 void SampleProfileProber::instrumentOneFunc(Function &F, TargetMachine *TM) {
   Module *M = F.getParent();
   MDBuilder MDB(F.getContext());
-  // Compute a GUID without considering the function's linkage type. This is
-  // fine since function name is the only key in the profile database.
-  uint64_t Guid = Function::getGUID(F.getName());
+  // Always use the name from debug info if it's avaiable. This is to be
+  // consistent with the probe name from the inline stack.
+  StringRef FName = F.getName();
+  if (auto *SP = F.getSubprogram()) {
+    FName = SP->getLinkageName();
+    if (FName.empty())
+      FName = SP->getName();
+  }
+  uint64_t Guid = Function::getGUID(FName);
 
   // Assign an artificial debug line to a probe that doesn't come with a real
   // line. A probe not having a debug line will get an incomplete inline


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146657.507482.patch
Type: text/x-patch
Size: 1090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230322/70570353/attachment.bin>


More information about the llvm-commits mailing list