https://github.com/mingmingl-llvm updated https://github.com/llvm/llvm-project/pull/178336
>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 1/2] 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, >From ff7bfb9a8da8b5f2d689c0c94e5805d70c4c305e Mon Sep 17 00:00:00 2001 From: mingmingl <[email protected]> Date: Wed, 28 Jan 2026 08:54:29 -0800 Subject: [PATCH 2/2] Move option from transforms to analysis pass --- llvm/lib/Analysis/StaticDataProfileInfo.cpp | 9 ++++++++- llvm/lib/Transforms/Instrumentation/MemProfUse.cpp | 9 +-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Analysis/StaticDataProfileInfo.cpp b/llvm/lib/Analysis/StaticDataProfileInfo.cpp index 96771ca8660a9..e06380bdd5d26 100644 --- a/llvm/lib/Analysis/StaticDataProfileInfo.cpp +++ b/llvm/lib/Analysis/StaticDataProfileInfo.cpp @@ -12,7 +12,14 @@ using namespace llvm; namespace llvm { -extern cl::opt<unsigned> AnnotateStringLiteralSectionPrefix; +// FIXME: This option is added for incremental rollout purposes. +// After the option, string literal partitioning should be implied by +// AnnotateStaticDataSectionPrefix in MemProfUse.cpp 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 memprof { // Returns true iff the global variable has custom section either by // __attribute__((section("name"))) diff --git a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp index d56fd90a48e66..cbb7ae03c245e 100644 --- a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp @@ -45,13 +45,7 @@ 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 below 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")); +extern cl::opt<bool> AnnotateStringLiteralSectionPrefix; } // namespace llvm // By default disable matching of allocation profiles onto operator new that @@ -99,7 +93,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")); - // 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
