21
21
#define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
22
22
23
23
#include " llvm/CodeGen/MachineFunctionPass.h"
24
+ #include " llvm/IR/PassManager.h"
24
25
#include " llvm/Support/Compiler.h"
26
+ #include " llvm/Support/raw_ostream.h"
27
+ #include < memory>
25
28
26
29
namespace llvm {
27
30
28
31
template <typename T> class ArrayRef ;
29
32
class LiveIntervals ;
30
33
class VirtRegMap ;
31
34
32
- class LiveDebugVariables : public MachineFunctionPass {
33
- void *pImpl = nullptr ;
35
+ class LiveDebugVariables {
34
36
35
37
public:
36
- static char ID; // Pass identification, replacement for typeid
37
-
38
+ class LDVImpl ;
38
39
LiveDebugVariables ();
39
- ~LiveDebugVariables () override ;
40
+ ~LiveDebugVariables ();
41
+ LiveDebugVariables (LiveDebugVariables &&);
40
42
43
+ void analyze (MachineFunction &MF, LiveIntervals *LIS);
41
44
// / splitRegister - Move any user variables in OldReg to the live ranges in
42
45
// / NewRegs where they are live. Mark the values as unavailable where no new
43
46
// / register is live.
@@ -49,12 +52,39 @@ class LiveDebugVariables : public MachineFunctionPass {
49
52
// / @param VRM Rename virtual registers according to map.
50
53
void emitDebugValues (VirtRegMap *VRM);
51
54
55
+ #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
52
56
// / dump - Print data structures to dbgs().
53
57
void dump () const ;
58
+ #endif
59
+
60
+ void print (raw_ostream &OS) const ;
61
+
62
+ void releaseMemory ();
63
+
64
+ bool invalidate (MachineFunction &MF, const PreservedAnalyses &PA,
65
+ MachineFunctionAnalysisManager::Invalidator &Inv);
54
66
55
67
private:
68
+ std::unique_ptr<LDVImpl> PImpl;
69
+ };
70
+
71
+ class LiveDebugVariablesWrapperLegacy : public MachineFunctionPass {
72
+ std::unique_ptr<LiveDebugVariables> Impl;
73
+
74
+ public:
75
+ static char ID; // Pass identification, replacement for typeid
76
+
77
+ LiveDebugVariablesWrapperLegacy ();
78
+
56
79
bool runOnMachineFunction (MachineFunction &) override ;
57
- void releaseMemory () override ;
80
+
81
+ LiveDebugVariables &getLDV () { return *Impl; }
82
+ const LiveDebugVariables &getLDV () const { return *Impl; }
83
+
84
+ void releaseMemory () override {
85
+ if (Impl)
86
+ Impl->releaseMemory ();
87
+ }
58
88
void getAnalysisUsage (AnalysisUsage &) const override ;
59
89
60
90
MachineFunctionProperties getSetProperties () const override {
@@ -63,6 +93,32 @@ class LiveDebugVariables : public MachineFunctionPass {
63
93
}
64
94
};
65
95
96
+ class LiveDebugVariablesAnalysis
97
+ : public AnalysisInfoMixin<LiveDebugVariablesAnalysis> {
98
+ friend AnalysisInfoMixin<LiveDebugVariablesAnalysis>;
99
+ static AnalysisKey Key;
100
+
101
+ public:
102
+ using Result = LiveDebugVariables;
103
+
104
+ MachineFunctionProperties getSetProperties () const {
105
+ return MachineFunctionProperties ().set (
106
+ MachineFunctionProperties::Property::TracksDebugUserValues);
107
+ }
108
+
109
+ Result run (MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
110
+ };
111
+
112
+ class LiveDebugVariablesPrinterPass
113
+ : public PassInfoMixin<LiveDebugVariablesPrinterPass> {
114
+ raw_ostream &OS;
115
+
116
+ public:
117
+ LiveDebugVariablesPrinterPass (raw_ostream &OS) : OS(OS) {}
118
+
119
+ PreservedAnalyses run (MachineFunction &MF,
120
+ MachineFunctionAnalysisManager &MFAM);
121
+ };
66
122
} // end namespace llvm
67
123
68
124
#endif // LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
0 commit comments