1 # RUN: llc -x mir -run-pass=twoaddressinstruction < %s | FileCheck %s
2 # RUN: llc -x mir --passes=two-address-instruction < %s | FileCheck %s
4 # This test checks that TwoAddressInstruction pass does not create redundate COPY
5 # instruction for STATEPOINT tied operands.
8 ; ModuleID = 'statepoint-vreg-twoaddr.ll'
9 source_filename = "statepoint-vreg-twoaddr.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 i1 @return_i1()
15 declare void @consume(ptr addrspace(1))
16 declare void @consume1(ptr addrspace(1), ptr addrspace(1))
18 define i1 @test_relocate(ptr addrspace(1) %a) gc "statepoint-example" {
20 %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) ]
21 %rel1 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 0) ; (%a, %a)
22 %res1 = call zeroext i1 @llvm.experimental.gc.result.i1(token %safepoint_token)
23 call void @consume(ptr addrspace(1) %rel1)
27 define void @test_duplicate_gcregs(ptr addrspace(1) %a) gc "statepoint-example" {
31 ; Function Attrs: nounwind readnone
32 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32 immarg, i32 immarg) #0
34 declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...)
36 ; Function Attrs: nounwind readnone
37 declare i1 @llvm.experimental.gc.result.i1(token) #0
39 attributes #0 = { nounwind readnone }
45 tracksRegLiveness: true
47 - { id: 0, class: gr64 }
48 - { id: 1, class: gr64 }
49 - { id: 2, class: gr8 }
50 machineFunctionInfo: {}
55 ; CHECK-LABEL: name: test_relocate
56 ; CHECK: [[VREG1:%[0-9]+]]:gr64 = COPY killed $rdi
57 ; CHECK-NOT: [[VREG2:%[0-9]+]]:gr64 = COPY [[VREG1]]
58 ; 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
59 ; CHECK: $rdi = COPY killed [[VREG1]]
60 ; CHECK: CALL64pcrel32 target-flags(x86-plt) @consume, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp
62 %0:gr64 = COPY killed $rdi
63 %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
64 %2:gr8 = COPY killed $al
66 CALL64pcrel32 target-flags(x86-plt) @consume, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp
72 name: test_duplicate_gcregs
74 tracksRegLiveness: true
76 - { reg: '$rdi', virtual-reg: '%0' }
81 ; CHECK-LABEL: name: test_duplicate_gcregs
82 ; CHECK: %1:gr64 = COPY %0
83 ; CHECK: %2:gr64 = COPY %0
84 ; 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
85 ; CHECK: $rdi = COPY killed %1
86 ; CHECK: $rsi = COPY killed %2
87 ; 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
89 %0:gr64 = COPY killed $rdi
90 %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
93 CALL64pcrel32 target-flags(x86-plt) @consume1, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $rsi, implicit-def $rsp, implicit-def $ssp