1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s
4 ; Ensure that the gc.statepoint calls / invokes we generate have the
5 ; set of arguments we expect it to have.
7 define ptr addrspace(1) @test_invoke_format(ptr addrspace(1) %obj, ptr addrspace(1) %obj1) gc "statepoint-example" personality ptr @personality {
8 ; CHECK-LABEL: @test_invoke_format(
10 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(ptr addrspace(1) (ptr addrspace(1))) @callee, i32 1, i32 0, ptr addrspace(1) [[OBJ:%.*]], i32 0, i32 0) [ "gc-live"(ptr addrspace(1) [[OBJ1:%.*]], ptr addrspace(1) [[OBJ]]) ]
11 ; CHECK-NEXT: to label [[NORMAL_RETURN:%.*]] unwind label [[EXCEPTIONAL_RETURN:%.*]]
12 ; CHECK: normal_return:
13 ; CHECK-NEXT: [[RET_VAL1:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.result.p1(token [[STATEPOINT_TOKEN]])
14 ; CHECK-NEXT: [[OBJ1_RELOCATED2:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
15 ; CHECK-NEXT: [[OBJ_RELOCATED3:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
16 ; CHECK-NEXT: ret ptr addrspace(1) [[RET_VAL1]]
17 ; CHECK: exceptional_return:
18 ; CHECK-NEXT: [[LANDING_PAD4:%.*]] = landingpad token
20 ; CHECK-NEXT: [[OBJ1_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[LANDING_PAD4]], i32 0, i32 0)
21 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[LANDING_PAD4]], i32 1, i32 1)
22 ; CHECK-NEXT: ret ptr addrspace(1) [[OBJ1_RELOCATED]]
25 %ret_val = invoke ptr addrspace(1) @callee(ptr addrspace(1) %obj)
26 to label %normal_return unwind label %exceptional_return
29 ret ptr addrspace(1) %ret_val
32 %landing_pad4 = landingpad token
34 ret ptr addrspace(1) %obj1
37 define ptr addrspace(1) @test_call_format(ptr addrspace(1) %obj, ptr addrspace(1) %obj1) gc "statepoint-example" {
38 ; CHECK-LABEL: @test_call_format(
40 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(ptr addrspace(1) (ptr addrspace(1))) @callee, i32 1, i32 0, ptr addrspace(1) [[OBJ:%.*]], i32 0, i32 0) [ "gc-live"(ptr addrspace(1) [[OBJ]]) ]
41 ; CHECK-NEXT: [[RET_VAL1:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.result.p1(token [[STATEPOINT_TOKEN]])
42 ; CHECK-NEXT: [[OBJ_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
43 ; CHECK-NEXT: ret ptr addrspace(1) [[RET_VAL1]]
46 %ret_val = call ptr addrspace(1) @callee(ptr addrspace(1) %obj)
47 ret ptr addrspace(1) %ret_val
50 ; This function is inlined when inserting a poll.
51 declare void @do_safepoint()
52 define void @gc.safepoint_poll() {
53 ; CHECK-LABEL: @gc.safepoint_poll(
55 ; CHECK-NEXT: call void @do_safepoint()
56 ; CHECK-NEXT: ret void
59 call void @do_safepoint()
63 declare ptr addrspace(1) @callee(ptr addrspace(1))
64 declare i32 @personality()