[llvm] [CodeGen] Strip Coroutine suffixes when generating pseudo probe (PR #173834)

via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 28 23:38:25 PST 2025


https://github.com/HighW4y2H3ll updated https://github.com/llvm/llvm-project/pull/173834

>From 451dffa686219e36b2fe7bbd51937a6ac6ed5252 Mon Sep 17 00:00:00 2001
From: h2h <h2h at meta.com>
Date: Sun, 28 Dec 2025 23:11:02 -0800
Subject: [PATCH 1/2] [CodeGen] Strip Coroutine suffixes when generating pseudo
 probe

---
 llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
index 4bf3bdfb5adfd..2185ed1d8309e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -17,6 +17,7 @@
 #include "llvm/IR/PseudoProbe.h"
 #include "llvm/MC/MCPseudoProbe.h"
 #include "llvm/MC/MCStreamer.h"
+#include "llvm/ProfileData/SampleProf.h"
 
 #ifndef NDEBUG
 #include "llvm/IR/Module.h"
@@ -32,10 +33,15 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
   // When it's done ReversedInlineStack looks like ([66, B], [88, A])
   // which means, Function A inlines function B at calliste with a probe id 88,
   // and B inlines C at probe 66 where C is represented by Guid.
+  static const SmallVector<StringRef, 3> CoroSuffixes{".cleanup", ".destroy",
+                                                      ".resume"};
   SmallVector<InlineSite, 8> ReversedInlineStack;
   auto *InlinedAt = DebugLoc ? DebugLoc->getInlinedAt() : nullptr;
   while (InlinedAt) {
     auto Name = InlinedAt->getSubprogramLinkageName();
+    // Strip Coroutine suffixes from CoroSplit Pass, since pseudo probes are
+    // generated in an earlier stage.
+    Name = FunctionSamples::getCanonicalFnName(Name, CoroSuffixes);
     // Use caching to avoid redundant md5 computation for build speed.
     uint64_t &CallerGuid = NameGuidMap[Name];
     if (!CallerGuid)

>From 837d8c3f38d82a69e2cd9365ca9bcc82f31628df Mon Sep 17 00:00:00 2001
From: h2h <h2h at meta.com>
Date: Sun, 28 Dec 2025 23:38:05 -0800
Subject: [PATCH 2/2] Add dependency

---
 llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt b/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
index 34969d7524890..58fab8b634ad6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
+++ b/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
@@ -41,6 +41,7 @@ add_llvm_component_library(LLVMAsmPrinter
   DebugInfoDWARFLowLevel
   MC
   MCParser
+  ProfileData
   Remarks
   Support
   Target



More information about the llvm-commits mailing list