[llvm] c94f798 - Strip .llvm. suffix after removing the coroutine suffixes to avoid breaking pseudo probe (#191354)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 10:10:01 PDT 2026


Author: HighW4y2H3ll
Date: 2026-04-10T10:09:56-07:00
New Revision: c94f79886035a61bb5f3dc992f75fe0c08bdcd4b

URL: https://github.com/llvm/llvm-project/commit/c94f79886035a61bb5f3dc992f75fe0c08bdcd4b
DIFF: https://github.com/llvm/llvm-project/commit/c94f79886035a61bb5f3dc992f75fe0c08bdcd4b.diff

LOG: Strip .llvm. suffix after removing the coroutine suffixes to avoid breaking pseudo probe (#191354)

Pseudo probe is currently broken when a coroutine function is promoted
with a global name during ThinLTO import. The top-level function GUID in
.pseudo_probe section are computed from the promoted name (with
".llvm.xxxx" suffix) instead of the original function name. Then it will
cause a dangling top-level GUID that doesn't have any reference in the
pseudo probe desc, and potentially hurt profile quality.

The root cause of the issue were:
1) ThinLTO post-link imports and promotes a local coroutine function,
creating a global function with ".llvm.xxxx" suffix.
2) https://github.com/llvm/llvm-project/pull/141889 introduces a change
in CoroSplit pass that updates the coroutine functions linkage name with
the ".cleanup", ".destroy", ".resume" suffixes, and this creates
top-level functions with ".llvm.xxxx.cleanup", ".llvm.xxxx.destroy",
".llvm.xxxx.resume" suffixes.
3) PseudoProbePrinter and PseudoProbeInserter only strips coroutine
suffix, and didn't consider the ".llvm." suffix.

This patch fixes the issue in step 3)

Added: 
    

Modified: 
    llvm/include/llvm/ProfileData/SampleProf.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index 14243688d075a..956d411bfba03 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -1227,8 +1227,12 @@ class FunctionSamples {
 
   static StringRef getCanonicalCoroFnName(StringRef FnName,
                                           StringRef Attr = "selected") {
+    // A local coroutine function from another CU can be promoted to a global
+    // function during ThinLTO import. This will create a linkage name like
+    // "_Zfoo.llvm.xxxx.cleanup". Remove the ".llvm." suffix after stripping all
+    // the coroutine suffixes to avoid pseudo probe mismatch.
     const SmallVector<StringRef, 3> CoroSuffixes{".cleanup", ".destroy",
-                                                 ".resume"};
+                                                 ".resume", LLVMSuffix};
     return getCanonicalFnName(FnName, CoroSuffixes, Attr);
   }
 


        


More information about the llvm-commits mailing list