[llvm] a0a3a9c - [DebugInfo] Fix multi-byte entry values in call site values
David Stenberg via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 18 05:23:42 PDT 2020
Author: David Stenberg
Date: 2020-03-18T13:23:17+01:00
New Revision: a0a3a9c5a83192254eae442654e65dd3eb724713
URL: https://github.com/llvm/llvm-project/commit/a0a3a9c5a83192254eae442654e65dd3eb724713
DIFF: https://github.com/llvm/llvm-project/commit/a0a3a9c5a83192254eae442654e65dd3eb724713.diff
LOG: [DebugInfo] Fix multi-byte entry values in call site values
Summary:
In D67768/D67492 I added support for entry values having blocks larger
than one byte, but I now noticed that the DIE implementation I added there
was broken. The takeNodes() function, that moves the entry value block
from a temporary buffer to the output buffer, would destroy the input
iterator when transferring the first node, meaning that only that node
was moved.
In practice, this meant that when emitting a call site value using a
DW_OP_entry_value operation with a DWARF register number larger than 31,
that multi-byte DW_OP_regx expression would be truncated.
Reviewers: djtodoro, aprantl, vsk
Reviewed By: djtodoro
Subscribers: llvm-commits
Tags: #debug-info, #llvm
Differential Revision: https://reviews.llvm.org/D76279
Added:
llvm/test/DebugInfo/AArch64/dbgcall-site-float-entry-value.ll
Modified:
llvm/include/llvm/CodeGen/DIE.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/DIE.h b/llvm/include/llvm/CodeGen/DIE.h
index cf01d456f1f8..c7baaf6aef3d 100644
--- a/llvm/include/llvm/CodeGen/DIE.h
+++ b/llvm/include/llvm/CodeGen/DIE.h
@@ -551,10 +551,21 @@ template <class T> class IntrusiveBackList : IntrusiveBackListBase {
}
void takeNodes(IntrusiveBackList<T> &Other) {
- for (auto &N : Other) {
- N.Next.setPointerAndInt(&N, true);
- push_back(N);
- }
+ if (Other.empty())
+ return;
+
+ T *FirstNode = static_cast<T *>(Other.Last->Next.getPointer());
+ T *IterNode = FirstNode;
+ do {
+ // Keep a pointer to the node and increment the iterator.
+ T *TmpNode = IterNode;
+ IterNode = static_cast<T *>(IterNode->Next.getPointer());
+
+ // Unlink the node and push it back to this list.
+ TmpNode->Next.setPointerAndInt(TmpNode, true);
+ push_back(*TmpNode);
+ } while (IterNode != FirstNode);
+
Other.Last = nullptr;
}
diff --git a/llvm/test/DebugInfo/AArch64/dbgcall-site-float-entry-value.ll b/llvm/test/DebugInfo/AArch64/dbgcall-site-float-entry-value.ll
new file mode 100644
index 000000000000..a925cd0c1452
--- /dev/null
+++ b/llvm/test/DebugInfo/AArch64/dbgcall-site-float-entry-value.ll
@@ -0,0 +1,49 @@
+; RUN: llc -mtriple aarch64-linux-gnu -emit-call-site-info -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
+
+; Based on the following C reproducer:
+;
+; extern void callee(float);
+;
+; void foo(float param) {
+; callee(param);
+; }
+
+; Verify that a call site value using DW_OP_GNU_entry_value(DW_OP_regx B0) is
+; emitted for the float parameter. Previously the entry value's multi-byte
+; DW_OP_regx expression would be truncated.
+
+; CHECK: DW_TAG_GNU_call_site_parameter
+; CHECK-NEXT: DW_AT_location (DW_OP_regx B0)
+; CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_regx B0)
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64"
+
+; Function Attrs: nounwind
+define dso_local void @foo(float %param) local_unnamed_addr !dbg !12 {
+entry:
+ tail call void @callee(float %param), !dbg !13
+ ret void, !dbg !14
+}
+
+declare !dbg !4 dso_local void @callee(float) local_unnamed_addr
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8, !9, !10}
+!llvm.ident = !{!11}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "float.c", directory: "/")
+!2 = !{}
+!3 = !{!4}
+!4 = !DISubprogram(name: "callee", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null, !7}
+!7 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
+!8 = !{i32 7, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"Debug Info Version", i32 3}
+!10 = !{i32 1, !"wchar_size", i32 4}
+!11 = !{!"clang version 11.0.0 "}
+!12 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+!13 = !DILocation(line: 4, scope: !12)
+!14 = !DILocation(line: 5, scope: !12)
More information about the llvm-commits
mailing list