1; RUN: llc < %s | FileCheck %s 2; This file contains a collection of basic tests to ensure we didn't 3; screw up normal call lowering when there are no deopt or gc arguments. 4 5target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128" 6target triple = "x86_64-pc-linux-gnu" 7 8declare zeroext i1 @return_i1() 9declare zeroext i32 @return_i32() 10declare i32* @return_i32ptr() 11declare float @return_float() 12declare void @varargf(i32, ...) 13 14define i1 @test_i1_return() gc "statepoint-example" { 15; CHECK-LABEL: test_i1_return 16; This is just checking that a i1 gets lowered normally when there's no extra 17; state arguments to the statepoint 18; CHECK: pushq %rax 19; CHECK: callq return_i1 20; CHECK: popq %rdx 21; CHECK: retq 22entry: 23 %safepoint_token = tail call i32 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0) 24 %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token) 25 ret i1 %call1 26} 27 28define i32 @test_i32_return() gc "statepoint-example" { 29; CHECK-LABEL: test_i32_return 30; CHECK: pushq %rax 31; CHECK: callq return_i32 32; CHECK: popq %rdx 33; CHECK: retq 34entry: 35 %safepoint_token = tail call i32 (i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i32 ()* @return_i32, i32 0, i32 0, i32 0) 36 %call1 = call zeroext i32 @llvm.experimental.gc.result.i32(i32 %safepoint_token) 37 ret i32 %call1 38} 39 40define i32* @test_i32ptr_return() gc "statepoint-example" { 41; CHECK-LABEL: test_i32ptr_return 42; CHECK: pushq %rax 43; CHECK: callq return_i32ptr 44; CHECK: popq %rdx 45; CHECK: retq 46entry: 47 %safepoint_token = tail call i32 (i32* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p0i32f(i32* ()* @return_i32ptr, i32 0, i32 0, i32 0) 48 %call1 = call i32* @llvm.experimental.gc.result.p0i32(i32 %safepoint_token) 49 ret i32* %call1 50} 51 52define float @test_float_return() gc "statepoint-example" { 53; CHECK-LABEL: test_float_return 54; CHECK: pushq %rax 55; CHECK: callq return_float 56; CHECK: popq %rax 57; CHECK: retq 58entry: 59 %safepoint_token = tail call i32 (float ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_f32f(float ()* @return_float, i32 0, i32 0, i32 0) 60 %call1 = call float @llvm.experimental.gc.result.f32(i32 %safepoint_token) 61 ret float %call1 62} 63 64define i1 @test_relocate(i32 addrspace(1)* %a) gc "statepoint-example" { 65; CHECK-LABEL: test_relocate 66; Check that an ununsed relocate has no code-generation impact 67; CHECK: pushq %rax 68; CHECK: callq return_i1 69; CHECK-NEXT: .Ltmp9: 70; CHECK-NEXT: popq %rdx 71; CHECK-NEXT: retq 72entry: 73 %safepoint_token = tail call i32 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 addrspace(1)* %a) 74 %call1 = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 4, i32 4) 75 %call2 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token) 76 ret i1 %call2 77} 78 79define void @test_void_vararg() gc "statepoint-example" { 80; CHECK-LABEL: test_void_vararg 81; Check a statepoint wrapping a *void* returning vararg function works 82; CHECK: callq varargf 83entry: 84 %safepoint_token = tail call i32 (void (i32, ...)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidi32varargf(void (i32, ...)* @varargf, i32 2, i32 0, i32 42, i32 43, i32 0) 85 ;; if we try to use the result from a statepoint wrapping a 86 ;; non-void-returning varargf, we will experience a crash. 87 ret void 88} 89 90declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...) 91declare i1 @llvm.experimental.gc.result.i1(i32) 92 93declare i32 @llvm.experimental.gc.statepoint.p0f_i32f(i32 ()*, i32, i32, ...) 94declare i32 @llvm.experimental.gc.result.i32(i32) 95 96declare i32 @llvm.experimental.gc.statepoint.p0f_p0i32f(i32* ()*, i32, i32, ...) 97declare i32* @llvm.experimental.gc.result.p0i32(i32) 98 99declare i32 @llvm.experimental.gc.statepoint.p0f_f32f(float ()*, i32, i32, ...) 100declare float @llvm.experimental.gc.result.f32(i32) 101 102declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidi32varargf(void (i32, ...)*, i32, i32, ...) 103 104declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) 105