[llvm] d9b4bdb - [CodeGen][NewPM] Port LiveDebugVariables to NPM (#115468)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 4 01:01:38 PST 2024
Author: Akshat Oke
Date: 2024-12-04T14:31:34+05:30
New Revision: d9b4bdbff597d0ed98dd82674e456ac4c751a6a0
URL: https://github.com/llvm/llvm-project/commit/d9b4bdbff597d0ed98dd82674e456ac4c751a6a0
DIFF: https://github.com/llvm/llvm-project/commit/d9b4bdbff597d0ed98dd82674e456ac4c751a6a0.diff
LOG: [CodeGen][NewPM] Port LiveDebugVariables to NPM (#115468)
The existing analysis was already a pimpl wrapper.
I have extracted legacy pass logic to a LDVImpl wrapper named
`LiveDebugVariables` which is the analysis::Result now. This controls
whether to activate the LDV (depending on `-live-debug-variables` and
DIsubprogram) itself.
The legacy and new analysis only construct the LiveDebugVariables.
VirtRegRewriter will test this.
Added:
Modified:
llvm/include/llvm/CodeGen/LiveDebugVariables.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/Passes/MachinePassRegistry.def
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/LiveDebugVariables.cpp
llvm/lib/CodeGen/RegAllocBasic.cpp
llvm/lib/CodeGen/RegAllocGreedy.cpp
llvm/lib/CodeGen/RegAllocGreedy.h
llvm/lib/CodeGen/StackSlotColoring.cpp
llvm/lib/CodeGen/VirtRegMap.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Target/LoongArch/LoongArchDeadRegisterDefinitions.cpp
llvm/lib/Target/RISCV/RISCVDeadRegisterDefinitions.cpp
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/LiveDebugVariables.h b/llvm/include/llvm/CodeGen/LiveDebugVariables.h
index a4b5a87fd3887a..2cb95f2c71ccda 100644
--- a/llvm/include/llvm/CodeGen/LiveDebugVariables.h
+++ b/llvm/include/llvm/CodeGen/LiveDebugVariables.h
@@ -21,7 +21,10 @@
#define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
+#include <memory>
namespace llvm {
@@ -29,15 +32,15 @@ template <typename T> class ArrayRef;
class LiveIntervals;
class VirtRegMap;
-class LiveDebugVariables : public MachineFunctionPass {
- void *pImpl = nullptr;
+class LiveDebugVariables {
public:
- static char ID; // Pass identification, replacement for typeid
-
+ class LDVImpl;
LiveDebugVariables();
- ~LiveDebugVariables() override;
+ ~LiveDebugVariables();
+ LiveDebugVariables(LiveDebugVariables &&);
+ void analyze(MachineFunction &MF, LiveIntervals *LIS);
/// splitRegister - Move any user variables in OldReg to the live ranges in
/// NewRegs where they are live. Mark the values as unavailable where no new
/// register is live.
@@ -49,12 +52,39 @@ class LiveDebugVariables : public MachineFunctionPass {
/// @param VRM Rename virtual registers according to map.
void emitDebugValues(VirtRegMap *VRM);
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// dump - Print data structures to dbgs().
void dump() const;
+#endif
+
+ void print(raw_ostream &OS) const;
+
+ void releaseMemory();
+
+ bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
+ MachineFunctionAnalysisManager::Invalidator &Inv);
private:
+ std::unique_ptr<LDVImpl> PImpl;
+};
+
+class LiveDebugVariablesWrapperLegacy : public MachineFunctionPass {
+ std::unique_ptr<LiveDebugVariables> Impl;
+
+public:
+ static char ID; // Pass identification, replacement for typeid
+
+ LiveDebugVariablesWrapperLegacy();
+
bool runOnMachineFunction(MachineFunction &) override;
- void releaseMemory() override;
+
+ LiveDebugVariables &getLDV() { return *Impl; }
+ const LiveDebugVariables &getLDV() const { return *Impl; }
+
+ void releaseMemory() override {
+ if (Impl)
+ Impl->releaseMemory();
+ }
void getAnalysisUsage(AnalysisUsage &) const override;
MachineFunctionProperties getSetProperties() const override {
@@ -63,6 +93,32 @@ class LiveDebugVariables : public MachineFunctionPass {
}
};
+class LiveDebugVariablesAnalysis
+ : public AnalysisInfoMixin<LiveDebugVariablesAnalysis> {
+ friend AnalysisInfoMixin<LiveDebugVariablesAnalysis>;
+ static AnalysisKey Key;
+
+public:
+ using Result = LiveDebugVariables;
+
+ MachineFunctionProperties getSetProperties() const {
+ return MachineFunctionProperties().set(
+ MachineFunctionProperties::Property::TracksDebugUserValues);
+ }
+
+ Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
+};
+
+class LiveDebugVariablesPrinterPass
+ : public PassInfoMixin<LiveDebugVariablesPrinterPass> {
+ raw_ostream &OS;
+
+public:
+ LiveDebugVariablesPrinterPass(raw_ostream &OS) : OS(OS) {}
+
+ PreservedAnalyses run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM);
+};
} // end namespace llvm
#endif // LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 88bca2c75c9498..7b81c9a8e143a3 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -154,7 +154,7 @@ void initializeLegalizerPass(PassRegistry &);
void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
void initializeLiveDebugValuesPass(PassRegistry &);
-void initializeLiveDebugVariablesPass(PassRegistry &);
+void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &);
void initializeLiveIntervalsWrapperPassPass(PassRegistry &);
void initializeLiveRangeShrinkPass(PassRegistry &);
void initializeLiveRegMatrixWrapperLegacyPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def
index 614e36cfbd1a04..e65bd58dae96b1 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -98,6 +98,7 @@ LOOP_PASS("loop-term-fold", LoopTermFoldPass())
// computed. (We still either need to regenerate kill flags after regalloc, or
// preferably fix the scavenger to not depend on them).
MACHINE_FUNCTION_ANALYSIS("edge-bundles", EdgeBundlesAnalysis())
+MACHINE_FUNCTION_ANALYSIS("livedebugvars", LiveDebugVariablesAnalysis())
MACHINE_FUNCTION_ANALYSIS("live-intervals", LiveIntervalsAnalysis())
MACHINE_FUNCTION_ANALYSIS("live-reg-matrix", LiveRegMatrixAnalysis())
MACHINE_FUNCTION_ANALYSIS("live-vars", LiveVariablesAnalysis())
@@ -146,6 +147,7 @@ MACHINE_FUNCTION_PASS("opt-phis", OptimizePHIsPass())
MACHINE_FUNCTION_PASS("peephole-opt", PeepholeOptimizerPass())
MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass())
MACHINE_FUNCTION_PASS("print", PrintMIRPass())
+MACHINE_FUNCTION_PASS("print<livedebugvars>", LiveDebugVariablesPrinterPass(errs()))
MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(errs()))
MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(errs()))
MACHINE_FUNCTION_PASS("print<machine-block-freq>",
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index 408395fefc298a..59428818c1ee7c 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -59,7 +59,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeInterleavedAccessPass(Registry);
initializeJMCInstrumenterPass(Registry);
initializeLiveDebugValuesPass(Registry);
- initializeLiveDebugVariablesPass(Registry);
+ initializeLiveDebugVariablesWrapperLegacyPass(Registry);
initializeLiveIntervalsWrapperPassPass(Registry);
initializeLiveRangeShrinkPass(Registry);
initializeLiveStacksPass(Registry);
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 2ff346d3fd0223..317d3401f000a4 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -38,6 +38,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineOperand.h"
+#include "llvm/CodeGen/MachinePassManager.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
@@ -74,24 +75,27 @@ EnableLDV("live-debug-variables", cl::init(true),
STATISTIC(NumInsertedDebugValues, "Number of DBG_VALUEs inserted");
STATISTIC(NumInsertedDebugLabels, "Number of DBG_LABELs inserted");
-char LiveDebugVariables::ID = 0;
+char LiveDebugVariablesWrapperLegacy::ID = 0;
-INITIALIZE_PASS_BEGIN(LiveDebugVariables, DEBUG_TYPE,
- "Debug Variable Analysis", false, false)
+INITIALIZE_PASS_BEGIN(LiveDebugVariablesWrapperLegacy, DEBUG_TYPE,
+ "Debug Variable Analysis", false, false)
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
-INITIALIZE_PASS_END(LiveDebugVariables, DEBUG_TYPE,
- "Debug Variable Analysis", false, false)
+INITIALIZE_PASS_END(LiveDebugVariablesWrapperLegacy, DEBUG_TYPE,
+ "Debug Variable Analysis", false, false)
-void LiveDebugVariables::getAnalysisUsage(AnalysisUsage &AU) const {
+void LiveDebugVariablesWrapperLegacy::getAnalysisUsage(
+ AnalysisUsage &AU) const {
AU.addRequired<MachineDominatorTreeWrapperPass>();
AU.addRequiredTransitive<LiveIntervalsWrapperPass>();
AU.setPreservesAll();
MachineFunctionPass::getAnalysisUsage(AU);
}
-LiveDebugVariables::LiveDebugVariables() : MachineFunctionPass(ID) {
- initializeLiveDebugVariablesPass(*PassRegistry::getPassRegistry());
+LiveDebugVariablesWrapperLegacy::LiveDebugVariablesWrapperLegacy()
+ : MachineFunctionPass(ID) {
+ initializeLiveDebugVariablesWrapperLegacyPass(
+ *PassRegistry::getPassRegistry());
}
enum : unsigned { UndefLocNo = ~0U };
@@ -274,8 +278,6 @@ using BlockSkipInstsMap =
namespace {
-class LDVImpl;
-
/// A user value is a part of a debug info user variable.
///
/// A DBG_VALUE instruction notes that (a sub-register of) a virtual register
@@ -285,6 +287,8 @@ class LDVImpl;
/// user values are related if they are held by the same virtual register. The
/// equivalence class is the transitive closure of that relation.
class UserValue {
+ using LDVImpl = LiveDebugVariables::LDVImpl;
+
const DILocalVariable *Variable; ///< The debug info variable we are part of.
/// The part of the variable we describe.
const std::optional<DIExpression::FragmentInfo> Fragment;
@@ -528,9 +532,17 @@ class UserLabel {
void print(raw_ostream &, const TargetRegisterInfo *);
};
+} // end anonymous namespace
+
+namespace llvm {
+
/// Implementation of the LiveDebugVariables pass.
-class LDVImpl {
- LiveDebugVariables &pass;
+
+LiveDebugVariables::LiveDebugVariables() = default;
+LiveDebugVariables::~LiveDebugVariables() = default;
+LiveDebugVariables::LiveDebugVariables(LiveDebugVariables &&) = default;
+
+class LiveDebugVariables::LDVImpl {
LocMap::Allocator allocator;
MachineFunction *MF = nullptr;
LiveIntervals *LIS;
@@ -634,7 +646,7 @@ class LDVImpl {
void computeIntervals();
public:
- LDVImpl(LiveDebugVariables *ps) : pass(*ps) {}
+ LDVImpl(LiveIntervals *LIS) : LIS(LIS) {}
bool runOnMachineFunction(MachineFunction &mf, bool InstrRef);
@@ -671,9 +683,8 @@ class LDVImpl {
void print(raw_ostream&);
};
-} // end anonymous namespace
+} // namespace llvm
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS,
const LLVMContext &Ctx) {
if (!DL)
@@ -753,7 +764,7 @@ void UserLabel::print(raw_ostream &OS, const TargetRegisterInfo *TRI) {
OS << '\n';
}
-void LDVImpl::print(raw_ostream &OS) {
+void LiveDebugVariables::LDVImpl::print(raw_ostream &OS) {
OS << "********** DEBUG VARIABLES **********\n";
for (auto &userValue : userValues)
userValue->print(OS, TRI);
@@ -761,18 +772,16 @@ void LDVImpl::print(raw_ostream &OS) {
for (auto &userLabel : userLabels)
userLabel->print(OS, TRI);
}
-#endif
-void UserValue::mapVirtRegs(LDVImpl *LDV) {
+void UserValue::mapVirtRegs(LiveDebugVariables::LDVImpl *LDV) {
for (const MachineOperand &MO : locations)
if (MO.isReg() && MO.getReg().isVirtual())
LDV->mapVirtReg(MO.getReg(), this);
}
-UserValue *
-LDVImpl::getUserValue(const DILocalVariable *Var,
- std::optional<DIExpression::FragmentInfo> Fragment,
- const DebugLoc &DL) {
+UserValue *LiveDebugVariables::LDVImpl::getUserValue(
+ const DILocalVariable *Var,
+ std::optional<DIExpression::FragmentInfo> Fragment, const DebugLoc &DL) {
// FIXME: Handle partially overlapping fragments. See
// https://reviews.llvm.org/D70121#1849741.
DebugVariable ID(Var, Fragment, DL->getInlinedAt());
@@ -785,19 +794,20 @@ LDVImpl::getUserValue(const DILocalVariable *Var,
return UV;
}
-void LDVImpl::mapVirtReg(Register VirtReg, UserValue *EC) {
+void LiveDebugVariables::LDVImpl::mapVirtReg(Register VirtReg, UserValue *EC) {
assert(VirtReg.isVirtual() && "Only map VirtRegs");
UserValue *&Leader = virtRegToEqClass[VirtReg];
Leader = UserValue::merge(Leader, EC);
}
-UserValue *LDVImpl::lookupVirtReg(Register VirtReg) {
+UserValue *LiveDebugVariables::LDVImpl::lookupVirtReg(Register VirtReg) {
if (UserValue *UV = virtRegToEqClass.lookup(VirtReg))
return UV->getLeader();
return nullptr;
}
-bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
+bool LiveDebugVariables::LDVImpl::handleDebugValue(MachineInstr &MI,
+ SlotIndex Idx) {
// DBG_VALUE loc, offset, variable, expr
// DBG_VALUE_LIST variable, expr, locs...
if (!MI.isDebugValue()) {
@@ -873,8 +883,8 @@ bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
return true;
}
-MachineBasicBlock::iterator LDVImpl::handleDebugInstr(MachineInstr &MI,
- SlotIndex Idx) {
+MachineBasicBlock::iterator
+LiveDebugVariables::LDVImpl::handleDebugInstr(MachineInstr &MI, SlotIndex Idx) {
assert(MI.isDebugValueLike() || MI.isDebugPHI());
// In instruction referencing mode, there should be no DBG_VALUE instructions
@@ -894,7 +904,8 @@ MachineBasicBlock::iterator LDVImpl::handleDebugInstr(MachineInstr &MI,
return NextInst;
}
-bool LDVImpl::handleDebugLabel(MachineInstr &MI, SlotIndex Idx) {
+bool LiveDebugVariables::LDVImpl::handleDebugLabel(MachineInstr &MI,
+ SlotIndex Idx) {
// DBG_LABEL label
if (MI.getNumOperands() != 1 || !MI.getOperand(0).isMetadata()) {
LLVM_DEBUG(dbgs() << "Can't handle " << MI);
@@ -917,7 +928,8 @@ bool LDVImpl::handleDebugLabel(MachineInstr &MI, SlotIndex Idx) {
return true;
}
-bool LDVImpl::collectDebugValues(MachineFunction &mf, bool InstrRef) {
+bool LiveDebugVariables::LDVImpl::collectDebugValues(MachineFunction &mf,
+ bool InstrRef) {
bool Changed = false;
for (MachineBasicBlock &MBB : mf) {
for (MachineBasicBlock::iterator MBBI = MBB.begin(), MBBE = MBB.end();
@@ -1250,7 +1262,7 @@ void UserValue::computeIntervals(MachineRegisterInfo &MRI,
I.setStopUnchecked(PrevEnd);
}
-void LDVImpl::computeIntervals() {
+void LiveDebugVariables::LDVImpl::computeIntervals() {
LexicalScopes LS;
LS.initialize(*MF);
@@ -1260,10 +1272,10 @@ void LDVImpl::computeIntervals() {
}
}
-bool LDVImpl::runOnMachineFunction(MachineFunction &mf, bool InstrRef) {
+bool LiveDebugVariables::LDVImpl::runOnMachineFunction(MachineFunction &mf,
+ bool InstrRef) {
clear();
MF = &mf;
- LIS = &pass.getAnalysis<LiveIntervalsWrapperPass>().getLIS();
TRI = mf.getSubtarget().getRegisterInfo();
LLVM_DEBUG(dbgs() << "********** COMPUTING LIVE DEBUG VARIABLES: "
<< mf.getName() << " **********\n");
@@ -1298,31 +1310,65 @@ static void removeDebugInstrs(MachineFunction &mf) {
}
}
-bool LiveDebugVariables::runOnMachineFunction(MachineFunction &mf) {
- if (!EnableLDV)
- return false;
- if (!mf.getFunction().getSubprogram()) {
- removeDebugInstrs(mf);
- return false;
- }
+bool LiveDebugVariablesWrapperLegacy::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;
+}
- if (!pImpl)
- pImpl = new LDVImpl(this);
- return static_cast<LDVImpl *>(pImpl)->runOnMachineFunction(mf, InstrRef);
+AnalysisKey LiveDebugVariablesAnalysis::Key;
+
+LiveDebugVariables
+LiveDebugVariablesAnalysis::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ MFPropsModifier _(*this, MF);
+
+ auto *LIS = &MFAM.getResult<LiveIntervalsAnalysis>(MF);
+ LiveDebugVariables LDV;
+ LDV.analyze(MF, LIS);
+ return LDV;
+}
+
+PreservedAnalyses
+LiveDebugVariablesPrinterPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ auto &LDV = MFAM.getResult<LiveDebugVariablesAnalysis>(MF);
+ LDV.print(OS);
+ return PreservedAnalyses::all();
}
void LiveDebugVariables::releaseMemory() {
- if (pImpl)
- static_cast<LDVImpl*>(pImpl)->clear();
+ if (PImpl)
+ PImpl->clear();
}
-LiveDebugVariables::~LiveDebugVariables() {
- if (pImpl)
- delete static_cast<LDVImpl*>(pImpl);
+bool LiveDebugVariables::invalidate(
+ MachineFunction &, const PreservedAnalyses &PA,
+ MachineFunctionAnalysisManager::Invalidator &) {
+ auto PAC = PA.getChecker<LiveDebugVariablesAnalysis>();
+ // Some architectures split the register allocation into multiple phases based
+ // on register classes. This requires preserving analyses between the phases
+ // by default.
+ return !PAC.preservedWhenStateless();
+}
+
+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();
+ PImpl->runOnMachineFunction(MF, InstrRef);
}
//===----------------------------------------------------------------------===//
@@ -1445,7 +1491,8 @@ UserValue::splitRegister(Register OldReg, ArrayRef<Register> NewRegs,
return DidChange;
}
-void LDVImpl::splitPHIRegister(Register OldReg, ArrayRef<Register> NewRegs) {
+void LiveDebugVariables::LDVImpl::splitPHIRegister(Register OldReg,
+ ArrayRef<Register> NewRegs) {
auto RegIt = RegToPHIIdx.find(OldReg);
if (RegIt == RegToPHIIdx.end())
return;
@@ -1483,7 +1530,8 @@ void LDVImpl::splitPHIRegister(Register OldReg, ArrayRef<Register> NewRegs) {
RegToPHIIdx[RegAndInstr.first].push_back(RegAndInstr.second);
}
-void LDVImpl::splitRegister(Register OldReg, ArrayRef<Register> NewRegs) {
+void LiveDebugVariables::LDVImpl::splitRegister(Register OldReg,
+ ArrayRef<Register> NewRegs) {
// Consider whether this split range affects any PHI locations.
splitPHIRegister(OldReg, NewRegs);
@@ -1504,8 +1552,8 @@ void LDVImpl::splitRegister(Register OldReg, ArrayRef<Register> NewRegs) {
void LiveDebugVariables::
splitRegister(Register OldReg, ArrayRef<Register> NewRegs, LiveIntervals &LIS) {
- if (pImpl)
- static_cast<LDVImpl*>(pImpl)->splitRegister(OldReg, NewRegs);
+ if (PImpl)
+ PImpl->splitRegister(OldReg, NewRegs);
}
void UserValue::rewriteLocations(VirtRegMap &VRM, const MachineFunction &MF,
@@ -1807,7 +1855,7 @@ void UserLabel::emitDebugLabel(LiveIntervals &LIS, const TargetInstrInfo &TII,
LLVM_DEBUG(dbgs() << '\n');
}
-void LDVImpl::emitDebugValues(VirtRegMap *VRM) {
+void LiveDebugVariables::LDVImpl::emitDebugValues(VirtRegMap *VRM) {
LLVM_DEBUG(dbgs() << "********** EMITTING LIVE DEBUG VARIABLES **********\n");
if (!MF)
return;
@@ -1956,13 +2004,15 @@ void LDVImpl::emitDebugValues(VirtRegMap *VRM) {
}
void LiveDebugVariables::emitDebugValues(VirtRegMap *VRM) {
- if (pImpl)
- static_cast<LDVImpl*>(pImpl)->emitDebugValues(VRM);
+ if (PImpl)
+ PImpl->emitDebugValues(VRM);
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-LLVM_DUMP_METHOD void LiveDebugVariables::dump() const {
- if (pImpl)
- static_cast<LDVImpl*>(pImpl)->print(dbgs());
-}
+LLVM_DUMP_METHOD void LiveDebugVariables::dump() const { print(dbgs()); }
#endif
+
+void LiveDebugVariables::print(raw_ostream &OS) const {
+ if (PImpl)
+ PImpl->print(OS);
+}
diff --git a/llvm/lib/CodeGen/RegAllocBasic.cpp b/llvm/lib/CodeGen/RegAllocBasic.cpp
index 55d806e768b910..7ee24c960dbe0c 100644
--- a/llvm/lib/CodeGen/RegAllocBasic.cpp
+++ b/llvm/lib/CodeGen/RegAllocBasic.cpp
@@ -130,7 +130,7 @@ char &llvm::RABasicID = RABasic::ID;
INITIALIZE_PASS_BEGIN(RABasic, "regallocbasic", "Basic Register Allocator",
false, false)
-INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)
+INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperLegacy)
INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer)
@@ -180,8 +180,8 @@ void RABasic::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<LiveIntervalsWrapperPass>();
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
- AU.addRequired<LiveDebugVariables>();
- AU.addPreserved<LiveDebugVariables>();
+ AU.addRequired<LiveDebugVariablesWrapperLegacy>();
+ AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addRequired<LiveStacks>();
AU.addPreserved<LiveStacks>();
AU.addRequired<ProfileSummaryInfoWrapperPass>();
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index d0d2c585f0b54c..8564fd8ca96dad 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -151,7 +151,7 @@ char &llvm::RAGreedyID = RAGreedy::ID;
INITIALIZE_PASS_BEGIN(RAGreedy, "greedy",
"Greedy Register Allocator", false, false)
-INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)
+INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperLegacy)
INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer)
@@ -204,8 +204,8 @@ void RAGreedy::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addRequired<SlotIndexesWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
- AU.addRequired<LiveDebugVariables>();
- AU.addPreserved<LiveDebugVariables>();
+ AU.addRequired<LiveDebugVariablesWrapperLegacy>();
+ AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addRequired<LiveStacks>();
AU.addPreserved<LiveStacks>();
AU.addRequired<MachineDominatorTreeWrapperPass>();
@@ -2732,7 +2732,7 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
Bundles = &getAnalysis<EdgeBundlesWrapperLegacy>().getEdgeBundles();
SpillPlacer = &getAnalysis<SpillPlacementWrapperLegacy>().getResult();
- DebugVars = &getAnalysis<LiveDebugVariables>();
+ DebugVars = &getAnalysis<LiveDebugVariablesWrapperLegacy>().getLDV();
initializeCSRCost();
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.h b/llvm/lib/CodeGen/RegAllocGreedy.h
index 9578b8d3bef876..594c481826cf09 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.h
+++ b/llvm/lib/CodeGen/RegAllocGreedy.h
@@ -24,6 +24,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/CalcSpillWeights.h"
+#include "llvm/CodeGen/LiveDebugVariables.h"
#include "llvm/CodeGen/LiveInterval.h"
#include "llvm/CodeGen/LiveRangeEdit.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -42,7 +43,7 @@ namespace llvm {
class AllocationOrder;
class AnalysisUsage;
class EdgeBundles;
-class LiveDebugVariables;
+class LiveDebugVariablesWrapperLegacy;
class LiveIntervals;
class LiveRegMatrix;
class MachineBasicBlock;
diff --git a/llvm/lib/CodeGen/StackSlotColoring.cpp b/llvm/lib/CodeGen/StackSlotColoring.cpp
index a1fa266354a526..cdc530621de621 100644
--- a/llvm/lib/CodeGen/StackSlotColoring.cpp
+++ b/llvm/lib/CodeGen/StackSlotColoring.cpp
@@ -159,7 +159,7 @@ namespace {
// may be invoked multiple times requiring it to save these analyses to be
// used by RA later.
AU.addPreserved<LiveIntervalsWrapperPass>();
- AU.addPreserved<LiveDebugVariables>();
+ AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
MachineFunctionPass::getAnalysisUsage(AU);
}
diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp
index 26a12512c87be0..2084e68c16e292 100644
--- a/llvm/lib/CodeGen/VirtRegMap.cpp
+++ b/llvm/lib/CodeGen/VirtRegMap.cpp
@@ -251,7 +251,7 @@ INITIALIZE_PASS_BEGIN(VirtRegRewriter, "virtregrewriter",
"Virtual Register Rewriter", false, false)
INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)
+INITIALIZE_PASS_DEPENDENCY(LiveDebugVariablesWrapperLegacy)
INITIALIZE_PASS_DEPENDENCY(LiveRegMatrixWrapperLegacy)
INITIALIZE_PASS_DEPENDENCY(LiveStacks)
INITIALIZE_PASS_DEPENDENCY(VirtRegMapWrapperLegacy)
@@ -264,14 +264,14 @@ void VirtRegRewriter::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addRequired<SlotIndexesWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
- AU.addRequired<LiveDebugVariables>();
+ AU.addRequired<LiveDebugVariablesWrapperLegacy>();
AU.addRequired<LiveStacks>();
AU.addPreserved<LiveStacks>();
AU.addRequired<VirtRegMapWrapperLegacy>();
AU.addRequired<LiveRegMatrixWrapperLegacy>();
if (!ClearVirtRegs)
- AU.addPreserved<LiveDebugVariables>();
+ AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
MachineFunctionPass::getAnalysisUsage(AU);
}
@@ -285,7 +285,7 @@ bool VirtRegRewriter::runOnMachineFunction(MachineFunction &fn) {
LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
LRM = &getAnalysis<LiveRegMatrixWrapperLegacy>().getLRM();
VRM = &getAnalysis<VirtRegMapWrapperLegacy>().getVRM();
- DebugVars = &getAnalysis<LiveDebugVariables>();
+ DebugVars = &getAnalysis<LiveDebugVariablesWrapperLegacy>().getLDV();
LLVM_DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
<< "********** Function: " << MF->getName() << '\n');
LLVM_DEBUG(VRM->dump());
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index ba52a37df9c25d..cc9f59727c6040 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -98,6 +98,7 @@
#include "llvm/CodeGen/InterleavedAccess.h"
#include "llvm/CodeGen/InterleavedLoadCombine.h"
#include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugVariables.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/LiveRegMatrix.h"
#include "llvm/CodeGen/LiveVariables.h"
diff --git a/llvm/lib/Target/LoongArch/LoongArchDeadRegisterDefinitions.cpp b/llvm/lib/Target/LoongArch/LoongArchDeadRegisterDefinitions.cpp
index f0e6837d49a97b..d682b7dbe3ce2f 100644
--- a/llvm/lib/Target/LoongArch/LoongArchDeadRegisterDefinitions.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchDeadRegisterDefinitions.cpp
@@ -37,7 +37,7 @@ class LoongArchDeadRegisterDefinitions : public MachineFunctionPass {
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addRequired<LiveIntervalsWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
- AU.addPreserved<LiveDebugVariables>();
+ AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addPreserved<LiveStacks>();
MachineFunctionPass::getAnalysisUsage(AU);
}
diff --git a/llvm/lib/Target/RISCV/RISCVDeadRegisterDefinitions.cpp b/llvm/lib/Target/RISCV/RISCVDeadRegisterDefinitions.cpp
index 4b35f3bb0a524f..7bcf3397df97ee 100644
--- a/llvm/lib/Target/RISCV/RISCVDeadRegisterDefinitions.cpp
+++ b/llvm/lib/Target/RISCV/RISCVDeadRegisterDefinitions.cpp
@@ -37,7 +37,7 @@ class RISCVDeadRegisterDefinitions : public MachineFunctionPass {
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addRequired<LiveIntervalsWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
- AU.addPreserved<LiveDebugVariables>();
+ AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addPreserved<LiveStacks>();
MachineFunctionPass::getAnalysisUsage(AU);
}
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 421150a370199b..870e393b40411f 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -889,7 +889,7 @@ class RISCVInsertVSETVLI : public MachineFunctionPass {
AU.addUsedIfAvailable<LiveIntervalsWrapperPass>();
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
- AU.addPreserved<LiveDebugVariables>();
+ AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addPreserved<LiveStacks>();
MachineFunctionPass::getAnalysisUsage(AU);
More information about the llvm-commits
mailing list