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,40 +27,45 @@ 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
50
42
MachineFunctionProperties getRequiredProperties () const override {
51
43
return MachineFunctionProperties ().setIsSSA ();
52
44
}
53
45
};
46
+
47
+ class ProcessImplicitDefs {
48
+ const TargetInstrInfo *TII = nullptr ;
49
+ const TargetRegisterInfo *TRI = nullptr ;
50
+ MachineRegisterInfo *MRI = nullptr ;
51
+
52
+ SmallSetVector<MachineInstr *, 16 > WorkList;
53
+
54
+ void processImplicitDef (MachineInstr *MI);
55
+ bool canTurnIntoImplicitDef (MachineInstr *MI);
56
+
57
+ public:
58
+ bool run (MachineFunction &MF);
59
+ };
54
60
} // end anonymous namespace
55
61
56
- char ProcessImplicitDefs ::ID = 0 ;
57
- char &llvm::ProcessImplicitDefsID = ProcessImplicitDefs ::ID;
62
+ char ProcessImplicitDefsLegacy ::ID = 0 ;
63
+ char &llvm::ProcessImplicitDefsID = ProcessImplicitDefsLegacy ::ID;
58
64
59
- INITIALIZE_PASS (ProcessImplicitDefs , DEBUG_TYPE,
65
+ INITIALIZE_PASS (ProcessImplicitDefsLegacy , DEBUG_TYPE,
60
66
" Process Implicit Definitions" , false , false )
61
67
62
- void ProcessImplicitDefs ::getAnalysisUsage(AnalysisUsage &AU) const {
68
+ void ProcessImplicitDefsLegacy ::getAnalysisUsage(AnalysisUsage &AU) const {
63
69
AU.setPreservesCFG ();
64
70
AU.addPreserved <AAResultsWrapperPass>();
65
71
MachineFunctionPass::getAnalysisUsage (AU);
@@ -132,9 +138,24 @@ void ProcessImplicitDefs::processImplicitDef(MachineInstr *MI) {
132
138
LLVM_DEBUG (dbgs () << " Keeping physreg: " << *MI);
133
139
}
134
140
141
+ bool ProcessImplicitDefsLegacy::runOnMachineFunction (MachineFunction &MF) {
142
+ return ProcessImplicitDefs ().run (MF);
143
+ }
144
+
145
+ PreservedAnalyses
146
+ ProcessImplicitDefsPass::run (MachineFunction &MF,
147
+ MachineFunctionAnalysisManager &MFAM) {
148
+ if (!ProcessImplicitDefs ().run (MF))
149
+ return PreservedAnalyses::all ();
150
+
151
+ return getMachineFunctionPassPreservedAnalyses ()
152
+ .preserveSet <CFGAnalyses>()
153
+ .preserve <AAManager>();
154
+ }
155
+
135
156
// / processImplicitDefs - Process IMPLICIT_DEF instructions and turn them into
136
157
// / <undef> operands.
137
- bool ProcessImplicitDefs::runOnMachineFunction (MachineFunction &MF) {
158
+ bool ProcessImplicitDefs::run (MachineFunction &MF) {
138
159
139
160
LLVM_DEBUG (dbgs () << " ********** PROCESS IMPLICIT DEFS **********\n "
140
161
<< " ********** Function: " << MF.getName () << ' \n ' );
0 commit comments