[Alignment][NFC] Use MaybeAlign in AttrBuilder
[llvm-complete.git] / include / llvm / IR / LegacyPassManager.h
blobd6bb79ab60199c84735bf736bcbdc2ac28b8f70e
1 //===- LegacyPassManager.h - Legacy Container for Passes --------*- C++ -*-===//
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 // This file defines the legacy PassManager class. This class is used to hold,
10 // maintain, and optimize execution of Passes. The PassManager class ensures
11 // that analysis results are available before a pass runs, and that Pass's are
12 // destroyed when the PassManager is destroyed.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_IR_LEGACYPASSMANAGER_H
17 #define LLVM_IR_LEGACYPASSMANAGER_H
19 #include "llvm/Pass.h"
20 #include "llvm/Support/CBindingWrapping.h"
22 namespace llvm {
24 class Pass;
25 class Module;
27 namespace legacy {
29 class PassManagerImpl;
30 class FunctionPassManagerImpl;
32 /// PassManagerBase - An abstract interface to allow code to add passes to
33 /// a pass manager without having to hard-code what kind of pass manager
34 /// it is.
35 class PassManagerBase {
36 public:
37 virtual ~PassManagerBase();
39 /// Add a pass to the queue of passes to run. This passes ownership of
40 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
41 /// will be destroyed as well, so there is no need to delete the pass. This
42 /// may even destroy the pass right away if it is found to be redundant. This
43 /// implies that all passes MUST be allocated with 'new'.
44 virtual void add(Pass *P) = 0;
47 /// PassManager manages ModulePassManagers
48 class PassManager : public PassManagerBase {
49 public:
51 PassManager();
52 ~PassManager() override;
54 void add(Pass *P) override;
56 /// run - Execute all of the passes scheduled for execution. Keep track of
57 /// whether any of the passes modifies the module, and if so, return true.
58 bool run(Module &M);
60 private:
61 /// PassManagerImpl_New is the actual class. PassManager is just the
62 /// wraper to publish simple pass manager interface
63 PassManagerImpl *PM;
66 /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
67 class FunctionPassManager : public PassManagerBase {
68 public:
69 /// FunctionPassManager ctor - This initializes the pass manager. It needs,
70 /// but does not take ownership of, the specified Module.
71 explicit FunctionPassManager(Module *M);
72 ~FunctionPassManager() override;
74 void add(Pass *P) override;
76 /// run - Execute all of the passes scheduled for execution. Keep
77 /// track of whether any of the passes modifies the function, and if
78 /// so, return true.
79 ///
80 bool run(Function &F);
82 /// doInitialization - Run all of the initializers for the function passes.
83 ///
84 bool doInitialization();
86 /// doFinalization - Run all of the finalizers for the function passes.
87 ///
88 bool doFinalization();
90 private:
91 FunctionPassManagerImpl *FPM;
92 Module *M;
95 } // End legacy namespace
97 // Create wrappers for C Binding types (see CBindingWrapping.h).
98 DEFINE_STDCXX_CONVERSION_FUNCTIONS(legacy::PassManagerBase, LLVMPassManagerRef)
100 } // End llvm namespace
102 #endif