blob: e447fa82f95b3e17a115158edc6986a670100481 [file] [log] [blame]
# RUN: llc %s --start-after=livedebugvalues -filetype=obj -o - \
# RUN: | llvm-dwarfdump - -name local* -regex \
# RUN: | FileCheck %s
#
# Test that we produce correct DWARF from DBG_VALUE_LIST instructions.
# Comments and test directives inline.
--- |
target triple = "x86_64-unknown-linux-gnu"
define dso_local i32 @fun() local_unnamed_addr !dbg !7 {
entry:
ret i32 0
}
!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: "example.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"}
!8 = !DISubroutineType(types: !9)
!9 = !{!10}
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !{!12, !13, !25}
!22 = !DISubroutineType(types: !23)
!23 = !{!10, !10}
; --- Important metadata ---
!7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
!15 = !DILocation(line: 1, column: 1, scope: !7)
!12 = !DILocalVariable(name: "locala", scope: !7, file: !1, line: 1, type: !10)
!13 = !DILocalVariable(name: "localb", scope: !7, file: !1, line: 2, type: !10)
!25 = !DILocalVariable(name: "localc", scope: !7, file: !1, line: 3, type: !10)
!26 = !DILocalVariable(name: "locald", scope: !7, file: !1, line: 4, type: !10)
!27 = !DILocalVariable(name: "locale", scope: !7, file: !1, line: 5, type: !10)
!28 = !DILocalVariable(name: "localf", scope: !7, file: !1, line: 6, type: !10)
!29 = !DILocalVariable(name: "localg", scope: !7, file: !1, line: 6, type: !10)
!30 = !DILocalVariable(name: "localh", scope: !7, file: !1, line: 6, type: !10)
...
---
name: fun
body: |
bb.0.entry:
; NOTE: By design, all DBG_VALUE_LIST instructions describe stack_value
; locations, so they are always created with a DW_OP_stack_value op.
;
; (1) Check a single reg arg works.
DBG_VALUE_LIST !12, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value), $eax, debug-location !15
; CHECK: DW_TAG_variable
; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_name ("locala")
; (2) Check multiple reg args work.
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
; CHECK: DW_TAG_variable
; 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)
; CHECK-NEXT: DW_AT_name ("localb")
; (3) Check that multiple references to one reg arg works.
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
; CHECK: DW_TAG_variable
; 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)
; CHECK-NEXT: DW_AT_name ("localc")
; (4) Check constant and reg args work together.
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
; CHECK: DW_TAG_variable
; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_lit5, DW_OP_mul, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_name ("locald")
; (5) Check that arg deref works.
DBG_VALUE_LIST !27, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_deref, DW_OP_stack_value), $eax, debug-location !15
; CHECK: DW_TAG_variable
; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_deref, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_name ("locale")
; (6) Check that fragments work.
DBG_VALUE_LIST !28, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value, DW_OP_LLVM_fragment, 0, 16), $eax, debug-location !15
; CHECK: DW_TAG_variable
; CHECK-NEXT: (DW_OP_breg0 RAX+0, DW_OP_constu 0xffffffff, DW_OP_and, DW_OP_stack_value, DW_OP_piece 0x2)
; CHECK-NEXT: DW_AT_name ("localf")
; (7) Check that constant register offsets are correctly folded.
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
; CHECK: DW_TAG_variable
; 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)
; CHECK-NEXT: DW_AT_name ("localg")
; (8) Check that a single $noreg location invalidates the entire entry.
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
; CHECK: DW_TAG_variable
; CHECK-NEXT: DW_AT_name ("localh")
; CHECK-NOT: DW_AT_location
RET64 debug-location !15
...