140 lines · plain
1# RUN: llc -start-after=phi-node-elimination -stop-after=virtregrewriter %s -mtriple=x86_64-unknown-unknown -o - -experimental-debug-variable-locations=false | FileCheck %s2#3# Test that when a livedebugvars interval crosses a basic block boundary,4# DBG_VALUEs are created in each covered basic block. In the IR below, control5# flow moves from the bottom upwards, and the DBG_VALUEs from the entry block6# to bb.1 become a single range. Check that they're transformed back into two7# DBG_VALUEs after regalloc.8 9# These checks look at the entry and bb.1 blocks, and ensure that there is a10# DBG_VALUE in each.11 12# CHECK: ![[VARNUM:[0-9]+]] = !DILocalVariable(name: "b",13# CHECK-LABEL: name: bar14# CHECK-LABEL: bb.0.entry:15# CHECK: DBG_VALUE $[[SOMEREG:[a-z]+]], $noreg, ![[VARNUM]], !DIExpression()16# CHECK-NEXT: JMP_1 %bb.317# CHECK-LABEL: bb.1.bb1:18# CHECK: DBG_VALUE $[[SOMEREG]], $noreg, ![[VARNUM]], !DIExpression()19# CHECK-NEXT: JMP_1 %bb.420 21--- |22 ; ModuleID = 'tmp.ll'23 source_filename = "tmp.ll"24 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"25 26 %struct.a = type { i32 }27 28 ; Function Attrs: nounwind ssp29 define i32 @bar(ptr nocapture %b, i32 %shoes) !dbg !4 {30 entry:31 tail call void @llvm.dbg.value(metadata i32 %shoes, metadata !9, metadata !DIExpression()), !dbg !1632 %tmp1 = getelementptr inbounds %struct.a, ptr %b, i64 0, i32 0, !dbg !1733 br label %bb334 35 bb1: ; preds = %bb236 tail call void @llvm.dbg.value(metadata i32 %shoes, metadata !9, metadata !DIExpression()), !dbg !1637 %add = add nsw i32 %tmp2, 1, !dbg !1838 br label %exit39 40 bb2: ; preds = %bb341 tail call void @llvm.dbg.value(metadata i32 %tmp2, metadata !14, metadata !DIExpression()), !dbg !1742 %call = tail call i32 (...) @foo(i32 %tmp2), !dbg !1943 br label %bb144 45 bb3: ; preds = %entry46 %tmp2 = load i32, ptr %tmp1, align 4, !dbg !1747 br label %bb248 49 exit: ; preds = %bb150 ret i32 %shoes, !dbg !1851 }52 53 declare i32 @foo(...)54 55 ; Function Attrs: nounwind readnone speculatable willreturn56 declare void @llvm.dbg.value(metadata, metadata, metadata)57 58 ; Function Attrs: nounwind59 declare void @llvm.stackprotector(ptr, ptr)60 61 !llvm.dbg.cu = !{!0}62 !llvm.module.flags = !{!3}63 64 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 2.9 (trunk 122997)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)65 !1 = !DIFile(filename: "bar.c", directory: "/private/tmp")66 !2 = !{}67 !3 = !{i32 1, !"Debug Info Version", i32 3}68 !4 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !5, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)69 !5 = !DISubroutineType(types: !6)70 !6 = !{!7}71 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)72 !8 = !{!9, !14}73 !9 = !DILocalVariable(name: "b", arg: 1, scope: !4, file: !1, line: 5, type: !10)74 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !0, baseType: !11, size: 64, align: 64)75 !11 = !DICompositeType(tag: DW_TAG_structure_type, name: "a", scope: !0, file: !1, line: 1, size: 32, align: 32, elements: !12)76 !12 = !{!13}77 !13 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !1, file: !1, line: 2, baseType: !7, size: 32, align: 32)78 !14 = !DILocalVariable(name: "x", scope: !15, file: !1, line: 6, type: !7)79 !15 = distinct !DILexicalBlock(scope: !4, file: !1, line: 5, column: 22)80 !16 = !DILocation(line: 5, column: 19, scope: !4)81 !17 = !DILocation(line: 6, column: 14, scope: !15)82 !18 = !DILocation(line: 8, column: 2, scope: !15)83 !19 = !DILocation(line: 7, column: 2, scope: !15)84 85...86---87name: bar88alignment: 1689tracksRegLiveness: true90registers:91 - { id: 0, class: gr64 }92 - { id: 1, class: gr32 }93 - { id: 2, class: gr64 }94 - { id: 3, class: gr64 }95 - { id: 4, class: gr32 }96 - { id: 5, class: gr32 }97 - { id: 6, class: gr32 }98 - { id: 7, class: gr32 }99liveins:100 - { reg: '$rdi', virtual-reg: '%2' }101 - { reg: '$esi', virtual-reg: '%4' }102frameInfo:103 adjustsStack: true104 hasCalls: true105machineFunctionInfo: {}106body: |107 bb.0.entry:108 liveins: $rdi, $esi109 110 %4:gr32 = COPY $esi111 %2:gr64 = COPY $rdi112 %3:gr64 = COPY killed %2113 %5:gr32 = COPY killed %4114 DBG_VALUE %5, $noreg, !9, !DIExpression(), debug-location !16115 JMP_1 %bb.3116 117 bb.1.bb1:118 DBG_VALUE %5, $noreg, !9, !DIExpression(), debug-location !16119 JMP_1 %bb.4120 121 bb.2.bb2:122 DBG_VALUE %6, $noreg, !14, !DIExpression(), debug-location !17123 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19124 $edi = COPY %6, debug-location !19125 $al = MOV8ri 0, debug-location !19126 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit $edi, implicit-def $eax, debug-location !19127 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !19128 %7:gr32 = COPY $eax, debug-location !19129 JMP_1 %bb.1130 131 bb.3.bb3:132 %6:gr32 = MOV32rm %3, 1, $noreg, 0, $noreg, debug-location !17 :: (load (s32) from %ir.tmp1)133 JMP_1 %bb.2134 135 bb.4.exit:136 $eax = COPY %5, debug-location !18137 RET64 implicit $eax, debug-location !18138 139...140