251 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 52; RUN: llc -max-registers-for-gc-values=256 -verify-machineinstrs -stop-after twoaddressinstruction < %s | FileCheck --check-prefix=CHECK-LV %s3; RUN: llc -max-registers-for-gc-values=256 -verify-machineinstrs -stop-after twoaddressinstruction -early-live-intervals < %s | FileCheck --check-prefix=CHECK-LIS %s4 5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"6target triple = "x86_64-unknown-linux-gnu"7 8declare void @foo() gc "statepoint-example"9declare void @bar(ptr addrspace(1)) gc "statepoint-example"10 11declare ptr @fake_personality_function()12 13; Simplest possible test demonstrating the problem14define void @test(ptr addrspace(1) %a) gc "statepoint-example" {15 ; CHECK-LV-LABEL: name: test16 ; CHECK-LV: bb.0.entry:17 ; CHECK-LV-NEXT: successors: %bb.2(0x30000000), %bb.1(0x50000000)18 ; CHECK-LV-NEXT: liveins: $rdi19 ; CHECK-LV-NEXT: {{ $}}20 ; CHECK-LV-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY killed $rdi21 ; CHECK-LV-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp22 ; CHECK-LV-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY [[COPY]]23 ; CHECK-LV-NEXT: [[COPY1:%[0-9]+]]:gr64 = STATEPOINT 2, 5, 0, undef %2:gr64, 2, 0, 2, 0, 2, 0, 2, 1, [[COPY1]](tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp24 ; CHECK-LV-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp25 ; CHECK-LV-NEXT: TEST64rr killed [[COPY]], [[COPY]], implicit-def $eflags26 ; CHECK-LV-NEXT: JCC_1 %bb.2, 4, implicit killed $eflags27 ; CHECK-LV-NEXT: JMP_1 %bb.128 ; CHECK-LV-NEXT: {{ $}}29 ; CHECK-LV-NEXT: bb.1.not_zero:30 ; CHECK-LV-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp31 ; CHECK-LV-NEXT: $rdi = COPY killed [[COPY1]]32 ; CHECK-LV-NEXT: STATEPOINT 2, 5, 1, undef %3:gr64, killed $rdi, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, csr_64, implicit-def $rsp, implicit-def $ssp33 ; CHECK-LV-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp34 ; CHECK-LV-NEXT: RET 035 ; CHECK-LV-NEXT: {{ $}}36 ; CHECK-LV-NEXT: bb.2.zero:37 ; CHECK-LV-NEXT: RET 038 ;39 ; CHECK-LIS-LABEL: name: test40 ; CHECK-LIS: bb.0.entry:41 ; CHECK-LIS-NEXT: successors: %bb.2(0x30000000), %bb.1(0x50000000)42 ; CHECK-LIS-NEXT: liveins: $rdi43 ; CHECK-LIS-NEXT: {{ $}}44 ; CHECK-LIS-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rdi45 ; CHECK-LIS-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp46 ; CHECK-LIS-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY [[COPY]]47 ; CHECK-LIS-NEXT: [[COPY1:%[0-9]+]]:gr64 = STATEPOINT 2, 5, 0, undef %2:gr64, 2, 0, 2, 0, 2, 0, 2, 1, [[COPY1]](tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp48 ; CHECK-LIS-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp49 ; CHECK-LIS-NEXT: TEST64rr [[COPY]], [[COPY]], implicit-def $eflags50 ; CHECK-LIS-NEXT: JCC_1 %bb.2, 4, implicit killed $eflags51 ; CHECK-LIS-NEXT: JMP_1 %bb.152 ; CHECK-LIS-NEXT: {{ $}}53 ; CHECK-LIS-NEXT: bb.1.not_zero:54 ; CHECK-LIS-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp55 ; CHECK-LIS-NEXT: $rdi = COPY [[COPY1]]56 ; CHECK-LIS-NEXT: STATEPOINT 2, 5, 1, undef %3:gr64, $rdi, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, csr_64, implicit-def $rsp, implicit-def $ssp57 ; CHECK-LIS-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp58 ; CHECK-LIS-NEXT: RET 059 ; CHECK-LIS-NEXT: {{ $}}60 ; CHECK-LIS-NEXT: bb.2.zero:61 ; CHECK-LIS-NEXT: RET 062entry:63 %not7 = icmp eq ptr addrspace(1) %a, null64 %statepoint_token1745 = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2, i32 5, ptr nonnull elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) %a) ]65 br i1 %not7, label %zero, label %not_zero66 67not_zero:68 %a.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %statepoint_token1745, i32 0, i32 0) ; (%a, %a)69 %statepoint_token1752 = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2, i32 5, ptr nonnull elementtype(void (ptr addrspace(1))) @bar, i32 1, i32 0, ptr addrspace(1) %a.relocated, i32 0, i32 0) [ "deopt"(), "gc-live"() ]70 ret void71 72zero:73 ret void74}75 76; A bit more complex test, where both registers are used in same successor BB77define void @test2(ptr addrspace(1) %this, i32 %0, ptr addrspace(1) %p0, ptr addrspace(1) %p1) gc "statepoint-example" personality ptr @fake_personality_function {78 ; CHECK-LV-LABEL: name: test279 ; CHECK-LV: bb.0.preheader:80 ; CHECK-LV-NEXT: successors: %bb.1(0x80000000)81 ; CHECK-LV-NEXT: liveins: $rdx, $rcx82 ; CHECK-LV-NEXT: {{ $}}83 ; CHECK-LV-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY killed $rcx84 ; CHECK-LV-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY killed $rdx85 ; CHECK-LV-NEXT: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def dead $eflags86 ; CHECK-LV-NEXT: [[COPY2:%[0-9]+]]:gr64 = COPY killed [[COPY1]]87 ; CHECK-LV-NEXT: [[COPY3:%[0-9]+]]:gr64 = COPY killed [[COPY]]88 ; CHECK-LV-NEXT: {{ $}}89 ; CHECK-LV-NEXT: bb.1.loop.head:90 ; CHECK-LV-NEXT: successors: %bb.6(0x04000000), %bb.2(0x7c000000)91 ; CHECK-LV-NEXT: {{ $}}92 ; CHECK-LV-NEXT: [[COPY4:%[0-9]+]]:gr64 = COPY killed [[COPY3]]93 ; CHECK-LV-NEXT: [[COPY5:%[0-9]+]]:gr64 = COPY killed [[COPY2]]94 ; CHECK-LV-NEXT: TEST64rr killed [[COPY5]], [[COPY5]], implicit-def $eflags95 ; CHECK-LV-NEXT: JCC_1 %bb.6, 5, implicit killed $eflags96 ; CHECK-LV-NEXT: JMP_1 %bb.297 ; CHECK-LV-NEXT: {{ $}}98 ; CHECK-LV-NEXT: bb.2.BB3:99 ; CHECK-LV-NEXT: successors: %bb.3(0x7ffff800), %bb.7(0x00000800)100 ; CHECK-LV-NEXT: {{ $}}101 ; CHECK-LV-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp102 ; CHECK-LV-NEXT: [[COPY4:%[0-9]+]]:gr64 = STATEPOINT 2882400000, 0, 0, undef %11:gr64, 2, 0, 2, 0, 2, 0, 2, 1, [[COPY4]](tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax103 ; CHECK-LV-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp104 ; CHECK-LV-NEXT: EH_LABEL <mcsymbol >105 ; CHECK-LV-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp106 ; CHECK-LV-NEXT: [[COPY6:%[0-9]+]]:gr64 = COPY [[COPY4]]107 ; CHECK-LV-NEXT: [[COPY6:%[0-9]+]]:gr64 = STATEPOINT 2882400000, 0, 0, undef %13:gr64, 2, 0, 2, 0, 2, 0, 2, 1, [[COPY6]](tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax108 ; CHECK-LV-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp109 ; CHECK-LV-NEXT: EH_LABEL <mcsymbol >110 ; CHECK-LV-NEXT: JMP_1 %bb.3111 ; CHECK-LV-NEXT: {{ $}}112 ; CHECK-LV-NEXT: bb.3.BB2:113 ; CHECK-LV-NEXT: successors: %bb.4(0x40000000), %bb.5(0x40000000)114 ; CHECK-LV-NEXT: {{ $}}115 ; CHECK-LV-NEXT: [[COPY7:%[0-9]+]]:gr8 = COPY [[MOV32r0_]].sub_8bit116 ; CHECK-LV-NEXT: TEST8rr killed [[COPY7]], [[COPY7]], implicit-def $eflags117 ; CHECK-LV-NEXT: JCC_1 %bb.5, 5, implicit killed $eflags118 ; CHECK-LV-NEXT: JMP_1 %bb.4119 ; CHECK-LV-NEXT: {{ $}}120 ; CHECK-LV-NEXT: bb.4.BB4:121 ; CHECK-LV-NEXT: successors: %bb.5(0x80000000)122 ; CHECK-LV-NEXT: {{ $}}123 ; CHECK-LV-NEXT: bb.5.tail:124 ; CHECK-LV-NEXT: successors: %bb.6(0x04000000), %bb.1(0x7c000000)125 ; CHECK-LV-NEXT: {{ $}}126 ; CHECK-LV-NEXT: [[COPY8:%[0-9]+]]:gr64 = COPY [[COPY6]]127 ; CHECK-LV-NEXT: [[COPY9:%[0-9]+]]:gr64 = COPY killed [[COPY6]]128 ; CHECK-LV-NEXT: [[COPY9:%[0-9]+]]:gr64 = nuw ADD64ri32 [[COPY9]], 8, implicit-def dead $eflags129 ; CHECK-LV-NEXT: TEST64rr killed [[COPY4]], [[COPY4]], implicit-def $eflags130 ; CHECK-LV-NEXT: [[COPY2:%[0-9]+]]:gr64 = COPY killed [[COPY9]]131 ; CHECK-LV-NEXT: [[COPY3:%[0-9]+]]:gr64 = COPY killed [[COPY8]]132 ; CHECK-LV-NEXT: JCC_1 %bb.1, 5, implicit killed $eflags133 ; CHECK-LV-NEXT: JMP_1 %bb.6134 ; CHECK-LV-NEXT: {{ $}}135 ; CHECK-LV-NEXT: bb.6.BB1:136 ; CHECK-LV-NEXT: RET 0137 ; CHECK-LV-NEXT: {{ $}}138 ; CHECK-LV-NEXT: bb.7.BB6 (landing-pad):139 ; CHECK-LV-NEXT: liveins: $rax, $rdx140 ; CHECK-LV-NEXT: {{ $}}141 ; CHECK-LV-NEXT: EH_LABEL <mcsymbol >142 ; CHECK-LV-NEXT: RET 0143 ;144 ; CHECK-LIS-LABEL: name: test2145 ; CHECK-LIS: bb.0.preheader:146 ; CHECK-LIS-NEXT: successors: %bb.1(0x80000000)147 ; CHECK-LIS-NEXT: liveins: $rdx, $rcx148 ; CHECK-LIS-NEXT: {{ $}}149 ; CHECK-LIS-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rcx150 ; CHECK-LIS-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY $rdx151 ; CHECK-LIS-NEXT: [[MOV32r0_:%[0-9]+]]:gr32 = MOV32r0 implicit-def dead $eflags152 ; CHECK-LIS-NEXT: [[COPY2:%[0-9]+]]:gr64 = COPY [[COPY1]]153 ; CHECK-LIS-NEXT: [[COPY3:%[0-9]+]]:gr64 = COPY [[COPY]]154 ; CHECK-LIS-NEXT: {{ $}}155 ; CHECK-LIS-NEXT: bb.1.loop.head:156 ; CHECK-LIS-NEXT: successors: %bb.6(0x04000000), %bb.2(0x7c000000)157 ; CHECK-LIS-NEXT: {{ $}}158 ; CHECK-LIS-NEXT: [[COPY4:%[0-9]+]]:gr64 = COPY [[COPY3]]159 ; CHECK-LIS-NEXT: [[COPY5:%[0-9]+]]:gr64 = COPY [[COPY2]]160 ; CHECK-LIS-NEXT: TEST64rr [[COPY5]], [[COPY5]], implicit-def $eflags161 ; CHECK-LIS-NEXT: JCC_1 %bb.6, 5, implicit killed $eflags162 ; CHECK-LIS-NEXT: JMP_1 %bb.2163 ; CHECK-LIS-NEXT: {{ $}}164 ; CHECK-LIS-NEXT: bb.2.BB3:165 ; CHECK-LIS-NEXT: successors: %bb.3(0x7ffff800), %bb.7(0x00000800)166 ; CHECK-LIS-NEXT: {{ $}}167 ; CHECK-LIS-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp168 ; CHECK-LIS-NEXT: [[COPY4:%[0-9]+]]:gr64 = STATEPOINT 2882400000, 0, 0, undef %11:gr64, 2, 0, 2, 0, 2, 0, 2, 1, [[COPY4]](tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax169 ; CHECK-LIS-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp170 ; CHECK-LIS-NEXT: EH_LABEL <mcsymbol >171 ; CHECK-LIS-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp172 ; CHECK-LIS-NEXT: [[COPY6:%[0-9]+]]:gr64 = COPY [[COPY4]]173 ; CHECK-LIS-NEXT: [[COPY6:%[0-9]+]]:gr64 = STATEPOINT 2882400000, 0, 0, undef %13:gr64, 2, 0, 2, 0, 2, 0, 2, 1, [[COPY6]](tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax174 ; CHECK-LIS-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp175 ; CHECK-LIS-NEXT: EH_LABEL <mcsymbol >176 ; CHECK-LIS-NEXT: JMP_1 %bb.3177 ; CHECK-LIS-NEXT: {{ $}}178 ; CHECK-LIS-NEXT: bb.3.BB2:179 ; CHECK-LIS-NEXT: successors: %bb.4(0x40000000), %bb.5(0x40000000)180 ; CHECK-LIS-NEXT: {{ $}}181 ; CHECK-LIS-NEXT: [[COPY7:%[0-9]+]]:gr8 = COPY [[MOV32r0_]].sub_8bit182 ; CHECK-LIS-NEXT: TEST8rr [[COPY7]], [[COPY7]], implicit-def $eflags183 ; CHECK-LIS-NEXT: JCC_1 %bb.5, 5, implicit killed $eflags184 ; CHECK-LIS-NEXT: JMP_1 %bb.4185 ; CHECK-LIS-NEXT: {{ $}}186 ; CHECK-LIS-NEXT: bb.4.BB4:187 ; CHECK-LIS-NEXT: successors: %bb.5(0x80000000)188 ; CHECK-LIS-NEXT: {{ $}}189 ; CHECK-LIS-NEXT: bb.5.tail:190 ; CHECK-LIS-NEXT: successors: %bb.6(0x04000000), %bb.1(0x7c000000)191 ; CHECK-LIS-NEXT: {{ $}}192 ; CHECK-LIS-NEXT: [[COPY8:%[0-9]+]]:gr64 = COPY [[COPY6]]193 ; CHECK-LIS-NEXT: [[COPY9:%[0-9]+]]:gr64 = COPY killed [[COPY6]]194 ; CHECK-LIS-NEXT: [[COPY9:%[0-9]+]]:gr64 = nuw ADD64ri32 [[COPY9]], 8, implicit-def dead $eflags195 ; CHECK-LIS-NEXT: TEST64rr killed [[COPY4]], [[COPY4]], implicit-def $eflags196 ; CHECK-LIS-NEXT: [[COPY2:%[0-9]+]]:gr64 = COPY [[COPY9]]197 ; CHECK-LIS-NEXT: [[COPY3:%[0-9]+]]:gr64 = COPY [[COPY8]]198 ; CHECK-LIS-NEXT: JCC_1 %bb.1, 5, implicit killed $eflags199 ; CHECK-LIS-NEXT: JMP_1 %bb.6200 ; CHECK-LIS-NEXT: {{ $}}201 ; CHECK-LIS-NEXT: bb.6.BB1:202 ; CHECK-LIS-NEXT: RET 0203 ; CHECK-LIS-NEXT: {{ $}}204 ; CHECK-LIS-NEXT: bb.7.BB6 (landing-pad):205 ; CHECK-LIS-NEXT: liveins: $rax, $rdx206 ; CHECK-LIS-NEXT: {{ $}}207 ; CHECK-LIS-NEXT: EH_LABEL <mcsymbol >208 ; CHECK-LIS-NEXT: RET 0209preheader:210 br label %loop.head211 212loop.head:213 %phi1 = phi ptr addrspace(1) [ %p0, %preheader ], [ %addr.i.i46797.remat64523, %tail ]214 %v1 = phi ptr addrspace(1) [ %p1, %preheader ], [ %v3, %tail ]215 %not3= icmp ne ptr addrspace(1) %phi1, null216 br i1 %not3, label %BB1, label %BB3217 218BB3:219 %token1 = call token (i64, i32, ptr addrspace(1) ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr addrspace(1) ()* elementtype(ptr addrspace(1) ()) undef, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) %v1) ]220 %v2 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token1, i32 0, i32 0) ; (%v1, %v1)221 %cond = icmp eq ptr addrspace(1) null, %v2222 %token2 = invoke token (i64, i32, ptr addrspace(1) ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr addrspace(1) ()* elementtype(ptr addrspace(1) ()) undef, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(ptr addrspace(1) %v2, ptr addrspace(1) %phi1) ]223 to label %BB2 unwind label %BB6224 225BB2:226 %v3 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token2, i32 0, i32 0) ; (%v2, %v2)227 %.remat64522 = getelementptr inbounds i8, ptr addrspace(1) %v3, i64 8228 %addr.i.i46797.remat64523 = bitcast ptr addrspace(1) %.remat64522 to ptr addrspace(1)229 br i1 undef, label %BB4, label %tail230 231BB4:232 %dummy = ptrtoint ptr undef to i64233 br label %tail234 235tail:236 br i1 %cond, label %BB1, label %loop.head237 238BB1:239 ret void240 241BB6:242 %lpad.split-lp = landingpad token243 cleanup244 ret void245 246}247 248 249declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #5250declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr addrspace(1) ()*, i32 immarg, i32 immarg, ...)251