1 //===- ModuleInliner.h - Module level Inliner pass --------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_TRANSFORMS_IPO_MODULEINLINER_H 10 #define LLVM_TRANSFORMS_IPO_MODULEINLINER_H 11 12 #include "llvm/Analysis/InlineAdvisor.h" 13 #include "llvm/Analysis/InlineCost.h" 14 #include "llvm/IR/PassManager.h" 15 #include "llvm/Support/Compiler.h" 16 17 namespace llvm { 18 19 /// The module inliner pass for the new pass manager. 20 /// 21 /// This pass wires together the inlining utilities and the inline cost 22 /// analysis into a module pass. Different from SCC inliner, it considers every 23 /// call in every function in the whole module and tries to inline if 24 /// profitable. With this module level inliner, it is possible to evaluate more 25 /// heuristics in the module level such like PriorityInlineOrder. It can be 26 /// tuned with a number of parameters to control what cost model is used and 27 /// what tradeoffs are made when making the decision. 28 class ModuleInlinerPass : public PassInfoMixin<ModuleInlinerPass> { 29 public: 30 ModuleInlinerPass(InlineParams Params = getInlineParams(), 31 InliningAdvisorMode Mode = InliningAdvisorMode::Default, 32 ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None) Params(Params)33 : Params(Params), Mode(Mode), LTOPhase(LTOPhase){}; 34 ModuleInlinerPass(ModuleInlinerPass &&Arg) = default; 35 36 LLVM_ABI PreservedAnalyses run(Module &, ModuleAnalysisManager &); 37 38 private: 39 InlineAdvisor &getAdvisor(const ModuleAnalysisManager &MAM, 40 FunctionAnalysisManager &FAM, Module &M); 41 std::unique_ptr<InlineAdvisor> OwnedAdvisor; 42 const InlineParams Params; 43 const InliningAdvisorMode Mode; 44 const ThinOrFullLTOPhase LTOPhase; 45 }; 46 } // end namespace llvm 47 48 #endif // LLVM_TRANSFORMS_IPO_MODULEINLINER_H 49