diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2024-01-22 15:39:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 15:39:35 +0000 |
commit | 8c1b7fba1fbe9729d6258127b633bd05339e766b (patch) | |
tree | b7625cabe5b5f5fd21f68d9f0cbb49efd35e4ad7 | |
parent | d9cb37c9045bb0b3692d6faaeac43150a26e42e4 (diff) | |
download | llvm-8c1b7fba1fbe9729d6258127b633bd05339e766b.zip llvm-8c1b7fba1fbe9729d6258127b633bd05339e766b.tar.gz llvm-8c1b7fba1fbe9729d6258127b633bd05339e766b.tar.bz2 |
[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!.
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 23 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h | 4 | ||||
-rw-r--r-- | llvm/test/CodeGen/AArch64/dbg-value-swift-async.ll | 4 |
3 files changed, 19 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 44c78a0..a7dd23f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -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) { @@ -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); @@ -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; } @@ -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; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 6dcb8c8..40e2f79 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -612,7 +612,9 @@ private: 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); diff --git a/llvm/test/CodeGen/AArch64/dbg-value-swift-async.ll b/llvm/test/CodeGen/AArch64/dbg-value-swift-async.ll index e65f488..4649fad 100644 --- a/llvm/test/CodeGen/AArch64/dbg-value-swift-async.ll +++ b/llvm/test/CodeGen/AArch64/dbg-value-swift-async.ll @@ -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) |