AlwaysInliner.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- AlwaysInliner.h - Pass to inline "always_inline" functions --------===//
  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. ///
  14. /// \file
  15. /// Provides passes to inlining "always_inline" functions.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H
  19. #define LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H
  20. #include "llvm/IR/PassManager.h"
  21. namespace llvm {
  22. class Module;
  23. class Pass;
  24. /// Inlines functions marked as "always_inline".
  25. ///
  26. /// Note that this does not inline call sites marked as always_inline and does
  27. /// not delete the functions even when all users are inlined. The normal
  28. /// inliner should be used to handle call site inlining, this pass's goal is to
  29. /// be the simplest possible pass to remove always_inline function definitions'
  30. /// uses by inlining them. The \c GlobalDCE pass can be used to remove these
  31. /// functions once all users are gone.
  32. class AlwaysInlinerPass : public PassInfoMixin<AlwaysInlinerPass> {
  33. bool InsertLifetime;
  34. public:
  35. AlwaysInlinerPass(bool InsertLifetime = true)
  36. : InsertLifetime(InsertLifetime) {}
  37. PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
  38. static bool isRequired() { return true; }
  39. };
  40. /// Create a legacy pass manager instance of a pass to inline and remove
  41. /// functions marked as "always_inline".
  42. Pass *createAlwaysInlinerLegacyPass(bool InsertLifetime = true);
  43. }
  44. #endif // LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H
  45. #ifdef __GNUC__
  46. #pragma GCC diagnostic pop
  47. #endif