1# RUN: llc %s --start-after=livedebugvalues -filetype=obj -o - \ 2# RUN: | llvm-dwarfdump - -name local* -regex \ 3# RUN: | FileCheck %s 4# 5## This tests certain single location detection functionality. The Test MIR 6## is hand written. 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, 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) 26 !9 = !{!10} 27 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 28 !22 = !DISubroutineType(types: !23) 29 !23 = !{!10, !10} 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) 41... 42--- 43name: fun 44body: | 45 bb.0.entry: 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 52 ;; } 53 ;; 54 ;; (1) Check that frame-setup instructions are not counted against 55 ;; locations being valid throughout the function call. 56 ; 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 63 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. 67 ; 68 ; CHECK: DW_TAG_variable 69 ; CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX) 70 ; CHECK-NEXT: DW_AT_name ("localb") 71 ; 72 ;; start scope, start location range 73 DBG_VALUE $ecx, $noreg, !13, !DIExpression(), debug-location !18 74 ;; end location range 75 $ecx = MOV32ri 1, debug-location !18 76 ;; end scope 77 DBG_VALUE $noreg, $noreg, !27, !DIExpression(), debug-location !18 78 79 ;; (3) The final instruction in the scope closes a location range. Check 80 ;; that location is considered valid throughout. 81 ; 82 ; CHECK: DW_TAG_variable 83 ; CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI) 84 ; CHECK-NEXT: DW_AT_name ("localc") 85 ; 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 90 91 RET64 debug-location !15 92... 93