Index: lib/Transforms/Scalar/PlaceSafepoints.cpp =================================================================== --- lib/Transforms/Scalar/PlaceSafepoints.cpp +++ lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -861,18 +861,22 @@ IRBuilder<> Builder(insertBefore); // First, create the statepoint (with all live ptrs as arguments). std::vector args; - // target, #args, unused, args + // target, #args, unused, ... args, #deopt args, ... deopt args, ... gc + // paramters Value *Target = CS.getCalledValue(); args.push_back(Target); int callArgSize = CS.arg_size(); args.push_back( ConstantInt::get(Type::getInt32Ty(M->getContext()), callArgSize)); - // TODO: add a 'Needs GC-rewrite' later flag + // unused args.push_back(ConstantInt::get(Type::getInt32Ty(M->getContext()), 0)); // Copy all the arguments of the original call args.insert(args.end(), CS.arg_begin(), CS.arg_end()); + // deopt + args.push_back(ConstantInt::get(Type::getInt32Ty(M->getContext()), 0)); + // Create the statepoint given all the arguments Instruction *token = nullptr; AttributeSet return_attributes; Index: test/Transforms/Safepoint/place.ll =================================================================== --- /dev/null +++ test/Transforms/Safepoint/place.ll @@ -0,0 +1,33 @@ +; RUN: opt %s -place-safepoints -S | FileCheck %s + +declare zeroext i1 @void_return_i1() +declare zeroext i1 @i1_return_i1(i1) + +define void @gc.safepoint_poll() { + ret void +} + +define i1 @test_basic() gc "statepoint-example" { +; CHECK-LABEL: test_basic +; This is checking that a statepoint_poll + statepoint + result is +; inserted for a function that doesn't take arguments. +; CHECK: gc.statepoint.p0f_isVoidf +; CHECK: gc.statepoint.p0f_i1f +; CHECK: gc.result.int.i1 +entry: + %call1 = tail call i1 ()* @void_return_i1() + ret i1 %call1 +} + +define i1 @test_argument() gc "statepoint-example" { +; CHECK-LABEL: test_argument +; This is checking that a statepoint_poll + statepoint + result is +; inserted for a function that takes 1 argument. +; CHECK: gc.statepoint.p0f_isVoidf +; CHECK: gc.statepoint.p0f_i1i1f +; CHECK: (i1 (i1)* @i1_return_i1, i32 1, i32 0, i1 false, i32 0) +; CHECK: gc.result.int.i1 +entry: + %call1 = tail call i1 (i1)* @i1_return_i1(i1 false) + ret i1 %call1 +} \ No newline at end of file