[PATCH] D149881: [AsmPrinter] Use EntryValue object info to emit Dwarf
Felipe de Azevedo Piovezan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 08:58:11 PDT 2023
fdeazeve updated this revision to Diff 521336.
fdeazeve added a comment.
Rebased
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149881/new/
https://reviews.llvm.org/D149881
Files:
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/AArch64/dbg-entry-value-swiftasync.mir
Index: llvm/test/DebugInfo/AArch64/dbg-entry-value-swiftasync.mir
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/AArch64/dbg-entry-value-swiftasync.mir
@@ -0,0 +1,45 @@
+# RUN: llc -start-after=machineverifier -O0 %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
+
+# CHECK: DW_TAG_variable
+# CHECK-NEXT: DW_AT_location (DW_OP_GNU_entry_value(DW_OP_reg22 W22))
+# CHECK-NEXT: DW_AT_name ("a")
+
+
+--- |
+ target triple = "aarch64--"
+ define void @foo(ptr %unused_arg, ptr swiftasync %async_arg) !dbg !4 {
+ call void @llvm.dbg.declare(metadata ptr %async_arg, metadata !10, metadata !DIExpression(DW_OP_LLVM_entry_value, 1)), !dbg !12
+ ret void, !dbg !12
+ }
+ declare void @llvm.dbg.declare(metadata, metadata, metadata)
+ declare void @consume(ptr)
+ !llvm.dbg.cu = !{!0}
+ !llvm.module.flags = !{!2, !3}
+ !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
+ !1 = !DIFile(filename: "x.c", directory: "/")
+ !2 = !{i32 2, !"Dwarf Version", i32 4}
+ !3 = !{i32 2, !"Debug Info Version", i32 3}
+ !4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !5, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
+ !5 = !DISubroutineType(types: !6)
+ !6 = !{null, !7, !7, !7}
+ !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
+ !9 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+ !10 = !DILocalVariable(name: "a", scope: !4, file: !1, line: 1, type: !7)
+ !12 = !DILocation(line: 1, column: 37, scope: !4)
+...
+---
+name: foo
+liveins:
+ - { reg: '$x0', virtual-reg: '' }
+ - { reg: '$x22', virtual-reg: '' }
+stack:
+ - { id: 0, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
+ stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true }
+entry_values:
+ - { entry-value-register: '$x22', debug-info-variable: '!10', debug-info-expression: '!DIExpression(DW_OP_LLVM_entry_value, 1)',
+ debug-info-location: '!12' }
+body: |
+ bb.0 (%ir-block.0):
+ liveins: $x0, $x22, $lr
+ RET undef $lr, debug-location !12
+...
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1529,7 +1529,7 @@
DwarfCompileUnit &TheCU, DenseSet<InlinedEntity> &Processed) {
SmallDenseMap<InlinedEntity, DbgVariable *> MFVars;
LLVM_DEBUG(dbgs() << "DwarfDebug: collecting variables from MF side table\n");
- for (const auto &VI : Asm->MF->getInStackSlotVariableDbgInfo()) {
+ for (const auto &VI : Asm->MF->getVariableDbgInfo()) {
if (!VI.Var)
continue;
assert(VI.Var->isValidLocationForIntrinsic(VI.Loc) &&
@@ -1549,13 +1549,24 @@
ensureAbstractEntityIsCreatedIfScoped(TheCU, Var.first, Scope->getScopeNode());
auto RegVar = std::make_unique<DbgVariable>(
cast<DILocalVariable>(Var.first), Var.second);
- RegVar->initializeMMI(VI.Expr, VI.getStackSlot());
+ if (VI.inStackSlot())
+ RegVar->initializeMMI(VI.Expr, VI.getStackSlot());
+ else {
+ MachineLocation MLoc(VI.getEntryValueRegister(), /*IsIndirect*/ true);
+ auto LocEntry = DbgValueLocEntry(MLoc);
+ RegVar->initializeDbgValue(DbgValueLoc(VI.Expr, LocEntry));
+ }
LLVM_DEBUG(dbgs() << "Created DbgVariable for " << VI.Var->getName()
<< "\n");
- if (DbgVariable *DbgVar = MFVars.lookup(Var))
- DbgVar->addMMIEntry(*RegVar);
- else if (InfoHolder.addScopeVariable(Scope, RegVar.get())) {
+ if (DbgVariable *DbgVar = MFVars.lookup(Var)) {
+ if (DbgVar->getValueLoc())
+ LLVM_DEBUG(dbgs() << "Dropping repeated entry value debug info for "
+ "variable "
+ << VI.Var->getName() << "\n");
+ else
+ DbgVar->addMMIEntry(*RegVar);
+ } else if (InfoHolder.addScopeVariable(Scope, RegVar.get())) {
MFVars.insert({Var, RegVar.get()});
ConcreteEntities.push_back(std::move(RegVar));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149881.521336.patch
Type: text/x-patch
Size: 4252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230511/01befbdc/attachment.bin>
More information about the llvm-commits
mailing list