Stephen Tozer | e64f3cc | 2021-03-10 14:35:55 +0000 | [diff] [blame] | 1 | # RUN: llc %s --start-after=livedebugvalues -filetype=obj -o - \
|
| 2 | # RUN: | llvm-dwarfdump - -name local* -regex \
|
| 3 | # RUN: | FileCheck %s
|
| 4 | #
|
| 5 | # Test that we produce correct DWARF from DBG_VALUE_LIST instructions.
|
| 6 | # Comments and test directives inline.
|
| 7 |
|
| 8 | --- |
|
| 9 | target triple = "x86_64-unknown-linux-gnu"
|
| 10 | define dso_local i32 @fun() local_unnamed_addr !dbg !7 {
|
| 11 | entry:
|
| 12 | ret i32 0
|
| 13 | }
|
| 14 |
|
| 15 | !llvm.dbg.cu = !{!0}
|
| 16 | !llvm.module.flags = !{!3, !4, !5}
|
| 17 | !llvm.ident = !{!6}
|
| 18 |
|
| 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)
|
| 20 | !1 = !DIFile(filename: "example.c", directory: "/")
|
| 21 | !2 = !{}
|
| 22 | !3 = !{i32 7, !"Dwarf Version", i32 4}
|
| 23 | !4 = !{i32 2, !"Debug Info Version", i32 3}
|
| 24 | !5 = !{i32 1, !"wchar_size", i32 4}
|
| 25 | !6 = !{!"clang version 11.0.0"}
|
| 26 | !8 = !DISubroutineType(types: !9)
|
| 27 | !9 = !{!10}
|
| 28 | !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
| 29 | !11 = !{!12, !13, !25}
|
| 30 | !22 = !DISubroutineType(types: !23)
|
| 31 | !23 = !{!10, !10}
|
| 32 | ; --- Important metadata ---
|
| 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)
|
| 34 | !15 = !DILocation(line: 1, column: 1, scope: !7)
|
| 35 | !12 = !DILocalVariable(name: "locala", scope: !7, file: !1, line: 1, type: !10)
|
| 36 | !13 = !DILocalVariable(name: "localb", scope: !7, file: !1, line: 2, type: !10)
|
| 37 | !25 = !DILocalVariable(name: "localc", scope: !7, file: !1, line: 3, type: !10)
|
| 38 | !26 = !DILocalVariable(name: "locald", scope: !7, file: !1, line: 4, type: !10)
|
| 39 | !27 = !DILocalVariable(name: "locale", scope: !7, file: !1, line: 5, type: !10)
|
| 40 | !28 = !DILocalVariable(name: "localf", scope: !7, file: !1, line: 6, type: !10)
|
| 41 | !29 = !DILocalVariable(name: "localg", scope: !7, file: !1, line: 6, type: !10)
|
| 42 | !30 = !DILocalVariable(name: "localh", scope: !7, file: !1, line: 6, type: !10)
|
| 43 |
|
| 44 | ...
|
| 45 | ---
|
| 46 | name: fun
|
| 47 | body: |
|
| 48 | bb.0.entry:
|
| 49 | ; NOTE: By design, all DBG_VALUE_LIST instructions describe stack_value
|
| 50 | ; locations, so they are always created with a DW_OP_stack_value op.
|
| 51 | ;
|
| 52 | ; (1) Check a single reg arg works.
|
| 53 | DBG_VALUE_LIST !12, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value), $eax, debug-location !15
|
| 54 | ; CHECK: DW_TAG_variable
|
| 55 | ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_stack_value)
|
| 56 | ; CHECK-NEXT: DW_AT_name ("locala")
|
| 57 |
|
| 58 | ; (2) Check multiple reg args work.
|
| 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
|
| 60 | ; CHECK: DW_TAG_variable
|
| 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)
|
| 62 | ; CHECK-NEXT: DW_AT_name ("localb")
|
| 63 |
|
| 64 | ; (3) Check that multiple references to one reg arg works.
|
| 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
|
| 66 | ; CHECK: DW_TAG_variable
|
| 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)
|
| 68 | ; CHECK-NEXT: DW_AT_name ("localc")
|
| 69 |
|
| 70 | ; (4) Check constant and reg args work together.
|
| 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
|
| 72 | ; CHECK: DW_TAG_variable
|
| 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)
|
| 74 | ; CHECK-NEXT: DW_AT_name ("locald")
|
| 75 |
|
| 76 | ; (5) Check that arg deref works.
|
| 77 | DBG_VALUE_LIST !27, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_deref, DW_OP_stack_value), $eax, debug-location !15
|
| 78 | ; CHECK: DW_TAG_variable
|
| 79 | ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_deref, DW_OP_stack_value)
|
| 80 | ; CHECK-NEXT: DW_AT_name ("locale")
|
| 81 |
|
| 82 | ; (6) Check that fragments work.
|
| 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
|
| 84 | ; CHECK: DW_TAG_variable
|
| 85 | ; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_stack_value, DW_OP_piece 0x2)
|
| 86 | ; CHECK-NEXT: DW_AT_name ("localf")
|
| 87 |
|
| 88 | ; (7) Check that constant register offsets are correctly folded.
|
| 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
|
| 90 | ; CHECK: DW_TAG_variable
|
| 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)
|
| 92 | ; CHECK-NEXT: DW_AT_name ("localg")
|
| 93 |
|
| 94 | ; (8) Check that a single $noreg location invalidates the entire entry.
|
| 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
|
| 96 | ; CHECK: DW_TAG_variable
|
| 97 | ; CHECK-NEXT: DW_AT_name ("localh")
|
| 98 | ; CHECK-NOT: DW_AT_location
|
| 99 |
|
Simon Pilgrim | d391e4f | 2021-11-07 15:06:54 +0000 | [diff] [blame] | 100 | RET64 debug-location !15
|
Stephen Tozer | e64f3cc | 2021-03-10 14:35:55 +0000 | [diff] [blame] | 101 | ...
|