• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 the -trim-var-locs option (enabled by default) works correctly.
6# Test directives and comments 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  !24 = distinct !DILexicalBlock(scope: !7, file: !1, line: 9, column: 3)
35  !14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 3)
36  !12 = !DILocalVariable(name: "locala", scope: !7, file: !1, line: 1, type: !10)
37  !13 = !DILocalVariable(name: "localb", scope: !14, file: !1, line: 2, type: !10)
38  !25 = !DILocalVariable(name: "localc", scope: !24, file: !1, line: 3, type: !10)
39  !15 = !DILocation(line: 1, column: 0, scope: !7)
40  !18 = !DILocation(line: 2, column: 1, scope: !14)
41  !26 = !DILocation(line: 3, column: 1, scope: !24)
42...
43---
44name:            fun
45body:             |
46  bb.0.entry:
47    ; This is the scope and variable structure:
48    ; int fun() {       // scope fun !7
49    ;   int locala;     // scope fun !7,        var locala !12, debug-location !15
50    ;   { int localb; } // scope fun:block !14, var localb !13, debug-location !18
51    ;   { int localc; } // scope fun:block !24, var localc !25, debug-location !26
52    ; }
53    ;
54    ; (1) Check that a variable location range found in implied scope fun !7 is
55    ;     not trimmed.
56    ;
57    ; CHECK:      DW_TAG_variable
58    ; CHECK-NEXT:   DW_AT_location
59    ; CHECK-NEXT:     DW_OP_reg0 RAX
60    ; CHECK-NEXT:   DW_AT_name ("locala")
61    ;
62    ; scope fun !7 is implied as we're in function fun and haven't seen a debug-location
63    $eax = MOV32ri 0
64    ; locala range 1 start in implicit scope fun !7
65    DBG_VALUE $eax, $noreg, !12, !DIExpression(), debug-location !15
66    $edi = MOV32ri 1
67    ; locala range 1 clobber in implicit scope fun !7
68    $eax = MOV32ri 2
69    ; scope fun !7 explicit start
70    $edi = MOV32ri 3, debug-location !15
71
72    ; (2) Check that a variable location range found outside lexical block is
73    ;     trimmed. See check directives for (3).
74    ;
75    ; localb range 1 start in scope fun !7 (outside block !14).
76    DBG_VALUE $eax, $noreg, !13, !DIExpression(), debug-location !18
77    ; localb range 1 clobber in scope fun !7
78    $edi = MOV32ri 4, debug-location !15
79
80    ; (3) Check that a variable location range which overlaps the entire lexical
81    ;     block is not trimmed.
82    ;
83    ; CHECK:      DW_TAG_variable
84    ; CHECK-NEXT:   DW_AT_location (DW_OP_reg5 RDI)
85    ; CHECK-NEXT:   DW_AT_name ("localb")
86    ;
87    ; localb range 2 clobber in scope fun !7 (outside block !14)
88    DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !18
89    ; scope block !14 start (and only instruction)
90    $edi = MOV32ri 5, debug-location !18
91
92    ; (4) Check that a variable location range in scope fun !7 (outside block
93    ;     !14) is trimmed. See check directives for (3).
94    ;
95    ; localb range 3 starts after scope !14 (prev instr is last in scope)
96    DBG_VALUE $rax, $noreg, !13, !DIExpression(), debug-location !18
97    ; scope block !14 end
98    $edi = MOV32ri 6, debug-location !15
99
100    ; (5) Check that a variable location range found between disjoint scope
101    ;     ranges is trimmed.
102    ;
103    ; CHECK:      DW_TAG_variable
104    ; CHECK-NOT:    DW_AT_location
105    ; CHECK-NEXT:   DW_AT_name ("localc")
106    ;
107    ; scope fun !7
108    $edi = MOV32ri 6, debug-location !15
109    ; scope block !24 start and end range 1
110    $edi = MOV32ri 7, debug-location !26
111    ; localc range 1 start in scope !7
112    DBG_VALUE $edi, $noreg, !25, !DIExpression(), debug-location !18
113    ; localc range 1 clobber in scope !7
114    $edi = MOV32ri 8, debug-location !15
115    ; scope block !24 start and end range 2
116    $edi = MOV32ri 9, debug-location !26
117
118    ; scope fun !7
119    RETQ debug-location !15
120...
121