1# RUN: llc -emit-call-site-info -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s 2 3## Compiled from source: 4## __attribute__((noinline)) 5## int foo (int x, int y, int a) { 6## int i; 7## for (i = 0; i < x * y; i++) { 8## if (i < x) { 9## a = a * x; 10## break; 11## } 12## } 13## return a; 14## } 15## Using commands: 16## $ clang -g -O1 test.c -emit-llvm -S -o test.ll 17## $ llc -emit-call-site-info -stop-after stackmap-liveness test.ll -o test.mir 18 19## Artificially added DBG_VALUE $esi, $noreg, !14, !DIExpression() into 20## for.cond Basic Block to prevent further usage of Entry Value in the loop. 21 22# CHECK: ![[ARG_Y:.*]] = !DILocalVariable(name: "y" 23# CHECK: for.cond: 24# CHECK: DBG_VALUE $esi, $noreg, ![[ARG_Y]], !DIExpression() 25# CHECK-NOT: DBG_VALUE $esi, $noreg, ![[ARG_Y]], !DIExpression(DW_OP_LLVM_entry_value, 1) 26--- | 27 ; ModuleID = 'test.ll' 28 source_filename = "test.c" 29 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 30 target triple = "x86_64-unknown-linux-gnu" 31 32 ; Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable 33 define dso_local i32 @foo(i32 %x, i32 %y, i32 %a) local_unnamed_addr !dbg !8 { 34 entry: 35 call void @llvm.dbg.value(metadata i32 %x, metadata !13, metadata !DIExpression()), !dbg !17 36 call void @llvm.dbg.value(metadata i32 %y, metadata !14, metadata !DIExpression()), !dbg !17 37 call void @llvm.dbg.value(metadata i32 %a, metadata !15, metadata !DIExpression()), !dbg !17 38 call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !17 39 %mul = mul nsw i32 %y, %x 40 call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !17 41 %cmp9 = icmp sgt i32 %mul, 0, !dbg !18 42 br i1 %cmp9, label %for.body.preheader, label %for.end, !dbg !21 43 44 for.body.preheader: ; preds = %entry 45 %0 = mul i32 %y, %x, !dbg !21 46 br label %for.body, !dbg !21 47 48 for.cond: ; preds = %for.body 49 call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !17 50 %lsr.iv.next = add i32 %lsr.iv, -1, !dbg !18 51 %exitcond.not = icmp eq i32 %lsr.iv.next, 0, !dbg !18 52 br i1 %exitcond.not, label %for.end, label %for.body, !dbg !21, !llvm.loop !22 53 54 for.body: ; preds = %for.cond, %for.body.preheader 55 %lsr.iv = phi i32 [ %lsr.iv.next, %for.cond ], [ %0, %for.body.preheader ] 56 %1 = icmp sgt i32 %x, 0 57 call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !17 58 call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !17 59 br i1 %1, label %if.then, label %for.cond, !dbg !26 60 61 if.then: ; preds = %for.body 62 %mul2 = mul nsw i32 %a, %x, !dbg !28 63 call void @llvm.dbg.value(metadata i32 %mul2, metadata !15, metadata !DIExpression()), !dbg !17 64 br label %for.end, !dbg !31 65 66 for.end: ; preds = %for.cond, %if.then, %entry 67 %a.addr.0 = phi i32 [ %mul2, %if.then ], [ %a, %entry ], [ %a, %for.cond ] 68 call void @llvm.dbg.value(metadata i32 %a.addr.0, metadata !15, metadata !DIExpression()), !dbg !17 69 ret i32 %a.addr.0, !dbg !32 70 } 71 72 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 73 declare void @llvm.dbg.value(metadata, metadata, metadata) 74 75 !llvm.dbg.cu = !{!0} 76 !llvm.module.flags = !{!3, !4, !5, !6} 77 !llvm.ident = !{!7} 78 79 !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) 80 !1 = !DIFile(filename: "test.c", directory: "/dir") 81 !2 = !{} 82 !3 = !{i32 7, !"Dwarf Version", i32 4} 83 !4 = !{i32 2, !"Debug Info Version", i32 3} 84 !5 = !{i32 1, !"wchar_size", i32 4} 85 !6 = !{i32 7, !"uwtable", i32 1} 86 !7 = !{!"clang version 13.0.0"} 87 !8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12) 88 !9 = !DISubroutineType(types: !10) 89 !10 = !{!11, !11, !11, !11} 90 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 91 !12 = !{!13, !14, !15, !16} 92 !13 = !DILocalVariable(name: "x", arg: 1, scope: !8, file: !1, line: 2, type: !11) 93 !14 = !DILocalVariable(name: "y", arg: 2, scope: !8, file: !1, line: 2, type: !11) 94 !15 = !DILocalVariable(name: "a", arg: 3, scope: !8, file: !1, line: 2, type: !11) 95 !16 = !DILocalVariable(name: "i", scope: !8, file: !1, line: 3, type: !11) 96 !17 = !DILocation(line: 0, scope: !8) 97 !18 = !DILocation(line: 4, column: 17, scope: !19) 98 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 4, column: 3) 99 !20 = distinct !DILexicalBlock(scope: !8, file: !1, line: 4, column: 3) 100 !21 = !DILocation(line: 4, column: 3, scope: !20) 101 !22 = distinct !{!22, !21, !23, !24, !25} 102 !23 = !DILocation(line: 9, column: 3, scope: !20) 103 !24 = !{!"llvm.loop.mustprogress"} 104 !25 = !{!"llvm.loop.unroll.disable"} 105 !26 = !DILocation(line: 5, column: 9, scope: !27) 106 !27 = distinct !DILexicalBlock(scope: !19, file: !1, line: 4, column: 31) 107 !28 = !DILocation(line: 6, column: 13, scope: !29) 108 !29 = distinct !DILexicalBlock(scope: !30, file: !1, line: 5, column: 16) 109 !30 = distinct !DILexicalBlock(scope: !27, file: !1, line: 5, column: 9) 110 !31 = !DILocation(line: 7, column: 7, scope: !29) 111 !32 = !DILocation(line: 10, column: 3, scope: !8) 112 113... 114--- 115name: foo 116alignment: 16 117liveins: 118 - { reg: '$edi', virtual-reg: '' } 119 - { reg: '$esi', virtual-reg: '' } 120 - { reg: '$edx', virtual-reg: '' } 121body: | 122 bb.0.entry: 123 successors: %bb.2(0x50000000), %bb.4(0x30000000) 124 liveins: $edi, $edx, $esi 125 126 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !17 127 DBG_VALUE $esi, $noreg, !14, !DIExpression(), debug-location !17 128 DBG_VALUE $edx, $noreg, !15, !DIExpression(), debug-location !17 129 $eax = MOV32rr $edx 130 DBG_VALUE 0, $noreg, !16, !DIExpression(), debug-location !17 131 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17 132 renamable $esi = nsw IMUL32rr killed renamable $esi, renamable $edi, implicit-def dead $eflags 133 TEST32rr renamable $esi, renamable $esi, implicit-def $eflags, debug-location !18 134 JCC_1 %bb.4, 14, implicit $eflags, debug-location !21 135 136 bb.2.for.body (align 16): 137 successors: %bb.3(0x04000000), %bb.1(0x7c000000) 138 liveins: $eax, $edi, $esi 139 140 TEST32rr renamable $edi, renamable $edi, implicit-def $eflags 141 DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17 142 JCC_1 %bb.3, 15, implicit $eflags, debug-location !26 143 144 bb.1.for.cond: 145 successors: %bb.4(0x04000000), %bb.2(0x7c000000) 146 liveins: $eax, $edi, $esi 147 148 DBG_VALUE $esi, $noreg, !14, !DIExpression(), debug-location !17 149 DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17 150 renamable $esi = ADD32ri8 killed renamable $esi, -1, implicit-def $eflags, debug-location !18 151 JCC_1 %bb.2, 5, implicit $eflags, debug-location !21 152 153 bb.4.for.end: 154 liveins: $eax 155 156 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17 157 RET64 $eax, debug-location !32 158 159 bb.3.if.then: 160 liveins: $eax, $edi 161 162 renamable $eax = nsw IMUL32rr killed renamable $eax, killed renamable $edi, implicit-def dead $eflags, debug-location !28 163 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17 164 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17 165 RET64 $eax, debug-location !32 166 167... 168