164 lines · plain
1# RUN: llc %s -o - -mtriple=x86_64-unknown-unknown \2# RUN: -experimental-debug-variable-locations \3# RUN: -start-before=phi-node-elimination \4# RUN: -stop-after=register-coalescer \5# RUN: | FileCheck %s --check-prefix=DOESCOALESCE6# RUN: llc %s -o - -mtriple=x86_64-unknown-unknown \7# RUN: -experimental-debug-variable-locations \8# RUN: -start-before=phi-node-elimination \9# RUN: -stop-after=virtregrewriter \10# RUN: | FileCheck %s --check-prefix=CHECK11#12# This is a sibling-test for phi-coalescing.mir, using similar code but where13# registers are coalesced across subregisters. Specifically, vreg %2 below is14# a 16-bit register, but will be coalesced into the lower 16 bits of a 32 bit15# vreg during coalescing. We should survive this transformation, and emit a16# DBG_PHI for $bx where the PHI was.17--- |18 ; ModuleID = 'promoted.ll'19 source_filename = "test.c"20 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"21 target triple = "x86_64-unknown-linux-gnu"22 23 ; Function Attrs: noinline nounwind uwtable24 define dso_local i32 @foo(i16 signext %bar, i16 signext %baz) !dbg !7 {25 entry:26 call void @llvm.dbg.value(metadata i16 %bar, metadata !12, metadata !DIExpression()), !dbg !1327 call void @llvm.dbg.value(metadata i16 %baz, metadata !14, metadata !DIExpression()), !dbg !1328 call void @ext(i16 signext %bar), !dbg !1329 %conv = sext i16 %bar to i32, !dbg !1330 %add = add nsw i32 %conv, 12, !dbg !1331 %conv1 = trunc i32 %add to i16, !dbg !1332 call void @llvm.dbg.value(metadata i16 %conv1, metadata !12, metadata !DIExpression()), !dbg !1333 call void @ext(i16 signext %conv1), !dbg !1334 %call = call signext i16 @getlong(), !dbg !1335 %tobool = icmp ne i16 %call, 0, !dbg !1336 br i1 %tobool, label %if.then, label %if.end, !dbg !1337 38 if.then: ; preds = %entry39 %conv2 = sext i16 %conv1 to i32, !dbg !1340 %add3 = add nsw i32 %conv2, 1, !dbg !1341 %conv4 = trunc i32 %add3 to i16, !dbg !1342 call void @llvm.dbg.value(metadata i16 %conv4, metadata !12, metadata !DIExpression()), !dbg !1343 br label %if.end, !dbg !1344 45 if.end: ; preds = %if.then, %entry46 %bar.addr.0 = phi i16 [ %conv4, %if.then ], [ %conv1, %entry ], !dbg !1347 call void @llvm.dbg.value(metadata i16 %bar.addr.0, metadata !12, metadata !DIExpression()), !dbg !1348 %conv5 = sext i16 %baz to i32, !dbg !1349 %conv6 = sext i16 %bar.addr.0 to i32, !dbg !1350 %add7 = add nsw i32 %conv6, %conv5, !dbg !1351 %conv8 = trunc i32 %add7 to i16, !dbg !1352 call void @llvm.dbg.value(metadata i16 %conv8, metadata !12, metadata !DIExpression()), !dbg !1353 call void @ext(i16 signext %conv8), !dbg !1354 %conv9 = sext i16 %conv8 to i32, !dbg !1355 ret i32 %conv9, !dbg !1356 }57 58 ; Function Attrs: nounwind readnone speculatable willreturn59 declare void @llvm.dbg.declare(metadata, metadata, metadata)60 61 declare dso_local void @ext(i16 signext)62 63 declare dso_local signext i16 @getlong()64 65 ; Function Attrs: nounwind readnone speculatable willreturn66 declare void @llvm.dbg.value(metadata, metadata, metadata)67 68 !llvm.dbg.cu = !{!0}69 !llvm.module.flags = !{!3, !4, !5}70 !llvm.ident = !{!6}71 72 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0 (git@github.com:llvm/llvm-project 79a35789efdf2378f97642ae4a5f3099b9087a11)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)73 !1 = !DIFile(filename: "test.c", directory: "/fast/fs/llvm3/llvm/test/DebugInfo/MIR/InstrRef")74 !2 = !{}75 !3 = !{i32 7, !"Dwarf Version", i32 4}76 !4 = !{i32 2, !"Debug Info Version", i32 3}77 !5 = !{i32 1, !"wchar_size", i32 4}78 !6 = !{!"clang version 12.0.0 (git@github.com:llvm/llvm-project 79a35789efdf2378f97642ae4a5f3099b9087a11)"}79 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)80 !8 = !DISubroutineType(types: !9)81 !9 = !{!10, !11, !11}82 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)83 !11 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)84 !12 = !DILocalVariable(name: "bar", arg: 1, scope: !7, file: !1, line: 3, type: !11)85 !13 = !DILocation(line: 0, scope: !7)86 !14 = !DILocalVariable(name: "baz", arg: 2, scope: !7, file: !1, line: 3, type: !11)87 !15 = distinct !DILexicalBlock(scope: !7, file: !1, line: 8, column: 7)88 89...90---91name: foo92alignment: 1693tracksRegLiveness: true94debugInstrRef: true95liveins:96 - { reg: '$edi', virtual-reg: '%3' }97 - { reg: '$esi', virtual-reg: '%4' }98frameInfo:99 maxAlignment: 1100 adjustsStack: true101 hasCalls: true102machineFunctionInfo: {}103body: |104 bb.0.entry:105 liveins: $edi, $esi106 107 %4:gr32 = COPY $esi108 %3:gr32 = COPY $edi109 %6:gr16 = COPY %4.sub_16bit110 %5:gr16 = COPY %3.sub_16bit111 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13112 %15:gr32 = MOVSX32rr16 %5, debug-location !13113 $edi = COPY %15, debug-location !13114 CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $edi, debug-location !13115 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13116 %14:gr32 = MOVSX32rr16 %5, debug-location !13117 %13:gr32 = ADD32ri8 killed %14, 12, implicit-def $eflags, debug-location !13118 %11:gr16 = COPY killed %13.sub_16bit, debug-location !13119 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13120 %9:gr32 = MOVSX32rr16 %11, debug-location !13121 $edi = COPY %9, debug-location !13122 CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $edi, debug-location !13123 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13124 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13125 CALL64pcrel32 @getlong, csr_64, implicit $rsp, implicit $ssp, implicit-def $ax, debug-location !13126 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13127 %8:gr16 = COPY $ax, debug-location !13128 CMP16ri8 %8, 0, implicit-def $eflags, debug-location !13129 JCC_1 %bb.2, 4, implicit $eflags, debug-location !13130 131 ; DOESCOALESCE-LABEL: bb.1.if.then:132 ; CHECK-LABEL: bb.1.if.then:133 bb.1.if.then:134 %20:gr32 = MOVSX32rr16 %11, debug-location !13135 %19:gr32 = ADD32ri8 killed %20, 1, implicit-def $eflags, debug-location !13136 %17:gr16 = COPY killed %19.sub_16bit, debug-location !13137 138 ; Verify that vreg 17 is coalesced into a gr32, and not copied any further.139 ; DOESCOALESCE: %{{[0-9]+}}:gr32 = ADD32ri8140 ; DOESCOALESCE-NOT: COPY141 ; Verify those registers land in $bx142 ; CHECK: renamable $ebp = ADD32ri8143 144 ; DOESCOALESCE-LABEL: bb.2.if.end:145 ; CHECK-LABEL: bb.2.if.end:146 bb.2.if.end:147 %2:gr16 = PHI %11, %bb.0, %17, %bb.1, debug-instr-number 1, debug-location !13148 ; CHECK: DBG_PHI $bp, 1149 DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !13150 %31:gr32 = MOVSX32rr16 %6, debug-location !13151 %30:gr32 = MOVSX32rr16 killed %2, debug-location !13152 %29:gr32 = ADD32rr killed %30, killed %31, implicit-def $eflags, debug-location !13153 %26:gr16 = COPY killed %29.sub_16bit, debug-location !13154 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13155 %24:gr32 = MOVSX32rr16 %26, debug-location !13156 $edi = COPY %24, debug-location !13157 CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $edi, debug-location !13158 ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp, debug-location !13159 %23:gr32 = MOVSX32rr16 %26, debug-location !13160 $eax = COPY %23, debug-location !13161 RET64 implicit $eax, debug-location !13162 163...164