2121#define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
2222
2323#include " llvm/CodeGen/MachineFunctionPass.h"
24+ #include " llvm/IR/PassManager.h"
2425#include " llvm/Support/Compiler.h"
26+ #include " llvm/Support/raw_ostream.h"
27+ #include < memory>
2528
2629namespace llvm {
2730
2831template <typename T> class ArrayRef ;
2932class LiveIntervals ;
3033class VirtRegMap ;
3134
32- class LiveDebugVariables : public MachineFunctionPass {
33- void *pImpl = nullptr ;
35+ class LiveDebugVariables {
3436
3537public:
36- static char ID; // Pass identification, replacement for typeid
37-
38+ class LDVImpl ;
3839 LiveDebugVariables ();
39- ~LiveDebugVariables () override ;
40+ ~LiveDebugVariables ();
41+ LiveDebugVariables (LiveDebugVariables &&);
4042
43+ void analyze (MachineFunction &MF, LiveIntervals *LIS);
4144 // / splitRegister - Move any user variables in OldReg to the live ranges in
4245 // / NewRegs where they are live. Mark the values as unavailable where no new
4346 // / register is live.
@@ -49,12 +52,39 @@ class LiveDebugVariables : public MachineFunctionPass {
4952 // / @param VRM Rename virtual registers according to map.
5053 void emitDebugValues (VirtRegMap *VRM);
5154
55+ #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
5256 // / dump - Print data structures to dbgs().
5357 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);
5466
5567private:
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+
5679 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+ }
5888 void getAnalysisUsage (AnalysisUsage &) const override ;
5989
6090 MachineFunctionProperties getSetProperties () const override {
@@ -63,6 +93,32 @@ class LiveDebugVariables : public MachineFunctionPass {
6393 }
6494};
6595
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+ };
66122} // end namespace llvm
67123
68124#endif // LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
0 commit comments