1 ; RUN: opt -S %s -verify | FileCheck %s
4 declare i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token, i32, i32)
5 declare i64 addrspace(1)* @llvm.experimental.gc.relocate.p1i64(token, i32, i32)
6 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
7 declare token @llvm.experimental.gc.statepoint.p0f_isVoidp0s_structsf(i64, i32, void (%struct*)*, i32, i32, ...)
8 declare i32 @"personality_function"()
11 define i64 addrspace(1)* @test1(i8 addrspace(1)* %arg) gc "statepoint-example" {
13 %cast = bitcast i8 addrspace(1)* %arg to i64 addrspace(1)*
14 %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 0, i32 0, i32 10, i32 0, i8 addrspace(1)* %arg, i64 addrspace(1)* %cast, i8 addrspace(1)* %arg, i8 addrspace(1)* %arg)
15 %reloc = call i64 addrspace(1)* @llvm.experimental.gc.relocate.p1i64(token %safepoint_token, i32 12, i32 13)
16 ;; It is perfectly legal to relocate the same value multiple times...
17 %reloc2 = call i64 addrspace(1)* @llvm.experimental.gc.relocate.p1i64(token %safepoint_token, i32 12, i32 13)
18 %reloc3 = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token, i32 13, i32 12)
19 ret i64 addrspace(1)* %reloc
25 ; CHECK: ret i64 addrspace(1)* %reloc
28 ; This test catches two cases where the verifier was too strict:
29 ; 1) A base doesn't need to be relocated if it's never used again
30 ; 2) A value can be replaced by one which is known equal. This
31 ; means a potentially derived pointer can be known base and that
32 ; we can't check that derived pointer are never bases.
33 define void @test2(i8 addrspace(1)* %arg, i64 addrspace(1)* %arg2) gc "statepoint-example" {
35 %cast = bitcast i8 addrspace(1)* %arg to i64 addrspace(1)*
36 %c = icmp eq i64 addrspace(1)* %cast, %arg2
37 br i1 %c, label %equal, label %notequal
43 %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 0, i32 0, i32 10, i32 0, i8 addrspace(1)* %arg, i64 addrspace(1)* %cast, i8 addrspace(1)* %arg, i8 addrspace(1)* %arg)
44 %reloc = call i64 addrspace(1)* @llvm.experimental.gc.relocate.p1i64(token %safepoint_token, i32 12, i32 13)
45 call void undef(i64 addrspace(1)* %reloc)
50 ; CHECK-NEXT: %reloc = call
55 ; Basic test for invoke statepoints
56 define i8 addrspace(1)* @test3(i8 addrspace(1)* %obj, i8 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @"personality_function" {
61 %0 = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0, i8 addrspace(1)* %obj, i8 addrspace(1)* %obj1)
62 to label %normal_dest unwind label %exceptional_return
65 ; CHECK-LABEL: normal_dest:
69 %obj.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %0, i32 12, i32 12)
70 %obj1.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %0, i32 12, i32 12)
71 ret i8 addrspace(1)* %obj.relocated
74 ; CHECK-LABEL: exceptional_return
77 %landing_pad = landingpad token
79 %obj.relocated1 = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %landing_pad, i32 12, i32 12)
80 %obj1.relocated1 = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %landing_pad, i32 12, i32 12)
81 ret i8 addrspace(1)* %obj1.relocated1
84 ; Test for statepoint with sret attribute.
85 ; This should be allowed as long as the wrapped function is not vararg.
86 %struct = type { i64, i64, i64 }
88 declare void @fn_sret(%struct* sret)
90 define void @test_sret() gc "statepoint-example" {
92 %statepoint_token = call token (i64, i32, void (%struct*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidp0s_structsf(i64 0, i32 0, void (%struct*)* @fn_sret, i32 1, i32 0, %struct* sret %x, i32 0, i32 0)
94 ; CHECK-LABEL: test_sret