Skip to content

Commit 2da2995

Browse files
[SelectionDAG][DebugInfo] Implement translation of entry_value vars
This commit implements SelectionDAG lowering of dbg.declare intrinsics targeting swiftasync Arguments, by putting them in the MachineFunction's table of variables whose location doesn't change throughout the function. Depends on D149882 Differential Revision: https://reviews.llvm.org/D149883
1 parent 53a4adc commit 2da2995

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,30 @@ static bool isFoldedOrDeadInstruction(const Instruction *I,
13421342
!FuncInfo.isExportedInst(I); // Exported instrs must be computed.
13431343
}
13441344

1345+
static bool processIfEntryValueDbgDeclare(FunctionLoweringInfo &FuncInfo,
1346+
const Value *Arg, DIExpression *Expr,
1347+
DILocalVariable *Var,
1348+
DebugLoc DbgLoc) {
1349+
if (!Expr->isEntryValue() || !isa<Argument>(Arg))
1350+
return false;
1351+
1352+
auto ArgIt = FuncInfo.ValueMap.find(Arg);
1353+
if (ArgIt == FuncInfo.ValueMap.end())
1354+
return false;
1355+
Register ArgVReg = ArgIt->getSecond();
1356+
1357+
// Find the corresponding livein physical register to this argument.
1358+
for (auto [PhysReg, VirtReg] : FuncInfo.RegInfo->liveins())
1359+
if (VirtReg == ArgVReg) {
1360+
FuncInfo.MF->setVariableDbgInfo(Var, Expr, PhysReg, DbgLoc);
1361+
LLVM_DEBUG(dbgs() << "processDbgDeclare: setVariableDbgInfo Var=" << *Var
1362+
<< ", Expr=" << *Expr << ", MCRegister=" << PhysReg
1363+
<< ", DbgLoc=" << DbgLoc << "\n");
1364+
return true;
1365+
}
1366+
return false;
1367+
}
1368+
13451369
static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo,
13461370
const Value *Address, DIExpression *Expr,
13471371
DILocalVariable *Var, DebugLoc DbgLoc) {
@@ -1350,6 +1374,10 @@ static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo,
13501374
<< " (bad address)\n");
13511375
return false;
13521376
}
1377+
1378+
if (processIfEntryValueDbgDeclare(FuncInfo, Address, Expr, Var, DbgLoc))
1379+
return true;
1380+
13531381
MachineFunction *MF = FuncInfo.MF;
13541382
const DataLayout &DL = MF->getDataLayout();
13551383

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

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

35
; CHECK: void @foo
46
; CHECK-NEXT: dbg.declare(metadata {{.*}}, metadata ![[VAR:.*]], metadata ![[EXPR:.*]]), !dbg ![[LOC:.*]]

0 commit comments

Comments
 (0)