Skip to content

Commit 1898fc1

Browse files
[FastISel] Implement translation of entry_value dbg.value intrinsics
For dbg.value intrinsics targeting an llvm::Argument address whose expression starts with an entry value, we lower this to a DEBUG_VALUE targeting the livein physical register corresponding to that Argument. Depends on D151332 Differential Revision: https://reviews.llvm.org/D151333
1 parent 62110aa commit 1898fc1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,24 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
13091309
.addMetadata(Expr);
13101310
return true;
13111311
}
1312+
if (const auto *Arg = dyn_cast<Argument>(V);
1313+
Arg && Expr && Expr->isEntryValue()) {
1314+
// As per the Verifier, this case is only valid for swift async Args.
1315+
assert(Arg->hasAttribute(Attribute::AttrKind::SwiftAsync));
1316+
1317+
Register Reg = getRegForValue(Arg);
1318+
for (auto [PhysReg, VirtReg] : FuncInfo.RegInfo->liveins())
1319+
if (Reg == VirtReg || Reg == PhysReg) {
1320+
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD.getDL(), II,
1321+
false /*IsIndirect*/, PhysReg, Var, Expr);
1322+
return true;
1323+
}
1324+
1325+
LLVM_DEBUG(dbgs() << "Dropping dbg.value: expression is entry_value but "
1326+
"couldn't find a physical register\n"
1327+
<< *DI << "\n");
1328+
return true;
1329+
}
13121330
if (Register Reg = lookUpRegForValue(V)) {
13131331
// FIXME: This does not handle register-indirect values at offset 0.
13141332
if (!FuncInfo.MF->useDebugInstrRef()) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; RUN: llc -O0 -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s
22
; RUN: llc -O0 -fast-isel=false -global-isel=false -stop-after=finalize-isel %s -o - | FileCheck %s
3+
; RUN: llc -O0 -fast-isel -stop-after=finalize-isel %s -o - | FileCheck %s
34

45
; CHECK-NOT: DBG_VALUE
56
; CHECK: DBG_VALUE $x22, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)

0 commit comments

Comments
 (0)