190 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2# RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -run-pass fixup-statepoint-caller-saved | FileCheck %s3# RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -passes='fixup-statepoint-caller-saved' | FileCheck %s4 5# NOTE: MIR in this test was hand edited to have two statepoints share single landing pad.6# This is forbidden in IR, but is allowed in MIR. I just was unable to reproduce conditions7# under which landing pad merge happens. So I did it manually.8#9--- |10 ; ModuleID = 'statepoint-fixup-shared-ehpad.ll'11 source_filename = "statepoint-fixup-shared-ehpad.ll"12 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"13 target triple = "x86_64-pc-linux-gnu"14 15 declare void @foo()16 17 declare void @bar()18 19 declare i32 @personality_function()20 21 define ptr addrspace(1) @test_one(i32 %a, ptr addrspace(1) %p, ptr addrspace(1) %q) gc "statepoint-example" personality ptr @personality_function {22 entry:23 %cmp = icmp eq i32 %a, 024 br i1 %cmp, label %zero, label %nonzero25 26 zero: ; preds = %entry27 %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) ]28 to label %normal_dest_a unwind label %exceptional_return_a29 30 nonzero: ; preds = %entry31 %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) ]32 to label %normal_dest_b unwind label %exceptional_return_b33 34 normal_dest_a: ; preds = %zero35 %p2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token, i32 0, i32 0) ; (%p, %p)36 ret ptr addrspace(1) %p237 38 exceptional_return_a: ; preds = %zero39 %landing_pad = landingpad token40 cleanup41 %q2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 1, i32 1) ; (%q, %q)42 ret ptr addrspace(1) %q243 44 normal_dest_b: ; preds = %nonzero45 %p3 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token2, i32 0, i32 0) ; (%p, %p)46 ret ptr addrspace(1) %p347 48 exceptional_return_b: ; preds = %nonzero49 %landing_pad2 = landingpad token50 cleanup51 %q3 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad2, i32 1, i32 1) ; (%q, %q)52 ret ptr addrspace(1) %q353 }54 55 declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...)56 57 ; Function Attrs: nounwind readonly58 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #059 60 attributes #0 = { nounwind readonly }61 attributes #1 = { nounwind }62 63...64---65name: test_one66alignment: 1667exposesReturnsTwice: false68legalized: false69regBankSelected: false70selected: false71failedISel: false72tracksRegLiveness: true73hasWinCFI: false74registers: []75liveins:76 - { reg: '$edi', virtual-reg: '' }77 - { reg: '$rsi', virtual-reg: '' }78 - { reg: '$rdx', virtual-reg: '' }79frameInfo:80 isFrameAddressTaken: false81 isReturnAddressTaken: false82 hasStackMap: false83 hasPatchPoint: false84 stackSize: 085 offsetAdjustment: 086 maxAlignment: 187 adjustsStack: false88 hasCalls: true89 stackProtector: ''90 maxCallFrameSize: 429496729591 cvBytesOfCalleeSavedRegisters: 092 hasOpaqueSPAdjustment: false93 hasVAStart: false94 hasMustTailInVarArgFunc: false95 localFrameSize: 096 savePoint: []97 restorePoint: []98fixedStack: []99stack: []100callSites: []101constants: []102machineFunctionInfo: {}103body: |104 ; CHECK-LABEL: name: test_one105 ; CHECK: bb.1:106 ; CHECK: successors: %bb.3(0x40000000), %bb.4(0x40000000)107 ; CHECK: liveins: $rbx, $r14108 ; CHECK: EH_LABEL <mcsymbol Ltmp0>109 ; CHECK: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp110 ; CHECK: MOV64mr [[STACK0:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $rbx :: (store (s64) into [[STACK0]])111 ; CHECK: MOV64mr [[STACK1:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $r14 :: (store (s64) into [[STACK1]])112 ; 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]])113 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK0]])114 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK1]])115 ; CHECK: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp116 ; CHECK: EH_LABEL <mcsymbol Ltmp1>117 ; CHECK: JMP_1 %bb.3118 ; CHECK: bb.2:119 ; CHECK: successors: %bb.5(0x40000000), %bb.4(0x40000000)120 ; CHECK: liveins: $rbx, $r14121 ; CHECK: EH_LABEL <mcsymbol Ltmp2>122 ; CHECK: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp123 ; CHECK-DAG: MOV64mr [[STACK0]], 1, $noreg, 0, $noreg, killed $rbx :: (store (s64) into [[STACK0]])124 ; CHECK-DAG: MOV64mr [[STACK1]], 1, $noreg, 0, $noreg, killed $r14 :: (store (s64) into [[STACK1]])125 ; 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]])126 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK0]])127 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK1]])128 ; CHECK: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp129 ; CHECK: EH_LABEL <mcsymbol Ltmp3>130 ; CHECK: JMP_1 %bb.5131 ; CHECK: bb.4 (landing-pad):132 ; CHECK: liveins: $rax, $rdx, $r14133 ; CHECK: EH_LABEL <mcsymbol Ltmp4>134 ; CHECK-DAG: $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK0]])135 ; CHECK-DAG: $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load (s64) from [[STACK1]])136 ; CHECK: $rax = COPY killed renamable $r14137 ; CHECK: RET 0, $rax138 bb.0:139 successors: %bb.1, %bb.2140 liveins: $edi, $rdx, $rsi141 142 renamable $r14 = COPY $rdx143 renamable $rbx = COPY $rsi144 TEST32rr killed renamable $edi, renamable $edi, implicit-def $eflags145 JCC_1 %bb.2, 5, implicit killed $eflags146 JMP_1 %bb.1147 148 bb.1:149 successors: %bb.3, %bb.4150 liveins: $rbx, $r14151 152 EH_LABEL <mcsymbol Ltmp0>153 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp154 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 $ssp155 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp156 EH_LABEL <mcsymbol Ltmp1>157 JMP_1 %bb.3158 159 bb.2:160 successors: %bb.5, %bb.4161 liveins: $rbx, $r14162 163 EH_LABEL <mcsymbol Ltmp2>164 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp165 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 $ssp166 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp167 EH_LABEL <mcsymbol Ltmp3>168 JMP_1 %bb.5169 170 bb.3:171 liveins: $rbx172 173 $rax = COPY killed renamable $rbx174 RET 0, $rax175 176 bb.4 (landing-pad):177 liveins: $rax, $rdx, $r14178 179 EH_LABEL <mcsymbol Ltmp4>180 $rax = COPY killed renamable $r14181 RET 0, $rax182 183 bb.5:184 liveins: $rbx185 186 $rax = COPY killed renamable $rbx187 RET 0, $rax188 189...190