1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -run-pass fixup-statepoint-caller-saved | FileCheck %s
4 # NOTE: MIR in this test was hand edited to have two statepoints share single landing pad.
5 # This is forbidden in IR, but is allowed in MIR. I just was unable to reproduce conditions
6 # under which landing pad merge happens. So I did it manually.
9 ; ModuleID = 'statepoint-fixup-shared-ehpad.ll'
10 source_filename = "statepoint-fixup-shared-ehpad.ll"
11 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
12 target triple = "x86_64-pc-linux-gnu"
18 declare i32 @personality_function()
20 define ptr addrspace(1) @test_one(i32 %a, ptr addrspace(1) %p, ptr addrspace(1) %q) gc "statepoint-example" personality ptr @personality_function {
22 %cmp = icmp eq i32 %a, 0
23 br i1 %cmp, label %zero, label %nonzero
25 zero: ; preds = %entry
26 %token = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(ptr addrspace(1) %p, ptr addrspace(1) %q) ]
27 to label %normal_dest_a unwind label %exceptional_return_a
29 nonzero: ; preds = %entry
30 %token2 = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @bar, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(ptr addrspace(1) %p, ptr addrspace(1) %q) ]
31 to label %normal_dest_b unwind label %exceptional_return_b
33 normal_dest_a: ; preds = %zero
34 %p2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token, i32 0, i32 0) ; (%p, %p)
35 ret ptr addrspace(1) %p2
37 exceptional_return_a: ; preds = %zero
38 %landing_pad = landingpad token
40 %q2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 1, i32 1) ; (%q, %q)
41 ret ptr addrspace(1) %q2
43 normal_dest_b: ; preds = %nonzero
44 %p3 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token2, i32 0, i32 0) ; (%p, %p)
45 ret ptr addrspace(1) %p3
47 exceptional_return_b: ; preds = %nonzero
48 %landing_pad2 = landingpad token
50 %q3 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad2, i32 1, i32 1) ; (%q, %q)
51 ret ptr addrspace(1) %q3
54 declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...)
56 ; Function Attrs: nounwind readonly
57 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #0
59 attributes #0 = { nounwind readonly }
60 attributes #1 = { nounwind }
66 exposesReturnsTwice: false
68 regBankSelected: false
71 tracksRegLiveness: true
75 - { reg: '$edi', virtual-reg: '' }
76 - { reg: '$rsi', virtual-reg: '' }
77 - { reg: '$rdx', virtual-reg: '' }
79 isFrameAddressTaken: false
80 isReturnAddressTaken: false
89 maxCallFrameSize: 4294967295
90 cvBytesOfCalleeSavedRegisters: 0
91 hasOpaqueSPAdjustment: false
93 hasMustTailInVarArgFunc: false
101 machineFunctionInfo: {}
103 ; CHECK-LABEL: name: test_one
105 ; CHECK: successors: %bb.3(0x40000000), %bb.4(0x40000000)
106 ; CHECK: liveins: $rbx, $r14
107 ; CHECK: EH_LABEL <mcsymbol Ltmp0>
108 ; CHECK: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
109 ; CHECK: MOV64mr [[STACK0:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $rbx :: (store (s64) into [[STACK0]])
110 ; CHECK: MOV64mr [[STACK1:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $r14 :: (store (s64) into [[STACK1]])
111 ; CHECK: STATEPOINT 0, 0, 0, @foo, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, [[STACK0]], 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store (s64) on [[STACK1]]), (load store (s64) on [[STACK0]])
112 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK0]])
113 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK1]])
114 ; CHECK: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
115 ; CHECK: EH_LABEL <mcsymbol Ltmp1>
118 ; CHECK: successors: %bb.5(0x40000000), %bb.4(0x40000000)
119 ; CHECK: liveins: $rbx, $r14
120 ; CHECK: EH_LABEL <mcsymbol Ltmp2>
121 ; CHECK: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
122 ; CHECK-DAG: MOV64mr [[STACK0]], 1, $noreg, 0, $noreg, killed $rbx :: (store (s64) into [[STACK0]])
123 ; CHECK-DAG: MOV64mr [[STACK1]], 1, $noreg, 0, $noreg, killed $r14 :: (store (s64) into [[STACK1]])
124 ; CHECK: STATEPOINT 0, 0, 0, @bar, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, %stack.0, 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store (s64) on [[STACK1]]), (load store (s64) on [[STACK0]])
125 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK0]])
126 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK1]])
127 ; CHECK: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
128 ; CHECK: EH_LABEL <mcsymbol Ltmp3>
130 ; CHECK: bb.4 (landing-pad):
131 ; CHECK: liveins: $rax, $rdx, $r14
132 ; CHECK: EH_LABEL <mcsymbol Ltmp4>
133 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK0]])
134 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK1]])
135 ; CHECK: $rax = COPY killed renamable $r14
138 successors: %bb.1, %bb.2
139 liveins: $edi, $rdx, $rsi
141 renamable $r14 = COPY $rdx
142 renamable $rbx = COPY $rsi
143 TEST32rr killed renamable $edi, renamable $edi, implicit-def $eflags
144 JCC_1 %bb.2, 5, implicit killed $eflags
148 successors: %bb.3, %bb.4
151 EH_LABEL <mcsymbol Ltmp0>
152 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
153 renamable $rbx, renamable $r14 = STATEPOINT 0, 0, 0, @foo, 2, 0, 2, 0, 2, 0, 2, 2, killed renamable $rbx(tied-def 0), killed renamable $r14(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp
154 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
155 EH_LABEL <mcsymbol Ltmp1>
159 successors: %bb.5, %bb.4
162 EH_LABEL <mcsymbol Ltmp2>
163 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
164 renamable $rbx, renamable $r14 = STATEPOINT 0, 0, 0, @bar, 2, 0, 2, 0, 2, 0, 2, 2, killed renamable $rbx(tied-def 0), killed renamable $r14(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp
165 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
166 EH_LABEL <mcsymbol Ltmp3>
172 $rax = COPY killed renamable $rbx
176 liveins: $rax, $rdx, $r14
178 EH_LABEL <mcsymbol Ltmp4>
179 $rax = COPY killed renamable $r14
185 $rax = COPY killed renamable $rbx