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
4 ; ModuleID = 'check-line-and-variables.mir'
5 source_filename = "check-line-and-variables.c"
7 @ga = dso_local local_unnamed_addr global i32 2, align 4
9 ; Function Attrs: nofree norecurse nounwind uwtable writeonly
10 define dso_local i32 @foo(i32 %a, i32 %b) local_unnamed_addr #0 !dbg !9 {
12 %add = add nsw i32 %b, %a, !dbg !15
13 call void @llvm.dbg.value(metadata i32 %add, metadata !12, metadata !DIExpression()), !dbg !15
14 %mul = shl nsw i32 %add, 1, !dbg !16
15 call void @llvm.dbg.value(metadata i32 %mul, metadata !14, metadata !DIExpression()), !dbg !16
16 store i32 %mul, i32* @ga, align 4, !dbg !17
17 ret i32 %add, !dbg !18
20 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
22 !llvm.module.flags = !{!0, !1}
25 !llvm.mir.debugify = !{!6, !7}
26 !llvm.debugify = !{!8, !7}
28 !0 = !{i32 1, !"wchar_size", i32 4}
29 !1 = !{i32 2, !"Debug Info Version", i32 3}
30 !2 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git c0a922b3db2d39f36c0c01776cce90cc160a7d62)"}
31 !3 = distinct !DICompileUnit(language: DW_LANG_C, file: !4, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5)
32 !4 = !DIFile(filename: "main.mir", directory: "/")
37 !9 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !4, line: 1, type: !10, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3, retainedNodes: !11)
38 !10 = !DISubroutineType(types: !5)
40 !12 = !DILocalVariable(name: "1", scope: !9, file: !4, line: 1, type: !13)
41 !13 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
42 !14 = !DILocalVariable(name: "2", scope: !9, file: !4, line: 2, type: !13)
43 !15 = !DILocation(line: 1, column: 1, scope: !9)
44 !16 = !DILocation(line: 2, column: 1, scope: !9)
45 !17 = !DILocation(line: 3, column: 1, scope: !9)
46 !18 = !DILocation(line: 4, column: 1, scope: !9)
55 %1:gr32 = COPY $esi, debug-location !15
56 DBG_VALUE %1, $noreg, !12, !DIExpression(), debug-location !15
57 ; Let it missing !14 and debug-location !16
58 ; %0:gr32 = COPY $edi, debug-location !16
59 ; DBG_VALUE %0, $noreg, !14, !DIExpression(), debug-location !16
61 %2:gr32 = nsw ADD32rr %1, %0, implicit-def dead $eflags, debug-location !17
62 DBG_VALUE %2, $noreg, !12, !DIExpression(), debug-location !17
63 DBG_VALUE $eflags, $noreg, !12, !DIExpression(), debug-location !17
64 %3:gr32 = nsw ADD32rr %2, %2, implicit-def dead $eflags, debug-location !18
65 DBG_VALUE %3, $noreg, !12, !DIExpression(), debug-location !18
66 DBG_VALUE $eflags, $noreg, !12, !DIExpression(), debug-location !18
67 MOV32mr $rip, 1, $noreg, @ga, $noreg, killed %3, debug-location !DILocation(line: 5, column: 1, scope: !9) :: (store (s32) into @ga, !tbaa !18)
68 DBG_VALUE 0, $noreg, !12, !DIExpression(), debug-location !DILocation(line: 5, column: 1, scope: !9)
69 ; Let it miss Line 6: Change "!DILocation(line: 6, ..." to "!DILocation(line: 5, ..."
70 $eax = COPY %2, debug-location !DILocation(line: 5, column: 1, scope: !9)
71 DBG_VALUE $eax, $noreg, !12, !DIExpression(), debug-location !DILocation(line: 6, column: 1, scope: !9)
72 RET 0, $eax, debug-location !DILocation(line: 7, column: 1, scope: !9)
74 ;CHECK: WARNING: Instruction with empty DebugLoc in function foo --%1:gr32 = COPY $edi
75 ;CHECK-NEXT: WARNING: Missing line 2
76 ;CHECK-NEXT: WARNING: Missing line 6
77 ;CHECK-NEXT: WARNING: Missing variable 2
78 ;CHECK-NEXT: Machine IR debug info check: FAIL