1 ; Test that we can correctly handle vectors of pointers in statepoint 2 ; rewriting. 3 ; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s 4 5 ; A non-vector relocation for comparison 6 define i64 addrspace(1)* @test(i64 addrspace(1)* %obj) gc "statepoint-example" { 7 ; CHECK-LABEL: test 8 ; CHECK: gc.statepoint 9 ; CHECK-NEXT: gc.relocate 10 ; CHECK-NEXT: bitcast 11 ; CHECK-NEXT: ret i64 addrspace(1)* 12 ; A base vector from a argument 13 entry: 14 call void @do_safepoint() [ "deopt"() ] 15 ret i64 addrspace(1)* %obj 16 } 17 18 ; A vector argument 19 define <2 x i64 addrspace(1)*> @test2(<2 x i64 addrspace(1)*> %obj) gc "statepoint-example" { 20 ; CHECK-LABEL: test2 21 ; CHECK-NEXT: gc.statepoint 22 ; CHECK-NEXT: gc.relocate 23 ; CHECK-NEXT: bitcast 24 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> 25 call void @do_safepoint() [ "deopt"() ] 26 ret <2 x i64 addrspace(1)*> %obj 27 } 28 29 ; A load 30 define <2 x i64 addrspace(1)*> @test3(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" { 31 ; CHECK-LABEL: test3 32 ; CHECK: load 33 ; CHECK-NEXT: gc.statepoint 34 ; CHECK-NEXT: gc.relocate 35 ; CHECK-NEXT: bitcast 36 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> 37 entry: 38 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr 39 call void @do_safepoint() [ "deopt"() ] 40 ret <2 x i64 addrspace(1)*> %obj 41 } 42 43 declare i32 @fake_personality_function() 44 45 ; When a statepoint is an invoke rather than a call 46 define <2 x i64 addrspace(1)*> @test4(<2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" personality i32 ()* @fake_personality_function { 47 ; CHECK-LABEL: test4 48 ; CHECK: load 49 ; CHECK-NEXT: gc.statepoint 50 entry: 51 %obj = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr 52 invoke void @do_safepoint() [ "deopt"() ] 53 to label %normal_return unwind label %exceptional_return 54 55 normal_return: ; preds = %entry 56 ; CHECK-LABEL: normal_return: 57 ; CHECK: gc.relocate 58 ; CHECK-NEXT: bitcast 59 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> 60 ret <2 x i64 addrspace(1)*> %obj 61 62 exceptional_return: ; preds = %entry 63 ; CHECK-LABEL: exceptional_return: 64 ; CHECK: gc.relocate 65 ; CHECK-NEXT: bitcast 66 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> 67 %landing_pad4 = landingpad token 68 cleanup 69 ret <2 x i64 addrspace(1)*> %obj 70 } 71 72 ; A newly created vector 73 define <2 x i64 addrspace(1)*> @test5(i64 addrspace(1)* %p) gc "statepoint-example" { 74 ; CHECK-LABEL: test5 75 ; CHECK: insertelement 76 ; CHECK-NEXT: insertelement 77 ; CHECK-NEXT: gc.statepoint 78 ; CHECK-NEXT: gc.relocate 79 ; CHECK-NEXT: bitcast 80 ; CHECK-NEXT: gc.relocate 81 ; CHECK-NEXT: bitcast 82 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> %vec.relocated.casted 83 entry: 84 %vec = insertelement <2 x i64 addrspace(1)*> undef, i64 addrspace(1)* %p, i32 0 85 call void @do_safepoint() [ "deopt"() ] 86 ret <2 x i64 addrspace(1)*> %vec 87 } 88 89 ; A merge point 90 define <2 x i64 addrspace(1)*> @test6(i1 %cnd, <2 x i64 addrspace(1)*>* %ptr) gc "statepoint-example" { 91 ; CHECK-LABEL: test6 92 entry: 93 br i1 %cnd, label %taken, label %untaken 94 95 taken: ; preds = %entry 96 %obja = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr 97 br label %merge 98 99 untaken: ; preds = %entry 100 %objb = load <2 x i64 addrspace(1)*>, <2 x i64 addrspace(1)*>* %ptr 101 br label %merge 102 103 merge: ; preds = %untaken, %taken 104 ; CHECK-LABEL: merge: 105 ; CHECK-NEXT: = phi 106 ; CHECK-NEXT: = phi 107 ; CHECK-NEXT: gc.statepoint 108 ; CHECK-NEXT: gc.relocate 109 ; CHECK-NEXT: bitcast 110 ; CHECK-NEXT: gc.relocate 111 ; CHECK-NEXT: bitcast 112 ; CHECK-NEXT: ret <2 x i64 addrspace(1)*> 113 %obj = phi <2 x i64 addrspace(1)*> [ %obja, %taken ], [ %objb, %untaken ] 114 call void @do_safepoint() [ "deopt"() ] 115 ret <2 x i64 addrspace(1)*> %obj 116 } 117 118 declare void @do_safepoint() 119