1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s
3 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s
6 declare void @site_for_call_safpeoint()
8 ; derived %merged_value base %merged_value.base
9 define i64 addrspace(1)* @test(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y, i1 %runtime_condition) gc "statepoint-example" {
12 ; CHECK-NEXT: br i1 [[RUNTIME_CONDITION:%.*]], label [[HERE:%.*]], label [[THERE:%.*]]
14 ; CHECK-NEXT: [[X:%.*]] = getelementptr i64, i64 addrspace(1)* [[BASE_OBJ_X:%.*]], i32 1
15 ; CHECK-NEXT: br label [[MERGE:%.*]]
17 ; CHECK-NEXT: [[Y:%.*]] = getelementptr i64, i64 addrspace(1)* [[BASE_OBJ_Y:%.*]], i32 1
18 ; CHECK-NEXT: br label [[MERGE]]
20 ; CHECK-NEXT: [[MERGED_VALUE_BASE:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_X]], [[HERE]] ], [ [[BASE_OBJ_Y]], [[THERE]] ], !is_base_value !0
21 ; CHECK-NEXT: [[MERGED_VALUE:%.*]] = phi i64 addrspace(1)* [ [[X]], [[HERE]] ], [ [[Y]], [[THERE]] ]
22 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @site_for_call_safpeoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[MERGED_VALUE]], i64 addrspace(1)* [[MERGED_VALUE_BASE]]) ]
23 ; CHECK-NEXT: [[MERGED_VALUE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
24 ; CHECK-NEXT: [[MERGED_VALUE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[MERGED_VALUE_RELOCATED]] to i64 addrspace(1)*
25 ; CHECK-NEXT: [[MERGED_VALUE_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
26 ; CHECK-NEXT: [[MERGED_VALUE_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[MERGED_VALUE_BASE_RELOCATED]] to i64 addrspace(1)*
27 ; CHECK-NEXT: ret i64 addrspace(1)* [[MERGED_VALUE_RELOCATED_CASTED]]
30 br i1 %runtime_condition, label %here, label %there
32 here: ; preds = %entry
33 %x = getelementptr i64, i64 addrspace(1)* %base_obj_x, i32 1
36 there: ; preds = %entry
37 %y = getelementptr i64, i64 addrspace(1)* %base_obj_y, i32 1
40 merge: ; preds = %there, %here
41 %merged_value = phi i64 addrspace(1)* [ %x, %here ], [ %y, %there ]
42 call void @site_for_call_safpeoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
43 ret i64 addrspace(1)* %merged_value