1 ; RUN: llc -max-registers-for-gc-values=256 -verify-machineinstrs -stop-after twoaddressinstruction < %s | FileCheck --check-prefixes CHECK,CHECK-LV %s
2 ; RUN: llc -max-registers-for-gc-values=256 -verify-machineinstrs -stop-after twoaddressinstruction -early-live-intervals < %s | FileCheck --check-prefixes CHECK,CHECK-LIS %s
4 target 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"
5 target triple = "x86_64-unknown-linux-gnu"
7 declare void @foo() gc "statepoint-example"
8 declare void @bar(ptr addrspace(1)) gc "statepoint-example"
10 declare ptr @fake_personality_function()
12 ; Simplest possible test demonstrating the problem
14 ; CHECK-LABEL: name: test
16 ; CHECK-LV: %0:gr64 = COPY killed $rdi
17 ; CHECK-LIS: %0:gr64 = COPY $rdi
18 ; CHECK: %1:gr64 = COPY %0
19 ; CHECK: %1:gr64 = STATEPOINT 2, 5, 0, undef %2:gr64, 2, 0, 2, 0, 2, 0, 2, 1, %1(tied-def 0), 2, 0, 2, 1, 0, 0
20 ; CHECK-LV: TEST64rr killed %0, %0, implicit-def $eflags
21 ; CHECK-LIS: TEST64rr %0, %0, implicit-def $eflags
22 ; CHECK: JCC_1 %bb.2, 4, implicit killed $eflags
25 ; CHECK-LV: $rdi = COPY killed %1
26 ; CHECK-LV: STATEPOINT 2, 5, 1, undef %3:gr64, killed $rdi, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0
27 ; CHECK-LIS: $rdi = COPY %1
28 ; CHECK-LIS: STATEPOINT 2, 5, 1, undef %3:gr64, $rdi, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0
32 define void @test(ptr addrspace(1) %a) gc "statepoint-example" {
34 %not7 = icmp eq ptr addrspace(1) %a, null
35 %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) ]
36 br i1 %not7, label %zero, label %not_zero
39 %a.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %statepoint_token1745, i32 0, i32 0) ; (%a, %a)
40 %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"() ]
47 ; A bit more complex test, where both registers are used in same successor BB
49 ; CHECK-LABEL: name: test2
51 ; CHECK: %1:gr64 = STATEPOINT 2882400000, 0, 0, undef %11:gr64, 2, 0, 2, 0, 2, 0, 2, 1, %1(tied-def 0), 2, 0, 2, 1, 0, 0, csr_64
52 ; CHECK: %10:gr64 = COPY %1
53 ; CHECK: %10:gr64 = STATEPOINT 2882400000, 0, 0, undef %13:gr64, 2, 0, 2, 0, 2, 0, 2, 1, %10(tied-def 0), 2, 0, 2, 1, 0, 0, csr_64
56 ; CHECK: %18:gr8 = COPY %17.sub_8bit
57 ; CHECK-LV: TEST8rr killed %18, %18, implicit-def $eflags
58 ; CHECK-LIS: TEST8rr %18, %18, implicit-def $eflags
59 ; CHECK: JCC_1 %bb.5, 5, implicit killed $eflags
63 ; CHECK: %3:gr64 = COPY %10
64 ; CHECK: %4:gr64 = COPY killed %10
65 ; CHECK: %4:gr64 = nuw ADD64ri32 %4, 8, implicit-def dead $eflags
66 ; CHECK: TEST64rr killed %1, %1, implicit-def $eflags
67 ; CHECK: JCC_1 %bb.1, 5, implicit killed $eflags
69 define void @test2(ptr addrspace(1) %this, i32 %0, ptr addrspace(1) %p0, ptr addrspace(1) %p1) gc "statepoint-example" personality ptr @fake_personality_function {
74 %phi1 = phi ptr addrspace(1) [ %p0, %preheader ], [ %addr.i.i46797.remat64523, %tail ]
75 %v1 = phi ptr addrspace(1) [ %p1, %preheader ], [ %v3, %tail ]
76 %not3= icmp ne ptr addrspace(1) %phi1, null
77 br i1 %not3, label %BB1, label %BB3
80 %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) ]
81 %v2 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token1, i32 0, i32 0) ; (%v1, %v1)
82 %cond = icmp eq ptr addrspace(1) null, %v2
83 %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) ]
84 to label %BB2 unwind label %BB6
87 %v3 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token2, i32 0, i32 0) ; (%v2, %v2)
88 %.remat64522 = getelementptr inbounds i8, ptr addrspace(1) %v3, i64 8
89 %addr.i.i46797.remat64523 = bitcast ptr addrspace(1) %.remat64522 to ptr addrspace(1)
90 br i1 undef, label %BB4, label %tail
93 %dummy = ptrtoint ptr undef to i64
97 br i1 %cond, label %BB1, label %loop.head
103 %lpad.split-lp = landingpad token
110 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #5
111 declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr addrspace(1) ()*, i32 immarg, i32 immarg, ...)