[llvm] [CodeGen][NewPM] Port LiveDebugVariables to NPM (PR #115468)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 08:14:06 PST 2024
================
@@ -1298,31 +1297,50 @@ 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);
+LiveDebugVariables::~LiveDebugVariables() {
+ if (PImpl)
+ delete static_cast<LDVImpl *>(PImpl);
}
void LiveDebugVariables::releaseMemory() {
- if (pImpl)
- static_cast<LDVImpl*>(pImpl)->clear();
+ if (PImpl)
+ static_cast<LDVImpl *>(PImpl)->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;
+ }
+
+ if (!PImpl)
+ PImpl = new LDVImpl(LIS); // reuse same object across analysis runs
----------------
arsenm wrote:
migrate to unique_ptr?
https://github.com/llvm/llvm-project/pull/115468
More information about the llvm-commits
mailing list