aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGen.cpp
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2025-03-28 16:31:46 -0700
committerGitHub <noreply@github.com>2025-03-28 16:31:46 -0700
commitc8a70f4c6e24076ac3fc18bfb9e2a41ece83e7fc (patch)
tree4640bde08baa5ae74e919711b2819fcab01aeca4 /llvm/lib/CodeGen/CodeGen.cpp
parent1e00bb16f488492198df692ae2e2abc405a138f3 (diff)
downloadllvm-c8a70f4c6e24076ac3fc18bfb9e2a41ece83e7fc.zip
llvm-c8a70f4c6e24076ac3fc18bfb9e2a41ece83e7fc.tar.gz
llvm-c8a70f4c6e24076ac3fc18bfb9e2a41ece83e7fc.tar.bz2
[CodeGen][StaticDataPartitioning]Place local-linkage global variables in hot or unlikely prefixed sections based on profile information (#125756)
In this PR, static-data-splitter pass finds out the local-linkage global variables in {`.rodata`, `.data.rel.ro`, `bss`, `.data`} sections by analyzing machine instruction operands, and aggregates their accesses from code across functions. A follow-up item is to analyze global variable initializers and count for access from data. * This limitation is demonstrated by `bss2` and `data3` in `llvm/test/CodeGen/X86/global-variable-partition.ll`. Some stats of static-data-splitter with this patch: **section**|**bss**|**rodata**|**data** :-----:|:-----:|:-----:|:-----: hot-prefixed section coverage|99.75%|97.71%|91.30% unlikely-prefixed section size percentage|67.94%|39.37%|63.10% 1. The coverage is defined as `#perf-sample-in-hot-prefixed <data> section / #perf-sample in <data.*> section` for each <data> section. * The perf command samples `MEM_INST_RETIRED.ALL_LOADS:u:pinned:precise=2` events at a high frequency (`perf -c 2251`) for 30 seconds. The profiled binary is built as non-PIE so `data.rel.ro` coverage data is not available. 2. The unlikely-prefixed `<data>` section size percentage is defined as `unlikely <data> section size / the sum size of <data>.* sections` for each `<data>` section
Diffstat (limited to 'llvm/lib/CodeGen/CodeGen.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGen.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index 9544151..771e45c 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -132,6 +132,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeStackProtectorPass(Registry);
initializeStackSlotColoringLegacyPass(Registry);
initializeStaticDataSplitterPass(Registry);
+ initializeStaticDataAnnotatorPass(Registry);
initializeStripDebugMachineModulePass(Registry);
initializeTailDuplicateLegacyPass(Registry);
initializeTargetPassConfigPass(Registry);