[llvm] ea5fb24 - [DebugInfo] Add tests for ISel handling of variadic debug values

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 9 04:51:34 PST 2021


Author: gbtozers
Date: 2021-03-09T12:42:15Z
New Revision: ea5fb241b614bcf555771d4316ad822d81de105f

URL: https://github.com/llvm/llvm-project/commit/ea5fb241b614bcf555771d4316ad822d81de105f
DIFF: https://github.com/llvm/llvm-project/commit/ea5fb241b614bcf555771d4316ad822d81de105f.diff

LOG: [DebugInfo] Add tests for ISel handling of variadic debug values

This patch adds a set of lit tests for ISel support of DIArgList/DBG_VALUE_LIST.

Differential Revision: https://reviews.llvm.org/D88593

Added: 
    llvm/test/DebugInfo/X86/arg-dbg-value-list.ll
    llvm/test/DebugInfo/X86/dbg-val-list-dangling.ll
    llvm/test/DebugInfo/X86/dbg-val-list-undef.ll
    llvm/test/DebugInfo/X86/dbg-value-list-dag-combine.ll
    llvm/test/DebugInfo/X86/dbg-value-list-selectiondag-salvage.ll
    llvm/test/DebugInfo/X86/debug_value_list_selectiondag.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/DebugInfo/X86/arg-dbg-value-list.ll b/llvm/test/DebugInfo/X86/arg-dbg-value-list.ll
new file mode 100644
index 000000000000..3886a545e1d6
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/arg-dbg-value-list.ll
@@ -0,0 +1,50 @@
+;; FIXME: We currently don't do any special bookkeeping for unused args used by
+;; variadic dbg_values. When/if we support them, the DBG_VALUE_LIST should be
+;; updated accordingly.
+
+; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -o - | FileCheck %s
+
+;; Check that unused argument values are handled the same way for variadic
+;; dbg_values as non-variadics.
+
+; CHECK: ![[A:[0-9]+]] = !DILocalVariable(name: "a",
+; CHECK: ![[B:[0-9]+]] = !DILocalVariable(name: "b",
+; CHECK: ![[C:[0-9]+]] = !DILocalVariable(name: "c",
+
+; CHECK: DBG_VALUE $ecx, $noreg, ![[A]], !DIExpression(), debug-location
+; CHECK: DBG_VALUE $edx, $noreg, ![[B]], !DIExpression(), debug-location
+; CHECK: DBG_VALUE_LIST ![[C]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value), $noreg, $noreg, debug-location
+
+target triple = "x86_64-pc-windows-msvc19.16.27034"
+define dso_local i32 @"?foo@@YAHHH at Z"(i32 %a, i32 %b) local_unnamed_addr !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32 %a, metadata !14, metadata !DIExpression()), !dbg !17
+  call void @llvm.dbg.value(metadata i32 %b, metadata !15, metadata !DIExpression()), !dbg !17
+  call void @llvm.dbg.value(metadata !DIArgList(i32 %a, i32 %b), metadata !16, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value)), !dbg !17
+  ret i32 0
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "test.cpp", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 2}
+!6 = !{i32 7, !"PIC Level", i32 2}
+!7 = !{!"clang version 11.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHHH at Z", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
+!9 = !DIFile(filename: "test.cpp", directory: "/")
+!10 = !DISubroutineType(types: !11)
+!11 = !{!12, !12, !12}
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14, !15, !16}
+!14 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 1, type: !12)
+!15 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !9, line: 1, type: !12)
+!16 = !DILocalVariable(name: "c", scope: !8, file: !9, line: 2, type: !12)
+!17 = !DILocation(line: 0, scope: !8)

diff  --git a/llvm/test/DebugInfo/X86/dbg-val-list-dangling.ll b/llvm/test/DebugInfo/X86/dbg-val-list-dangling.ll
new file mode 100644
index 000000000000..4d0dde8d3997
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dbg-val-list-dangling.ll
@@ -0,0 +1,68 @@
+;; At the moment we emit an undef as soon as we encounter "dangling" variadic
+;; dbg_value nodes. This does not reduce correctness but does reduce coverage.
+;; We should make variadic dbg_values work in the same way as their
+;; non-variadic counterparts here.
+;; FIXME: When dangling nodes for a variadic dbg_value are found, we should be
+;; able to recover the value in some cases.
+
+; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -o - | FileCheck %s
+
+;; Check that dangling debug info in the SelectionDAG build phase is handled
+;; in the same way for variadic dbg_value ndoes as non-variadics.
+
+;; Generated from the following source with -g -O2. Second dbg.value modified
+;; to be variadic by hand:
+;; void a(char*);
+;; void b() {
+;;   char *c = "abc";
+;;   char *d = "abc";
+;;   a("abc");
+;; }
+
+; CHECK: ![[C:[0-9]+]] = !DILocalVariable(name: "c",
+; CHECK: ![[D:[0-9]+]] = !DILocalVariable(name: "d",
+
+; CHECK-DAG: DBG_VALUE %[[VREG:[0-9]]], $noreg, ![[C]], !DIExpression(), debug-location
+; CHECK-DAG: DBG_VALUE_LIST ![[D]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value), $noreg, debug-location
+
+target triple = "x86_64-unknown-linux-gnu"
+
+ at .str = private unnamed_addr constant [4 x i8] c"abc\00", align 1
+
+define dso_local void @b() local_unnamed_addr !dbg !7 {
+entry:
+  call void @llvm.dbg.value(metadata i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), metadata !11, metadata !DIExpression()), !dbg !15
+  call void @llvm.dbg.value(metadata !DIArgList(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0)), metadata !14, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value)), !dbg !15
+  tail call void @a(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0)) #3, !dbg !16
+  ret void, !dbg !17
+}
+
+declare !dbg !18 dso_local void @a(i8*) local_unnamed_addr
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "test.c", directory: "/")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 11.0.0"}
+!7 = distinct !DISubprogram(name: "b", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !{!11, !14}
+!11 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 3, type: !12)
+!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
+!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!14 = !DILocalVariable(name: "d", scope: !7, file: !1, line: 4, type: !12)
+!15 = !DILocation(line: 0, scope: !7)
+!16 = !DILocation(line: 5, column: 3, scope: !7)
+!17 = !DILocation(line: 6, column: 1, scope: !7)
+!18 = !DISubprogram(name: "a", scope: !1, file: !1, line: 1, type: !19, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!19 = !DISubroutineType(types: !20)
+!20 = !{null, !12}

diff  --git a/llvm/test/DebugInfo/X86/dbg-val-list-undef.ll b/llvm/test/DebugInfo/X86/dbg-val-list-undef.ll
new file mode 100644
index 000000000000..c5c352276252
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dbg-val-list-undef.ll
@@ -0,0 +1,41 @@
+; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -o - | FileCheck %s
+
+;; %y is unused and cannot (FIXME: currently) be salvaged. Ensure that the
+;; variadic dbg_value using %y becomes undef.
+
+; CHECK: ![[C:[0-9]+]] = !DILocalVariable(name: "c",
+; CHECK: DBG_VALUE_LIST ![[C]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value), $noreg, $noreg, debug-location
+
+target triple = "x86_64-pc-windows-msvc19.16.27034"
+define dso_local i32 @"?foo@@YAHHH at Z"(i32 %a, i32 %b) local_unnamed_addr !dbg !8 {
+entry:
+  %x = add i32 %a, %b
+  %y = mul i32 %x, %b
+  call void @llvm.dbg.value(metadata !DIArgList(i32 %x, i32 %y), metadata !16, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value)), !dbg !17
+  ret i32 %x
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "test.cpp", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 2}
+!6 = !{i32 7, !"PIC Level", i32 2}
+!7 = !{!"clang version 11.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHHH at Z", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
+!9 = !DIFile(filename: "test.cpp", directory: "/")
+!10 = !DISubroutineType(types: !11)
+!11 = !{!12, !12, !12}
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14, !15, !16}
+!14 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 1, type: !12)
+!15 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !9, line: 1, type: !12)
+!16 = !DILocalVariable(name: "c", scope: !8, file: !9, line: 2, type: !12)
+!17 = !DILocation(line: 0, scope: !8)

diff  --git a/llvm/test/DebugInfo/X86/dbg-value-list-dag-combine.ll b/llvm/test/DebugInfo/X86/dbg-value-list-dag-combine.ll
new file mode 100644
index 000000000000..0670adfc0a18
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dbg-value-list-dag-combine.ll
@@ -0,0 +1,61 @@
+; RUN: llc < %s -start-after=codegenprepare -stop-before=finalize-isel | FileCheck %s --implicit-check-not=DBG_VALUE
+
+;; Test for PR 9817 adapted for variadic dbg.values (those using !DIArgList) by
+;; hand.  The debug nodes for idx and gid are transferred to new nodes via
+;; TransferDbgValue. There should be a DEBUG_VALUE_LIST for each call to
+;; llvm.dbg.value.
+
+; CHECK-DAG: ![[ip:[0-9]+]]  = !DILocalVariable(name: "ip",
+; CHECK-DAG: ![[gid:[0-9]+]] = !DILocalVariable(name: "gid",
+; CHECK-DAG: ![[xxx:[0-9]+]] = !DILocalVariable(name: "xxx",
+; CHECK-DAG: ![[idx:[0-9]+]] = !DILocalVariable(name: "idx",
+
+; CHECK: DBG_VALUE_LIST ![[ip]],  !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value),
+; CHECK: DBG_VALUE_LIST ![[gid]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value),
+;; Constant value dbg.value should keep its value.
+; CHECK: DBG_VALUE_LIST ![[xxx]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value), 0
+; CHECK: DBG_VALUE_LIST ![[idx]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value),
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32"
+target triple = "i686-apple-darwin"
+
+declare <4 x i32> @__amdil_get_global_id_int()
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+define void @__OpenCL_test_kernel(i32 addrspace(1)* %ip) nounwind !dbg !0 {
+entry:
+  call void @llvm.dbg.value(metadata !DIArgList(i32 addrspace(1)* %ip), metadata !7, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value)), !dbg !8
+  %0 = call <4 x i32> @__amdil_get_global_id_int() nounwind
+  %1 = extractelement <4 x i32> %0, i32 0
+  call void @llvm.dbg.value(metadata !DIArgList(i32 %1), metadata !9, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value)), !dbg !11
+  call void @llvm.dbg.value(metadata !DIArgList(i32 0), metadata !21, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value)), !dbg !14
+  %tmp2 = load i32, i32 addrspace(1)* %ip, align 4, !dbg !15
+  %tmp3 = add i32 0, %tmp2, !dbg !15
+  call void @llvm.dbg.value(metadata !DIArgList(i32 %tmp3), metadata !13, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value)), !dbg !15
+  %arrayidx = getelementptr i32, i32 addrspace(1)* %ip, i32 %1, !dbg !16
+  store i32 %tmp3, i32 addrspace(1)* %arrayidx, align 4, !dbg !16
+  ret void, !dbg !17
+}
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!20}
+
+!0 = distinct !DISubprogram(name: "__OpenCL_test_kernel", linkageName: "__OpenCL_test_kernel", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !2, file: !19, scope: !1, type: !3)
+!1 = !DIFile(filename: "OCL6368.tmp.cl", directory: "E:CUsersCmvillmow.AMDCAppDataCLocalCTemp")
+!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "clc", isOptimized: false, emissionKind: FullDebug, file: !19, enums: !12, retainedTypes: !12, imports:  null)
+!3 = !DISubroutineType(types: !4)
+!4 = !{null, !5}
+!5 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 32, align: 32, scope: !2, baseType: !6)
+!6 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
+!7 = !DILocalVariable(name: "ip", line: 1, arg: 1, scope: !0, file: !1, type: !5)
+!8 = !DILocation(line: 1, column: 42, scope: !0)
+!9 = !DILocalVariable(name: "gid", line: 3, scope: !10, file: !1, type: !6)
+!10 = distinct !DILexicalBlock(line: 2, column: 1, file: !19, scope: !0)
+!11 = !DILocation(line: 3, column: 41, scope: !10)
+!12 = !{}
+!13 = !DILocalVariable(name: "idx", line: 4, scope: !10, file: !1, type: !6)
+!14 = !DILocation(line: 4, column: 20, scope: !10)
+!15 = !DILocation(line: 5, column: 15, scope: !10)
+!16 = !DILocation(line: 6, column: 18, scope: !10)
+!17 = !DILocation(line: 7, column: 1, scope: !0)
+!19 = !DIFile(filename: "OCL6368.tmp.cl", directory: "E:\5CUsers\5Cmvillmow.AMD\5CAppData\5CLocal\5CTemp")
+!20 = !{i32 1, !"Debug Info Version", i32 3}
+!21 = !DILocalVariable(name: "xxx", line: 4, scope: !10, file: !1, type: !6)

diff  --git a/llvm/test/DebugInfo/X86/dbg-value-list-selectiondag-salvage.ll b/llvm/test/DebugInfo/X86/dbg-value-list-selectiondag-salvage.ll
new file mode 100644
index 000000000000..6cb37d1e09b7
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dbg-value-list-selectiondag-salvage.ll
@@ -0,0 +1,72 @@
+; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -o - | FileCheck %s
+
+;; Generated from clang -O2 -emit-llvm -S -g reduce.c -o -
+;; $ cat reduce.c
+;; struct {
+;;   int a;
+;; } * b;
+;; int c;
+;; void d() {
+;;   int *e = &b->a - 1;  // XXX
+;;   c = *e;
+;; }
+;;
+;; The line marked XXX becomes a load and gep in IR. We have a variadic
+;; dbg.value using the gep, but we lose that gep in SelectionDAG. Ensure that
+;; we salvage the value.
+
+; CHECK: [[E_REG:%[0-9]+]]{{.+}} = MOV{{.+}} @b
+; CHECK: DBG_VALUE_LIST {{.*}}, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_constu, 4, DW_OP_minus, DW_OP_stack_value), [[E_REG]], debug-location
+
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.anon = type { i32 }
+
+ at b = dso_local local_unnamed_addr global %struct.anon* null, align 8, !dbg !0
+ at c = dso_local local_unnamed_addr global i32 0, align 4, !dbg !6
+
+define dso_local void @d() local_unnamed_addr !dbg !17 {
+entry:
+  %0 = load %struct.anon*, %struct.anon** @b, align 8, !dbg !23
+  %add.ptr = getelementptr inbounds %struct.anon, %struct.anon* %0, i64 -1, i32 0, !dbg !28
+  call void @llvm.dbg.value(metadata !DIArgList(i32* %add.ptr), metadata !21, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value)), !dbg !29
+  %1 = load i32, i32* %add.ptr, align 4, !dbg !30
+  store i32 %1, i32* @c, align 4, !dbg !33
+  ret void, !dbg !34
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!13, !14, !15}
+!llvm.ident = !{!16}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 3, type: !9, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "reduce.c", directory: "/")
+!4 = !{}
+!5 = !{!0, !6}
+!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
+!7 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 4, type: !8, isLocal: false, isDefinition: true)
+!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
+!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !3, line: 1, size: 32, elements: !11)
+!11 = !{!12}
+!12 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !10, file: !3, line: 2, baseType: !8, size: 32)
+!13 = !{i32 7, !"Dwarf Version", i32 4}
+!14 = !{i32 2, !"Debug Info Version", i32 3}
+!15 = !{i32 1, !"wchar_size", i32 4}
+!16 = !{!"clang version 11.0.0"}
+!17 = distinct !DISubprogram(name: "d", scope: !3, file: !3, line: 5, type: !18, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !20)
+!18 = !DISubroutineType(types: !19)
+!19 = !{null}
+!20 = !{!21}
+!21 = !DILocalVariable(name: "e", scope: !17, file: !3, line: 6, type: !22)
+!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
+!23 = !DILocation(line: 6, column: 13, scope: !17)
+!28 = !DILocation(line: 6, column: 18, scope: !17)
+!29 = !DILocation(line: 0, scope: !17)
+!30 = !DILocation(line: 7, column: 7, scope: !17)
+!33 = !DILocation(line: 7, column: 5, scope: !17)
+!34 = !DILocation(line: 8, column: 1, scope: !17)

diff  --git a/llvm/test/DebugInfo/X86/debug_value_list_selectiondag.ll b/llvm/test/DebugInfo/X86/debug_value_list_selectiondag.ll
new file mode 100644
index 000000000000..6159dddf6e41
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/debug_value_list_selectiondag.ll
@@ -0,0 +1,50 @@
+; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -o - | FileCheck %s
+
+;; Test that a dbg.value that uses a DIArgList is correctly converted to a
+;; DBG_VALUE_LIST that uses the registers corresponding to its operands.
+
+; CHECK-DAG: [[A_VAR:![0-9]+]] = !DILocalVariable(name: "a"
+; CHECK-DAG: [[B_VAR:![0-9]+]] = !DILocalVariable(name: "b"
+; CHECK-DAG: [[C_VAR:![0-9]+]] = !DILocalVariable(name: "c"
+; CHECK-LABEL: bb.0.entry
+; CHECK-DAG: DBG_VALUE_LIST [[A_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), %0, debug-location
+; CHECK-DAG: DBG_VALUE_LIST [[B_VAR]], !DIExpression(DW_OP_LLVM_arg, 0), %1, debug-location
+; CHECK: DBG_VALUE_LIST [[C_VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), %0, %1, debug-location
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.16.27034"
+
+define dso_local i32 @"?foo@@YAHHH at Z"(i32 %a, i32 %b) local_unnamed_addr !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata !DIArgList(i32 %b), metadata !14, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
+  call void @llvm.dbg.value(metadata !DIArgList(i32 %a), metadata !15, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
+  call void @llvm.dbg.value(metadata !DIArgList(i32 %a, i32 %b), metadata !16, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg !17
+  %mul = mul nsw i32 %b, %a, !dbg !18
+  ret i32 %mul, !dbg !18
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "debug_value_list_selectiondag.cpp", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 2}
+!6 = !{i32 7, !"PIC Level", i32 2}
+!7 = !{!"clang version 11.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHHH at Z", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
+!9 = !DIFile(filename: ".\\debug_value_list.cpp", directory: "/tmp")
+!10 = !DISubroutineType(types: !11)
+!11 = !{!12, !12, !12}
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14, !15, !16}
+!14 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !9, line: 1, type: !12)
+!15 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 1, type: !12)
+!16 = !DILocalVariable(name: "c", scope: !8, file: !9, line: 2, type: !12)
+!17 = !DILocation(line: 0, scope: !8)
+!18 = !DILocation(line: 3, scope: !8)


        


More information about the llvm-commits mailing list