1# REQUIRES: x86-registered-target 2# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass=mir-check-debugify -o - %s 2>&1 | FileCheck %s 3# RUN: llc --experimental-debuginfo-iterators=false -mtriple=x86_64-unknown-linux-gnu -run-pass=mir-check-debugify -o - %s 2>&1 | FileCheck %s 4--- | 5 ; ModuleID = 'check-line-and-variables.mir' 6 source_filename = "check-line-and-variables.c" 7 8 @ga = dso_local local_unnamed_addr global i32 2, align 4 9 10 ; Function Attrs: nofree norecurse nounwind uwtable writeonly 11 define dso_local i32 @foo(i32 %a, i32 %b) local_unnamed_addr #0 !dbg !9 { 12 entry: 13 %add = add nsw i32 %b, %a, !dbg !15 14 call void @llvm.dbg.value(metadata i32 %add, metadata !12, metadata !DIExpression()), !dbg !15 15 %mul = shl nsw i32 %add, 1, !dbg !16 16 call void @llvm.dbg.value(metadata i32 %mul, metadata !14, metadata !DIExpression()), !dbg !16 17 store i32 %mul, ptr @ga, align 4, !dbg !17 18 ret i32 %add, !dbg !18 19 } 20 21 declare void @llvm.dbg.value(metadata, metadata, metadata) #1 22 23 !llvm.module.flags = !{!0, !1} 24 !llvm.ident = !{!2} 25 !llvm.dbg.cu = !{!3} 26 !llvm.mir.debugify = !{!6, !7} 27 !llvm.debugify = !{!8, !7} 28 29 !0 = !{i32 1, !"wchar_size", i32 4} 30 !1 = !{i32 2, !"Debug Info Version", i32 3} 31 !2 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git c0a922b3db2d39f36c0c01776cce90cc160a7d62)"} 32 !3 = distinct !DICompileUnit(language: DW_LANG_C, file: !4, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5) 33 !4 = !DIFile(filename: "main.mir", directory: "/") 34 !5 = !{} 35 !6 = !{i32 6} 36 !7 = !{i32 2} 37 !8 = !{i32 4} 38 !9 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !4, line: 1, type: !10, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3, retainedNodes: !11) 39 !10 = !DISubroutineType(types: !5) 40 !11 = !{!12, !14} 41 !12 = !DILocalVariable(name: "1", scope: !9, file: !4, line: 1, type: !13) 42 !13 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) 43 !14 = !DILocalVariable(name: "2", scope: !9, file: !4, line: 2, type: !13) 44 !15 = !DILocation(line: 1, column: 1, scope: !9) 45 !16 = !DILocation(line: 2, column: 1, scope: !9) 46 !17 = !DILocation(line: 3, column: 1, scope: !9) 47 !18 = !DILocation(line: 4, column: 1, scope: !9) 48 49... 50--- 51name: foo 52body: | 53 bb.0.entry: 54 liveins: $edi, $esi 55 56 %1:gr32 = COPY $esi, debug-location !15 57 DBG_VALUE %1, $noreg, !12, !DIExpression(), debug-location !15 58 ; Let it missing !14 and debug-location !16 59 ; %0:gr32 = COPY $edi, debug-location !16 60 ; DBG_VALUE %0, $noreg, !14, !DIExpression(), debug-location !16 61 %0:gr32 = COPY $edi 62 %2:gr32 = nsw ADD32rr %1, %0, implicit-def dead $eflags, debug-location !17 63 DBG_VALUE %2, $noreg, !12, !DIExpression(), debug-location !17 64 DBG_VALUE $eflags, $noreg, !12, !DIExpression(), debug-location !17 65 %3:gr32 = nsw ADD32rr %2, %2, implicit-def dead $eflags, debug-location !18 66 DBG_VALUE %3, $noreg, !12, !DIExpression(), debug-location !18 67 DBG_VALUE $eflags, $noreg, !12, !DIExpression(), debug-location !18 68 MOV32mr $rip, 1, $noreg, @ga, $noreg, killed %3, debug-location !DILocation(line: 5, column: 1, scope: !9) :: (store (s32) into @ga, !tbaa !18) 69 DBG_VALUE 0, $noreg, !12, !DIExpression(), debug-location !DILocation(line: 5, column: 1, scope: !9) 70 ; Let it miss Line 6: Change "!DILocation(line: 6, ..." to "!DILocation(line: 5, ..." 71 $eax = COPY %2, debug-location !DILocation(line: 5, column: 1, scope: !9) 72 DBG_VALUE $eax, $noreg, !12, !DIExpression(), debug-location !DILocation(line: 6, column: 1, scope: !9) 73 RET 0, $eax, debug-location !DILocation(line: 7, column: 1, scope: !9) 74 75 ;CHECK: WARNING: Instruction with empty DebugLoc in function foo --%1:gr32 = COPY $edi 76 ;CHECK-NEXT: WARNING: Missing line 2 77 ;CHECK-NEXT: WARNING: Missing line 6 78 ;CHECK-NEXT: WARNING: Missing variable 2 79 ;CHECK-NEXT: Machine IR debug info check: FAIL 80 81... 82