https://github.com/mingmingl-llvm created 
https://github.com/llvm/llvm-project/pull/178336

None

>From d87fb4893d7f59c9cc6725a57fd8f8fbea914d90 Mon Sep 17 00:00:00 2001
From: Mingming Liu <[email protected]>
Date: Tue, 27 Jan 2026 17:41:33 -0800
Subject: [PATCH] Update codegen pass

---
 llvm/lib/Analysis/StaticDataProfileInfo.cpp        | 10 +++++-----
 llvm/lib/Transforms/Instrumentation/MemProfUse.cpp | 14 +++++++-------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/llvm/lib/Analysis/StaticDataProfileInfo.cpp 
b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
index 61d49350c7702..96771ca8660a9 100644
--- a/llvm/lib/Analysis/StaticDataProfileInfo.cpp
+++ b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
@@ -12,6 +12,7 @@
 using namespace llvm;
 
 namespace llvm {
+extern cl::opt<unsigned> AnnotateStringLiteralSectionPrefix;
 namespace memprof {
 // Returns true iff the global variable has custom section either by
 // __attribute__((section("name")))
@@ -124,11 +125,12 @@ StringRef StaticDataProfileInfo::getConstantSectionPrefix(
 #endif
 
   if (EnableDataAccessProf) {
-    // Module flag `HasDataAccessProf` is 1 -> empty section prefix means
-    // unknown hotness except for string literals.
+    // Both data access profiles and PGO counters are available. Use the
+    //  hotter one.
     if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C);
         GV && llvm::memprof::IsAnnotationOK(*GV) &&
-        !GV->getName().starts_with(".str")) {
+        (AnnotateStringLiteralSectionPrefix ||
+         !GV->getName().starts_with(".str"))) {
       auto HotnessFromDataAccessProf =
           getSectionHotnessUsingDataAccessProfile(GV->getSectionPrefix());
 
@@ -140,8 +142,6 @@ StringRef StaticDataProfileInfo::getConstantSectionPrefix(
         return Prefix;
       }
 
-      // Both data access profiles and PGO counters are available. Use the
-      // hotter one.
       auto HotnessFromPGO = getConstantHotnessUsingProfileCount(C, PSI, 
*Count);
       StaticDataHotness GlobalVarHotness = 
StaticDataHotness::LukewarmOrUnknown;
       if (HotnessFromDataAccessProf == StaticDataHotness::Hot ||
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp 
b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
index bf7df69ee5c3b..c2856bb532930 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
@@ -45,6 +45,13 @@ namespace llvm {
 extern cl::opt<bool> PGOWarnMissing;
 extern cl::opt<bool> NoPGOWarnMismatch;
 extern cl::opt<bool> NoPGOWarnMismatchComdatWeak;
+// FIXME: This option is added for incremental rollout purposes.
+// After the option, string literal partitioning should be implied by
+// AnnotateStaticDataSectionPrefix above and this option should be cleaned up.
+cl::opt<bool> AnnotateStringLiteralSectionPrefix(
+    "memprof-annotate-string-literal-section-prefix", cl::init(false),
+    cl::Hidden,
+    cl::desc("If true, annotate the string literal data section prefix"));
 } // namespace llvm
 
 // By default disable matching of allocation profiles onto operator new that
@@ -92,13 +99,6 @@ static cl::opt<bool> AnnotateStaticDataSectionPrefix(
     "memprof-annotate-static-data-prefix", cl::init(false), cl::Hidden,
     cl::desc("If true, annotate the static data section prefix"));
 
-// FIXME: This option is added for incremental rollout purposes.
-// After the option, string literal partitioning should be implied by
-// AnnotateStaticDataSectionPrefix above and this option should be cleaned up.
-static cl::opt<bool> AnnotateStringLiteralSectionPrefix(
-    "memprof-annotate-string-literal-section-prefix", cl::init(false), 
cl::Hidden,
-    cl::desc("If true, annotate the string literal data section prefix"));
-
 // Matching statistics
 STATISTIC(NumOfMemProfMissing, "Number of functions without memory profile.");
 STATISTIC(NumOfMemProfMismatch,

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to