Skip to content

[RemoveDIs][NFC] Remove dbg intrinsic handling code from SelectionDAG ISel #144702

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 1 commit into from
Jun 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
4 changes: 1 addition & 3 deletions llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace llvm {
class Argument;
class BasicBlock;
class BranchProbabilityInfo;
class DbgDeclareInst;
class Function;
class Instruction;
class MachineFunction;
Expand Down Expand Up @@ -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
Expand Down
45 changes: 0 additions & 45 deletions llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ void FunctionLoweringInfo::clear() {
StatepointStackSlots.clear();
StatepointRelocationMaps.clear();
PreferredExtendType.clear();
PreprocessedDbgDeclares.clear();
PreprocessedDVRDeclares.clear();
}

Expand Down
63 changes: 0 additions & 63 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class CleanupPadInst;
class CleanupReturnInst;
class Constant;
class ConstrainedFPIntrinsic;
class DbgValueInst;
class DataLayout;
class DIExpression;
class DILocalVariable;
Expand Down
4 changes: 0 additions & 4 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading