AlwaysInliner.h 1.8 KB

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