[llvm] [LiveDebugValues][NFC] Remove TargetPassConfig from LDVImpl (PR #131562)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 17 03:39:46 PDT 2025
https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/131562
>From cd06f548dc895a09c2362920d9c45614afc8936b Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 12 Mar 2025 06:46:50 +0000
Subject: [PATCH 1/2] [LiveDebugValues][NFC] Remove TargetPassConfig from
LDVImpl
---
.../LiveDebugValues/InstrRefBasedImpl.cpp | 17 +++++++------
.../LiveDebugValues/InstrRefBasedImpl.h | 17 ++++++-------
.../LiveDebugValues/LiveDebugValues.cpp | 6 +++--
.../CodeGen/LiveDebugValues/LiveDebugValues.h | 3 ++-
.../LiveDebugValues/VarLocBasedImpl.cpp | 24 ++++++++-----------
5 files changed, 31 insertions(+), 36 deletions(-)
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index a9afc8ff65ea7..17e795996d54f 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -270,12 +270,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 {
@@ -3547,9 +3547,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;
@@ -3692,7 +3692,7 @@ 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.
@@ -3700,7 +3700,6 @@ bool InstrRefBasedLDV::ExtendRanges(MachineFunction &MF,
return false;
LLVM_DEBUG(dbgs() << "\nDebug Range Extension\n");
- this->TPC = TPC;
this->DomTree = DomTree;
TRI = MF.getSubtarget().getRegisterInfo();
@@ -3841,7 +3840,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;
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
index 68db65ace9a42..810a71f4d8af4 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
@@ -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.
@@ -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:
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
index a7f089928f84d..484143a03fca1 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -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) {
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.h b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.h
index 6cc1685c00222..3bbe9ce34b355 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.h
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.h
@@ -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;
};
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index f7150f96b625d..3089235650e63 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -284,7 +284,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;
@@ -1088,7 +1088,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:
@@ -1648,11 +1648,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,
@@ -2189,11 +2186,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());
@@ -2217,7 +2211,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");
@@ -2235,7 +2230,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;
>From 00f4e092dd61c51e9327959f299838990b513817 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Mon, 17 Mar 2025 10:39:29 +0000
Subject: [PATCH 2/2] fix condition and remove includes
---
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 1 -
llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 17e795996d54f..b9da975698c42 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -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"
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index 3089235650e63..82e0c28f2f26c 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -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"
@@ -2186,7 +2185,7 @@ void VarLocBasedLDV::recordEntryValue(const MachineInstr &MI,
const DefinedRegsSet &DefinedRegs,
OpenRangesSet &OpenRanges,
VarLocMap &VarLocIDs) {
- if (ShouldEmitDebugEntryValues)
+ if (!ShouldEmitDebugEntryValues)
return;
DebugVariable V(MI.getDebugVariable(), MI.getDebugExpression(),
More information about the llvm-commits
mailing list