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/Analysis/ReplayInlineAdvisor.h"
15 #include "llvm/Analysis/Utils/ImportedFunctionsInliningStatistics.h"
16 #include "llvm/IR/PassManager.h"
17 #include <utility>
18 
19 namespace llvm {
20 
21 /// The module inliner pass for the new pass manager.
22 ///
23 /// This pass wires together the inlining utilities and the inline cost
24 /// analysis into a module pass. Different from SCC inliner, it considers every
25 /// call in every function in the whole module and tries to inline if
26 /// profitable. With this module level inliner, it is possible to evaluate more
27 /// heuristics in the module level such like PriorityInlineOrder. It can be
28 /// tuned with a number of parameters to control what cost model is used and
29 /// what tradeoffs are made when making the decision.
30 class ModuleInlinerPass : public PassInfoMixin<ModuleInlinerPass> {
31 public:
32   ModuleInlinerPass(InlineParams Params = getInlineParams(),
33                     InliningAdvisorMode Mode = InliningAdvisorMode::Default)
34       : Params(Params), Mode(Mode){};
35   ModuleInlinerPass(ModuleInlinerPass &&Arg) = default;
36 
37   PreservedAnalyses run(Module &, ModuleAnalysisManager &);
38 
39 private:
40   InlineAdvisor &getAdvisor(const ModuleAnalysisManager &MAM,
41                             FunctionAnalysisManager &FAM, Module &M);
42   std::unique_ptr<InlineAdvisor> OwnedAdvisor;
43   const InlineParams Params;
44   const InliningAdvisorMode Mode;
45 };
46 } // end namespace llvm
47 
48 #endif // LLVM_TRANSFORMS_IPO_MODULEINLINER_H
49