177 lines · plain
1# RUN: llc -run-pass=livedebugvalues -o - %s | FileCheck %s2# RUN: llc -force-instr-ref-livedebugvalues=1 -run-pass=livedebugvalues -o - %s | FileCheck %s3#4#extern void fn1 (int, int, int);5#__attribute__((noinline))6#int7#fn2 (int a, int b, int c) {8# int q = 2 + a;9# fn1 (5, 6, q);10# if (b < 17) {11# b = b + 7;12# fn1 (5, b, q);13# } else {14# b = b + 1;15# fn1 (1, b, q);16# }17# return b;18#}19# CHECK: ![[ARG_C:.*]] = !DILocalVariable(name: "c"20# CHECK: bb.0.entry:21# CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)22# CHECK: bb.1.if.then:23# CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)24# CHECK: bb.2.if.else:25# CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)26# CHECK: bb.3.if.end:27# CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)28#29--- |30 ; ModuleID = 'test.c'31 source_filename = "test.c"32 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"33 target triple = "x86_64-unknown-linux-gnu"34 35 ; Function Attrs: noinline nounwind uwtable36 define dso_local i32 @fn2(i32 %a, i32 %b, i32 %c) local_unnamed_addr !dbg !12 {37 entry:38 call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !DIExpression()), !dbg !2039 call void @llvm.dbg.value(metadata i32 %b, metadata !17, metadata !DIExpression()), !dbg !2040 call void @llvm.dbg.value(metadata i32 %c, metadata !18, metadata !DIExpression()), !dbg !2041 %add = add nsw i32 %a, 2, !dbg !2142 call void @llvm.dbg.value(metadata i32 %add, metadata !19, metadata !DIExpression()), !dbg !2043 tail call void @fn1(i32 5, i32 6, i32 %add), !dbg !2244 %cmp = icmp slt i32 %b, 17, !dbg !2345 br i1 %cmp, label %if.then, label %if.else, !dbg !2546 47 if.then: ; preds = %entry48 %add1 = add nsw i32 %b, 7, !dbg !2649 call void @llvm.dbg.value(metadata i32 %add1, metadata !17, metadata !DIExpression()), !dbg !2050 tail call void @fn1(i32 5, i32 %add1, i32 %add), !dbg !2851 br label %if.end, !dbg !2952 53 if.else: ; preds = %entry54 %add2 = add nuw nsw i32 %b, 1, !dbg !3055 call void @llvm.dbg.value(metadata i32 %add2, metadata !17, metadata !DIExpression()), !dbg !2056 tail call void @fn1(i32 1, i32 %add2, i32 %add), !dbg !3257 br label %if.end58 59 if.end: ; preds = %if.else, %if.then60 %b.addr.0 = phi i32 [ %add1, %if.then ], [ %add2, %if.else ], !dbg !3361 call void @llvm.dbg.value(metadata i32 %b.addr.0, metadata !17, metadata !DIExpression()), !dbg !2062 ret i32 %b.addr.0, !dbg !3463 }64 65 declare !dbg !4 dso_local void @fn1(i32, i32, i32) local_unnamed_addr66 67 ; Function Attrs: nounwind readnone speculatable willreturn68 declare void @llvm.dbg.value(metadata, metadata, metadata)69 70 !llvm.dbg.cu = !{!0}71 !llvm.module.flags = !{!8, !9, !10}72 !llvm.ident = !{!11}73 74 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)75 !1 = !DIFile(filename: "test.c", directory: "/")76 !2 = !{}77 !3 = !{!4}78 !4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)79 !5 = !DISubroutineType(types: !6)80 !6 = !{null, !7, !7, !7}81 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)82 !8 = !{i32 2, !"Dwarf Version", i32 4}83 !9 = !{i32 2, !"Debug Info Version", i32 3}84 !10 = !{i32 1, !"wchar_size", i32 4}85 !11 = !{!"clang version 10.0.0"}86 !12 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 5, type: !13, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)87 !13 = !DISubroutineType(types: !14)88 !14 = !{!7, !7, !7, !7}89 !15 = !{!16, !17, !18, !19}90 !16 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !1, line: 5, type: !7)91 !17 = !DILocalVariable(name: "b", arg: 2, scope: !12, file: !1, line: 5, type: !7)92 !18 = !DILocalVariable(name: "c", arg: 3, scope: !12, file: !1, line: 5, type: !7)93 !19 = !DILocalVariable(name: "q", scope: !12, file: !1, line: 7, type: !7)94 !20 = !DILocation(line: 0, scope: !12)95 !21 = !DILocation(line: 7, column: 15, scope: !12)96 !22 = !DILocation(line: 9, column: 5, scope: !12)97 !23 = !DILocation(line: 11, column: 11, scope: !24)98 !24 = distinct !DILexicalBlock(scope: !12, file: !1, line: 11, column: 9)99 !25 = !DILocation(line: 11, column: 9, scope: !12)100 !26 = !DILocation(line: 12, column: 13, scope: !27)101 !27 = distinct !DILexicalBlock(scope: !24, file: !1, line: 11, column: 17)102 !28 = !DILocation(line: 13, column: 8, scope: !27)103 !29 = !DILocation(line: 14, column: 5, scope: !27)104 !30 = !DILocation(line: 15, column: 13, scope: !31)105 !31 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 12)106 !32 = !DILocation(line: 16, column: 7, scope: !31)107 !33 = !DILocation(line: 0, scope: !24)108 !34 = !DILocation(line: 19, column: 5, scope: !12)109 110...111---112name: fn2113alignment: 16114body: |115 bb.0.entry:116 successors: %bb.1(0x40000000), %bb.2(0x40000000)117 liveins: $edi, $esi, $rbp, $rbx118 119 DBG_VALUE $edi, $noreg, !16, !DIExpression(), debug-location !20120 DBG_VALUE $esi, $noreg, !17, !DIExpression(), debug-location !20121 DBG_VALUE $edx, $noreg, !18, !DIExpression(), debug-location !20122 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp123 CFI_INSTRUCTION def_cfa_offset 16124 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp125 CFI_INSTRUCTION def_cfa_offset 24126 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp127 CFI_INSTRUCTION def_cfa_offset 32128 CFI_INSTRUCTION offset $rbx, -24129 CFI_INSTRUCTION offset $rbp, -16130 $ebx = MOV32rr $esi131 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20132 $ebp = MOV32rr $edi133 DBG_VALUE $ebp, $noreg, !16, !DIExpression(), debug-location !20134 renamable $ebp = nsw ADD32ri8 killed renamable $ebp, 2, implicit-def dead $eflags, debug-location !21135 DBG_VALUE $ebp, $noreg, !19, !DIExpression(), debug-location !20136 $edi = MOV32ri 5, debug-location !22137 $esi = MOV32ri 6, debug-location !22138 $edx = MOV32rr $ebp, debug-location !22139 CALL64pcrel32 @fn1, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit killed $edx, implicit-def $rsp, implicit-def $ssp, debug-location !22140 CMP32ri8 renamable $ebx, 16, implicit-def $eflags, debug-location !23141 JCC_1 %bb.2, 15, implicit killed $eflags, debug-location !25142 143 bb.1.if.then:144 successors: %bb.3(0x80000000)145 liveins: $ebp, $ebx146 147 renamable $ebx = nsw ADD32ri8 killed renamable $ebx, 7, implicit-def dead $eflags, debug-location !26148 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20149 $edi = MOV32ri 5, debug-location !28150 JMP_1 %bb.3151 152 bb.2.if.else:153 successors: %bb.3(0x80000000)154 liveins: $ebp, $ebx155 156 renamable $ebx = nuw nsw ADD32ri8 killed renamable $ebx, 1, implicit-def dead $eflags, debug-location !30157 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20158 $edi = MOV32ri 1, debug-location !32159 160 bb.3.if.end:161 liveins: $ebx, $edi, $ebp162 163 $esi = MOV32rr $ebx, debug-location !33164 $edx = MOV32rr killed $ebp, debug-location !33165 CALL64pcrel32 @fn1, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit killed $edx, implicit-def $rsp, implicit-def $ssp, debug-location !33166 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20167 $eax = MOV32rr killed $ebx, debug-location !34168 $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !34169 CFI_INSTRUCTION def_cfa_offset 24, debug-location !34170 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34171 CFI_INSTRUCTION def_cfa_offset 16, debug-location !34172 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34173 CFI_INSTRUCTION def_cfa_offset 8, debug-location !34174 RET64 killed $eax, debug-location !34175 176...177