[llvm] [CodeGen][NewPM] Port LiveDebugVariables to NPM (PR #115468)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 00:07:19 PST 2024
================
@@ -1298,31 +1297,48 @@ static void removeDebugInstrs(MachineFunction &mf) {
}
}
-bool LiveDebugVariables::runOnMachineFunction(MachineFunction &mf) {
- if (!EnableLDV)
- return false;
- if (!mf.getFunction().getSubprogram()) {
- removeDebugInstrs(mf);
- return false;
- }
+bool LiveDebugVariablesWrapperPass::runOnMachineFunction(MachineFunction &mf) {
+ auto *LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
- // Have we been asked to track variable locations using instruction
- // referencing?
- bool InstrRef = mf.useDebugInstrRef();
+ Impl = std::make_unique<LiveDebugVariables>();
+ Impl->analyze(mf, LIS);
+ return false;
+}
+
+AnalysisKey LiveDebugVariablesAnalysis::Key;
+
+LiveDebugVariables
+LiveDebugVariablesAnalysis::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ auto *LIS = &MFAM.getResult<LiveIntervalsAnalysis>(MF);
+ LiveDebugVariables LDV;
+ LDV.analyze(MF, LIS);
+ return LDV;
+}
- if (!pImpl)
- pImpl = new LDVImpl(this);
- return static_cast<LDVImpl *>(pImpl)->runOnMachineFunction(mf, InstrRef);
+void LiveDebugVariables::Deleter::operator()(void *Ptr) const {
+ delete static_cast<LDVImpl *>(Ptr);
}
void LiveDebugVariables::releaseMemory() {
- if (pImpl)
- static_cast<LDVImpl*>(pImpl)->clear();
+ if (PImpl)
+ static_cast<LDVImpl *>(PImpl.get())->clear();
}
-LiveDebugVariables::~LiveDebugVariables() {
- if (pImpl)
- delete static_cast<LDVImpl*>(pImpl);
+void LiveDebugVariables::analyze(MachineFunction &MF, LiveIntervals *LIS) {
+ if (!EnableLDV)
+ return;
+ if (!MF.getFunction().getSubprogram()) {
+ removeDebugInstrs(MF);
+ return;
+ }
+
+ PImpl.reset(new LDVImpl(LIS));
+
+ // Have we been asked to track variable locations using instruction
+ // referencing?
+ bool InstrRef = MF.useDebugInstrRef();
+ static_cast<LDVImpl *>(PImpl.get())->runOnMachineFunction(MF, InstrRef);
----------------
optimisan wrote:
It is a void pointer-is there another way?
https://github.com/llvm/llvm-project/pull/115468
More information about the llvm-commits
mailing list