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
4 # Check that COPY is not eliminated if dest register is used in
5 # non-meta arguments of statepoint.
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"
13 declare void @foo(i64)
15 define ptr addrspace(1) @test(i64 %a, i64 %b, i64 %c, ptr addrspace(1) %p) gc "statepoint-example" {
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
22 ; Function Attrs: nounwind readonly
23 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #0
25 declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...)
27 attributes #0 = { nounwind readonly }
33 exposesReturnsTwice: false
35 regBankSelected: false
38 tracksRegLiveness: true
42 - { reg: '$rsi', virtual-reg: '' }
43 - { reg: '$rcx', virtual-reg: '' }
45 isFrameAddressTaken: false
46 isReturnAddressTaken: false
55 maxCallFrameSize: 4294967295
56 cvBytesOfCalleeSavedRegisters: 0
57 hasOpaqueSPAdjustment: false
59 hasMustTailInVarArgFunc: false
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: '' }
70 machineFunctionInfo: {}
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)
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)