llvm-6502/test/Transforms/PlaceSafepoints/invokes.ll
Sanjoy Das ead2d1fbe0 [Statepoints] Support for "patchable" statepoints.
Summary:
This change adds two new parameters to the statepoint intrinsic, `i64 id`
and `i32 num_patch_bytes`.  `id` gets propagated to the ID field
in the generated StackMap section.  If the `num_patch_bytes` is
non-zero then the statepoint is lowered to `num_patch_bytes` bytes of
nops instead of a call (the spill and reload code remains unchanged).
A non-zero `num_patch_bytes` is useful in situations where a language
runtime requires complete control over how a call is lowered.

This change brings statepoints one step closer to patchpoints.  With
some additional work (that is not part of this patch) it should be
possible to get rid of `TargetOpcode::STATEPOINT` altogether.

PlaceSafepoints generates `statepoint` wrappers with `id` set to
`0xABCDEF00` (the old default value for the ID reported in the stackmap)
and `num_patch_bytes` set to `0`.  This can be made more sophisticated
later.

Reviewers: reames, pgavlin, swaroop.sridhar, AndyAyers

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D9546

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237214 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-12 23:52:24 +00:00

111 lines
3.0 KiB
LLVM

; RUN: opt %s -S -place-safepoints | FileCheck %s
declare i64 addrspace(1)* @"some_call"(i64 addrspace(1)*)
declare i32 @"personality_function"()
define i64 addrspace(1)* @test_basic(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" {
; CHECK-LABEL: entry:
entry:
; CHECK: invoke
; CHECK: statepoint
; CHECK: some_call
%ret_val = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
to label %normal_return unwind label %exceptional_return
; CHECK-LABEL: normal_return:
; CHECK: gc.result
; CHECK: ret i64
normal_return:
ret i64 addrspace(1)* %ret_val
; CHECK-LABEL: exceptional_return:
; CHECK: landingpad
; CHECK: ret i64
exceptional_return:
%landing_pad4 = landingpad {i8*, i32} personality i32 ()* @"personality_function"
cleanup
ret i64 addrspace(1)* %obj1
}
define i64 addrspace(1)* @test_two_invokes(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" {
; CHECK-LABEL: entry:
entry:
; CHECK: invoke
; CHECK: statepoint
; CHECK: some_call
%ret_val1 = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
to label %second_invoke unwind label %exceptional_return
; CHECK-LABEL: second_invoke:
second_invoke:
; CHECK: invoke
; CHECK: statepoint
; CHECK: some_call
%ret_val2 = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %ret_val1)
to label %normal_return unwind label %exceptional_return
; CHECK-LABEL: normal_return:
normal_return:
; CHECK: gc.result
; CHECK: ret i64
ret i64 addrspace(1)* %ret_val2
; CHECK: exceptional_return:
; CHECK: ret i64
exceptional_return:
%landing_pad4 = landingpad {i8*, i32} personality i32 ()* @"personality_function"
cleanup
ret i64 addrspace(1)* %obj1
}
define i64 addrspace(1)* @test_phi_node(i1 %cond, i64 addrspace(1)* %obj) gc "statepoint-example" {
; CHECK-LABEL: @test_phi_node
; CHECK-LABEL: entry:
entry:
br i1 %cond, label %left, label %right
left:
%ret_val_left = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
to label %merge unwind label %exceptional_return
right:
%ret_val_right = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
to label %merge unwind label %exceptional_return
; CHECK: merge[[A:[0-9]]]:
; CHECK: gc.result
; CHECK: br label %[[with_phi:merge[0-9]*]]
; CHECK: merge[[B:[0-9]]]:
; CHECK: gc.result
; CHECK: br label %[[with_phi]]
; CHECK: [[with_phi]]:
; CHECK: phi
; CHECK: ret i64 addrspace(1)* %ret_val
merge:
%ret_val = phi i64 addrspace(1)* [%ret_val_left, %left], [%ret_val_right, %right]
ret i64 addrspace(1)* %ret_val
; CHECK-LABEL: exceptional_return:
; CHECK: ret i64 addrspace(1)*
exceptional_return:
%landing_pad4 = landingpad {i8*, i32} personality i32 ()* @"personality_function"
cleanup
ret i64 addrspace(1)* %obj
}
declare void @do_safepoint()
define void @gc.safepoint_poll() {
; CHECK-LABEL: gc.safepoint_poll
; CHECK-LABEL: entry
; CHECK-NEXT: do_safepoint
; CHECK-NEXT: ret void
entry:
call void @do_safepoint()
ret void
}