[PATCH] D152595: [PseudoProbe] Disgard probes for dead functions.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 16:42:33 PDT 2023


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

Probes of dead functions may be left over in the final binary for some reason, and they should be disgarded during decoding. The llvm-profgen profile generation path should already disgarded them due to its on-demand style decoding. I'm fixing for the --show-disassembly path which unconditionally decodes all probes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152595

Files:
  llvm/lib/MC/MCPseudoProbe.cpp


Index: llvm/lib/MC/MCPseudoProbe.cpp
===================================================================
--- llvm/lib/MC/MCPseudoProbe.cpp
+++ llvm/lib/MC/MCPseudoProbe.cpp
@@ -446,8 +446,12 @@
     Cur = Cur->getOrAddNode(std::make_tuple(Guid, Index));
     Cur->Guid = Guid;
     if (IsTopLevelFunc && !EncodingIsAddrBased) {
-      if (auto V = FuncStartAddrs.lookup(Guid))
+      if (auto V = FuncStartAddrs.lookup(Guid)) {
         LastAddr = V;
+      } else {
+        // The probe metadata is for a dead function, so discard it.
+        Cur = nullptr;
+      }
     }
   }
 
@@ -490,8 +494,12 @@
       if (isSentinelProbe(Attr)) {
         // For sentinel probe, the addr field actually stores the GUID of the
         // split function. Convert it to the real address.
-        if (auto V = FuncStartAddrs.lookup(Addr))
+        if (auto V = FuncStartAddrs.lookup(Addr)) {
           Addr = V;
+        } else {
+          // The probe metadata is for a dead function, so discard it.
+          Cur = nullptr;
+        }
       } else {
         // For now we assume all probe encoding should be either based on
         // leading probe address or function start address.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152595.530115.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230609/f8561565/attachment.bin>


More information about the llvm-commits mailing list