1; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s 2 3declare void @g() 4declare i32 @h() 5 6define i32 addrspace(1)* @f0(i32 addrspace(1)* %arg) gc "statepoint-example" { 7; CHECK-LABEL: @f0( 8 entry: 9; CHECK: [[TOKEN_0:%[^ ]+]] = call token {{[^@]*}} @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @g, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg) 10 call void @g() [ "deopt"(i32 100) ] 11 12; CHECK: %arg.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_0]], i32 8, i32 8) 13 ret i32 addrspace(1)* %arg 14} 15 16define i32 addrspace(1)* @f1(i32 addrspace(1)* %arg) gc "statepoint-example" personality i32 8 { 17; CHECK-LABEL: @f1( 18 entry: 19; CHECK: [[TOKEN_1:%[^ ]+]] = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @g, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg) 20 invoke void @g() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest 21 22 normal_dest: 23; CHECK: %arg.relocated1 = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_1]], i32 8, i32 8) 24 ret i32 addrspace(1)* %arg 25 26 unwind_dest: 27 %lpad = landingpad token cleanup 28 resume token undef 29} 30 31define i32 addrspace(1)* @f2(i32 addrspace(1)* %arg) gc "statepoint-example" { 32; CHECK-LABEL: @f2( 33 entry: 34; CHECK: [[TOKEN_2:%[^ ]+]] = call token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* @h, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg) 35 %val = call i32 @h() [ "deopt"(i32 100) ] 36 37; CHECK: [[RESULT_F2:%[^ ]+]] = call i32 @llvm.experimental.gc.result.i32(token [[TOKEN_2]]) 38; CHECK: %arg.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_2]], i32 8, i32 8) 39; CHECK: %arg.relocated.casted = bitcast i8 addrspace(1)* %arg.relocated to i32 addrspace(1)* 40 41 store i32 %val, i32 addrspace(1)* %arg 42; CHECK: store i32 [[RESULT_F2]], i32 addrspace(1)* %arg.relocated.casted 43 ret i32 addrspace(1)* %arg 44} 45 46define i32 addrspace(1)* @f3(i32 addrspace(1)* %arg) gc "statepoint-example" personality i32 8 { 47; CHECK-LABEL: @f3( 48 entry: 49; CHECK: [[TOKEN_3:%[^ ]+]] = invoke token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* @h, i32 0, i32 0, i32 0, i32 1, i32 100, i32 addrspace(1)* %arg) 50 %val = invoke i32 @h() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest 51 52 normal_dest: 53; CHECK: [[RESULT_F3:%[^ ]+]] = call i32 @llvm.experimental.gc.result.i32(token [[TOKEN_3]]) 54; CHECK: [[ARG_RELOCATED:%[^ ]+]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TOKEN_3]], i32 8, i32 8) 55; CHECK: [[ARG_RELOCATED_CASTED:%[^ ]+]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED]] to i32 addrspace(1)* 56 57 store i32 %val, i32 addrspace(1)* %arg 58 59; CHECK: store i32 [[RESULT_F3]], i32 addrspace(1)* [[ARG_RELOCATED_CASTED]] 60 ret i32 addrspace(1)* %arg 61 62 unwind_dest: 63 %lpad = landingpad token cleanup 64 resume token undef 65} 66 67define i32 addrspace(1)* @f4(i32 addrspace(1)* %arg) gc "statepoint-example" { 68; CHECK-LABEL: @f4( 69 entry: 70; CHECK: @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @g, i32 0, i32 1, i32 2, i32 400, i8 90, 71 call void @g() [ "gc-transition"(i32 400, i8 90) ] 72 ret i32 addrspace(1)* %arg 73} 74