[llvm] [RemoveDIs][NFC] Remove dbg intrinsic handling code from SelectionDAG ISel (PR #144702)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 18 06:46:07 PDT 2025
https://github.com/OCHyams created https://github.com/llvm/llvm-project/pull/144702
None
>From ce078494923bb24755eb513658c3a3c18a1798d5 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Wed, 18 Jun 2025 14:43:50 +0100
Subject: [PATCH] [RemoveDIs][NFC] Remove dbg intrinsic handling code from
SelectionDAG ISel
---
.../llvm/CodeGen/FunctionLoweringInfo.h | 4 +-
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 45 -------------
.../SelectionDAG/FunctionLoweringInfo.cpp | 1 -
.../SelectionDAG/SelectionDAGBuilder.cpp | 63 -------------------
.../SelectionDAG/SelectionDAGBuilder.h | 1 -
.../CodeGen/SelectionDAG/SelectionDAGISel.cpp | 4 --
6 files changed, 1 insertion(+), 117 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
index 392da3f512df0..b892a0e222a47 100644
--- a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
@@ -35,7 +35,6 @@ namespace llvm {
class Argument;
class BasicBlock;
class BranchProbabilityInfo;
-class DbgDeclareInst;
class Function;
class Instruction;
class MachineFunction;
@@ -191,9 +190,8 @@ class FunctionLoweringInfo {
/// The current call site index being processed, if any. 0 if none.
unsigned CurCallSite = 0;
- /// Collection of dbg.declare instructions handled after argument
+ /// Collection of dbg_declare instructions handled after argument
/// lowering and before ISel proper.
- SmallPtrSet<const DbgDeclareInst *, 8> PreprocessedDbgDeclares;
SmallPtrSet<const DbgVariableRecord *, 8> PreprocessedDVRDeclares;
/// set - Initialize this FunctionLoweringInfo with the given Function
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index e8a3df3366b2b..fb9eff942a464 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1395,51 +1395,6 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
// Neither does the llvm.experimental.noalias.scope.decl intrinsic
case Intrinsic::experimental_noalias_scope_decl:
return true;
- case Intrinsic::dbg_declare: {
- const DbgDeclareInst *DI = cast<DbgDeclareInst>(II);
- assert(DI->getVariable() && "Missing variable");
- if (FuncInfo.PreprocessedDbgDeclares.contains(DI))
- return true;
-
- const Value *Address = DI->getAddress();
- if (!lowerDbgDeclare(Address, DI->getExpression(), DI->getVariable(),
- MIMD.getDL()))
- LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI);
-
- return true;
- }
- case Intrinsic::dbg_assign:
- // A dbg.assign is a dbg.value with more information, typically produced
- // during optimisation. If one reaches fastisel then something odd has
- // happened (such as an optimised function being always-inlined into an
- // optnone function). We will not be using the extra information in the
- // dbg.assign in that case, just use its dbg.value fields.
- [[fallthrough]];
- case Intrinsic::dbg_value: {
- // This form of DBG_VALUE is target-independent.
- const DbgValueInst *DI = cast<DbgValueInst>(II);
- const Value *V = DI->getValue();
- DIExpression *Expr = DI->getExpression();
- DILocalVariable *Var = DI->getVariable();
- if (DI->hasArgList())
- // Signal that we don't have a location for this.
- V = nullptr;
-
- assert(Var->isValidLocationForIntrinsic(MIMD.getDL()) &&
- "Expected inlined-at fields to agree");
-
- if (!lowerDbgValue(V, Expr, Var, MIMD.getDL()))
- LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n");
-
- return true;
- }
- case Intrinsic::dbg_label: {
- const DbgLabelInst *DI = cast<DbgLabelInst>(II);
- assert(DI->getLabel() && "Missing label");
- BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
- TII.get(TargetOpcode::DBG_LABEL)).addMetadata(DI->getLabel());
- return true;
- }
case Intrinsic::objectsize:
llvm_unreachable("llvm.objectsize.* should have been lowered already");
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index d4ed158729ca7..098005b6adfa2 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -369,7 +369,6 @@ void FunctionLoweringInfo::clear() {
StatepointStackSlots.clear();
StatepointRelocationMaps.clear();
PreferredExtendType.clear();
- PreprocessedDbgDeclares.clear();
PreprocessedDVRDeclares.clear();
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index ec0c5473b0db0..c01f1e7928477 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -6674,69 +6674,6 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
DAG.setRoot(Res.getValue(1));
return;
}
- case Intrinsic::dbg_declare: {
- const auto &DI = cast<DbgDeclareInst>(I);
- // Debug intrinsics are handled separately in assignment tracking mode.
- // Some intrinsics are handled right after Argument lowering.
- if (AssignmentTrackingEnabled ||
- FuncInfo.PreprocessedDbgDeclares.count(&DI))
- return;
- LLVM_DEBUG(dbgs() << "SelectionDAG visiting dbg_declare: " << DI << "\n");
- DILocalVariable *Variable = DI.getVariable();
- DIExpression *Expression = DI.getExpression();
- dropDanglingDebugInfo(Variable, Expression);
- // Assume dbg.declare can not currently use DIArgList, i.e.
- // it is non-variadic.
- assert(!DI.hasArgList() && "Only dbg.value should currently use DIArgList");
- handleDebugDeclare(DI.getVariableLocationOp(0), Variable, Expression,
- DI.getDebugLoc());
- return;
- }
- case Intrinsic::dbg_label: {
- const DbgLabelInst &DI = cast<DbgLabelInst>(I);
- DILabel *Label = DI.getLabel();
- assert(Label && "Missing label");
-
- SDDbgLabel *SDV;
- SDV = DAG.getDbgLabel(Label, dl, SDNodeOrder);
- DAG.AddDbgLabel(SDV);
- return;
- }
- case Intrinsic::dbg_assign: {
- // Debug intrinsics are handled separately in assignment tracking mode.
- if (AssignmentTrackingEnabled)
- return;
- // If assignment tracking hasn't been enabled then fall through and treat
- // the dbg.assign as a dbg.value.
- [[fallthrough]];
- }
- case Intrinsic::dbg_value: {
- // Debug intrinsics are handled separately in assignment tracking mode.
- if (AssignmentTrackingEnabled)
- return;
- const DbgValueInst &DI = cast<DbgValueInst>(I);
- assert(DI.getVariable() && "Missing variable");
-
- DILocalVariable *Variable = DI.getVariable();
- DIExpression *Expression = DI.getExpression();
- dropDanglingDebugInfo(Variable, Expression);
-
- if (DI.isKillLocation()) {
- handleKillDebugValue(Variable, Expression, DI.getDebugLoc(), SDNodeOrder);
- return;
- }
-
- SmallVector<Value *, 4> Values(DI.getValues());
- if (Values.empty())
- return;
-
- bool IsVariadic = DI.hasArgList();
- if (!handleDebugValue(Values, Variable, Expression, DI.getDebugLoc(),
- SDNodeOrder, IsVariadic))
- addDanglingDebugInfo(Values, Variable, Expression, IsVariadic,
- DI.getDebugLoc(), SDNodeOrder);
- return;
- }
case Intrinsic::eh_typeid_for: {
// Find the type id for the given typeinfo.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index 35c15bc269d4b..1c278076a219d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -56,7 +56,6 @@ class CleanupPadInst;
class CleanupReturnInst;
class Constant;
class ConstrainedFPIntrinsic;
-class DbgValueInst;
class DataLayout;
class DIExpression;
class DILocalVariable;
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index ac6d25f141ec6..4b98d87fcc63b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1592,10 +1592,6 @@ static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo,
/// in case the declarations refer to arguments.
static void processDbgDeclares(FunctionLoweringInfo &FuncInfo) {
for (const auto &I : instructions(*FuncInfo.Fn)) {
- const auto *DI = dyn_cast<DbgDeclareInst>(&I);
- if (DI && processDbgDeclare(FuncInfo, DI->getAddress(), DI->getExpression(),
- DI->getVariable(), DI->getDebugLoc()))
- FuncInfo.PreprocessedDbgDeclares.insert(DI);
for (const DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange())) {
if (DVR.Type == DbgVariableRecord::LocationType::Declare &&
processDbgDeclare(FuncInfo, DVR.getVariableLocationOp(0),
More information about the llvm-commits
mailing list