1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s
7 define ptr addrspace(1) @f0(ptr addrspace(1) %arg) gc "statepoint-example" {
10 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @g, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ]
11 ; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
12 ; CHECK-NEXT: ret ptr addrspace(1) [[ARG_RELOCATED]]
15 call void @g() [ "deopt"(i32 100) ]
17 ret ptr addrspace(1) %arg
20 define ptr addrspace(1) @f1(ptr addrspace(1) %arg) gc "statepoint-example" personality i32 8 {
23 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @g, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ]
24 ; CHECK-NEXT: to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]]
26 ; CHECK-NEXT: [[ARG_RELOCATED1:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
27 ; CHECK-NEXT: ret ptr addrspace(1) [[ARG_RELOCATED1]]
29 ; CHECK-NEXT: [[LPAD:%.*]] = landingpad token
31 ; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[LPAD]], i32 0, i32 0)
32 ; CHECK-NEXT: resume token undef
35 invoke void @g() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest
38 ret ptr addrspace(1) %arg
41 %lpad = landingpad token cleanup
45 define ptr addrspace(1) @f2(ptr addrspace(1) %arg) gc "statepoint-example" {
48 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(i32 ()) @h, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ]
49 ; CHECK-NEXT: [[VAL1:%.*]] = call i32 @llvm.experimental.gc.result.i32(token [[STATEPOINT_TOKEN]])
50 ; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
51 ; CHECK-NEXT: store i32 [[VAL1]], ptr addrspace(1) [[ARG_RELOCATED]], align 4
52 ; CHECK-NEXT: ret ptr addrspace(1) [[ARG_RELOCATED]]
55 %val = call i32 @h() [ "deopt"(i32 100) ]
58 store i32 %val, ptr addrspace(1) %arg
59 ret ptr addrspace(1) %arg
62 define ptr addrspace(1) @f3(ptr addrspace(1) %arg) gc "statepoint-example" personality i32 8 {
65 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(i32 ()) @h, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 100), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ]
66 ; CHECK-NEXT: to label [[NORMAL_DEST:%.*]] unwind label [[UNWIND_DEST:%.*]]
68 ; CHECK-NEXT: [[VAL1:%.*]] = call i32 @llvm.experimental.gc.result.i32(token [[STATEPOINT_TOKEN]])
69 ; CHECK-NEXT: [[ARG_RELOCATED2:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
70 ; CHECK-NEXT: store i32 [[VAL1]], ptr addrspace(1) [[ARG_RELOCATED2]], align 4
71 ; CHECK-NEXT: ret ptr addrspace(1) [[ARG_RELOCATED2]]
73 ; CHECK-NEXT: [[LPAD:%.*]] = landingpad token
75 ; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[LPAD]], i32 0, i32 0)
76 ; CHECK-NEXT: resume token undef
79 %val = invoke i32 @h() [ "deopt"(i32 100) ] to label %normal_dest unwind label %unwind_dest
83 store i32 %val, ptr addrspace(1) %arg
85 ret ptr addrspace(1) %arg
88 %lpad = landingpad token cleanup
92 define ptr addrspace(1) @f4(ptr addrspace(1) %arg) gc "statepoint-example" {
95 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @g, i32 0, i32 1, i32 0, i32 0) [ "gc-transition"(i32 400, i8 90), "gc-live"(ptr addrspace(1) [[ARG:%.*]]) ]
96 ; CHECK-NEXT: [[ARG_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
97 ; CHECK-NEXT: ret ptr addrspace(1) [[ARG_RELOCATED]]
100 call void @g() [ "gc-transition"(i32 400, i8 90) ]
101 ret ptr addrspace(1) %arg