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 3 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. 7# 8--- | 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" 13 14 declare void @foo() 15 16 declare void @bar() 17 18 declare i32 @personality_function() 19 20 define i8 addrspace(1)* @test_one(i32 %a, i8 addrspace(1)* %p, i8 addrspace(1)* %q) gc "statepoint-example" personality i32 ()* @personality_function { 21 entry: 22 %cmp = icmp eq i32 %a, 0 23 br i1 %cmp, label %zero, label %nonzero 24 25 zero: ; preds = %entry 26 %token = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i8 addrspace(1)* %p, i8 addrspace(1)* %q) ] 27 to label %normal_dest_a unwind label %exceptional_return_a 28 29 nonzero: ; preds = %entry 30 %token2 = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @bar, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i8 addrspace(1)* %p, i8 addrspace(1)* %q) ] 31 to label %normal_dest_b unwind label %exceptional_return_b 32 33 normal_dest_a: ; preds = %zero 34 %p2 = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %token, i32 0, i32 0) ; (%p, %p) 35 ret i8 addrspace(1)* %p2 36 37 exceptional_return_a: ; preds = %zero 38 %landing_pad = landingpad token 39 cleanup 40 %q2 = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %landing_pad, i32 1, i32 1) ; (%q, %q) 41 ret i8 addrspace(1)* %q2 42 43 normal_dest_b: ; preds = %nonzero 44 %p3 = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %token2, i32 0, i32 0) ; (%p, %p) 45 ret i8 addrspace(1)* %p3 46 47 exceptional_return_b: ; preds = %nonzero 48 %landing_pad2 = landingpad token 49 cleanup 50 %q3 = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %landing_pad2, i32 1, i32 1) ; (%q, %q) 51 ret i8 addrspace(1)* %q3 52 } 53 54 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 immarg, i32 immarg, void ()*, i32 immarg, i32 immarg, ...) 55 56 ; Function Attrs: nounwind readonly 57 declare i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token, i32 immarg, i32 immarg) #0 58 59 attributes #0 = { nounwind readonly } 60 attributes #1 = { nounwind } 61 62... 63--- 64name: test_one 65alignment: 16 66exposesReturnsTwice: false 67legalized: false 68regBankSelected: false 69selected: false 70failedISel: false 71tracksRegLiveness: true 72hasWinCFI: false 73registers: [] 74liveins: 75 - { reg: '$edi', virtual-reg: '' } 76 - { reg: '$rsi', virtual-reg: '' } 77 - { reg: '$rdx', virtual-reg: '' } 78frameInfo: 79 isFrameAddressTaken: false 80 isReturnAddressTaken: false 81 hasStackMap: false 82 hasPatchPoint: false 83 stackSize: 0 84 offsetAdjustment: 0 85 maxAlignment: 1 86 adjustsStack: false 87 hasCalls: true 88 stackProtector: '' 89 maxCallFrameSize: 4294967295 90 cvBytesOfCalleeSavedRegisters: 0 91 hasOpaqueSPAdjustment: false 92 hasVAStart: false 93 hasMustTailInVarArgFunc: false 94 localFrameSize: 0 95 savePoint: '' 96 restorePoint: '' 97fixedStack: [] 98stack: [] 99callSites: [] 100constants: [] 101machineFunctionInfo: {} 102body: | 103 ; CHECK-LABEL: name: test_one 104 ; CHECK: bb.1: 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 8 into [[STACK0]]) 110 ; CHECK: MOV64mr [[STACK1:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $r14 :: (store 8 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 8 on [[STACK0]]), (load store 8 on [[STACK1]]) 112 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK0]]) 113 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load 8 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> 116 ; CHECK: JMP_1 %bb.3 117 ; CHECK: bb.2: 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 8 into [[STACK0]]) 123 ; CHECK-DAG: MOV64mr [[STACK1]], 1, $noreg, 0, $noreg, killed $r14 :: (store 8 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 8 on [[STACK0]]), (load store 8 on [[STACK1]]) 125 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK0]]) 126 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load 8 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> 129 ; CHECK: JMP_1 %bb.5 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 8 from [[STACK0]]) 134 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK1]]) 135 ; CHECK: $rax = COPY killed renamable $r14 136 ; CHECK: RET 0, $rax 137 bb.0: 138 successors: %bb.1, %bb.2 139 liveins: $edi, $rdx, $rsi 140 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 145 JMP_1 %bb.1 146 147 bb.1: 148 successors: %bb.3, %bb.4 149 liveins: $rbx, $r14 150 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> 156 JMP_1 %bb.3 157 158 bb.2: 159 successors: %bb.5, %bb.4 160 liveins: $rbx, $r14 161 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> 167 JMP_1 %bb.5 168 169 bb.3: 170 liveins: $rbx 171 172 $rax = COPY killed renamable $rbx 173 RET 0, $rax 174 175 bb.4 (landing-pad): 176 liveins: $rax, $rdx, $r14 177 178 EH_LABEL <mcsymbol Ltmp4> 179 $rax = COPY killed renamable $r14 180 RET 0, $rax 181 182 bb.5: 183 liveins: $rbx 184 185 $rax = COPY killed renamable $rbx 186 RET 0, $rax 187 188... 189