[SelectionDAGBuilder] Handle entry_value dbg.value intrinsics

Summary:
DbgValue intrinsics whose expression is an entry_value and whose address is
described an llvm::Argument must be lowered to the corresponding livein physical
register for that Argument.

Depends on D151329

Reviewers: aprantl

Subscribers:
This commit is contained in:
Felipe de Azevedo Piovezan 2023-05-23 13:52:01 -04:00
parent e8aee45be7
commit aba1bea673
2 changed files with 21 additions and 0 deletions

View File

@ -5804,6 +5804,26 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
if (!Op)
return false;
// If the expression refers to the entry value of an Argument, use the
// corresponding livein physical register. As per the Verifier, this is only
// allowed for swiftasync Arguments.
if (Op->isReg() && Expr->isEntryValue()) {
assert(Arg->hasAttribute(Attribute::AttrKind::SwiftAsync));
auto OpReg = Op->getReg();
for (auto [PhysReg, VirtReg] : FuncInfo.RegInfo->liveins())
if (OpReg == VirtReg || OpReg == PhysReg) {
SDDbgValue *SDV = DAG.getVRegDbgValue(
Variable, Expr, PhysReg,
Kind != FuncArgumentDbgValueKind::Value /*is indirect*/, DL,
SDNodeOrder);
DAG.AddDbgValue(SDV, false /*treat as dbg.declare byval parameter*/);
return true;
}
LLVM_DEBUG(dbgs() << "Dropping dbg.value: expression is entry_value but "
"couldn't find a physical register\n");
return true;
}
assert(Variable->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
MachineInstr *NewMI = nullptr;

View File

@ -1,4 +1,5 @@
; RUN: llc -O0 -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s
; RUN: llc -O0 -fast-isel=false -global-isel=false -stop-after=finalize-isel %s -o - | FileCheck %s
; CHECK-NOT: DBG_VALUE
; CHECK: DBG_VALUE $x22, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)