6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
+ #include " llvm/CodeGen/ProcessImplicitDefs.h"
9
10
#include " llvm/ADT/SetVector.h"
10
11
#include " llvm/Analysis/AliasAnalysis.h"
11
12
#include " llvm/CodeGen/MachineFunctionPass.h"
@@ -26,24 +27,15 @@ using namespace llvm;
26
27
namespace {
27
28
// / Process IMPLICIT_DEF instructions and make sure there is one implicit_def
28
29
// / for each use. Add isUndef marker to implicit_def defs and their uses.
29
- class ProcessImplicitDefs : public MachineFunctionPass {
30
- const TargetInstrInfo *TII = nullptr ;
31
- const TargetRegisterInfo *TRI = nullptr ;
32
- MachineRegisterInfo *MRI = nullptr ;
33
-
34
- SmallSetVector<MachineInstr*, 16 > WorkList;
35
-
36
- void processImplicitDef (MachineInstr *MI);
37
- bool canTurnIntoImplicitDef (MachineInstr *MI);
38
-
30
+ class ProcessImplicitDefsLegacy : public MachineFunctionPass {
39
31
public:
40
32
static char ID;
41
33
42
- ProcessImplicitDefs () : MachineFunctionPass(ID) {
43
- initializeProcessImplicitDefsPass (*PassRegistry::getPassRegistry ());
34
+ ProcessImplicitDefsLegacy () : MachineFunctionPass(ID) {
35
+ initializeProcessImplicitDefsLegacyPass (*PassRegistry::getPassRegistry ());
44
36
}
45
37
46
- void getAnalysisUsage (AnalysisUsage &au ) const override ;
38
+ void getAnalysisUsage (AnalysisUsage &AU ) const override ;
47
39
48
40
bool runOnMachineFunction (MachineFunction &MF) override ;
49
41
@@ -52,15 +44,29 @@ class ProcessImplicitDefs : public MachineFunctionPass {
52
44
MachineFunctionProperties::Property::IsSSA);
53
45
}
54
46
};
47
+
48
+ class ProcessImplicitDefs {
49
+ const TargetInstrInfo *TII = nullptr ;
50
+ const TargetRegisterInfo *TRI = nullptr ;
51
+ MachineRegisterInfo *MRI = nullptr ;
52
+
53
+ SmallSetVector<MachineInstr *, 16 > WorkList;
54
+
55
+ void processImplicitDef (MachineInstr *MI);
56
+ bool canTurnIntoImplicitDef (MachineInstr *MI);
57
+
58
+ public:
59
+ bool run (MachineFunction &MF);
60
+ };
55
61
} // end anonymous namespace
56
62
57
- char ProcessImplicitDefs ::ID = 0 ;
58
- char &llvm::ProcessImplicitDefsID = ProcessImplicitDefs ::ID;
63
+ char ProcessImplicitDefsLegacy ::ID = 0 ;
64
+ char &llvm::ProcessImplicitDefsID = ProcessImplicitDefsLegacy ::ID;
59
65
60
- INITIALIZE_PASS (ProcessImplicitDefs , DEBUG_TYPE,
66
+ INITIALIZE_PASS (ProcessImplicitDefsLegacy , DEBUG_TYPE,
61
67
" Process Implicit Definitions" , false , false )
62
68
63
- void ProcessImplicitDefs ::getAnalysisUsage(AnalysisUsage &AU) const {
69
+ void ProcessImplicitDefsLegacy ::getAnalysisUsage(AnalysisUsage &AU) const {
64
70
AU.setPreservesCFG ();
65
71
AU.addPreserved <AAResultsWrapperPass>();
66
72
MachineFunctionPass::getAnalysisUsage (AU);
@@ -133,9 +139,24 @@ void ProcessImplicitDefs::processImplicitDef(MachineInstr *MI) {
133
139
LLVM_DEBUG (dbgs () << " Keeping physreg: " << *MI);
134
140
}
135
141
142
+ bool ProcessImplicitDefsLegacy::runOnMachineFunction (MachineFunction &MF) {
143
+ return ProcessImplicitDefs ().run (MF);
144
+ }
145
+
146
+ PreservedAnalyses
147
+ ProcessImplicitDefsPass::run (MachineFunction &MF,
148
+ MachineFunctionAnalysisManager &MFAM) {
149
+ if (!ProcessImplicitDefs ().run (MF))
150
+ return PreservedAnalyses::all ();
151
+
152
+ return getMachineFunctionPassPreservedAnalyses ()
153
+ .preserveSet <CFGAnalyses>()
154
+ .preserve <AAManager>();
155
+ }
156
+
136
157
// / processImplicitDefs - Process IMPLICIT_DEF instructions and turn them into
137
158
// / <undef> operands.
138
- bool ProcessImplicitDefs::runOnMachineFunction (MachineFunction &MF) {
159
+ bool ProcessImplicitDefs::run (MachineFunction &MF) {
139
160
140
161
LLVM_DEBUG (dbgs () << " ********** PROCESS IMPLICIT DEFS **********\n "
141
162
<< " ********** Function: " << MF.getName () << ' \n ' );
0 commit comments