1 | //===-- AlwaysInliner.h - Pass to inline "always_inline" functions --------===// |
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 | /// \file |
10 | /// Provides passes to inlining "always_inline" functions. |
11 | /// |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #ifndef LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H |
15 | #define LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H |
16 | |
17 | #include "llvm/IR/PassManager.h" |
18 | |
19 | namespace llvm { |
20 | |
21 | class Module; |
22 | class Pass; |
23 | |
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 | |
35 | public: |
36 | AlwaysInlinerPass(bool InsertLifetime = true) |
37 | : InsertLifetime(InsertLifetime) {} |
38 | |
39 | PreservedAnalyses run(Module &M, ModuleAnalysisManager &); |
40 | static bool isRequired() { return true; } |
41 | }; |
42 | |
43 | /// Create a legacy pass manager instance of a pass to inline and remove |
44 | /// functions marked as "always_inline". |
45 | Pass *createAlwaysInlinerLegacyPass(bool InsertLifetime = true); |
46 | |
47 | } |
48 | |
49 | #endif // LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H |
50 | |