1# RUN: llc -run-pass=greedy -run-pass=virtregrewriter %s -o - | FileCheck %s 2 3## This tests that LiveDebugVariables does not trim non-inlined variable 4## location. 5 6# CHECK: ![[VARA:.*]] = !DILocalVariable(name: "a" 7# CHECK: ![[VARB:.*]] = !DILocalVariable(name: "b" 8# CHECK: ![[VARC:.*]] = !DILocalVariable(name: "c" 9# CHECK: $at = COPY $a2 10# CHECK-NEXT: DBG_VALUE $at, $noreg, ![[VARC]], !DIExpression(), debug-location 11# CHECK: $s0 = COPY $a1 12# CHECK-NEXT: DBG_VALUE $a0, $noreg, ![[VARA]], !DIExpression(), debug-location 13# CHECK-NEXT: DBG_VALUE $s0, $noreg, ![[VARB]], !DIExpression(), debug-location 14 15--- | 16 ; ModuleID = 'test.c' 17 source_filename = "test.c" 18 target datalayout = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64" 19 target triple = "mips-unknown-linux-gnu" 20 21 ; Function Attrs: nounwind 22 define dso_local i32 @fn2(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr !dbg !7 { 23 entry: 24 call void @llvm.dbg.value(metadata i32 %a, metadata !12, metadata !DIExpression()), !dbg !16 25 call void @llvm.dbg.value(metadata i32 %b, metadata !13, metadata !DIExpression()), !dbg !16 26 call void @llvm.dbg.value(metadata i32 %c, metadata !14, metadata !DIExpression()), !dbg !16 27 %add = add nsw i32 %b, %a, !dbg !17 28 %add1 = add nsw i32 %b, 10, !dbg !18 29 %call = tail call i32 @fn1(i32 signext %add, i32 signext %c, i32 signext %add1), !dbg !19 30 call void @llvm.dbg.value(metadata i32 %call, metadata !15, metadata !DIExpression()), !dbg !16 31 %cmp = icmp sgt i32 %call, 10, !dbg !20 32 %add2 = add nsw i32 %call, 10, !dbg !22 33 %retval.0 = select i1 %cmp, i32 %add2, i32 %b, !dbg !22 34 ret i32 %retval.0, !dbg !23 35 } 36 37 declare !dbg !24 dso_local i32 @fn1(i32 signext, i32 signext, i32 signext) local_unnamed_addr 38 39 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn mustprogress 40 declare void @llvm.dbg.value(metadata, metadata, metadata) 41 42 !llvm.dbg.cu = !{!0} 43 !llvm.module.flags = !{!3, !4, !5} 44 !llvm.ident = !{!6} 45 46 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 47 !1 = !DIFile(filename: "test.c", directory: "/dir") 48 !2 = !{} 49 !3 = !{i32 7, !"Dwarf Version", i32 4} 50 !4 = !{i32 2, !"Debug Info Version", i32 3} 51 !5 = !{i32 1, !"wchar_size", i32 4} 52 !6 = !{!"clang version 13.0.0"} 53 !7 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) 54 !8 = !DISubroutineType(types: !9) 55 !9 = !{!10, !10, !10, !10} 56 !10 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) 57 !11 = !{!12, !13, !14, !15} 58 !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10) 59 !13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 2, type: !10) 60 !14 = !DILocalVariable(name: "c", arg: 3, scope: !7, file: !1, line: 2, type: !10) 61 !15 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 3, type: !10) 62 !16 = !DILocation(line: 0, scope: !7) 63 !17 = !DILocation(line: 3, column: 22, scope: !7) 64 !18 = !DILocation(line: 3, column: 30, scope: !7) 65 !19 = !DILocation(line: 3, column: 17, scope: !7) 66 !20 = !DILocation(line: 4, column: 14, scope: !21) 67 !21 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 8) 68 !22 = !DILocation(line: 4, column: 8, scope: !7) 69 !23 = !DILocation(line: 7, column: 2, scope: !7) 70 !24 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) 71 72... 73--- 74name: fn2 75alignment: 4 76tracksRegLiveness: true 77frameInfo: 78 adjustsStack: true 79registers: 80 - { id: 0, class: gpr32, preferred-register: '' } 81 - { id: 1, class: gpr32, preferred-register: '' } 82 - { id: 2, class: gpr32, preferred-register: '' } 83 - { id: 3, class: gpr32, preferred-register: '' } 84 - { id: 4, class: gpr32, preferred-register: '' } 85 - { id: 5, class: gpr32, preferred-register: '' } 86 - { id: 6, class: gpr32, preferred-register: '' } 87 - { id: 7, class: gpr32, preferred-register: '' } 88 - { id: 8, class: gpr32, preferred-register: '' } 89liveins: 90 - { reg: '$a0', virtual-reg: '%0' } 91 - { reg: '$a1', virtual-reg: '%1' } 92 - { reg: '$a2', virtual-reg: '%2' } 93body: | 94 bb.0.entry: 95 liveins: $a0, $a1, $a2 96 97 DBG_VALUE $a0, $noreg, !12, !DIExpression(), debug-location !16 98 DBG_VALUE $a1, $noreg, !13, !DIExpression(), debug-location !16 99 DBG_VALUE $a2, $noreg, !14, !DIExpression(), debug-location !16 100 %2:gpr32 = COPY $a2 101 DBG_VALUE %2, $noreg, !14, !DIExpression(), debug-location !16 102 %8:gpr32 = COPY $a1 103 DBG_VALUE %8, $noreg, !13, !DIExpression(), debug-location !16 104 %0:gpr32 = COPY $a0 105 DBG_VALUE %0, $noreg, !12, !DIExpression(), debug-location !16 106 %3:gpr32 = nsw ADDu %8, %0, debug-location !17 107 ADJCALLSTACKDOWN 16, 0, implicit-def dead $sp, implicit $sp, debug-location !19 108 %4:gpr32 = nsw ADDiu %8, 10, debug-location !18 109 $a0 = COPY %3, debug-location !19 110 $a1 = COPY %2, debug-location !19 111 DBG_VALUE $a1, $noreg, !14, !DIExpression(), debug-location !16 112 $a2 = COPY %4, debug-location !19 113 JAL @fn1, csr_o32, implicit-def dead $ra, implicit $a0, implicit $a1, implicit $a2, implicit-def $sp, implicit-def $v0, debug-location !19 114 ADJCALLSTACKUP 16, 0, implicit-def dead $sp, implicit $sp, debug-location !19 115 %5:gpr32 = COPY killed $v0, debug-location !19 116 DBG_VALUE %5, $noreg, !15, !DIExpression(), debug-location !16 117 %6:gpr32 = SLTi %5, 11, debug-location !22 118 %7:gpr32 = nsw ADDiu %5, 10, debug-location !22 119 %8:gpr32 = MOVZ_I_I %7, %6, %8, debug-location !22 120 $v0 = COPY %8, debug-location !23 121 RetRA implicit killed $v0, debug-location !23 122 123... 124