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