diff options
| author | Rahman Lavaee <rahmanl@google.com> | 2024-11-22 22:23:29 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-22 22:23:29 -0800 |
| commit | 68f7b075c07197803625431ba92c337af7470c85 (patch) | |
| tree | 6306eea578639a52c39a128340bbaa64dc147931 /llvm/lib/CodeGen/TargetPassConfig.cpp | |
| parent | 9d8a11fb3924a8176ff9959684ca1cebe1c0143f (diff) | |
[BasicBlockSections] Allow mixing of -basic-block-sections with MFS. (#117076)
This PR allows mixing `-basic-block-sections` with
`-enable-machine-function-splitter`. The strategy is to let
`-basic-block-sections` take precedence over functions with profiles.
Diffstat (limited to 'llvm/lib/CodeGen/TargetPassConfig.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/TargetPassConfig.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index a6159a38753c..d407e9f0871d 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -1235,13 +1235,13 @@ void TargetPassConfig::addMachinePasses() { addPass(createMIRAddFSDiscriminatorsPass( sampleprof::FSDiscriminatorPass::PassLast)); - bool NeedsBBSections = - TM->getBBSectionsType() != llvm::BasicBlockSection::None; - // Machine function splitter uses the basic block sections feature. Both - // cannot be enabled at the same time. We do not apply machine function - // splitter if -basic-block-sections is requested. - if (!NeedsBBSections && (TM->Options.EnableMachineFunctionSplitter || - EnableMachineFunctionSplitter)) { + // Machine function splitter uses the basic block sections feature. + // When used along with `-basic-block-sections=`, the basic-block-sections + // feature takes precedence. This means functions eligible for + // basic-block-sections optimizations (`=all`, or `=list=` with function + // included in the list profile) will get that optimization instead. + if (TM->Options.EnableMachineFunctionSplitter || + EnableMachineFunctionSplitter) { const std::string ProfileFile = getFSProfileFile(TM); if (!ProfileFile.empty()) { if (EnableFSDiscriminator) { @@ -1260,7 +1260,8 @@ void TargetPassConfig::addMachinePasses() { } // We run the BasicBlockSections pass if either we need BB sections or BB // address map (or both). - if (NeedsBBSections || TM->Options.BBAddrMap) { + if (TM->getBBSectionsType() != llvm::BasicBlockSection::None || + TM->Options.BBAddrMap) { if (TM->getBBSectionsType() == llvm::BasicBlockSection::List) { addPass(llvm::createBasicBlockSectionsProfileReaderWrapperPass( TM->getBBSectionsFuncListBuf())); |
