1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s
6 declare ptr addrspace(1) @generate_obj()
8 declare void @consume_obj(ptr addrspace(1))
10 ; derived %obj_to_consume base %obj_to_consume.base
11 define void @test(i32 %condition) gc "statepoint-example" {
14 ; CHECK-NEXT: br label [[LOOP:%.*]]
16 ; 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) ()) @generate_obj, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
17 ; CHECK-NEXT: [[TMP0:%.*]] = call ptr addrspace(1) @llvm.experimental.gc.result.p1(token [[STATEPOINT_TOKEN]])
18 ; CHECK-NEXT: switch i32 [[CONDITION:%.*]], label [[DEST_A:%.*]] [
19 ; CHECK-NEXT: i32 0, label [[DEST_B:%.*]]
20 ; CHECK-NEXT: i32 1, label [[DEST_C:%.*]]
23 ; CHECK-NEXT: br label [[MERGE:%.*]]
25 ; CHECK-NEXT: br label [[MERGE]]
27 ; CHECK-NEXT: br label [[MERGE]]
29 ; CHECK-NEXT: [[OBJ_TO_CONSUME:%.*]] = phi ptr addrspace(1) [ [[TMP0]], [[DEST_A]] ], [ null, [[DEST_B]] ], [ null, [[DEST_C]] ]
30 ; CHECK-NEXT: [[STATEPOINT_TOKEN1:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void (ptr addrspace(1))) @consume_obj, i32 1, i32 0, ptr addrspace(1) [[OBJ_TO_CONSUME]], i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(ptr addrspace(1) [[OBJ_TO_CONSUME]]) ]
31 ; CHECK-NEXT: [[OBJ_TO_CONSUME_RELOCATED:%.*]] = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token [[STATEPOINT_TOKEN1]], i32 0, i32 0)
32 ; CHECK-NEXT: br label [[MERGE_SPLIT:%.*]]
34 ; CHECK-NEXT: [[STATEPOINT_TOKEN2:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
35 ; CHECK-NEXT: br label [[LOOP]]
40 loop: ; preds = %merge.split, %entry
41 %0 = call ptr addrspace(1) @generate_obj() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
42 switch i32 %condition, label %dest_a [
47 dest_a: ; preds = %loop
50 dest_b: ; preds = %loop
53 dest_c: ; preds = %loop
56 merge: ; preds = %dest_c, %dest_b, %dest_a
57 %obj_to_consume = phi ptr addrspace(1) [ %0, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
58 call void @consume_obj(ptr addrspace(1) %obj_to_consume) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
61 merge.split: ; preds = %merge
62 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]