1 # RUN: llc %s --start-after=livedebugvalues -filetype=obj -o - \
\r
2 # RUN: | llvm-dwarfdump - -name local* -regex \
\r
3 # RUN: | FileCheck %s
\r
5 # Test that we produce correct DWARF from DBG_VALUE_LIST instructions.
\r
6 # Comments and test directives inline.
\r
9 target triple = "x86_64-unknown-linux-gnu"
\r
10 define dso_local i32 @fun() local_unnamed_addr !dbg !7 {
\r
15 !llvm.dbg.cu = !{!0}
\r
16 !llvm.module.flags = !{!3, !4, !5}
\r
19 !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)
\r
20 !1 = !DIFile(filename: "example.c", directory: "/")
\r
22 !3 = !{i32 7, !"Dwarf Version", i32 4}
\r
23 !4 = !{i32 2, !"Debug Info Version", i32 3}
\r
24 !5 = !{i32 1, !"wchar_size", i32 4}
\r
25 !6 = !{!"clang version 11.0.0"}
\r
26 !8 = !DISubroutineType(types: !9)
\r
28 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
\r
29 !11 = !{!12, !13, !25}
\r
30 !22 = !DISubroutineType(types: !23)
\r
32 ; --- Important metadata ---
\r
33 !7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
\r
34 !15 = !DILocation(line: 1, column: 1, scope: !7)
\r
35 !12 = !DILocalVariable(name: "locala", scope: !7, file: !1, line: 1, type: !10)
\r
36 !13 = !DILocalVariable(name: "localb", scope: !7, file: !1, line: 2, type: !10)
\r
37 !25 = !DILocalVariable(name: "localc", scope: !7, file: !1, line: 3, type: !10)
\r
38 !26 = !DILocalVariable(name: "locald", scope: !7, file: !1, line: 4, type: !10)
\r
39 !27 = !DILocalVariable(name: "locale", scope: !7, file: !1, line: 5, type: !10)
\r
40 !28 = !DILocalVariable(name: "localf", scope: !7, file: !1, line: 6, type: !10)
\r
41 !29 = !DILocalVariable(name: "localg", scope: !7, file: !1, line: 6, type: !10)
\r
42 !30 = !DILocalVariable(name: "localh", scope: !7, file: !1, line: 6, type: !10)
\r
49 ; NOTE: By design, all DBG_VALUE_LIST instructions describe stack_value
\r
50 ; locations, so they are always created with a DW_OP_stack_value op.
\r
52 ; (1) Check a single reg arg works.
\r
53 DBG_VALUE_LIST !12, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value), $eax, debug-location !15
\r
54 ; CHECK: DW_TAG_variable
\r
55 ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_stack_value)
\r
56 ; CHECK-NEXT: DW_AT_name ("locala")
\r
58 ; (2) Check multiple reg args work.
\r
59 DBG_VALUE_LIST !13, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value), $eax, $edi, debug-location !15
\r
60 ; CHECK: DW_TAG_variable
\r
61 ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_breg5 RDI+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_stack_value)
\r
62 ; CHECK-NEXT: DW_AT_name ("localb")
\r
64 ; (3) Check that multiple references to one reg arg works.
\r
65 DBG_VALUE_LIST !25, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 0, DW_OP_minus, DW_OP_stack_value), $eax, debug-location !15
\r
66 ; CHECK: DW_TAG_variable
\r
67 ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_minus, DW_OP_stack_value)
\r
68 ; CHECK-NEXT: DW_AT_name ("localc")
\r
70 ; (4) Check constant and reg args work together.
\r
71 DBG_VALUE_LIST !26, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_mul, DW_OP_stack_value), $eax, 5, debug-location !15
\r
72 ; CHECK: DW_TAG_variable
\r
73 ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_lit5, DW_OP_mul, DW_OP_stack_value)
\r
74 ; CHECK-NEXT: DW_AT_name ("locald")
\r
76 ; (5) Check that arg deref works.
\r
77 DBG_VALUE_LIST !27, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_deref, DW_OP_stack_value), $eax, debug-location !15
\r
78 ; CHECK: DW_TAG_variable
\r
79 ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_deref, DW_OP_stack_value)
\r
80 ; CHECK-NEXT: DW_AT_name ("locale")
\r
82 ; (6) Check that fragments work.
\r
83 DBG_VALUE_LIST !28, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value, DW_OP_LLVM_fragment, 0, 16), $eax, debug-location !15
\r
84 ; CHECK: DW_TAG_variable
\r
85 ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_stack_value, DW_OP_piece 0x2)
\r
86 ; CHECK-NEXT: DW_AT_name ("localf")
\r
88 ; (7) Check that constant register offsets are correctly folded.
\r
89 DBG_VALUE_LIST !29, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 5, DW_OP_LLVM_arg, 1, DW_OP_plus_uconst, 17, DW_OP_plus, DW_OP_stack_value), $eax, $edi, debug-location !15
\r
90 ; CHECK: DW_TAG_variable
\r
91 ; CHECK-NEXT: (DW_OP_breg0 RAX+5, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_breg5 RDI+17, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_stack_value)
\r
92 ; CHECK-NEXT: DW_AT_name ("localg")
\r
94 ; (8) Check that a single $noreg location invalidates the entire entry.
\r
95 DBG_VALUE_LIST !30, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value), $eax, $noreg, debug-location !15
\r
96 ; CHECK: DW_TAG_variable
\r
97 ; CHECK-NEXT: DW_AT_name ("localh")
\r
98 ; CHECK-NOT: DW_AT_location
\r
100 RETQ debug-location !15
\r