diff options
author | Mingming Liu <mingmingl@google.com> | 2025-03-28 16:31:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-28 16:31:46 -0700 |
commit | c8a70f4c6e24076ac3fc18bfb9e2a41ece83e7fc (patch) | |
tree | 4640bde08baa5ae74e919711b2819fcab01aeca4 /llvm/lib/CodeGen/TargetPassConfig.cpp | |
parent | 1e00bb16f488492198df692ae2e2abc405a138f3 (diff) | |
download | llvm-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/TargetPassConfig.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetPassConfig.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index f788ec5..fa1bb84 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -1257,8 +1257,13 @@ void TargetPassConfig::addMachinePasses() { } } addPass(createMachineFunctionSplitterPass()); - if (SplitStaticData || TM->Options.EnableStaticDataPartitioning) + if (SplitStaticData || TM->Options.EnableStaticDataPartitioning) { + // The static data splitter pass is a machine function pass. and + // static data annotator pass is a module-wide pass. See the file comment + // in StaticDataAnnotator.cpp for the motivation. addPass(createStaticDataSplitterPass()); + addPass(createStaticDataAnnotatorPass()); + } } // We run the BasicBlockSections pass if either we need BB sections or BB // address map (or both). |