188 lines · plain
1# RUN: llc -debug-entry-values -run-pass=livedebugvalues -o - %s -experimental-debug-variable-locations=false | FileCheck %s --check-prefixes=CHECK,VARLOCLDV2#3# The test case was artificially adjusted, in order to make proper diamond basic4# block structure relevant to the debug entry values clobbering.5#6# CHECK: ![[ARG_B:.*]] = !DILocalVariable(name: "b"7# CHECK: bb.0.entry8# CHECK: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression()9# CHECK: bb.1.if.then10# CHECK: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression()11# CHECK: $ebx = MOV32rr $esi12# CHECK-NEXT: DBG_VALUE $ebx, $noreg, ![[ARG_B]], !DIExpression()13# CHECK-NEXT: $esi = MOV32ri 514# CHECK-NEXT: $ebx = MOV32ri 115# CHECK-NEXT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)16# CHECK: bb.2.if.else17# CHECK: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression()18# CHECK: $ebp = MOV32rr $esi19# CHECK: DBG_VALUE $ebp, $noreg, ![[ARG_B]], !DIExpression()20# CHECK-NEXT: $esi = MOV32ri 121# CHECK-NEXT: $ebp = MOV32ri 222# CHECK-NEXT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)23# CHECK: bb.3.if.end24# VARLOCLDV-NOT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)25#26## Final two lines: VarLoc LiveDebugValues cannot determine that the DBG_VALUEs27## down either path of the diamond set the variable to be its original value,28## wheras instruction referencing LiveDebugValues can.29##30## An identical test in llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir31## checks this for InstrRefBasedLDV.32#33--- |34 ; ModuleID = 'test.c'35 source_filename = "test.c"36 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"37 target triple = "x86_64-unknown-linux-gnu"38 39 ; Function Attrs: noinline nounwind uwtable40 define dso_local i32 @fn2(i32 %a, i32 %b, i32 %c) local_unnamed_addr !dbg !12 {41 entry:42 call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !DIExpression()), !dbg !2043 call void @llvm.dbg.value(metadata i32 %b, metadata !17, metadata !DIExpression()), !dbg !2044 call void @llvm.dbg.value(metadata i32 %c, metadata !18, metadata !DIExpression()), !dbg !2045 %add = add nsw i32 %a, 2, !dbg !2146 call void @llvm.dbg.value(metadata i32 %add, metadata !19, metadata !DIExpression()), !dbg !2047 tail call void @fn1(i32 5, i32 6, i32 %add), !dbg !2248 %cmp = icmp slt i32 %b, 17, !dbg !2349 br i1 %cmp, label %if.then, label %if.else, !dbg !2550 51 if.then: ; preds = %entry52 %add1 = add nsw i32 %b, 7, !dbg !2653 call void @llvm.dbg.value(metadata i32 %add1, metadata !17, metadata !DIExpression()), !dbg !2054 tail call void @fn1(i32 5, i32 %add1, i32 %c), !dbg !2855 br label %if.end, !dbg !2956 57 if.else: ; preds = %entry58 %add2 = add nuw nsw i32 %b, 1, !dbg !3059 call void @llvm.dbg.value(metadata i32 %add2, metadata !17, metadata !DIExpression()), !dbg !2060 tail call void @fn1(i32 1, i32 %add2, i32 %c), !dbg !3261 br label %if.end62 63 if.end: ; preds = %if.else, %if.then64 %b.addr.0 = phi i32 [ %add1, %if.then ], [ %add2, %if.else ], !dbg !3365 call void @llvm.dbg.value(metadata i32 %b.addr.0, metadata !17, metadata !DIExpression()), !dbg !2066 ret i32 %b.addr.0, !dbg !3467 }68 69 declare !dbg !4 dso_local void @fn1(i32, i32, i32) local_unnamed_addr70 71 ; Function Attrs: nounwind readnone speculatable willreturn72 declare void @llvm.dbg.value(metadata, metadata, metadata)73 74 !llvm.dbg.cu = !{!0}75 !llvm.module.flags = !{!8, !9, !10}76 !llvm.ident = !{!11}77 78 !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)79 !1 = !DIFile(filename: "test.c", directory: "/dir")80 !2 = !{}81 !3 = !{!4}82 !4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)83 !5 = !DISubroutineType(types: !6)84 !6 = !{null, !7, !7, !7}85 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)86 !8 = !{i32 2, !"Dwarf Version", i32 4}87 !9 = !{i32 2, !"Debug Info Version", i32 3}88 !10 = !{i32 1, !"wchar_size", i32 4}89 !11 = !{!"clang version 10.0.0"}90 !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)91 !13 = !DISubroutineType(types: !14)92 !14 = !{!7, !7, !7, !7}93 !15 = !{!16, !17, !18, !19}94 !16 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !1, line: 5, type: !7)95 !17 = !DILocalVariable(name: "b", arg: 2, scope: !12, file: !1, line: 5, type: !7)96 !18 = !DILocalVariable(name: "c", arg: 3, scope: !12, file: !1, line: 5, type: !7)97 !19 = !DILocalVariable(name: "q", scope: !12, file: !1, line: 7, type: !7)98 !20 = !DILocation(line: 0, scope: !12)99 !21 = !DILocation(line: 7, column: 15, scope: !12)100 !22 = !DILocation(line: 9, column: 5, scope: !12)101 !23 = !DILocation(line: 11, column: 11, scope: !24)102 !24 = distinct !DILexicalBlock(scope: !12, file: !1, line: 11, column: 9)103 !25 = !DILocation(line: 11, column: 9, scope: !12)104 !26 = !DILocation(line: 12, column: 13, scope: !27)105 !27 = distinct !DILexicalBlock(scope: !24, file: !1, line: 11, column: 17)106 !28 = !DILocation(line: 13, column: 8, scope: !27)107 !29 = !DILocation(line: 14, column: 5, scope: !27)108 !30 = !DILocation(line: 15, column: 13, scope: !31)109 !31 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 12)110 !32 = !DILocation(line: 16, column: 7, scope: !31)111 !33 = !DILocation(line: 0, scope: !24)112 !34 = !DILocation(line: 19, column: 5, scope: !12)113 114...115---116name: fn2117alignment: 16118fixedStack:119 - { id: 0, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,120 callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',121 debug-info-expression: '', debug-info-location: '' }122 - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,123 callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',124 debug-info-expression: '', debug-info-location: '' }125body: |126 bb.0.entry:127 successors: %bb.1(0x40000000), %bb.2(0x40000000)128 liveins: $edi, $edx, $esi, $rbp, $rbx129 130 DBG_VALUE $edi, $noreg, !16, !DIExpression(), debug-location !20131 DBG_VALUE $esi, $noreg, !17, !DIExpression(), debug-location !20132 DBG_VALUE $edx, $noreg, !18, !DIExpression(), debug-location !20133 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp134 CFI_INSTRUCTION def_cfa_offset 16135 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp136 CFI_INSTRUCTION def_cfa_offset 24137 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp138 CFI_INSTRUCTION def_cfa_offset 32139 CFI_INSTRUCTION offset $rbx, -24140 CFI_INSTRUCTION offset $rbp, -16141 $ebp = MOV32rr $edx142 DBG_VALUE $ebp, $noreg, !18, !DIExpression(), debug-location !20143 renamable $edi = KILL $edi, implicit-def $rdi144 DBG_VALUE $edi, $noreg, !16, !DIExpression(), debug-location !20145 renamable $edx = LEA64_32r killed renamable $rdi, 1, $noreg, 2, $noreg, debug-location !21146 DBG_VALUE $edx, $noreg, !19, !DIExpression(), debug-location !20147 $edi = MOV32ri 5, debug-location !22148 CMP32ri8 renamable $ebp, 16, implicit-def $eflags, debug-location !23149 JCC_1 %bb.2, 15, implicit killed $eflags, debug-location !25150 151 bb.1.if.then:152 successors: %bb.3(0x80000000)153 liveins: $ebp, $ebx, $esi154 155 $ebx = MOV32rr $esi156 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20157 $esi = MOV32ri 5, debug-location !28158 $ebx = MOV32ri 1159 JMP_1 %bb.3160 161 bb.2.if.else:162 successors: %bb.3(0x80000000)163 liveins: $ebp, $ebx, $esi164 165 $ebp = MOV32rr $esi166 DBG_VALUE $ebp, $noreg, !17, !DIExpression(), debug-location !20167 $esi = MOV32ri 1, debug-location !32168 $ebp = MOV32ri 2169 170 bb.3.if.end:171 liveins: $ebx, $edi, $ebp172 173 $esi = MOV32rr $ebx, debug-location !33174 $edx = MOV32rr killed $ebp, debug-location !33175 CALL64pcrel32 @fn1, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $edx, implicit-def $rsp, implicit-def $ssp, debug-location !33176 DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20177 $eax = MOV32rr killed $ebx, debug-location !34178 $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !34179 CFI_INSTRUCTION def_cfa_offset 24, debug-location !34180 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34181 CFI_INSTRUCTION def_cfa_offset 16, debug-location !34182 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34183 CFI_INSTRUCTION def_cfa_offset 8, debug-location !34184 RET64 killed $eax, debug-location !34185 186...187 188