xref: /llvm-project/llvm/test/DebugInfo/X86/dbg-val-list-dangling.ll (revision d53425e2a33a0ff7336c86d3f668b1855c47a6de)
1;; At the moment we emit an undef as soon as we encounter "dangling" variadic
2;; dbg_value nodes. This does not reduce correctness but does reduce coverage.
3;; We should make variadic dbg_values work in the same way as their
4;; non-variadic counterparts here.
5;; FIXME: When dangling nodes for a variadic dbg_value are found, we should be
6;; able to recover the value in some cases.
7
8; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -o - -experimental-debug-variable-locations=false | FileCheck %s
9; RUN: llc %s -start-after=codegenprepare -stop-before=finalize-isel -o - -experimental-debug-variable-locations=false --try-experimental-debuginfo-iterators | FileCheck %s
10
11;; Check that dangling debug info in the SelectionDAG build phase is handled
12;; in the same way for variadic dbg_value ndoes as non-variadics.
13
14;; Generated from the following source with -g -O2. Second dbg.value modified
15;; to be variadic by hand:
16;; void a(char*);
17;; void b() {
18;;   char *c = "abc";
19;;   char *d = "abc";
20;;   a("abc");
21;; }
22
23; CHECK: ![[C:[0-9]+]] = !DILocalVariable(name: "c",
24; CHECK: ![[D:[0-9]+]] = !DILocalVariable(name: "d",
25
26; CHECK-DAG: DBG_VALUE %[[VREG:[0-9]]], $noreg, ![[C]], !DIExpression(), debug-location
27; CHECK-DAG: DBG_VALUE_LIST ![[D]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value), $noreg, debug-location
28
29target triple = "x86_64-unknown-linux-gnu"
30
31@.str = private unnamed_addr constant [4 x i8] c"abc\00", align 1
32
33define dso_local void @b() local_unnamed_addr !dbg !7 {
34entry:
35  call void @llvm.dbg.value(metadata ptr @.str, metadata !11, metadata !DIExpression()), !dbg !15
36  call void @llvm.dbg.value(metadata !DIArgList(ptr @.str), metadata !14, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value)), !dbg !15
37  tail call void @a(ptr @.str) #3, !dbg !16
38  ret void, !dbg !17
39}
40
41declare !dbg !18 dso_local void @a(ptr) local_unnamed_addr
42declare void @llvm.dbg.value(metadata, metadata, metadata)
43
44
45!llvm.dbg.cu = !{!0}
46!llvm.module.flags = !{!3, !4, !5}
47!llvm.ident = !{!6}
48
49!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)
50!1 = !DIFile(filename: "test.c", directory: "/")
51!2 = !{}
52!3 = !{i32 7, !"Dwarf Version", i32 4}
53!4 = !{i32 2, !"Debug Info Version", i32 3}
54!5 = !{i32 1, !"wchar_size", i32 4}
55!6 = !{!"clang version 11.0.0"}
56!7 = distinct !DISubprogram(name: "b", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
57!8 = !DISubroutineType(types: !9)
58!9 = !{null}
59!10 = !{!11, !14}
60!11 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 3, type: !12)
61!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
62!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
63!14 = !DILocalVariable(name: "d", scope: !7, file: !1, line: 4, type: !12)
64!15 = !DILocation(line: 0, scope: !7)
65!16 = !DILocation(line: 5, column: 3, scope: !7)
66!17 = !DILocation(line: 6, column: 1, scope: !7)
67!18 = !DISubprogram(name: "a", scope: !1, file: !1, line: 1, type: !19, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
68!19 = !DISubroutineType(types: !20)
69!20 = !{null, !12}
70