ModuleInliner.h 2.1 KB

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