Skip to content

[SelectionDAG][DebugInfo][RemoveDIs] Handle entry value variables in DPValues too #78726

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
Jan 22, 2024
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
23 changes: 12 additions & 11 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,11 @@ bool SelectionDAGBuilder::handleDebugValue(ArrayRef<const Value *> Values,
unsigned Order, bool IsVariadic) {
if (Values.empty())
return true;

// Filter EntryValue locations out early.
if (visitEntryValueDbgValue(Values, Var, Expr, DbgLoc))
return true;

SmallVector<SDDbgOperand> LocationOps;
SmallVector<SDNode *> Dependencies;
for (const Value *V : Values) {
Expand Down Expand Up @@ -6023,14 +6028,14 @@ static const CallBase *FindPreallocatedCall(const Value *PreallocatedSetup) {
/// If DI is a debug value with an EntryValue expression, lower it using the
/// corresponding physical register of the associated Argument value
/// (guaranteed to exist by the verifier).
bool SelectionDAGBuilder::visitEntryValueDbgValue(const DbgValueInst &DI) {
DILocalVariable *Variable = DI.getVariable();
DIExpression *Expr = DI.getExpression();
if (!Expr->isEntryValue() || !hasSingleElement(DI.getValues()))
bool SelectionDAGBuilder::visitEntryValueDbgValue(
ArrayRef<const Value *> Values, DILocalVariable *Variable,
DIExpression *Expr, DebugLoc DbgLoc) {
if (!Expr->isEntryValue() || !hasSingleElement(Values))
return false;

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

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

for (auto [PhysReg, VirtReg] : FuncInfo.RegInfo->liveins())
if (ArgVReg == VirtReg || ArgVReg == PhysReg) {
SDDbgValue *SDV =
DAG.getVRegDbgValue(Variable, Expr, PhysReg, false /*IsIndidrect*/,
DI.getDebugLoc(), SDNodeOrder);
SDDbgValue *SDV = DAG.getVRegDbgValue(
Variable, Expr, PhysReg, false /*IsIndidrect*/, DbgLoc, SDNodeOrder);
DAG.AddDbgValue(SDV, false /*treat as dbg.declare byval parameter*/);
return true;
}
Expand Down Expand Up @@ -6338,9 +6342,6 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
DIExpression *Expression = DI.getExpression();
dropDanglingDebugInfo(Variable, Expression);

if (visitEntryValueDbgValue(DI))
return;

if (DI.isKillLocation()) {
handleKillDebugValue(Variable, Expression, DI.getDebugLoc(), SDNodeOrder);
return;
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ class SelectionDAGBuilder {
void visitInlineAsm(const CallBase &Call,
const BasicBlock *EHPadBB = nullptr);

bool visitEntryValueDbgValue(const DbgValueInst &I);
bool visitEntryValueDbgValue(ArrayRef<const Value *> Values,
DILocalVariable *Variable, DIExpression *Expr,
DebugLoc DbgLoc);
void visitIntrinsicCall(const CallInst &I, unsigned Intrinsic);
void visitTargetIntrinsic(const CallInst &I, unsigned Intrinsic);
void visitConstrainedFPIntrinsic(const ConstrainedFPIntrinsic &FPI);
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/AArch64/dbg-value-swift-async.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
; RUN: llc --mtriple="aarch64-" -O0 -fast-isel=false -global-isel=false -stop-after=finalize-isel %s -o - | FileCheck %s --check-prefix=AARCH
; RUN: llc --mtriple="aarch64-" -O0 -fast-isel -stop-after=finalize-isel %s -o - | FileCheck %s --check-prefix=AARCH

; RUN: llc --mtriple="aarch64-" -O0 -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - --try-experimental-debuginfo-iterators | FileCheck %s --check-prefix=AARCH
; 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
; RUN: llc --mtriple="aarch64-" -O0 -fast-isel -stop-after=finalize-isel %s -o - --try-experimental-debuginfo-iterators | FileCheck %s --check-prefix=AARCH

; AARCH-NOT: DBG_VALUE
; AARCH: DBG_VALUE $x22, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)
; AARCH-NEXT: DBG_VALUE $x22, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)
Expand Down