1 ; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
2 ; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s
4 ; CHECK: declare i8 addrspace(1)* @some_function_ret_deref()
5 ; CHECK: define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* %a)
6 ; CHECK: define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* %a)
7 ; CHECK: define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* %a)
11 declare i8 addrspace(1)* @some_function() "gc-leaf-function"
13 declare void @some_function_consumer(i8 addrspace(1)*) "gc-leaf-function"
15 declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() "gc-leaf-function"
16 declare noalias i8 addrspace(1)* @some_function_ret_noalias() "gc-leaf-function"
18 define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" {
20 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
21 ret i8 addrspace(1)* %a
24 define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* dereferenceable_or_null(4) %a) gc "statepoint-example" {
26 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
27 ret i8 addrspace(1)* %a
30 define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" {
32 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
33 ret i8 addrspace(1)* %a
36 define i8 addrspace(1)* @test_deref_retval() gc "statepoint-example" {
37 ; CHECK-LABEL: @test_deref_retval(
38 ; CHECK: %a = call i8 addrspace(1)* @some_function()
40 %a = call dereferenceable(4) i8 addrspace(1)* @some_function()
41 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
42 ret i8 addrspace(1)* %a
45 define i8 addrspace(1)* @test_deref_or_null_retval() gc "statepoint-example" {
46 ; CHECK-LABEL: @test_deref_or_null_retval(
47 ; CHECK: %a = call i8 addrspace(1)* @some_function()
49 %a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function()
50 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
51 ret i8 addrspace(1)* %a
54 define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" {
55 ; CHECK-LABEL: @test_noalias_retval(
56 ; CHECK: %a = call i8 addrspace(1)* @some_function()
58 %a = call noalias i8 addrspace(1)* @some_function()
59 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
60 ret i8 addrspace(1)* %a
63 define i8 @test_md(i8 addrspace(1)* %ptr) gc "statepoint-example" {
64 ; CHECK-LABEL: @test_md(
65 ; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa [[TAG_old:!.*]]
67 %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0
68 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
72 ; Same as test_md() above, but with new-format TBAA metadata.
73 define i8 @test_md_new(i8 addrspace(1)* %ptr) gc "statepoint-example" {
74 ; CHECK-LABEL: @test_md_new(
75 ; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa [[TAG_new:!.*]]
77 %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !4
78 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
82 define i8 addrspace(1)* @test_decl_only_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" {
83 ; CHECK-LABEL: @test_decl_only_attribute(
84 ; No change here, but the prototype of some_function_ret_deref should have changed.
85 ; CHECK: call i8 addrspace(1)* @some_function_ret_deref()
87 %a = call i8 addrspace(1)* @some_function_ret_deref()
88 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
89 ret i8 addrspace(1)* %a
92 define i8 addrspace(1)* @test_decl_only_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" {
93 ; CHECK-LABEL: @test_decl_only_noalias(
94 ; No change here, but the prototype of some_function_ret_noalias should have changed.
95 ; CHECK: call i8 addrspace(1)* @some_function_ret_noalias()
97 %a = call i8 addrspace(1)* @some_function_ret_noalias()
98 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
99 ret i8 addrspace(1)* %a
102 define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" {
103 ; CHECK-LABEL: @test_callsite_arg_attribute(
104 ; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr)
106 call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) noalias %ptr)
107 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
108 ret i8 addrspace(1)* %ptr
111 !0 = !{!1, !2, i64 0, i64 1} ; TAG_old
112 !1 = !{!"type_base_old", !2, i64 0}
113 !2 = !{!"type_access_old", !3}
116 !4 = !{!5, !6, i64 0, i64 1, i64 1} ; TAG_new
117 !5 = !{!3, i64 1, !"type_base_new", !6, i64 0, i64 1}
118 !6 = !{!3, i64 1, !"type_access_new"}
120 ; CHECK-DAG: [[ROOT:!.*]] = !{!"root"}
121 ; CHECK-DAG: [[TYPE_access_old:!.*]] = !{!"type_access_old", [[ROOT]]}
122 ; CHECK-DAG: [[TYPE_base_old:!.*]] = !{!"type_base_old", [[TYPE_access_old]], i64 0}
123 ; CHECK-DAG: [[TAG_old]] = !{[[TYPE_base_old]], [[TYPE_access_old]], i64 0}
124 ; CHECK-DAG: [[TYPE_access_new:!.*]] = !{[[ROOT]], i64 1, !"type_access_new"}
125 ; CHECK-DAG: [[TYPE_base_new:!.*]] = !{[[ROOT]], i64 1, !"type_base_new", [[TYPE_access_new]], i64 0, i64 1}
126 ; CHECK-DAG: [[TAG_new]] = !{[[TYPE_base_new]], [[TYPE_access_new]], i64 0, i64 1}