aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authormingmingl <mingmingl@google.com>2025-08-30 20:34:28 -0700
committermingmingl <mingmingl@google.com>2025-09-13 22:26:24 -0700
commitd4e4d958ce165b82f4da2b509bec5a7e4aaec756 (patch)
treed9caa5e5f0864a28c0c8e74adaea215b66cbe0cb /llvm/lib/Transforms
parent4a7ba1de7100e15d7fb444c0b9868977b16b5494 (diff)
downloadllvm-users/mingmingl-llvm/annotator.zip
llvm-users/mingmingl-llvm/annotator.tar.gz
llvm-users/mingmingl-llvm/annotator.tar.bz2
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemProfUse.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
index ecb2f2d..789396c 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
@@ -41,6 +41,7 @@ using namespace llvm::memprof;
#define DEBUG_TYPE "memprof"
namespace llvm {
+extern cl::opt<bool> AnnotateStaticDataSectionPrefix;
extern cl::opt<bool> PGOWarnMissing;
extern cl::opt<bool> NoPGOWarnMismatch;
extern cl::opt<bool> NoPGOWarnMismatchComdatWeak;
@@ -76,10 +77,6 @@ static cl::opt<unsigned> MinMatchedColdBytePercent(
"memprof-matching-cold-threshold", cl::init(100), cl::Hidden,
cl::desc("Min percent of cold bytes matched to hint allocation cold"));
-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,
@@ -797,7 +794,11 @@ bool MemProfUsePass::annotateGlobalVariables(
if (!AnnotateStaticDataSectionPrefix || M.globals().empty())
return false;
+ // The module flag helps codegen passes interpret empty section prefix:
+ // - 0 : empty section prefix is expected for each GV.
+ // - 1 : empty section prefix means the GV has unknown hotness.
if (!DataAccessProf) {
+ M.addModuleFlag(Module::Warning, "HasDataAccessProf", 0U);
M.getContext().diagnose(DiagnosticInfoPGOProfile(
MemoryProfileFileName.data(),
StringRef("Data access profiles not found in memprof. Ignore "
@@ -806,6 +807,8 @@ bool MemProfUsePass::annotateGlobalVariables(
return false;
}
+ M.addModuleFlag(Module::Warning, "HasDataAccessProf", 1);
+
bool Changed = false;
// Iterate all global variables in the module and annotate them based on
// data access profiles. Note it's up to the linker to decide how to map input