106a8a867SPhilip Reames; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 206a8a867SPhilip Reames; RUN: opt < %s -rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s 306a8a867SPhilip Reames; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s 4cee313d2SEric Christopher 5cee313d2SEric Christopherdeclare i1 @runtime_value() "gc-leaf-function" 6cee313d2SEric Christopher 7cee313d2SEric Christopherdeclare void @do_safepoint() 8cee313d2SEric Christopher 9cee313d2SEric Christopherdefine void @select_of_phi(i64 addrspace(1)* %base_obj_x, i64 addrspace(1)* %base_obj_y) gc "statepoint-example" { 1006a8a867SPhilip Reames; CHECK-LABEL: @select_of_phi( 1106a8a867SPhilip Reames; CHECK-NEXT: entry: 1206a8a867SPhilip Reames; CHECK-NEXT: br label [[LOOP:%.*]] 1306a8a867SPhilip Reames; CHECK: loop: 1406a8a867SPhilip Reames; CHECK-NEXT: [[DOT01:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_X:%.*]], [[ENTRY:%.*]] ], [ [[BASE_OBJ_X_RELOCATED_CASTED:%.*]], [[MERGE:%.*]] ] 1506a8a867SPhilip Reames; CHECK-NEXT: [[DOT0:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_Y:%.*]], [[ENTRY]] ], [ [[BASE_OBJ_Y_RELOCATED_CASTED:%.*]], [[MERGE]] ] 1606a8a867SPhilip Reames; CHECK-NEXT: [[CURRENT_X:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_X]], [[ENTRY]] ], [ [[NEXT_X_RELOCATED_CASTED:%.*]], [[MERGE]] ] 1706a8a867SPhilip Reames; CHECK-NEXT: [[CURRENT_Y:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_Y]], [[ENTRY]] ], [ [[NEXT_Y_RELOCATED_CASTED:%.*]], [[MERGE]] ] 1806a8a867SPhilip Reames; CHECK-NEXT: [[CURRENT:%.*]] = phi i64 addrspace(1)* [ null, [[ENTRY]] ], [ [[NEXT_RELOCATED_CASTED:%.*]], [[MERGE]] ] 1906a8a867SPhilip Reames; CHECK-NEXT: [[CONDITION:%.*]] = call i1 @runtime_value() 2006a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_X:%.*]] = getelementptr i64, i64 addrspace(1)* [[CURRENT_X]], i32 1 2106a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_Y:%.*]] = getelementptr i64, i64 addrspace(1)* [[CURRENT_Y]], i32 1 2206a8a867SPhilip Reames; CHECK-NEXT: br i1 [[CONDITION]], label [[TRUE:%.*]], label [[FALSE:%.*]] 2306a8a867SPhilip Reames; CHECK: true: 2406a8a867SPhilip Reames; CHECK-NEXT: br label [[MERGE]] 2506a8a867SPhilip Reames; CHECK: false: 2606a8a867SPhilip Reames; CHECK-NEXT: br label [[MERGE]] 2706a8a867SPhilip Reames; CHECK: merge: 2806a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_BASE:%.*]] = phi i64 addrspace(1)* [ [[DOT01]], [[TRUE]] ], [ [[DOT0]], [[FALSE]] ], !is_base_value !0 2906a8a867SPhilip Reames; CHECK-NEXT: [[NEXT:%.*]] = phi i64 addrspace(1)* [ [[NEXT_X]], [[TRUE]] ], [ [[NEXT_Y]], [[FALSE]] ] 30*c680eeabSNikita Popov; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* elementtype(void ()) @do_safepoint, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0), "gc-live"(i64 addrspace(1)* [[NEXT_X]], i64 addrspace(1)* [[NEXT_Y]], i64 addrspace(1)* [[NEXT]], i64 addrspace(1)* [[DOT01]], i64 addrspace(1)* [[DOT0]], i64 addrspace(1)* [[NEXT_BASE]]) ] 3106a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_X_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 3, i32 0) 3206a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_X_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[NEXT_X_RELOCATED]] to i64 addrspace(1)* 3306a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_Y_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 4, i32 1) 3406a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_Y_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[NEXT_Y_RELOCATED]] to i64 addrspace(1)* 3506a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 5, i32 2) 3606a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[NEXT_RELOCATED]] to i64 addrspace(1)* 3706a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_X_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 3, i32 3) 3806a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_X_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[BASE_OBJ_X_RELOCATED]] to i64 addrspace(1)* 3906a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_Y_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 4, i32 4) 4006a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_Y_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[BASE_OBJ_Y_RELOCATED]] to i64 addrspace(1)* 4106a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 5, i32 5) 4206a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[NEXT_BASE_RELOCATED]] to i64 addrspace(1)* 4306a8a867SPhilip Reames; CHECK-NEXT: br label [[LOOP]] 4406a8a867SPhilip Reames; 45cee313d2SEric Christopherentry: 46cee313d2SEric Christopher br label %loop 47cee313d2SEric Christopher 48cee313d2SEric Christopherloop: ; preds = %merge, %entry 49cee313d2SEric Christopher %current_x = phi i64 addrspace(1)* [ %base_obj_x, %entry ], [ %next_x, %merge ] 50cee313d2SEric Christopher %current_y = phi i64 addrspace(1)* [ %base_obj_y, %entry ], [ %next_y, %merge ] 51cee313d2SEric Christopher %current = phi i64 addrspace(1)* [ null, %entry ], [ %next, %merge ] 52cee313d2SEric Christopher %condition = call i1 @runtime_value() 53cee313d2SEric Christopher %next_x = getelementptr i64, i64 addrspace(1)* %current_x, i32 1 54cee313d2SEric Christopher %next_y = getelementptr i64, i64 addrspace(1)* %current_y, i32 1 55cee313d2SEric Christopher br i1 %condition, label %true, label %false 56cee313d2SEric Christopher 57cee313d2SEric Christophertrue: ; preds = %loop 58cee313d2SEric Christopher br label %merge 59cee313d2SEric Christopher 60cee313d2SEric Christopherfalse: ; preds = %loop 61cee313d2SEric Christopher br label %merge 62cee313d2SEric Christopher 63cee313d2SEric Christophermerge: ; preds = %false, %true 64cee313d2SEric Christopher %next = phi i64 addrspace(1)* [ %next_x, %true ], [ %next_y, %false ] 65cee313d2SEric Christopher call void @do_safepoint() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 66cee313d2SEric Christopher br label %loop 67cee313d2SEric Christopher} 68