Skip to content

Commit 8c1b7fb

Browse files
authored
[SelectionDAG][DebugInfo][RemoveDIs] Handle entry value variables in DPValues too (#78726)
This patch abstracts visitEntryValueDbgValue to deal with the substance of variable locations (Value, Var, Expr, DebugLoc) rather than how they're stored. That allows us to call it from handleDebugValue, which is similarly abstracted. This allows the entry-value behaviour (see the test) to be supported with non-instruction debug-info too!.
1 parent d9cb37c commit 8c1b7fb

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,11 @@ bool SelectionDAGBuilder::handleDebugValue(ArrayRef<const Value *> Values,
15491549
unsigned Order, bool IsVariadic) {
15501550
if (Values.empty())
15511551
return true;
1552+
1553+
// Filter EntryValue locations out early.
1554+
if (visitEntryValueDbgValue(Values, Var, Expr, DbgLoc))
1555+
return true;
1556+
15521557
SmallVector<SDDbgOperand> LocationOps;
15531558
SmallVector<SDNode *> Dependencies;
15541559
for (const Value *V : Values) {
@@ -6023,14 +6028,14 @@ static const CallBase *FindPreallocatedCall(const Value *PreallocatedSetup) {
60236028
/// If DI is a debug value with an EntryValue expression, lower it using the
60246029
/// corresponding physical register of the associated Argument value
60256030
/// (guaranteed to exist by the verifier).
6026-
bool SelectionDAGBuilder::visitEntryValueDbgValue(const DbgValueInst &DI) {
6027-
DILocalVariable *Variable = DI.getVariable();
6028-
DIExpression *Expr = DI.getExpression();
6029-
if (!Expr->isEntryValue() || !hasSingleElement(DI.getValues()))
6031+
bool SelectionDAGBuilder::visitEntryValueDbgValue(
6032+
ArrayRef<const Value *> Values, DILocalVariable *Variable,
6033+
DIExpression *Expr, DebugLoc DbgLoc) {
6034+
if (!Expr->isEntryValue() || !hasSingleElement(Values))
60306035
return false;
60316036

60326037
// These properties are guaranteed by the verifier.
6033-
Argument *Arg = cast<Argument>(DI.getValue(0));
6038+
const Argument *Arg = cast<Argument>(Values[0]);
60346039
assert(Arg->hasAttribute(Attribute::AttrKind::SwiftAsync));
60356040

60366041
auto ArgIt = FuncInfo.ValueMap.find(Arg);
@@ -6044,9 +6049,8 @@ bool SelectionDAGBuilder::visitEntryValueDbgValue(const DbgValueInst &DI) {
60446049

60456050
for (auto [PhysReg, VirtReg] : FuncInfo.RegInfo->liveins())
60466051
if (ArgVReg == VirtReg || ArgVReg == PhysReg) {
6047-
SDDbgValue *SDV =
6048-
DAG.getVRegDbgValue(Variable, Expr, PhysReg, false /*IsIndidrect*/,
6049-
DI.getDebugLoc(), SDNodeOrder);
6052+
SDDbgValue *SDV = DAG.getVRegDbgValue(
6053+
Variable, Expr, PhysReg, false /*IsIndidrect*/, DbgLoc, SDNodeOrder);
60506054
DAG.AddDbgValue(SDV, false /*treat as dbg.declare byval parameter*/);
60516055
return true;
60526056
}
@@ -6338,9 +6342,6 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
63386342
DIExpression *Expression = DI.getExpression();
63396343
dropDanglingDebugInfo(Variable, Expression);
63406344

6341-
if (visitEntryValueDbgValue(DI))
6342-
return;
6343-
63446345
if (DI.isKillLocation()) {
63456346
handleKillDebugValue(Variable, Expression, DI.getDebugLoc(), SDNodeOrder);
63466347
return;

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,9 @@ class SelectionDAGBuilder {
612612
void visitInlineAsm(const CallBase &Call,
613613
const BasicBlock *EHPadBB = nullptr);
614614

615-
bool visitEntryValueDbgValue(const DbgValueInst &I);
615+
bool visitEntryValueDbgValue(ArrayRef<const Value *> Values,
616+
DILocalVariable *Variable, DIExpression *Expr,
617+
DebugLoc DbgLoc);
616618
void visitIntrinsicCall(const CallInst &I, unsigned Intrinsic);
617619
void visitTargetIntrinsic(const CallInst &I, unsigned Intrinsic);
618620
void visitConstrainedFPIntrinsic(const ConstrainedFPIntrinsic &FPI);

llvm/test/CodeGen/AArch64/dbg-value-swift-async.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
; RUN: llc --mtriple="aarch64-" -O0 -fast-isel=false -global-isel=false -stop-after=finalize-isel %s -o - | FileCheck %s --check-prefix=AARCH
33
; RUN: llc --mtriple="aarch64-" -O0 -fast-isel -stop-after=finalize-isel %s -o - | FileCheck %s --check-prefix=AARCH
44

5+
; RUN: llc --mtriple="aarch64-" -O0 -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - --try-experimental-debuginfo-iterators | FileCheck %s --check-prefix=AARCH
6+
; RUN: llc --mtriple="aarch64-" -O0 -fast-isel=false -global-isel=false -stop-after=finalize-isel %s -o - --try-experimental-debuginfo-iterators | FileCheck %s --check-prefix=AARCH
7+
; RUN: llc --mtriple="aarch64-" -O0 -fast-isel -stop-after=finalize-isel %s -o - --try-experimental-debuginfo-iterators | FileCheck %s --check-prefix=AARCH
8+
59
; AARCH-NOT: DBG_VALUE
610
; AARCH: DBG_VALUE $x22, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)
711
; AARCH-NEXT: DBG_VALUE $x22, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)

0 commit comments

Comments
 (0)