1b90eb0f2SPhilip Reames; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2cee313d2SEric Christopher; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s 3cee313d2SEric Christopher; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s 4cee313d2SEric Christopher 5cee313d2SEric Christopherdeclare void @g() 6cee313d2SEric Christopherdeclare i32 @h() 7cee313d2SEric Christopher 8cee313d2SEric Christopherdefine i32 addrspace(1)* @f0(i32 addrspace(1)* %arg) gc "statepoint-example" { 9cee313d2SEric Christopher; CHECK-LABEL: @f0( 10b90eb0f2SPhilip Reames; CHECK-NEXT: entry: 11*c680eeabSNikita Popov; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* elementtype(void ()) @g, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(i32 addrspace(1)* [[ARG:%.*]]) ] 123d40c751SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0) 13b90eb0f2SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED]] to i32 addrspace(1)* 14b90eb0f2SPhilip Reames; CHECK-NEXT: ret i32 addrspace(1)* [[ARG_RELOCATED_CASTED]] 15b90eb0f2SPhilip Reames; 16cee313d2SEric Christopher entry: 17cee313d2SEric Christopher call void @g() [ "deopt"(i32 100) ] 18cee313d2SEric Christopher 19cee313d2SEric Christopher ret i32 addrspace(1)* %arg 20cee313d2SEric Christopher} 21cee313d2SEric Christopher 22cee313d2SEric Christopherdefine i32 addrspace(1)* @f1(i32 addrspace(1)* %arg) gc "statepoint-example" personality i32 8 { 23cee313d2SEric Christopher; CHECK-LABEL: @f1( 24b90eb0f2SPhilip Reames; CHECK-NEXT: entry: 25*c680eeabSNikita Popov; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* elementtype(void ()) @g, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(i32 addrspace(1)* [[ARG:%.*]]) ] 26b90eb0f2SPhilip Reames; CHECK-NEXT: to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]] 27b90eb0f2SPhilip Reames; CHECK: normal_dest: 283d40c751SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED1:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0) 29b90eb0f2SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED1_CASTED:%.*]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED1]] to i32 addrspace(1)* 30b90eb0f2SPhilip Reames; CHECK-NEXT: ret i32 addrspace(1)* [[ARG_RELOCATED1_CASTED]] 31b90eb0f2SPhilip Reames; CHECK: unwind_dest: 32b90eb0f2SPhilip Reames; CHECK-NEXT: [[LPAD:%.*]] = landingpad token 33b90eb0f2SPhilip Reames; CHECK-NEXT: cleanup 343d40c751SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[LPAD]], i32 0, i32 0) 35b90eb0f2SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED]] to i32 addrspace(1)* 36b90eb0f2SPhilip Reames; CHECK-NEXT: resume token undef 37b90eb0f2SPhilip Reames; 38cee313d2SEric Christopher entry: 39cee313d2SEric Christopher invoke void @g() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest 40cee313d2SEric Christopher 41cee313d2SEric Christopher normal_dest: 42cee313d2SEric Christopher ret i32 addrspace(1)* %arg 43cee313d2SEric Christopher 44cee313d2SEric Christopher unwind_dest: 45cee313d2SEric Christopher %lpad = landingpad token cleanup 46cee313d2SEric Christopher resume token undef 47cee313d2SEric Christopher} 48cee313d2SEric Christopher 49cee313d2SEric Christopherdefine i32 addrspace(1)* @f2(i32 addrspace(1)* %arg) gc "statepoint-example" { 50cee313d2SEric Christopher; CHECK-LABEL: @f2( 51b90eb0f2SPhilip Reames; CHECK-NEXT: entry: 52*c680eeabSNikita Popov; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* elementtype(i32 ()) @h, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(i32 addrspace(1)* [[ARG:%.*]]) ] 53b90eb0f2SPhilip Reames; CHECK-NEXT: [[VAL1:%.*]] = call i32 @llvm.experimental.gc.result.i32(token [[STATEPOINT_TOKEN]]) 543d40c751SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0) 55b90eb0f2SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED]] to i32 addrspace(1)* 56b90eb0f2SPhilip Reames; CHECK-NEXT: store i32 [[VAL1]], i32 addrspace(1)* [[ARG_RELOCATED_CASTED]], align 4 57b90eb0f2SPhilip Reames; CHECK-NEXT: ret i32 addrspace(1)* [[ARG_RELOCATED_CASTED]] 58b90eb0f2SPhilip Reames; 59cee313d2SEric Christopher entry: 60cee313d2SEric Christopher %val = call i32 @h() [ "deopt"(i32 100) ] 61cee313d2SEric Christopher 62cee313d2SEric Christopher 63cee313d2SEric Christopher store i32 %val, i32 addrspace(1)* %arg 64cee313d2SEric Christopher ret i32 addrspace(1)* %arg 65cee313d2SEric Christopher} 66cee313d2SEric Christopher 67cee313d2SEric Christopherdefine i32 addrspace(1)* @f3(i32 addrspace(1)* %arg) gc "statepoint-example" personality i32 8 { 68cee313d2SEric Christopher; CHECK-LABEL: @f3( 69b90eb0f2SPhilip Reames; CHECK-NEXT: entry: 70*c680eeabSNikita Popov; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* elementtype(i32 ()) @h, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(i32 addrspace(1)* [[ARG:%.*]]) ] 71b90eb0f2SPhilip Reames; CHECK-NEXT: to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]] 72b90eb0f2SPhilip Reames; CHECK: normal_dest: 73b90eb0f2SPhilip Reames; CHECK-NEXT: [[VAL1:%.*]] = call i32 @llvm.experimental.gc.result.i32(token [[STATEPOINT_TOKEN]]) 743d40c751SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED2:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0) 75b90eb0f2SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED2_CASTED:%.*]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED2]] to i32 addrspace(1)* 76b90eb0f2SPhilip Reames; CHECK-NEXT: store i32 [[VAL1]], i32 addrspace(1)* [[ARG_RELOCATED2_CASTED]], align 4 77b90eb0f2SPhilip Reames; CHECK-NEXT: ret i32 addrspace(1)* [[ARG_RELOCATED2_CASTED]] 78b90eb0f2SPhilip Reames; CHECK: unwind_dest: 79b90eb0f2SPhilip Reames; CHECK-NEXT: [[LPAD:%.*]] = landingpad token 80b90eb0f2SPhilip Reames; CHECK-NEXT: cleanup 813d40c751SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[LPAD]], i32 0, i32 0) 82b90eb0f2SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED]] to i32 addrspace(1)* 83b90eb0f2SPhilip Reames; CHECK-NEXT: resume token undef 84b90eb0f2SPhilip Reames; 85cee313d2SEric Christopher entry: 86cee313d2SEric Christopher %val = invoke i32 @h() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest 87cee313d2SEric Christopher 88cee313d2SEric Christopher normal_dest: 89cee313d2SEric Christopher 90cee313d2SEric Christopher store i32 %val, i32 addrspace(1)* %arg 91cee313d2SEric Christopher 92cee313d2SEric Christopher ret i32 addrspace(1)* %arg 93cee313d2SEric Christopher 94cee313d2SEric Christopher unwind_dest: 95cee313d2SEric Christopher %lpad = landingpad token cleanup 96cee313d2SEric Christopher resume token undef 97cee313d2SEric Christopher} 98cee313d2SEric Christopher 99cee313d2SEric Christopherdefine i32 addrspace(1)* @f4(i32 addrspace(1)* %arg) gc "statepoint-example" { 100cee313d2SEric Christopher; CHECK-LABEL: @f4( 101b90eb0f2SPhilip Reames; CHECK-NEXT: entry: 102*c680eeabSNikita Popov; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* elementtype(void ()) @g, i32 0, i32 1, i32 0, i32 0) [ "gc-transition"(i32 400, i8 90), "gc-live"(i32 addrspace(1)* [[ARG:%.*]]) ] 1033d40c751SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0) 104b90eb0f2SPhilip Reames; CHECK-NEXT: [[ARG_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[ARG_RELOCATED]] to i32 addrspace(1)* 105b90eb0f2SPhilip Reames; CHECK-NEXT: ret i32 addrspace(1)* [[ARG_RELOCATED_CASTED]] 106b90eb0f2SPhilip Reames; 107cee313d2SEric Christopher entry: 108cee313d2SEric Christopher call void @g() [ "gc-transition"(i32 400, i8 90) ] 109cee313d2SEric Christopher ret i32 addrspace(1)* %arg 110cee313d2SEric Christopher} 111