From cb5e48d1c2c4774ed9f17ff89412f1291b640172 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Mon, 6 Feb 2023 13:25:59 -0800 Subject: [PATCH] [IPO] Remove some legacy passes These are part of the optimization pipeline, of which the legacy pass manager version is deprecated. --- llvm/include/llvm-c/Transforms/IPO.h | 3 -- llvm/include/llvm/InitializePasses.h | 4 -- llvm/include/llvm/LinkAllPasses.h | 2 - llvm/include/llvm/Transforms/IPO.h | 19 ------- llvm/lib/Transforms/IPO/CalledValuePropagation.cpp | 30 ----------- llvm/lib/Transforms/IPO/HotColdSplitting.cpp | 55 ------------------- llvm/lib/Transforms/IPO/IPO.cpp | 8 --- llvm/lib/Transforms/IPO/IROutliner.cpp | 51 ------------------ llvm/lib/Transforms/IPO/PartialInlining.cpp | 61 ---------------------- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 1 - .../test/Transforms/HotColdSplit/coldentrycount.ll | 2 +- 11 files changed, 1 insertion(+), 235 deletions(-) diff --git a/llvm/include/llvm-c/Transforms/IPO.h b/llvm/include/llvm-c/Transforms/IPO.h index 06a342d..429673b 100644 --- a/llvm/include/llvm-c/Transforms/IPO.h +++ b/llvm/include/llvm-c/Transforms/IPO.h @@ -30,9 +30,6 @@ LLVM_C_EXTERN_C_BEGIN /** See llvm::createConstantMergePass function. */ void LLVMAddConstantMergePass(LLVMPassManagerRef PM); -/** See llvm::createCalledValuePropagationPass function. */ -void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM); - /** See llvm::createDeadArgEliminationPass function. */ void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM); diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index 620d142..16a8dd7a 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -88,7 +88,6 @@ void initializeCallGraphPrinterLegacyPassPass(PassRegistry&); void initializeCallGraphViewerPass(PassRegistry&); void initializeCallGraphWrapperPassPass(PassRegistry&); void initializeCallSiteSplittingLegacyPassPass(PassRegistry&); -void initializeCalledValuePropagationLegacyPassPass(PassRegistry &); void initializeCheckDebugMachineModulePass(PassRegistry &); void initializeCodeGenPreparePass(PassRegistry&); void initializeComplexDeinterleavingLegacyPassPass(PassRegistry&); @@ -156,10 +155,8 @@ void initializeGlobalsAAWrapperPassPass(PassRegistry&); void initializeGuardWideningLegacyPassPass(PassRegistry&); void initializeHardwareLoopsPass(PassRegistry&); void initializeMIRProfileLoaderPassPass(PassRegistry &); -void initializeHotColdSplittingLegacyPassPass(PassRegistry&); void initializeIPSCCPLegacyPassPass(PassRegistry&); void initializeIRCELegacyPassPass(PassRegistry&); -void initializeIROutlinerLegacyPassPass(PassRegistry&); void initializeIRSimilarityIdentifierWrapperPassPass(PassRegistry&); void initializeIRTranslatorPass(PassRegistry&); void initializeIVUsersWrapperPassPass(PassRegistry&); @@ -301,7 +298,6 @@ void initializeOptimizationRemarkEmitterWrapperPassPass(PassRegistry&); void initializeOptimizePHIsPass(PassRegistry&); void initializePEIPass(PassRegistry&); void initializePHIEliminationPass(PassRegistry&); -void initializePartialInlinerLegacyPassPass(PassRegistry&); void initializePartiallyInlineLibCallsLegacyPassPass(PassRegistry&); void initializePatchableFunctionPass(PassRegistry&); void initializePeepholeOptimizerPass(PassRegistry&); diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h index ff2aa67..6313e79 100644 --- a/llvm/include/llvm/LinkAllPasses.h +++ b/llvm/include/llvm/LinkAllPasses.h @@ -82,7 +82,6 @@ namespace { (void) llvm::createCFGSimplificationPass(); (void) llvm::createStructurizeCFGPass(); (void) llvm::createLibCallsShrinkWrapPass(); - (void) llvm::createCalledValuePropagationPass(); (void) llvm::createConstantMergePass(); (void) llvm::createCostModelAnalysisPass(); (void) llvm::createDeadArgEliminationPass(); @@ -184,7 +183,6 @@ namespace { (void) llvm::createPrintModulePass(os); (void) llvm::createPrintFunctionPass(os); (void) llvm::createModuleDebugInfoPrinterPass(); - (void) llvm::createPartialInliningPass(); (void) llvm::createLintLegacyPassPass(); (void) llvm::createSinkingPass(); (void) llvm::createLowerAtomicPass(); diff --git a/llvm/include/llvm/Transforms/IPO.h b/llvm/include/llvm/Transforms/IPO.h index a14b16d..6c0c026 100644 --- a/llvm/include/llvm/Transforms/IPO.h +++ b/llvm/include/llvm/Transforms/IPO.h @@ -170,29 +170,10 @@ ModulePass *createStripDeadPrototypesPass(); Pass *createReversePostOrderFunctionAttrsPass(); //===----------------------------------------------------------------------===// -/// createHotColdSplittingPass - This pass outlines cold blocks into a separate -/// function(s). -ModulePass *createHotColdSplittingPass(); - -//===----------------------------------------------------------------------===// -/// createIROutlinerPass - This pass finds similar code regions and factors -/// those regions out into functions. -ModulePass *createIROutlinerPass(); - -//===----------------------------------------------------------------------===// -/// createPartialInliningPass - This pass inlines parts of functions. -/// -ModulePass *createPartialInliningPass(); - -//===----------------------------------------------------------------------===// /// createBarrierNoopPass - This pass is purely a module pass barrier in a pass /// manager. ModulePass *createBarrierNoopPass(); -/// createCalledValuePropagationPass - Attach metadata to indirct call sites -/// indicating the set of functions they may target at run-time. -ModulePass *createCalledValuePropagationPass(); - /// What to do with the summary when running passes that operate on it. enum class PassSummaryAction { None, ///< Do nothing. diff --git a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp index 64bfcb2..2b7f734 100644 --- a/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp +++ b/llvm/lib/Transforms/IPO/CalledValuePropagation.cpp @@ -405,33 +405,3 @@ PreservedAnalyses CalledValuePropagationPass::run(Module &M, runCVP(M); return PreservedAnalyses::all(); } - -namespace { -class CalledValuePropagationLegacyPass : public ModulePass { -public: - static char ID; - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesAll(); - } - - CalledValuePropagationLegacyPass() : ModulePass(ID) { - initializeCalledValuePropagationLegacyPassPass( - *PassRegistry::getPassRegistry()); - } - - bool runOnModule(Module &M) override { - if (skipModule(M)) - return false; - return runCVP(M); - } -}; -} // namespace - -char CalledValuePropagationLegacyPass::ID = 0; -INITIALIZE_PASS(CalledValuePropagationLegacyPass, "called-value-propagation", - "Called Value Propagation", false, false) - -ModulePass *llvm::createCalledValuePropagationPass() { - return new CalledValuePropagationLegacyPass(); -} diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp index 95e8ae0..82dedd9 100644 --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -169,23 +169,6 @@ static bool markFunctionCold(Function &F, bool UpdateEntryCount = false) { return Changed; } -class HotColdSplittingLegacyPass : public ModulePass { -public: - static char ID; - HotColdSplittingLegacyPass() : ModulePass(ID) { - initializeHotColdSplittingLegacyPassPass(*PassRegistry::getPassRegistry()); - } - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired(); - AU.addRequired(); - AU.addRequired(); - AU.addUsedIfAvailable(); - } - - bool runOnModule(Module &M) override; -}; - } // end anonymous namespace /// Check whether \p F is inherently cold. @@ -713,32 +696,6 @@ bool HotColdSplitting::run(Module &M) { return Changed; } -bool HotColdSplittingLegacyPass::runOnModule(Module &M) { - if (skipModule(M)) - return false; - ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); - auto GTTI = [this](Function &F) -> TargetTransformInfo & { - return this->getAnalysis().getTTI(F); - }; - auto GBFI = [this](Function &F) { - return &this->getAnalysis(F).getBFI(); - }; - std::unique_ptr ORE; - std::function GetORE = - [&ORE](Function &F) -> OptimizationRemarkEmitter & { - ORE.reset(new OptimizationRemarkEmitter(&F)); - return *ORE; - }; - auto LookupAC = [this](Function &F) -> AssumptionCache * { - if (auto *ACT = getAnalysisIfAvailable()) - return ACT->lookupAssumptionCache(F); - return nullptr; - }; - - return HotColdSplitting(PSI, GBFI, GTTI, &GetORE, LookupAC).run(M); -} - PreservedAnalyses HotColdSplittingPass::run(Module &M, ModuleAnalysisManager &AM) { auto &FAM = AM.getResult(M).getManager(); @@ -769,15 +726,3 @@ HotColdSplittingPass::run(Module &M, ModuleAnalysisManager &AM) { return PreservedAnalyses::none(); return PreservedAnalyses::all(); } - -char HotColdSplittingLegacyPass::ID = 0; -INITIALIZE_PASS_BEGIN(HotColdSplittingLegacyPass, "hotcoldsplit", - "Hot Cold Splitting", false, false) -INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(BlockFrequencyInfoWrapperPass) -INITIALIZE_PASS_END(HotColdSplittingLegacyPass, "hotcoldsplit", - "Hot Cold Splitting", false, false) - -ModulePass *llvm::createHotColdSplittingPass() { - return new HotColdSplittingLegacyPass(); -} diff --git a/llvm/lib/Transforms/IPO/IPO.cpp b/llvm/lib/Transforms/IPO/IPO.cpp index b9cc4d0..26983d5 100644 --- a/llvm/lib/Transforms/IPO/IPO.cpp +++ b/llvm/lib/Transforms/IPO/IPO.cpp @@ -24,7 +24,6 @@ using namespace llvm; void llvm::initializeIPO(PassRegistry &Registry) { initializeAnnotation2MetadataLegacyPass(Registry); - initializeCalledValuePropagationLegacyPassPass(Registry); initializeConstantMergeLegacyPassPass(Registry); initializeCrossDSOCFIPass(Registry); initializeDAEPass(Registry); @@ -33,15 +32,12 @@ void llvm::initializeIPO(PassRegistry &Registry) { initializeGlobalDCELegacyPassPass(Registry); initializeGlobalOptLegacyPassPass(Registry); initializeGlobalSplitPass(Registry); - initializeHotColdSplittingLegacyPassPass(Registry); - initializeIROutlinerLegacyPassPass(Registry); initializeAlwaysInlinerLegacyPassPass(Registry); initializeSimpleInlinerPass(Registry); initializeInferFunctionAttrsLegacyPassPass(Registry); initializeInternalizeLegacyPassPass(Registry); initializeLoopExtractorLegacyPassPass(Registry); initializeSingleLoopExtractorPass(Registry); - initializePartialInlinerLegacyPassPass(Registry); initializeAttributorLegacyPassPass(Registry); initializeAttributorCGSCCLegacyPassPass(Registry); initializePostOrderFunctionAttrsLegacyPassPass(Registry); @@ -60,10 +56,6 @@ void LLVMInitializeIPO(LLVMPassRegistryRef R) { initializeIPO(*unwrap(R)); } -void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM) { - unwrap(PM)->add(createCalledValuePropagationPass()); -} - void LLVMAddConstantMergePass(LLVMPassManagerRef PM) { unwrap(PM)->add(createConstantMergePass()); } diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp index 1c50ce3..de8f736 100644 --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -3024,46 +3024,6 @@ bool IROutliner::run(Module &M) { return doOutline(M) > 0; } -// Pass Manager Boilerplate -namespace { -class IROutlinerLegacyPass : public ModulePass { -public: - static char ID; - IROutlinerLegacyPass() : ModulePass(ID) { - initializeIROutlinerLegacyPassPass(*PassRegistry::getPassRegistry()); - } - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired(); - AU.addRequired(); - AU.addRequired(); - } - - bool runOnModule(Module &M) override; -}; -} // namespace - -bool IROutlinerLegacyPass::runOnModule(Module &M) { - if (skipModule(M)) - return false; - - std::unique_ptr ORE; - auto GORE = [&ORE](Function &F) -> OptimizationRemarkEmitter & { - ORE.reset(new OptimizationRemarkEmitter(&F)); - return *ORE; - }; - - auto GTTI = [this](Function &F) -> TargetTransformInfo & { - return this->getAnalysis().getTTI(F); - }; - - auto GIRSI = [this](Module &) -> IRSimilarityIdentifier & { - return this->getAnalysis().getIRSI(); - }; - - return IROutliner(GTTI, GIRSI, GORE).run(M); -} - PreservedAnalyses IROutlinerPass::run(Module &M, ModuleAnalysisManager &AM) { auto &FAM = AM.getResult(M).getManager(); @@ -3088,14 +3048,3 @@ PreservedAnalyses IROutlinerPass::run(Module &M, ModuleAnalysisManager &AM) { return PreservedAnalyses::none(); return PreservedAnalyses::all(); } - -char IROutlinerLegacyPass::ID = 0; -INITIALIZE_PASS_BEGIN(IROutlinerLegacyPass, "iroutliner", "IR Outliner", false, - false) -INITIALIZE_PASS_DEPENDENCY(IRSimilarityIdentifierWrapperPass) -INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass) -INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) -INITIALIZE_PASS_END(IROutlinerLegacyPass, "iroutliner", "IR Outliner", false, - false) - -ModulePass *llvm::createIROutlinerPass() { return new IROutlinerLegacyPass(); } diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp index 310e4d4..b040187 100644 --- a/llvm/lib/Transforms/IPO/PartialInlining.cpp +++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp @@ -342,52 +342,6 @@ private: OptimizationRemarkEmitter &ORE) const; }; -struct PartialInlinerLegacyPass : public ModulePass { - static char ID; // Pass identification, replacement for typeid - - PartialInlinerLegacyPass() : ModulePass(ID) { - initializePartialInlinerLegacyPassPass(*PassRegistry::getPassRegistry()); - } - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired(); - AU.addRequired(); - AU.addRequired(); - AU.addRequired(); - } - - bool runOnModule(Module &M) override { - if (skipModule(M)) - return false; - - AssumptionCacheTracker *ACT = &getAnalysis(); - TargetTransformInfoWrapperPass *TTIWP = - &getAnalysis(); - ProfileSummaryInfo &PSI = - getAnalysis().getPSI(); - - auto GetAssumptionCache = [&ACT](Function &F) -> AssumptionCache & { - return ACT->getAssumptionCache(F); - }; - - auto LookupAssumptionCache = [ACT](Function &F) -> AssumptionCache * { - return ACT->lookupAssumptionCache(F); - }; - - auto GetTTI = [&TTIWP](Function &F) -> TargetTransformInfo & { - return TTIWP->getTTI(F); - }; - - auto GetTLI = [this](Function &F) -> TargetLibraryInfo & { - return this->getAnalysis().getTLI(F); - }; - - return PartialInlinerImpl(GetAssumptionCache, LookupAssumptionCache, GetTTI, - GetTLI, PSI) - .run(M); - } -}; - } // end anonymous namespace std::unique_ptr @@ -1497,21 +1451,6 @@ bool PartialInlinerImpl::run(Module &M) { return Changed; } -char PartialInlinerLegacyPass::ID = 0; - -INITIALIZE_PASS_BEGIN(PartialInlinerLegacyPass, "partial-inliner", - "Partial Inliner", false, false) -INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) -INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) -INITIALIZE_PASS_END(PartialInlinerLegacyPass, "partial-inliner", - "Partial Inliner", false, false) - -ModulePass *llvm::createPartialInliningPass() { - return new PartialInlinerLegacyPass(); -} - PreservedAnalyses PartialInlinerPass::run(Module &M, ModuleAnalysisManager &AM) { auto &FAM = AM.getResult(M).getManager(); diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 4653e7b..0f9ab60 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -317,7 +317,6 @@ void PassManagerBuilder::populateModulePassManager( MPM.add(createCallSiteSplittingPass()); MPM.add(createIPSCCPPass()); // IP SCCP - MPM.add(createCalledValuePropagationPass()); MPM.add(createGlobalOptimizerPass()); // Optimize out global vars // Promote any localized global vars. diff --git a/llvm/test/Transforms/HotColdSplit/coldentrycount.ll b/llvm/test/Transforms/HotColdSplit/coldentrycount.ll index fbd0e4d..1a113ff 100644 --- a/llvm/test/Transforms/HotColdSplit/coldentrycount.ll +++ b/llvm/test/Transforms/HotColdSplit/coldentrycount.ll @@ -1,5 +1,5 @@ ; REQUIRES: x86-registered-target -; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -codegenprepare -S < %s | FileCheck %s +; RUN: opt -passes=hotcoldsplit -hotcoldsplit-threshold=0 < %s | opt -codegenprepare -S | FileCheck %s ; Test to ensure that split cold function gets 0 entry count profile ; metadata when compiling with pgo. -- 2.7.4