[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.
This commit is contained in:
Akshat Oke 2024-12-04 14:31:34 +05:30 committed by GitHub
parent 3b0cb89796
commit d9b4bdbff5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 195 additions and 85 deletions

View File

@ -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 @@ public:
/// @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 @@ private:
}
};
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

View File

@ -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 &);

View File

@ -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>",

View File

@ -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);

View File

@ -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 @@ public:
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 @@ public:
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);
}

View File

@ -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>();

View File

@ -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();

View File

@ -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;

View File

@ -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);
}

View File

@ -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());

View File

@ -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"

View File

@ -37,7 +37,7 @@ public:
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addRequired<LiveIntervalsWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
AU.addPreserved<LiveDebugVariables>();
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addPreserved<LiveStacks>();
MachineFunctionPass::getAnalysisUsage(AU);
}

View File

@ -37,7 +37,7 @@ public:
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addRequired<LiveIntervalsWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
AU.addPreserved<LiveDebugVariables>();
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addPreserved<LiveStacks>();
MachineFunctionPass::getAnalysisUsage(AU);
}

View File

@ -889,7 +889,7 @@ public:
AU.addUsedIfAvailable<LiveIntervalsWrapperPass>();
AU.addPreserved<LiveIntervalsWrapperPass>();
AU.addPreserved<SlotIndexesWrapperPass>();
AU.addPreserved<LiveDebugVariables>();
AU.addPreserved<LiveDebugVariablesWrapperLegacy>();
AU.addPreserved<LiveStacks>();
MachineFunctionPass::getAnalysisUsage(AU);