ModuleInliner.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ModuleInliner.h - Module level Inliner pass --------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TRANSFORMS_IPO_MODULEINLINER_H
  14. #define LLVM_TRANSFORMS_IPO_MODULEINLINER_H
  15. #include "llvm/Analysis/InlineAdvisor.h"
  16. #include "llvm/Analysis/InlineCost.h"
  17. #include "llvm/IR/PassManager.h"
  18. namespace llvm {
  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)
  33. : Params(Params), Mode(Mode), LTOPhase(LTOPhase){};
  34. ModuleInlinerPass(ModuleInlinerPass &&Arg) = default;
  35. PreservedAnalyses run(Module &, ModuleAnalysisManager &);
  36. private:
  37. InlineAdvisor &getAdvisor(const ModuleAnalysisManager &MAM,
  38. FunctionAnalysisManager &FAM, Module &M);
  39. std::unique_ptr<InlineAdvisor> OwnedAdvisor;
  40. const InlineParams Params;
  41. const InliningAdvisorMode Mode;
  42. const ThinOrFullLTOPhase LTOPhase;
  43. };
  44. } // end namespace llvm
  45. #endif // LLVM_TRANSFORMS_IPO_MODULEINLINER_H
  46. #ifdef __GNUC__
  47. #pragma GCC diagnostic pop
  48. #endif