1 # RUN: llc -x mir -run-pass=twoaddressinstruction < %s | FileCheck %s
3 # This test checks that TwoAddressInstruction pass does not create redundate COPY
4 # instruction for STATEPOINT tied operands.
7 ; ModuleID = 'statepoint-vreg-twoaddr.ll'
8 source_filename = "statepoint-vreg-twoaddr.ll"
9 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
10 target triple = "x86_64-pc-linux-gnu"
12 declare i1 @return_i1()
14 declare void @consume(ptr addrspace(1))
15 declare void @consume1(ptr addrspace(1), ptr addrspace(1))
17 define i1 @test_relocate(ptr addrspace(1) %a) gc "statepoint-example" {
19 %safepoint_token = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(i1 ()) @return_i1, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(ptr addrspace(1) %a) ]
20 %rel1 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 0) ; (%a, %a)
21 %res1 = call zeroext i1 @llvm.experimental.gc.result.i1(token %safepoint_token)
22 call void @consume(ptr addrspace(1) %rel1)
26 define void @test_duplicate_gcregs(ptr addrspace(1) %a) gc "statepoint-example" {
30 ; Function Attrs: nounwind readnone
31 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #0
33 declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...)
35 ; Function Attrs: nounwind readnone
36 declare i1 @llvm.experimental.gc.result.i1(token) #0
38 attributes #0 = { nounwind readnone }
44 tracksRegLiveness: true
46 - { id: 0, class: gr64 }
47 - { id: 1, class: gr64 }
48 - { id: 2, class: gr8 }
49 machineFunctionInfo: {}
54 ; CHECK-LABEL: name: test_relocate
55 ; CHECK: [[VREG1:%[0-9]+]]:gr64 = COPY killed $rdi
56 ; CHECK-NOT: [[VREG2:%[0-9]+]]:gr64 = COPY [[VREG1]]
57 ; CHECK: [[VREG1]]:gr64 = STATEPOINT 0, 0, 0, target-flags(x86-plt) @return_i1, 2, 0, 2, 0, 2, 0, 2, 1, killed [[VREG1]](tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def $al
58 ; CHECK: $rdi = COPY killed [[VREG1]]
59 ; CHECK: CALL64pcrel32 target-flags(x86-plt) @consume, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp
61 %0:gr64 = COPY killed $rdi
62 %1:gr64 = STATEPOINT 0, 0, 0, target-flags(x86-plt) @return_i1, 2, 0, 2, 0, 2, 0, 2, 1, killed %0(tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def $al
63 %2:gr8 = COPY killed $al
65 CALL64pcrel32 target-flags(x86-plt) @consume, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp
71 name: test_duplicate_gcregs
73 tracksRegLiveness: true
75 - { reg: '$rdi', virtual-reg: '%0' }
80 ; CHECK-LABEL: name: test_duplicate_gcregs
81 ; CHECK: %1:gr64 = COPY %0
82 ; CHECK: %2:gr64 = COPY %0
83 ; CHECK: %1:gr64, %2:gr64 = STATEPOINT 0, 0, 0, target-flags(x86-plt) @return_i1, 2, 0, 2, 0, 2, 0, 2, 2, %1(tied-def 0), %2(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_64
84 ; CHECK: $rdi = COPY killed %1
85 ; CHECK: $rsi = COPY killed %2
86 ; CHECK: CALL64pcrel32 target-flags(x86-plt) @consume1, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $rsi, implicit-def $rsp, implicit-def $ssp
88 %0:gr64 = COPY killed $rdi
89 %1:gr64, %2:gr64 = STATEPOINT 0, 0, 0, target-flags(x86-plt) @return_i1, 2, 0, 2, 0, 2, 0, 2, 2, killed %0(tied-def 0), killed %0(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def dead $al
92 CALL64pcrel32 target-flags(x86-plt) @consume1, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $rsi, implicit-def $rsp, implicit-def $ssp