168 lines · plain
1# RUN: llc -emit-call-site-info -run-pass=livedebugvalues -o - %s | FileCheck %s2 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.ll17## $ llc -emit-call-site-info -stop-after stackmap-liveness test.ll -o test.mir18 19## Artificially added DBG_VALUE $esi, $noreg, !14, !DIExpression() into20## 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 uwtable33 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 !1736 call void @llvm.dbg.value(metadata i32 %y, metadata !14, metadata !DIExpression()), !dbg !1737 call void @llvm.dbg.value(metadata i32 %a, metadata !15, metadata !DIExpression()), !dbg !1738 call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !1739 %mul = mul nsw i32 %y, %x40 call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !1741 %cmp9 = icmp sgt i32 %mul, 0, !dbg !1842 br i1 %cmp9, label %for.body.preheader, label %for.end, !dbg !2143 44 for.body.preheader: ; preds = %entry45 %0 = mul i32 %y, %x, !dbg !2146 br label %for.body, !dbg !2147 48 for.cond: ; preds = %for.body49 call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !1750 %lsr.iv.next = add i32 %lsr.iv, -1, !dbg !1851 %exitcond.not = icmp eq i32 %lsr.iv.next, 0, !dbg !1852 br i1 %exitcond.not, label %for.end, label %for.body, !dbg !21, !llvm.loop !2253 54 for.body: ; preds = %for.cond, %for.body.preheader55 %lsr.iv = phi i32 [ %lsr.iv.next, %for.cond ], [ %0, %for.body.preheader ]56 %1 = icmp sgt i32 %x, 057 call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !1758 call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !1759 br i1 %1, label %if.then, label %for.cond, !dbg !2660 61 if.then: ; preds = %for.body62 %mul2 = mul nsw i32 %a, %x, !dbg !2863 call void @llvm.dbg.value(metadata i32 %mul2, metadata !15, metadata !DIExpression()), !dbg !1764 br label %for.end, !dbg !3165 66 for.end: ; preds = %for.cond, %if.then, %entry67 %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 !1769 ret i32 %a.addr.0, !dbg !3270 }71 72 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn73 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: foo116alignment: 16117liveins: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, $esi125 126 DBG_VALUE $edi, $noreg, !13, !DIExpression(), debug-location !17127 DBG_VALUE $esi, $noreg, !14, !DIExpression(), debug-location !17128 DBG_VALUE $edx, $noreg, !15, !DIExpression(), debug-location !17129 $eax = MOV32rr $edx130 DBG_VALUE 0, $noreg, !16, !DIExpression(), debug-location !17131 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17132 renamable $esi = nsw IMUL32rr killed renamable $esi, renamable $edi, implicit-def dead $eflags133 TEST32rr renamable $esi, renamable $esi, implicit-def $eflags, debug-location !18134 JCC_1 %bb.4, 14, implicit $eflags, debug-location !21135 136 bb.2.for.body (align 16):137 successors: %bb.3(0x04000000), %bb.1(0x7c000000)138 liveins: $eax, $edi, $esi139 140 TEST32rr renamable $edi, renamable $edi, implicit-def $eflags141 DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17142 JCC_1 %bb.3, 15, implicit $eflags, debug-location !26143 144 bb.1.for.cond:145 successors: %bb.4(0x04000000), %bb.2(0x7c000000)146 liveins: $eax, $edi, $esi147 148 DBG_VALUE $esi, $noreg, !14, !DIExpression(), debug-location !17149 DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !17150 renamable $esi = ADD32ri8 killed renamable $esi, -1, implicit-def $eflags, debug-location !18151 JCC_1 %bb.2, 5, implicit $eflags, debug-location !21152 153 bb.4.for.end:154 liveins: $eax155 156 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17157 RET64 $eax, debug-location !32158 159 bb.3.if.then:160 liveins: $eax, $edi161 162 renamable $eax = nsw IMUL32rr killed renamable $eax, killed renamable $edi, implicit-def dead $eflags, debug-location !28163 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17164 DBG_VALUE $eax, $noreg, !15, !DIExpression(), debug-location !17165 RET64 $eax, debug-location !32166 167...168