1 ; RUN: opt -S -rewrite-statepoints-for-gc -rs4gc-use-deopt-bundles < %s | FileCheck %s 2 3 ; CHECK: declare i8 addrspace(1)* @some_function_ret_deref() 4 ; CHECK: define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* %a) 5 ; CHECK: define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* %a) 6 ; CHECK: define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* %a) 7 8 declare void @foo() 9 10 declare i8 addrspace(1)* @some_function() "gc-leaf-function" 11 12 declare void @some_function_consumer(i8 addrspace(1)*) "gc-leaf-function" 13 14 declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() "gc-leaf-function" 15 declare noalias i8 addrspace(1)* @some_function_ret_noalias() "gc-leaf-function" 16 17 define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" { 18 entry: 19 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 20 ret i8 addrspace(1)* %a 21 } 22 23 define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* dereferenceable_or_null(4) %a) gc "statepoint-example" { 24 entry: 25 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 26 ret i8 addrspace(1)* %a 27 } 28 29 define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" { 30 entry: 31 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 32 ret i8 addrspace(1)* %a 33 } 34 35 define i8 addrspace(1)* @test_deref_retval() gc "statepoint-example" { 36 ; CHECK-LABEL: @test_deref_retval( 37 ; CHECK: %a = call i8 addrspace(1)* @some_function() 38 entry: 39 %a = call dereferenceable(4) i8 addrspace(1)* @some_function() 40 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 41 ret i8 addrspace(1)* %a 42 } 43 44 define i8 addrspace(1)* @test_deref_or_null_retval() gc "statepoint-example" { 45 ; CHECK-LABEL: @test_deref_or_null_retval( 46 ; CHECK: %a = call i8 addrspace(1)* @some_function() 47 entry: 48 %a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function() 49 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 50 ret i8 addrspace(1)* %a 51 } 52 53 define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" { 54 ; CHECK-LABEL: @test_noalias_retval( 55 ; CHECK: %a = call i8 addrspace(1)* @some_function() 56 entry: 57 %a = call noalias i8 addrspace(1)* @some_function() 58 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 59 ret i8 addrspace(1)* %a 60 } 61 62 define i8 @test_md(i8 addrspace(1)* %ptr) gc "statepoint-example" { 63 ; CHECK-LABEL: @test_md( 64 ; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0 65 entry: 66 %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0 67 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 68 ret i8 %tmp 69 } 70 71 define i8 addrspace(1)* @test_decl_only_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { 72 ; CHECK-LABEL: @test_decl_only_attribute( 73 ; No change here, but the prototype of some_function_ret_deref should have changed. 74 ; CHECK: call i8 addrspace(1)* @some_function_ret_deref() 75 entry: 76 %a = call i8 addrspace(1)* @some_function_ret_deref() 77 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 78 ret i8 addrspace(1)* %a 79 } 80 81 define i8 addrspace(1)* @test_decl_only_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" { 82 ; CHECK-LABEL: @test_decl_only_noalias( 83 ; No change here, but the prototype of some_function_ret_noalias should have changed. 84 ; CHECK: call i8 addrspace(1)* @some_function_ret_noalias() 85 entry: 86 %a = call i8 addrspace(1)* @some_function_ret_noalias() 87 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 88 ret i8 addrspace(1)* %a 89 } 90 91 define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { 92 ; CHECK-LABEL: @test_callsite_arg_attribute( 93 ; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr) 94 ; CHECK: !0 = !{!1, !1, i64 0} 95 ; CHECK: !1 = !{!"red", !2} 96 ; CHECK: !2 = !{!"blue"} 97 entry: 98 call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) noalias %ptr) 99 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ] 100 ret i8 addrspace(1)* %ptr 101 } 102 !0 = !{!1, !1, i64 0, i64 1} 103 !1 = !{!"red", !2} 104 !2 = !{!"blue"} 105