From 84728a3d75496ff3f48436f968a01ba2c05ee37e Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Mon, 6 Feb 2023 13:50:49 -0800 Subject: [PATCH] [Inliner] Remove legacy simple inliner It's part of the optimization pipeline, of which the legacy pass manager version is deprecated. --- llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c | 6 -- llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml | 3 - llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli | 5 - .../LLJITWithOptimizingIRTransform.cpp | 1 - llvm/include/llvm-c/Transforms/IPO.h | 3 - llvm/include/llvm/InitializePasses.h | 1 - llvm/include/llvm/LinkAllPasses.h | 1 - llvm/include/llvm/Transforms/IPO.h | 15 --- llvm/lib/Transforms/IPO/CMakeLists.txt | 1 - llvm/lib/Transforms/IPO/IPO.cpp | 5 - llvm/lib/Transforms/IPO/InlineSimple.cpp | 118 --------------------- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 3 +- llvm/test/Bindings/OCaml/ipo.ml | 1 - llvm/tools/bugpoint/bugpoint.cpp | 5 +- .../gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn | 1 - polly/lib/Transform/Canonicalization.cpp | 1 - 16 files changed, 2 insertions(+), 168 deletions(-) delete mode 100644 llvm/lib/Transforms/IPO/InlineSimple.cpp diff --git a/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c b/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c index d93028a..8e263cb 100644 --- a/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c +++ b/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c @@ -38,12 +38,6 @@ value llvm_add_function_attrs(LLVMPassManagerRef PM) { } /* [`Module] Llvm.PassManager.t -> unit */ -value llvm_add_function_inlining(LLVMPassManagerRef PM) { - LLVMAddFunctionInliningPass(PM); - return Val_unit; -} - -/* [`Module] Llvm.PassManager.t -> unit */ value llvm_add_always_inliner(LLVMPassManagerRef PM) { LLVMAddAlwaysInlinerPass(PM); return Val_unit; diff --git a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml index 553d55c..d1ebd56 100644 --- a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml +++ b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml @@ -15,9 +15,6 @@ external add_dead_arg_elimination external add_function_attrs : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_function_attrs" -external add_function_inlining - : [ `Module ] Llvm.PassManager.t -> unit - = "llvm_add_function_inlining" external add_always_inliner : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_always_inliner" diff --git a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli index 7177a30..68c772e 100644 --- a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli +++ b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli @@ -26,11 +26,6 @@ external add_function_attrs : [ `Module ] Llvm.PassManager.t -> unit = "llvm_add_function_attrs" -(** See the [llvm::createFunctionInliningPass] function. *) -external add_function_inlining - : [ `Module ] Llvm.PassManager.t -> unit - = "llvm_add_function_inlining" - (** See the [llvm::createAlwaysInlinerPass] function. *) external add_always_inliner : [ `Module ] Llvm.PassManager.t -> unit diff --git a/llvm/examples/OrcV2Examples/LLJITWithOptimizingIRTransform/LLJITWithOptimizingIRTransform.cpp b/llvm/examples/OrcV2Examples/LLJITWithOptimizingIRTransform/LLJITWithOptimizingIRTransform.cpp index 6bd63bf..a5fd384 100644 --- a/llvm/examples/OrcV2Examples/LLJITWithOptimizingIRTransform/LLJITWithOptimizingIRTransform.cpp +++ b/llvm/examples/OrcV2Examples/LLJITWithOptimizingIRTransform/LLJITWithOptimizingIRTransform.cpp @@ -74,7 +74,6 @@ class MyOptimizationTransform { public: MyOptimizationTransform() : PM(std::make_unique()) { PM->add(createTailCallEliminationPass()); - PM->add(createFunctionInliningPass()); PM->add(createIndVarSimplifyPass()); PM->add(createCFGSimplificationPass()); } diff --git a/llvm/include/llvm-c/Transforms/IPO.h b/llvm/include/llvm-c/Transforms/IPO.h index 1e28082..f4da3f50 100644 --- a/llvm/include/llvm-c/Transforms/IPO.h +++ b/llvm/include/llvm-c/Transforms/IPO.h @@ -36,9 +36,6 @@ void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM); /** See llvm::createFunctionAttrsPass function. */ void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM); -/** See llvm::createFunctionInliningPass function. */ -void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM); - /** See llvm::createAlwaysInlinerPass function. */ void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM); diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index 8e8f2d3..a693bc2 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -362,7 +362,6 @@ void initializeScopedNoAliasAAWrapperPassPass(PassRegistry&); void initializeSeparateConstOffsetFromGEPLegacyPassPass(PassRegistry &); void initializeShadowStackGCLoweringPass(PassRegistry&); void initializeShrinkWrapPass(PassRegistry&); -void initializeSimpleInlinerPass(PassRegistry&); void initializeSimpleLoopUnswitchLegacyPassPass(PassRegistry&); void initializeSingleLoopExtractorPass(PassRegistry&); void initializeSinkingLegacyPassPass(PassRegistry&); diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h index 855f3b9..2359630 100644 --- a/llvm/include/llvm/LinkAllPasses.h +++ b/llvm/include/llvm/LinkAllPasses.h @@ -92,7 +92,6 @@ namespace { (void) llvm::createDomPrinterWrapperPassPass(); (void) llvm::createDomOnlyViewerWrapperPassPass(); (void) llvm::createDomViewerWrapperPassPass(); - (void) llvm::createFunctionInliningPass(); (void) llvm::createAlwaysInlinerLegacyPass(); (void) llvm::createGlobalDCEPass(); (void) llvm::createGlobalOptimizerPass(); diff --git a/llvm/include/llvm/Transforms/IPO.h b/llvm/include/llvm/Transforms/IPO.h index 51eb50d..59a659c 100644 --- a/llvm/include/llvm/Transforms/IPO.h +++ b/llvm/include/llvm/Transforms/IPO.h @@ -72,21 +72,6 @@ ModulePass *createGVExtractionPass(std::vector& GVs, bool deleteFn = false, bool keepConstInit = false); //===----------------------------------------------------------------------===// -/// createFunctionInliningPass - Return a new pass object that uses a heuristic -/// to inline direct function calls to small functions. -/// -/// The Threshold can be passed directly, or asked to be computed from the -/// given optimization and size optimization arguments. -/// -/// The -inline-threshold command line option takes precedence over the -/// threshold given here. -Pass *createFunctionInliningPass(); -Pass *createFunctionInliningPass(int Threshold); -Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel, - bool DisableInlineHotCallSite); -Pass *createFunctionInliningPass(InlineParams &Params); - -//===----------------------------------------------------------------------===// /// createDeadArgEliminationPass - This pass removes arguments from functions /// which are not used by the body of the function. /// diff --git a/llvm/lib/Transforms/IPO/CMakeLists.txt b/llvm/lib/Transforms/IPO/CMakeLists.txt index e682088..34a1e4c 100644 --- a/llvm/lib/Transforms/IPO/CMakeLists.txt +++ b/llvm/lib/Transforms/IPO/CMakeLists.txt @@ -23,7 +23,6 @@ add_llvm_component_library(LLVMipo IPO.cpp IROutliner.cpp InferFunctionAttrs.cpp - InlineSimple.cpp Inliner.cpp Internalize.cpp LoopExtractor.cpp diff --git a/llvm/lib/Transforms/IPO/IPO.cpp b/llvm/lib/Transforms/IPO/IPO.cpp index 4a447bb..6de623f8 100644 --- a/llvm/lib/Transforms/IPO/IPO.cpp +++ b/llvm/lib/Transforms/IPO/IPO.cpp @@ -33,7 +33,6 @@ void llvm::initializeIPO(PassRegistry &Registry) { initializeGlobalOptLegacyPassPass(Registry); initializeGlobalSplitPass(Registry); initializeAlwaysInlinerLegacyPassPass(Registry); - initializeSimpleInlinerPass(Registry); initializeInferFunctionAttrsLegacyPassPass(Registry); initializeLoopExtractorLegacyPassPass(Registry); initializeSingleLoopExtractorPass(Registry); @@ -61,10 +60,6 @@ void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createPostOrderFunctionAttrsLegacyPass()); } -void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) { - unwrap(PM)->add(createFunctionInliningPass()); -} - void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createAlwaysInlinerLegacyPass()); } diff --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp deleted file mode 100644 index eba0d66..0000000 --- a/llvm/lib/Transforms/IPO/InlineSimple.cpp +++ /dev/null @@ -1,118 +0,0 @@ -//===- InlineSimple.cpp - Code to perform simple function inlining --------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file implements bottom-up inlining of functions into callees. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Analysis/AssumptionCache.h" -#include "llvm/Analysis/InlineCost.h" -#include "llvm/Analysis/OptimizationRemarkEmitter.h" -#include "llvm/Analysis/TargetTransformInfo.h" -#include "llvm/InitializePasses.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/Transforms/IPO/Inliner.h" - -using namespace llvm; - -#define DEBUG_TYPE "inline" - -namespace { - -/// Actual inliner pass implementation. -/// -/// The common implementation of the inlining logic is shared between this -/// inliner pass and the always inliner pass. The two passes use different cost -/// analyses to determine when to inline. -class SimpleInliner : public LegacyInlinerBase { - - InlineParams Params; - -public: - SimpleInliner() : LegacyInlinerBase(ID), Params(llvm::getInlineParams()) { - initializeSimpleInlinerPass(*PassRegistry::getPassRegistry()); - } - - explicit SimpleInliner(InlineParams Params) - : LegacyInlinerBase(ID), Params(std::move(Params)) { - initializeSimpleInlinerPass(*PassRegistry::getPassRegistry()); - } - - static char ID; // Pass identification, replacement for typeid - - InlineCost getInlineCost(CallBase &CB) override { - Function *Callee = CB.getCalledFunction(); - TargetTransformInfo &TTI = TTIWP->getTTI(*Callee); - - bool RemarksEnabled = false; - const auto &BBs = *CB.getCaller(); - if (!BBs.empty()) { - auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &BBs.front()); - if (DI.isEnabled()) - RemarksEnabled = true; - } - OptimizationRemarkEmitter ORE(CB.getCaller()); - - std::function GetAssumptionCache = - [&](Function &F) -> AssumptionCache & { - return ACT->getAssumptionCache(F); - }; - return llvm::getInlineCost(CB, Params, TTI, GetAssumptionCache, GetTLI, - /*GetBFI=*/nullptr, PSI, - RemarksEnabled ? &ORE : nullptr); - } - - bool runOnSCC(CallGraphSCC &SCC) override; - void getAnalysisUsage(AnalysisUsage &AU) const override; - -private: - TargetTransformInfoWrapperPass *TTIWP; - -}; - -} // end anonymous namespace - -char SimpleInliner::ID = 0; -INITIALIZE_PASS_BEGIN(SimpleInliner, "inline", "Function Integration/Inlining", - false, false) -INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) -INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass) -INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) -INITIALIZE_PASS_END(SimpleInliner, "inline", "Function Integration/Inlining", - false, false) - -Pass *llvm::createFunctionInliningPass() { return new SimpleInliner(); } - -Pass *llvm::createFunctionInliningPass(int Threshold) { - return new SimpleInliner(llvm::getInlineParams(Threshold)); -} - -Pass *llvm::createFunctionInliningPass(unsigned OptLevel, - unsigned SizeOptLevel, - bool DisableInlineHotCallSite) { - auto Param = llvm::getInlineParams(OptLevel, SizeOptLevel); - if (DisableInlineHotCallSite) - Param.HotCallSiteThreshold = 0; - return new SimpleInliner(Param); -} - -Pass *llvm::createFunctionInliningPass(InlineParams &Params) { - return new SimpleInliner(Params); -} - -bool SimpleInliner::runOnSCC(CallGraphSCC &SCC) { - TTIWP = &getAnalysis(); - return LegacyInlinerBase::runOnSCC(SCC); -} - -void SimpleInliner::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); - LegacyInlinerBase::getAnalysisUsage(AU); -} diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 4afa8fe..93465a3 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -473,8 +473,7 @@ LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, void LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, unsigned Threshold) { - PassManagerBuilder *Builder = unwrap(PMB); - Builder->Inliner = createFunctionInliningPass(Threshold); + // TODO: remove this } void diff --git a/llvm/test/Bindings/OCaml/ipo.ml b/llvm/test/Bindings/OCaml/ipo.ml index 8517660..6bea990 100644 --- a/llvm/test/Bindings/OCaml/ipo.ml +++ b/llvm/test/Bindings/OCaml/ipo.ml @@ -50,7 +50,6 @@ let test_transforms () = ++ add_constant_merge ++ add_dead_arg_elimination ++ add_function_attrs - ++ add_function_inlining ++ add_always_inliner ++ add_global_dce ++ add_global_optimizer diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp index 0305f64..42d3395 100644 --- a/llvm/tools/bugpoint/bugpoint.cpp +++ b/llvm/tools/bugpoint/bugpoint.cpp @@ -121,10 +121,7 @@ static void AddOptimizationPasses(legacy::FunctionPassManager &FPM, Builder.OptLevel = OptLevel; Builder.SizeLevel = SizeLevel; - if (OptLevel > 1) - Builder.Inliner = createFunctionInliningPass(OptLevel, SizeLevel, false); - else - Builder.Inliner = createAlwaysInlinerLegacyPass(); + Builder.Inliner = createAlwaysInlinerLegacyPass(); Builder.populateFunctionPassManager(FPM); Builder.populateModulePassManager(FPM); diff --git a/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn index e43a5f4..e960be0 100644 --- a/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn @@ -44,7 +44,6 @@ static_library("IPO") { "IPO.cpp", "IROutliner.cpp", "InferFunctionAttrs.cpp", - "InlineSimple.cpp", "Inliner.cpp", "Internalize.cpp", "LoopExtractor.cpp", diff --git a/polly/lib/Transform/Canonicalization.cpp b/polly/lib/Transform/Canonicalization.cpp index edb8e5e..8cb235f 100644 --- a/polly/lib/Transform/Canonicalization.cpp +++ b/polly/lib/Transform/Canonicalization.cpp @@ -50,7 +50,6 @@ void polly::registerCanonicalicationPasses(llvm::legacy::PassManagerBase &PM) { PM.add(llvm::createReassociatePass()); PM.add(llvm::createLoopRotatePass()); if (PollyInliner) { - PM.add(llvm::createFunctionInliningPass(200)); PM.add(llvm::createPromoteMemoryToRegisterPass()); PM.add(llvm::createCFGSimplificationPass()); PM.add(llvm::createInstructionCombiningPass()); -- 2.7.4