[llvm] 2da2995 - [SelectionDAG][DebugInfo] Implement translation of entry_value vars
Felipe de Azevedo Piovezan via llvm-commits
llvm-commits at lists.llvm.org
Fri May 12 09:00:26 PDT 2023
Author: Felipe de Azevedo Piovezan
Date: 2023-05-12T12:00:13-04:00
New Revision: 2da29955fbc9753e7f0d565d64cc859492ab6afb
URL: https://github.com/llvm/llvm-project/commit/2da29955fbc9753e7f0d565d64cc859492ab6afb
DIFF: https://github.com/llvm/llvm-project/commit/2da29955fbc9753e7f0d565d64cc859492ab6afb.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/test/CodeGen/AArch64/dbg-declare-swift-async.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 36611b117296a..35abd990f9689 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1342,6 +1342,30 @@ static bool isFoldedOrDeadInstruction(const Instruction *I,
!FuncInfo.isExportedInst(I); // Exported instrs must be computed.
}
+static bool processIfEntryValueDbgDeclare(FunctionLoweringInfo &FuncInfo,
+ const Value *Arg, DIExpression *Expr,
+ DILocalVariable *Var,
+ DebugLoc DbgLoc) {
+ if (!Expr->isEntryValue() || !isa<Argument>(Arg))
+ return false;
+
+ auto ArgIt = FuncInfo.ValueMap.find(Arg);
+ if (ArgIt == FuncInfo.ValueMap.end())
+ return false;
+ Register ArgVReg = ArgIt->getSecond();
+
+ // Find the corresponding livein physical register to this argument.
+ for (auto [PhysReg, VirtReg] : FuncInfo.RegInfo->liveins())
+ if (VirtReg == ArgVReg) {
+ FuncInfo.MF->setVariableDbgInfo(Var, Expr, PhysReg, DbgLoc);
+ LLVM_DEBUG(dbgs() << "processDbgDeclare: setVariableDbgInfo Var=" << *Var
+ << ", Expr=" << *Expr << ", MCRegister=" << PhysReg
+ << ", DbgLoc=" << DbgLoc << "\n");
+ return true;
+ }
+ return false;
+}
+
static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo,
const Value *Address, DIExpression *Expr,
DILocalVariable *Var, DebugLoc DbgLoc) {
@@ -1350,6 +1374,10 @@ static bool processDbgDeclare(FunctionLoweringInfo &FuncInfo,
<< " (bad address)\n");
return false;
}
+
+ if (processIfEntryValueDbgDeclare(FuncInfo, Address, Expr, Var, DbgLoc))
+ return true;
+
MachineFunction *MF = FuncInfo.MF;
const DataLayout &DL = MF->getDataLayout();
diff --git a/llvm/test/CodeGen/AArch64/dbg-declare-swift-async.ll b/llvm/test/CodeGen/AArch64/dbg-declare-swift-async.ll
index 4a68f0548bbaf..8309090908829 100644
--- a/llvm/test/CodeGen/AArch64/dbg-declare-swift-async.ll
+++ b/llvm/test/CodeGen/AArch64/dbg-declare-swift-async.ll
@@ -1,4 +1,6 @@
; RUN: llc -O0 -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s
+; RUN: llc -O0 -fast-isel -stop-after=finalize-isel %s -o - | FileCheck %s
+; RUN: llc -O0 -fast-isel=false -global-isel=false -stop-after=finalize-isel %s -o - | FileCheck %s
; CHECK: void @foo
; CHECK-NEXT: dbg.declare(metadata {{.*}}, metadata ![[VAR:.*]], metadata ![[EXPR:.*]]), !dbg ![[LOC:.*]]
More information about the llvm-commits
mailing list