1; RUN: opt %s -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles -S 2>&1 | FileCheck %s 2 3 4declare void @use_obj16(i16 addrspace(1)*) "gc-leaf-function" 5declare void @use_obj32(i32 addrspace(1)*) "gc-leaf-function" 6declare void @use_obj64(i64 addrspace(1)*) "gc-leaf-function" 7 8declare void @do_safepoint() 9 10define void @test_gep_const(i32 addrspace(1)* %base) gc "statepoint-example" { 11; CHECK-LABEL: test_gep_const 12entry: 13 %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15 14 call void @do_safepoint() [ "deopt"() ] 15 call void @use_obj32(i32 addrspace(1)* %base) 16 call void @use_obj32(i32 addrspace(1)* %ptr) 17 ret void 18} 19 20define void @test_gep_idx(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { 21; CHECK-LABEL: test_gep_idx 22entry: 23 %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 %idx 24 call void @do_safepoint() [ "deopt"() ] 25 call void @use_obj32(i32 addrspace(1)* %base) 26 call void @use_obj32(i32 addrspace(1)* %ptr) 27 ret void 28} 29 30define void @test_bitcast(i32 addrspace(1)* %base) gc "statepoint-example" { 31; CHECK-LABEL: test_bitcast 32entry: 33 %ptr = bitcast i32 addrspace(1)* %base to i64 addrspace(1)* 34 call void @do_safepoint() [ "deopt"() ] 35 call void @use_obj32(i32 addrspace(1)* %base) 36 call void @use_obj64(i64 addrspace(1)* %ptr) 37 ret void 38} 39 40define void @test_bitcast_gep(i32 addrspace(1)* %base) gc "statepoint-example" { 41; CHECK-LABEL: test_bitcast_gep 42entry: 43 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 44 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* 45 call void @do_safepoint() [ "deopt"() ] 46 call void @use_obj32(i32 addrspace(1)* %base) 47 call void @use_obj64(i64 addrspace(1)* %ptr.cast) 48 ret void 49} 50 51define void @test_intersecting_chains(i32 addrspace(1)* %base, i32 %idx) gc "statepoint-example" { 52; CHECK-LABEL: test_intersecting_chains 53entry: 54 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 55 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* 56 %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)* 57 call void @do_safepoint() [ "deopt"() ] 58 call void @use_obj64(i64 addrspace(1)* %ptr.cast) 59 call void @use_obj16(i16 addrspace(1)* %ptr.cast2) 60 ret void 61} 62 63define void @test_cost_threshold(i32 addrspace(1)* %base, i32 %idx1, i32 %idx2, i32 %idx3) gc "statepoint-example" { 64; CHECK-LABEL: test_cost_threshold 65entry: 66 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 67 %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 %idx1 68 %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 %idx2 69 %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 %idx3 70 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep4 to i64 addrspace(1)* 71 call void @do_safepoint() [ "deopt"() ] 72 call void @use_obj64(i64 addrspace(1)* %ptr.cast) 73 ret void 74} 75 76define void @test_two_derived(i32 addrspace(1)* %base) gc "statepoint-example" { 77; CHECK-LABEL: test_two_derived 78entry: 79 %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15 80 %ptr2 = getelementptr i32, i32 addrspace(1)* %base, i32 12 81 call void @do_safepoint() [ "deopt"() ] 82 call void @use_obj32(i32 addrspace(1)* %ptr) 83 call void @use_obj32(i32 addrspace(1)* %ptr2) 84 ret void 85} 86 87define void @test_gep_smallint_array([3 x i32] addrspace(1)* %base) gc "statepoint-example" { 88; CHECK-LABEL: test_gep_smallint_array 89entry: 90 %ptr = getelementptr [3 x i32], [3 x i32] addrspace(1)* %base, i32 0, i32 2 91 call void @do_safepoint() [ "deopt"() ] 92 call void @use_obj32(i32 addrspace(1)* %ptr) 93 ret void 94} 95 96declare i32 @fake_personality_function() 97 98define void @test_invoke(i32 addrspace(1)* %base) gc "statepoint-example" personality i32 ()* @fake_personality_function { 99; CHECK-LABEL: test_invoke 100entry: 101 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 102 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)* 103 %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)* 104 invoke void @do_safepoint() [ "deopt"() ] 105 to label %normal unwind label %exception 106 107normal: ; preds = %entry 108 call void @use_obj64(i64 addrspace(1)* %ptr.cast) 109 call void @use_obj16(i16 addrspace(1)* %ptr.cast2) 110 ret void 111 112exception: ; preds = %entry 113 %landing_pad4 = landingpad { i8*, i32 } 114 cleanup 115 call void @use_obj64(i64 addrspace(1)* %ptr.cast) 116 call void @use_obj16(i16 addrspace(1)* %ptr.cast2) 117 ret void 118} 119 120define void @test_loop(i32 addrspace(1)* %base) gc "statepoint-example" { 121; CHECK-LABEL: test_loop 122entry: 123 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 124 br label %loop 125 126loop: ; preds = %loop, %entry 127 call void @use_obj32(i32 addrspace(1)* %ptr.gep) 128 call void @do_safepoint() [ "deopt"() ] 129 br label %loop 130} 131 132define void @test_too_long(i32 addrspace(1)* %base) gc "statepoint-example" { 133; CHECK-LABEL: test_too_long 134entry: 135 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15 136 %ptr.gep1 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 15 137 %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep1, i32 15 138 %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 15 139 %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 15 140 %ptr.gep5 = getelementptr i32, i32 addrspace(1)* %ptr.gep4, i32 15 141 %ptr.gep6 = getelementptr i32, i32 addrspace(1)* %ptr.gep5, i32 15 142 %ptr.gep7 = getelementptr i32, i32 addrspace(1)* %ptr.gep6, i32 15 143 %ptr.gep8 = getelementptr i32, i32 addrspace(1)* %ptr.gep7, i32 15 144 %ptr.gep9 = getelementptr i32, i32 addrspace(1)* %ptr.gep8, i32 15 145 %ptr.gep10 = getelementptr i32, i32 addrspace(1)* %ptr.gep9, i32 15 146 %ptr.gep11 = getelementptr i32, i32 addrspace(1)* %ptr.gep10, i32 15 147 call void @do_safepoint() [ "deopt"() ] 148 call void @use_obj32(i32 addrspace(1)* %ptr.gep11) 149 ret void 150} 151