[llvm] [CodeGen][NPM] Port BranchFolder to NPM (PR #128858)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 27 00:26:43 PST 2025
================
@@ -88,38 +89,62 @@ TailMergeSize("tail-merge-size",
namespace {
/// BranchFolderPass - Wrap branch folder in a machine function pass.
- class BranchFolderPass : public MachineFunctionPass {
- public:
- static char ID;
+class BranchFolderLegacy : public MachineFunctionPass {
+public:
+ static char ID;
- explicit BranchFolderPass(): MachineFunctionPass(ID) {}
+ explicit BranchFolderLegacy() : MachineFunctionPass(ID) {}
- bool runOnMachineFunction(MachineFunction &MF) override;
+ bool runOnMachineFunction(MachineFunction &MF) override;
- void getAnalysisUsage(AnalysisUsage &AU) const override {
- AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
- AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
- AU.addRequired<ProfileSummaryInfoWrapperPass>();
- AU.addRequired<TargetPassConfig>();
- MachineFunctionPass::getAnalysisUsage(AU);
- }
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
+ AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
+ AU.addRequired<ProfileSummaryInfoWrapperPass>();
+ AU.addRequired<TargetPassConfig>();
+ MachineFunctionPass::getAnalysisUsage(AU);
+ }
- MachineFunctionProperties getRequiredProperties() const override {
- return MachineFunctionProperties().set(
- MachineFunctionProperties::Property::NoPHIs);
- }
- };
+ MachineFunctionProperties getRequiredProperties() const override {
+ return MachineFunctionProperties().set(
+ MachineFunctionProperties::Property::NoPHIs);
+ }
+};
} // end anonymous namespace
-char BranchFolderPass::ID = 0;
-
-char &llvm::BranchFolderPassID = BranchFolderPass::ID;
-
-INITIALIZE_PASS(BranchFolderPass, DEBUG_TYPE,
- "Control Flow Optimizer", false, false)
+char BranchFolderLegacy::ID = 0;
+
+char &llvm::BranchFolderPassID = BranchFolderLegacy::ID;
+
+INITIALIZE_PASS(BranchFolderLegacy, DEBUG_TYPE, "Control Flow Optimizer", false,
+ false)
+
+PreservedAnalyses BranchFolderPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ MFPropsModifier _(*this, MF);
+ bool EnableTailMerge =
+ !MF.getTarget().requiresStructuredCFG() && this->EnableTailMerge;
+
+ auto &MBPI = MFAM.getResult<MachineBranchProbabilityAnalysis>(MF);
+ auto *PSI = MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF)
+ .getCachedResult<ProfileSummaryAnalysis>(
----------------
optimisan wrote:
ProfileSummary is a Module analysis, so it cannot be run from this machineFunction pass. Only cached result is available which needs to be inserted in the pipeline if not present.
https://github.com/llvm/llvm-project/pull/128858
More information about the llvm-commits
mailing list