1*06a8a867SPhilip Reames; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2*06a8a867SPhilip Reames; RUN: opt < %s -rewrite-statepoints-for-gc -S 2>&1 | FileCheck %s 3*06a8a867SPhilip 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" { 10*06a8a867SPhilip Reames; CHECK-LABEL: @select_of_phi( 11*06a8a867SPhilip Reames; CHECK-NEXT: entry: 12*06a8a867SPhilip Reames; CHECK-NEXT: br label [[LOOP:%.*]] 13*06a8a867SPhilip Reames; CHECK: loop: 14*06a8a867SPhilip Reames; CHECK-NEXT: [[DOT01:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_X:%.*]], [[ENTRY:%.*]] ], [ [[BASE_OBJ_X_RELOCATED_CASTED:%.*]], [[MERGE:%.*]] ] 15*06a8a867SPhilip Reames; CHECK-NEXT: [[DOT0:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_Y:%.*]], [[ENTRY]] ], [ [[BASE_OBJ_Y_RELOCATED_CASTED:%.*]], [[MERGE]] ] 16*06a8a867SPhilip Reames; CHECK-NEXT: [[CURRENT_X:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_X]], [[ENTRY]] ], [ [[NEXT_X_RELOCATED_CASTED:%.*]], [[MERGE]] ] 17*06a8a867SPhilip Reames; CHECK-NEXT: [[CURRENT_Y:%.*]] = phi i64 addrspace(1)* [ [[BASE_OBJ_Y]], [[ENTRY]] ], [ [[NEXT_Y_RELOCATED_CASTED:%.*]], [[MERGE]] ] 18*06a8a867SPhilip Reames; CHECK-NEXT: [[CURRENT:%.*]] = phi i64 addrspace(1)* [ null, [[ENTRY]] ], [ [[NEXT_RELOCATED_CASTED:%.*]], [[MERGE]] ] 19*06a8a867SPhilip Reames; CHECK-NEXT: [[CONDITION:%.*]] = call i1 @runtime_value() 20*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_X:%.*]] = getelementptr i64, i64 addrspace(1)* [[CURRENT_X]], i32 1 21*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_Y:%.*]] = getelementptr i64, i64 addrspace(1)* [[CURRENT_Y]], i32 1 22*06a8a867SPhilip Reames; CHECK-NEXT: br i1 [[CONDITION]], label [[TRUE:%.*]], label [[FALSE:%.*]] 23*06a8a867SPhilip Reames; CHECK: true: 24*06a8a867SPhilip Reames; CHECK-NEXT: br label [[MERGE]] 25*06a8a867SPhilip Reames; CHECK: false: 26*06a8a867SPhilip Reames; CHECK-NEXT: br label [[MERGE]] 27*06a8a867SPhilip Reames; CHECK: merge: 28*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_BASE:%.*]] = phi i64 addrspace(1)* [ [[DOT01]], [[TRUE]] ], [ [[DOT0]], [[FALSE]] ], !is_base_value !0 29*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT:%.*]] = phi i64 addrspace(1)* [ [[NEXT_X]], [[TRUE]] ], [ [[NEXT_Y]], [[FALSE]] ] 30*06a8a867SPhilip Reames; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, 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]]) ] 31*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_X_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 3, i32 0) 32*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_X_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[NEXT_X_RELOCATED]] to i64 addrspace(1)* 33*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_Y_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 4, i32 1) 34*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_Y_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[NEXT_Y_RELOCATED]] to i64 addrspace(1)* 35*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 5, i32 2) 36*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[NEXT_RELOCATED]] to i64 addrspace(1)* 37*06a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_X_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 3, i32 3) 38*06a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_X_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[BASE_OBJ_X_RELOCATED]] to i64 addrspace(1)* 39*06a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_Y_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 4, i32 4) 40*06a8a867SPhilip Reames; CHECK-NEXT: [[BASE_OBJ_Y_RELOCATED_CASTED]] = bitcast i8 addrspace(1)* [[BASE_OBJ_Y_RELOCATED]] to i64 addrspace(1)* 41*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 5, i32 5) 42*06a8a867SPhilip Reames; CHECK-NEXT: [[NEXT_BASE_RELOCATED_CASTED:%.*]] = bitcast i8 addrspace(1)* [[NEXT_BASE_RELOCATED]] to i64 addrspace(1)* 43*06a8a867SPhilip Reames; CHECK-NEXT: br label [[LOOP]] 44*06a8a867SPhilip 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