LLVM 22.0.0git
LegacyPassManager.h
Go to the documentation of this file.
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.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_IR_LEGACYPASSMANAGER_H
17#define LLVM_IR_LEGACYPASSMANAGER_H
18
21
22namespace llvm {
23
24class Function;
25class Pass;
26class Module;
27
28namespace legacy {
29
30// Whether or not -debug-pass has been specified. For use to check if it's
31// specified alongside the new PM.
33
34class PassManagerImpl;
35class FunctionPassManagerImpl;
36
37/// PassManagerBase - An abstract interface to allow code to add passes to
38/// a pass manager without having to hard-code what kind of pass manager
39/// it is.
41public:
43
44 /// Add a pass to the queue of passes to run. This passes ownership of
45 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
46 /// will be destroyed as well, so there is no need to delete the pass. This
47 /// may even destroy the pass right away if it is found to be redundant. This
48 /// implies that all passes MUST be allocated with 'new'.
49 virtual void add(Pass *P) = 0;
50};
51
52/// PassManager manages ModulePassManagers
54public:
55
57 ~PassManager() override;
58
59 void add(Pass *P) override;
60
61 /// run - Execute all of the passes scheduled for execution. Keep track of
62 /// whether any of the passes modifies the module, and if so, return true.
63 bool run(Module &M);
64
65private:
66 /// PassManagerImpl_New is the actual class. PassManager is just the
67 /// wraper to publish simple pass manager interface
69};
70
71/// FunctionPassManager manages FunctionPasses.
73public:
74 /// FunctionPassManager ctor - This initializes the pass manager. It needs,
75 /// but does not take ownership of, the specified Module.
76 explicit FunctionPassManager(Module *M);
77 ~FunctionPassManager() override;
78
79 void add(Pass *P) override;
80
81 /// run - Execute all of the passes scheduled for execution. Keep
82 /// track of whether any of the passes modifies the function, and if
83 /// so, return true.
84 ///
85 bool run(Function &F);
86
87 /// doInitialization - Run all of the initializers for the function passes.
88 ///
89 bool doInitialization();
90
91 /// doFinalization - Run all of the finalizers for the function passes.
92 ///
93 bool doFinalization();
94
95private:
97 Module *M;
98};
99
100} // End legacy namespace
101
102// Create wrappers for C Binding types (see CBindingWrapping.h).
104
105} // End llvm namespace
106
107#endif
#define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_ABI
Definition: Compiler.h:213
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
#define P(N)
Shrink Wrap Pass
Definition: ShrinkWrap.cpp:301
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:99
FunctionPassManagerImpl manages FPPassManagers.
FunctionPassManager manages FunctionPasses.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
virtual void add(Pass *P)=0
Add a pass to the queue of passes to run.
PassManagerImpl manages MPPassManagers.
PassManager manages ModulePassManagers.
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Types.h:127
LLVM_ABI bool debugPassSpecified()
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18