1 # RUN: llc %s --start-after=livedebugvalues -filetype=obj -o - \
2 # RUN: | llvm-dwarfdump - -name local* -regex \
5 ## This tests certain single location detection functionality. The Test MIR
6 ## is hand written. Test directives and comments inline.
9 target triple = "x86_64-unknown-linux-gnu"
10 define dso_local i32 @fun() local_unnamed_addr !dbg !7 {
16 !llvm.module.flags = !{!3, !4, !5}
19 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
20 !1 = !DIFile(filename: "example.c", directory: "/")
21 !3 = !{i32 7, !"Dwarf Version", i32 4}
22 !4 = !{i32 2, !"Debug Info Version", i32 3}
23 !5 = !{i32 1, !"wchar_size", i32 4}
24 !6 = !{!"clang version 11.0.0"}
25 !8 = !DISubroutineType(types: !9)
27 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
28 !22 = !DISubroutineType(types: !23)
30 ; --- Important metadata ---
31 !7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
32 !24 = distinct !DILexicalBlock(scope: !7, file: !1, line: 9, column: 3)
33 !14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 3)
34 !12 = !DILocalVariable(name: "locala", scope: !7, file: !1, line: 1, type: !10)
35 !13 = !DILocalVariable(name: "localb", scope: !14, file: !1, line: 2, type: !10)
36 !25 = !DILocalVariable(name: "localc", scope: !24, file: !1, line: 3, type: !10)
37 !27 = !DILocalVariable(name: "tmp", scope: !14, file: !1, line: 2, type: !10)
38 !15 = !DILocation(line: 1, column: 0, scope: !7)
39 !18 = !DILocation(line: 2, column: 1, scope: !14)
40 !26 = !DILocation(line: 3, column: 1, scope: !24)
46 ;; This is the scope and variable structure:
47 ;; int fun() { // scope fun !7
48 ;; int locala; // scope fun !7, var locala !12, debug-location !15
49 ;; { int localb; // scope fun:block !14, var localb !13, debug-location !18
50 ;; int tmp; } // scope fun:block !14, var localb !27, debug-location !18
51 ;; { int localc; } // scope fun:block !24, var localc !25, debug-location !26
54 ;; (1) Check that frame-setup instructions are not counted against
55 ;; locations being valid throughout the function call.
57 ; CHECK: DW_TAG_variable
58 ; CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI)
59 ; CHECK-NEXT: DW_AT_name ("locala")
60 $rbp = frame-setup MOV64rr $rsp
61 DBG_VALUE $edi, $noreg, !12, !DIExpression(), debug-location !15
62 $eax = MOV32ri 0, debug-location !15
64 ;; (2) The scope block ends with a meta instruction. A location range ends
65 ;; with the final non-meta instruction in the scope. Check that
66 ;; location is considered valid throughout.
68 ; CHECK: DW_TAG_variable
69 ; CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX)
70 ; CHECK-NEXT: DW_AT_name ("localb")
72 ;; start scope, start location range
73 DBG_VALUE $ecx, $noreg, !13, !DIExpression(), debug-location !18
75 $ecx = MOV32ri 1, debug-location !18
77 DBG_VALUE $noreg, $noreg, !27, !DIExpression(), debug-location !18
79 ;; (3) The final instruction in the scope closes a location range. Check
80 ;; that location is considered valid throughout.
82 ; CHECK: DW_TAG_variable
83 ; CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI)
84 ; CHECK-NEXT: DW_AT_name ("localc")
86 ;; start scope, start location range
87 DBG_VALUE $esi, $noreg, !25, !DIExpression(), debug-location !26
88 ;; end scope, end location range
89 $esi = MOV32ri 2, debug-location !26
91 RETQ debug-location !15