[llvm] [CodeGen] Add a FunctionSplittingMode target option (PR #226575)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 12:48:14 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Rahman Lavaee (rlavaee)

<details>
<summary>Changes</summary>

Introduce llvm::FunctionSplittingMode {Default, None, BBSectionsOnly, All} and TargetOptions::FunctionSplitting, exposed through a new -function-splitting={none,bbsections,all} codegen flag, together with the resolveFunctionSplittingMode() helper which resolves it against the legacy -split-machine-functions / -enable-split-machine-functions options and the basic block sections mode.

The hidden -enable-split-machine-functions cl::opt moves from TargetPassConfig.cpp to BasicBlockSections.cpp (declared in BasicBlockSectionUtils.h, mirroring BBSectionsColdTextPrefix) so that both can share it, and TargetPassConfig schedules MachineFunctionSplitter when the resolved mode is 'all'.

This is behavior preserving for every existing command line: the resolved mode is 'all' exactly when one of the legacy options is set, since FunctionSplitting stays 'Default' unless the new flag is passed.

This is the first step towards merging MachineFunctionSplitter into BasicBlockSections, where 'none' (layout only) and 'bbsections' will gain their full per-function meaning.

---
Full diff: https://github.com/llvm/llvm-project/pull/226575.diff


7 Files Affected:

- (modified) llvm/include/llvm/CodeGen/BasicBlockSectionUtils.h (+13) 
- (modified) llvm/include/llvm/CodeGen/CommandFlags.h (+2) 
- (modified) llvm/include/llvm/Target/TargetOptions.h (+18) 
- (modified) llvm/lib/CodeGen/BasicBlockSections.cpp (+21) 
- (modified) llvm/lib/CodeGen/CommandFlags.cpp (+17) 
- (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+6-10) 
- (added) llvm/test/CodeGen/X86/function-splitting-mode.ll (+68) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


https://github.com/llvm/llvm-project/pull/226575


More information about the llvm-commits mailing list