Skip to content

[LiveDebugValues][NFC] Remove TargetPassConfig from LDVImpl #131562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Config/llvm-config.h"
Expand Down Expand Up @@ -270,12 +269,12 @@ class TransferTracker {
TransferTracker(const TargetInstrInfo *TII, MLocTracker *MTracker,
MachineFunction &MF, const DebugVariableMap &DVMap,
const TargetRegisterInfo &TRI,
const BitVector &CalleeSavedRegs, const TargetPassConfig &TPC)
const BitVector &CalleeSavedRegs,
bool ShouldEmitDebugEntryValues)
: TII(TII), MTracker(MTracker), MF(MF), DVMap(DVMap), TRI(TRI),
CalleeSavedRegs(CalleeSavedRegs) {
TLI = MF.getSubtarget().getTargetLowering();
auto &TM = TPC.getTM<TargetMachine>();
ShouldEmitDebugEntryValues = TM.Options.ShouldEmitDebugEntryValues();
this->ShouldEmitDebugEntryValues = ShouldEmitDebugEntryValues;
}

bool isCalleeSaved(LocIdx L) const {
Expand Down Expand Up @@ -3547,9 +3546,9 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
const ScopeToVarsT &ScopeToVars, ScopeToAssignBlocksT &ScopeToAssignBlocks,
LiveInsT &Output, FuncValueTable &MOutLocs, FuncValueTable &MInLocs,
SmallVectorImpl<VLocTracker> &AllTheVLocs, MachineFunction &MF,
const TargetPassConfig &TPC) {
TTracker =
new TransferTracker(TII, MTracker, MF, DVMap, *TRI, CalleeSavedRegs, TPC);
bool ShouldEmitDebugEntryValues) {
TTracker = new TransferTracker(TII, MTracker, MF, DVMap, *TRI,
CalleeSavedRegs, ShouldEmitDebugEntryValues);
unsigned NumLocs = MTracker->getNumLocs();
VTracker = nullptr;

Expand Down Expand Up @@ -3692,15 +3691,14 @@ bool InstrRefBasedLDV::emitTransfers() {
/// extend ranges across basic blocks.
bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
MachineDominatorTree *DomTree,
TargetPassConfig *TPC,
bool ShouldEmitDebugEntryValues,
unsigned InputBBLimit,
unsigned InputDbgValLimit) {
// No subprogram means this function contains no debuginfo.
if (!MF.getFunction().getSubprogram())
return false;

LLVM_DEBUG(dbgs() << "\nDebug Range Extension\n");
this->TPC = TPC;

this->DomTree = DomTree;
TRI = MF.getSubtarget().getRegisterInfo();
Expand Down Expand Up @@ -3841,7 +3839,7 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
// the "else" block of this condition.
Changed = depthFirstVLocAndEmit(
MaxNumBlocks, ScopeToDILocation, ScopeToVars, ScopeToAssignBlocks,
SavedLiveIns, MOutLocs, MInLocs, vlocs, MF, *TPC);
SavedLiveIns, MOutLocs, MInLocs, vlocs, MF, ShouldEmitDebugEntryValues);
}

delete MTracker;
Expand Down
17 changes: 7 additions & 10 deletions llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,6 @@ class InstrRefBasedLDV : public LDVImpl {
const MachineFrameInfo *MFI;
BitVector CalleeSavedRegs;
LexicalScopes LS;
TargetPassConfig *TPC;

// An empty DIExpression. Used default / placeholder DbgValueProperties
// objects, as we can't have null expressions.
Expand Down Expand Up @@ -1478,17 +1477,15 @@ class InstrRefBasedLDV : public LDVImpl {
/// block information can be fully computed before exploration finishes,
/// allowing us to emit it and free data structures earlier than otherwise.
/// It's also good for locality.
bool depthFirstVLocAndEmit(unsigned MaxNumBlocks,
const ScopeToDILocT &ScopeToDILocation,
const ScopeToVarsT &ScopeToVars,
ScopeToAssignBlocksT &ScopeToBlocks,
LiveInsT &Output, FuncValueTable &MOutLocs,
FuncValueTable &MInLocs,
SmallVectorImpl<VLocTracker> &AllTheVLocs,
MachineFunction &MF, const TargetPassConfig &TPC);
bool depthFirstVLocAndEmit(
unsigned MaxNumBlocks, const ScopeToDILocT &ScopeToDILocation,
const ScopeToVarsT &ScopeToVars, ScopeToAssignBlocksT &ScopeToBlocks,
LiveInsT &Output, FuncValueTable &MOutLocs, FuncValueTable &MInLocs,
SmallVectorImpl<VLocTracker> &AllTheVLocs, MachineFunction &MF,
bool ShouldEmitDebugEntryValues);

bool ExtendRanges(MachineFunction &MF, MachineDominatorTree *DomTree,
TargetPassConfig *TPC, unsigned InputBBLimit,
bool ShouldEmitDebugEntryValues, unsigned InputBBLimit,
unsigned InputDbgValLimit) override;

public:
Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) {
TheImpl = &*InstrRefImpl;
}

return TheImpl->ExtendRanges(MF, DomTree, TPC, InputBBLimit,
InputDbgValueLimit);
return TheImpl->ExtendRanges(
MF, DomTree,
TPC->getTM<TargetMachine>().Options.ShouldEmitDebugEntryValues(),
InputBBLimit, InputDbgValueLimit);
}

bool llvm::debuginfoShouldUseDebugInstrRef(const Triple &T) {
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ inline namespace SharedLiveDebugValues {
class LDVImpl {
public:
virtual bool ExtendRanges(MachineFunction &MF, MachineDominatorTree *DomTree,
TargetPassConfig *TPC, unsigned InputBBLimit,
bool ShouldEmitDebugEntryValues,
unsigned InputBBLimit,
unsigned InputDbgValLimit) = 0;
virtual ~LDVImpl() = default;
};
Expand Down
25 changes: 10 additions & 15 deletions llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Config/llvm-config.h"
Expand Down Expand Up @@ -284,7 +283,7 @@ class VarLocBasedLDV : public LDVImpl {
const TargetRegisterInfo *TRI;
const TargetInstrInfo *TII;
const TargetFrameLowering *TFI;
TargetPassConfig *TPC;
bool ShouldEmitDebugEntryValues;
BitVector CalleeSavedRegs;
LexicalScopes LS;
VarLocSet::Allocator Alloc;
Expand Down Expand Up @@ -1088,7 +1087,7 @@ class VarLocBasedLDV : public LDVImpl {
void flushPendingLocs(VarLocInMBB &PendingInLocs, VarLocMap &VarLocIDs);

bool ExtendRanges(MachineFunction &MF, MachineDominatorTree *DomTree,
TargetPassConfig *TPC, unsigned InputBBLimit,
bool ShouldEmitDebugEntryValues, unsigned InputBBLimit,
unsigned InputDbgValLimit) override;

public:
Expand Down Expand Up @@ -1648,11 +1647,8 @@ void VarLocBasedLDV::transferRegisterDef(MachineInstr &MI,
collectIDsForRegs(KillSet, DeadRegs, OpenRanges.getVarLocs(), VarLocIDs);
OpenRanges.erase(KillSet, VarLocIDs, LocIndex::kUniversalLocation);

if (TPC) {
auto &TM = TPC->getTM<TargetMachine>();
if (TM.Options.ShouldEmitDebugEntryValues())
emitEntryValues(MI, OpenRanges, VarLocIDs, EntryValTransfers, KillSet);
}
if (ShouldEmitDebugEntryValues)
emitEntryValues(MI, OpenRanges, VarLocIDs, EntryValTransfers, KillSet);
}

void VarLocBasedLDV::transferWasmDef(MachineInstr &MI,
Expand Down Expand Up @@ -2189,11 +2185,8 @@ void VarLocBasedLDV::recordEntryValue(const MachineInstr &MI,
const DefinedRegsSet &DefinedRegs,
OpenRangesSet &OpenRanges,
VarLocMap &VarLocIDs) {
if (TPC) {
auto &TM = TPC->getTM<TargetMachine>();
if (!TM.Options.ShouldEmitDebugEntryValues())
return;
}
if (!ShouldEmitDebugEntryValues)
return;

DebugVariable V(MI.getDebugVariable(), MI.getDebugExpression(),
MI.getDebugLoc()->getInlinedAt());
Expand All @@ -2217,7 +2210,8 @@ void VarLocBasedLDV::recordEntryValue(const MachineInstr &MI,
/// extend ranges across basic blocks.
bool VarLocBasedLDV::ExtendRanges(MachineFunction &MF,
MachineDominatorTree *DomTree,
TargetPassConfig *TPC, unsigned InputBBLimit,
bool ShouldEmitDebugEntryValues,
unsigned InputBBLimit,
unsigned InputDbgValLimit) {
(void)DomTree;
LLVM_DEBUG(dbgs() << "\nDebug Range Extension: " << MF.getName() << "\n");
Expand All @@ -2235,7 +2229,8 @@ bool VarLocBasedLDV::ExtendRanges(MachineFunction &MF,
TII = MF.getSubtarget().getInstrInfo();
TFI = MF.getSubtarget().getFrameLowering();
TFI->getCalleeSaves(MF, CalleeSavedRegs);
this->TPC = TPC;
this->ShouldEmitDebugEntryValues = ShouldEmitDebugEntryValues;

LS.initialize(MF);

bool Changed = false;
Expand Down