xref: /llvm-project/llvm/test/DebugInfo/X86/sdag-ir-salvage.ll (revision d53425e2a33a0ff7336c86d3f668b1855c47a6de)
1; RUN: llc -mtriple=x86_64-unknown-unknown -start-after=codegenprepare \
2; RUN:    -stop-before finalize-isel %s -o -  \
3; RUN:    -experimental-debug-variable-locations=false \
4; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE
5; RUN: llc -mtriple=x86_64-unknown-unknown -start-after=codegenprepare \
6; RUN:    -stop-before finalize-isel %s -o -  \
7; RUN:    -experimental-debug-variable-locations=true \
8; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF
9
10; RUN: llc -mtriple=x86_64-unknown-unknown -start-after=codegenprepare \
11; RUN:    -stop-before finalize-isel %s -o -  \
12; RUN:    -experimental-debug-variable-locations=false --try-experimental-debuginfo-iterators \
13; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE
14
15; Test that the dbg.value for %baz, which doesn't exist in the 'next' bb,
16; can be salvaged back to the underlying argument vreg.
17
18; CHECK:       ![[AAAVAR:.*]] = !DILocalVariable(name: "aaa",
19; CHECK-LABEL: bb.0.entry:
20; INSTRREF:    DBG_PHI $rdi, 1
21; CHECK-LABEL: bb.1.next:
22; INSTRREF:    DBG_INSTR_REF ![[AAAVAR]], {{.+}}, dbg-instr-ref(1, 0)
23; DBGVALUE:    DBG_VALUE %{{[0-9]+}}, $noreg, ![[AAAVAR]]
24
25target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
26target triple = "x86_64-linux-gnu"
27
28define i8 @f(ptr %foo) local_unnamed_addr !dbg !6 {
29entry:
30  %bar = getelementptr i32, ptr %foo, i32 4
31  %quux = load i8, ptr %bar
32  br label %next
33
34next:                                             ; preds = %entry
35  tail call void @llvm.dbg.value(metadata ptr %bar, metadata !15, metadata !DIExpression()), !dbg !30
36  %xyzzy = add i8 %quux, 123
37  br label %fin
38
39fin:                                              ; preds = %next
40  %trains = getelementptr i32, ptr %foo, i32 3
41  %cars = load i8, ptr %trains
42  %ret = add i8 %xyzzy, %cars
43  ret i8 %ret
44}
45
46; Function Attrs: nounwind readnone speculatable
47declare void @llvm.dbg.value(metadata, metadata, metadata) #0
48
49attributes #0 = { nounwind readnone speculatable }
50
51!llvm.dbg.cu = !{!0}
52!llvm.module.flags = !{!25, !26, !27, !28}
53!llvm.ident = !{!29}
54
55!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
56!1 = !DIFile(filename: "test.c", directory: ".")
57!2 = !{}
58!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 18, type: !7, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
59!7 = !DISubroutineType(types: !8)
60!8 = !{!13}
61!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_unsigned)
62!14 = !{!15}
63!15 = !DILocalVariable(name: "aaa", scope: !6, file: !1, line: 18, type: !13)
64!25 = !{i32 2, !"Dwarf Version", i32 4}
65!26 = !{i32 2, !"Debug Info Version", i32 3}
66!27 = !{i32 1, !"wchar_size", i32 4}
67!28 = !{i32 7, !"PIC Level", i32 2}
68!29 = !{!"clang"}
69!30 = !DILocation(line: 18, column: 14, scope: !6)
70