[all-commits] [llvm/llvm-project] d23c5c: [CGData] Global Merge Functions (#112671)
Kyungwoo Lee via All-commits
all-commits at lists.llvm.org
Wed Nov 13 17:34:29 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d23c5c2d6566fce4380cfa31d438422db19fbce9
https://github.com/llvm/llvm-project/commit/d23c5c2d6566fce4380cfa31d438422db19fbce9
Author: Kyungwoo Lee <kyulee at meta.com>
Date: 2024-11-13 (Wed, 13 Nov 2024)
Changed paths:
M llvm/include/llvm/CGData/CodeGenData.h
M llvm/include/llvm/CGData/StableFunctionMap.h
M llvm/include/llvm/CGData/StableFunctionMapRecord.h
A llvm/include/llvm/CodeGen/GlobalMergeFunctions.h
M llvm/include/llvm/CodeGen/Passes.h
M llvm/include/llvm/InitializePasses.h
M llvm/include/llvm/LinkAllPasses.h
M llvm/include/llvm/Passes/CodeGenPassBuilder.h
M llvm/include/llvm/Passes/MachinePassRegistry.def
M llvm/include/llvm/Target/CGPassBuilderOption.h
M llvm/lib/CGData/StableFunctionMap.cpp
M llvm/lib/CodeGen/CMakeLists.txt
A llvm/lib/CodeGen/GlobalMergeFunctions.cpp
M llvm/lib/CodeGen/TargetPassConfig.cpp
M llvm/lib/Passes/PassBuilder.cpp
M llvm/lib/Passes/PassBuilderPipelines.cpp
M llvm/lib/Passes/PassRegistry.def
A llvm/test/ThinLTO/AArch64/cgdata-merge-local.ll
A llvm/test/ThinLTO/AArch64/cgdata-merge-read.ll
A llvm/test/ThinLTO/AArch64/cgdata-merge-two-rounds.ll
A llvm/test/ThinLTO/AArch64/cgdata-merge-write.ll
M llvm/test/tools/llvm-cgdata/merge-combined-funcmap-hashtree.test
M llvm/test/tools/llvm-cgdata/merge-funcmap-archive.test
M llvm/test/tools/llvm-cgdata/merge-funcmap-concat.test
M llvm/test/tools/llvm-cgdata/merge-funcmap-double.test
M llvm/test/tools/llvm-cgdata/merge-funcmap-single.test
M llvm/tools/llvm-cgdata/Opts.td
M llvm/tools/llvm-cgdata/llvm-cgdata.cpp
M llvm/unittests/CGData/StableFunctionMapTest.cpp
Log Message:
-----------
[CGData] Global Merge Functions (#112671)
This implements a global function merging pass. Unlike traditional
function merging passes that use IR comparators, this pass employs a
structurally stable hash to identify similar functions while ignoring
certain constant operands. These ignored constants are tracked and
encoded into a stable function summary. When merging, instead of
explicitly folding similar functions and their call sites, we form a
merging instance by supplying different parameters via thunks. The
actual size reduction occurs when identically created merging instances
are folded by the linker.
Currently, this pass is wired to a pre-codegen pass, enabled by the
`-enable-global-merge-func` flag.
In a local merging mode, the analysis and merging steps occur
sequentially within a module:
- `analyze`: Collects stable function hashes and tracks locations of
ignored constant operands.
- `finalize`: Identifies merge candidates with matching hashes and
computes the set of parameters that point to different constants.
- `merge`: Uses the stable function map to optimistically create a
merged function.
We can enable a global merging mode similar to the global function
outliner
(https://discourse.llvm.org/t/rfc-enhanced-machine-outliner-part-2-thinlto-nolto/78753/),
which will perform the above steps separately.
- `-codegen-data-generate`: During the first round of code generation,
we analyze local merging instances and publish their summaries.
- Offline using `llvm-cgdata` or at link-time, we can finalize all these
merging summaries that are combined to determine parameters.
- `-codegen-data-use`: During the second round of code generation, we
optimistically create merging instances within each module, and finally,
the linker folds identically created merging instances.
Depends on #112664
This is a patch for
https://discourse.llvm.org/t/rfc-global-function-merging/82608.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list