1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -o - %s -run-pass fixup-statepoint-caller-saved -verify-machineinstrs | FileCheck %s 3 4# Check that COPY is not eliminated if dest register is used in 5# non-meta arguments of statepoint. 6 7--- | 8 ; ModuleID = 'cp.ll' 9 source_filename = "cp.ll" 10 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 11 target triple = "x86_64-pc-linux-gnu" 12 13 declare void @foo(i64) 14 15 define ptr addrspace(1) @test(i64 %a, i64 %b, i64 %c, ptr addrspace(1) %p) gc "statepoint-example" { 16 entry: 17 %token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void (i64)) @foo, i32 1, i32 0, i64 %b, i3 0, i32 0) [ "deopt"(i64 %b), "gc-live"(ptr addrspace(1) %p) ] 18 %p2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %token, i32 0, i32 0) ; (%p, %p) 19 ret ptr addrspace(1) %p2 20 } 21 22 ; Function Attrs: nounwind readonly 23 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #0 24 25 declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...) 26 27 attributes #0 = { nounwind readonly } 28 29... 30--- 31name: test 32alignment: 16 33exposesReturnsTwice: false 34legalized: false 35regBankSelected: false 36selected: false 37failedISel: false 38tracksRegLiveness: true 39hasWinCFI: false 40registers: [] 41liveins: 42 - { reg: '$rsi', virtual-reg: '' } 43 - { reg: '$rcx', virtual-reg: '' } 44frameInfo: 45 isFrameAddressTaken: false 46 isReturnAddressTaken: false 47 hasStackMap: false 48 hasPatchPoint: false 49 stackSize: 0 50 offsetAdjustment: 0 51 maxAlignment: 8 52 adjustsStack: false 53 hasCalls: true 54 stackProtector: '' 55 maxCallFrameSize: 4294967295 56 cvBytesOfCalleeSavedRegisters: 0 57 hasOpaqueSPAdjustment: false 58 hasVAStart: false 59 hasMustTailInVarArgFunc: false 60 localFrameSize: 0 61 savePoint: '' 62 restorePoint: '' 63fixedStack: [] 64stack: 65 - { id: 0, name: '', type: default, offset: 0, size: 8, alignment: 8, 66 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 67 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 68callSites: [] 69constants: [] 70machineFunctionInfo: {} 71body: | 72 bb.0.entry: 73 liveins: $rcx, $rsi 74 75 ; CHECK-LABEL: name: test 76 ; CHECK: liveins: $rcx, $rsi 77 ; CHECK: renamable $rdi = COPY $rsi 78 ; CHECK: MOV64mr %stack.0, 1, $noreg, 0, $noreg, killed renamable $rcx :: (store (s64) into %stack.0) 79 ; CHECK: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 80 ; CHECK: MOV64mr %stack.1, 1, $noreg, 0, $noreg, $rdi :: (store (s64) into %stack.1) 81 ; CHECK: STATEPOINT 0, 0, 1, @foo, $rdi, 2, 0, 2, 0, 2, 1, 1, 8, %stack.1, 0, 2, 1, 1, 8, %stack.0, 0, 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp :: (volatile load store (s64) on %stack.0), (load (s64) from %stack.1) 82 ; CHECK: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 83 ; CHECK: renamable $rax = MOV64rm %stack.0, 1, $noreg, 0, $noreg :: (load (s64) from %stack.0) 84 ; CHECK: RET 0, $rax 85 renamable $rdi = COPY $rsi 86 MOV64mr %stack.0, 1, $noreg, 0, $noreg, killed renamable $rcx :: (store (s64) into %stack.0) 87 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 88 STATEPOINT 0, 0, 1, @foo, $rdi, 2, 0, 2, 0, 2, 1, killed renamable $rdi, 2, 1, 1, 8, %stack.0, 0, 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp :: (volatile load store (s64) on %stack.0) 89 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 90 renamable $rax = MOV64rm %stack.0, 1, $noreg, 0, $noreg :: (load (s64) from %stack.0) 91 RET 0, $rax 92 93... 94