blob: d08da73887a3a23a6cc25a0007b24935b4543aee [file] [log] [blame]
Sanjoy Das353a19e2015-06-02 22:33:37 +00001; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
Fedor Sergeev4b86d792017-12-15 09:32:11 +00002; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s
Sanjoy Das353a19e2015-06-02 22:33:37 +00003
Sanjoy Das353a19e2015-06-02 22:33:37 +00004; CHECK: declare i8 addrspace(1)* @some_function_ret_deref()
Sanjoy Das04071082016-01-29 00:28:57 +00005; 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)
8
9declare void @foo()
10
11declare i8 addrspace(1)* @some_function() "gc-leaf-function"
12
13declare void @some_function_consumer(i8 addrspace(1)*) "gc-leaf-function"
14
15declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() "gc-leaf-function"
16declare noalias i8 addrspace(1)* @some_function_ret_noalias() "gc-leaf-function"
Sanjoy Das353a19e2015-06-02 22:33:37 +000017
18define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" {
Sanjoy Das353a19e2015-06-02 22:33:37 +000019entry:
Sanjoy Das04071082016-01-29 00:28:57 +000020 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Sanjoy Das353a19e2015-06-02 22:33:37 +000021 ret i8 addrspace(1)* %a
22}
23
24define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* dereferenceable_or_null(4) %a) gc "statepoint-example" {
Sanjoy Das353a19e2015-06-02 22:33:37 +000025entry:
Sanjoy Das04071082016-01-29 00:28:57 +000026 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
27 ret i8 addrspace(1)* %a
28}
29
30define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" {
31entry:
32 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Sanjoy Das353a19e2015-06-02 22:33:37 +000033 ret i8 addrspace(1)* %a
34}
35
36define i8 addrspace(1)* @test_deref_retval() gc "statepoint-example" {
37; CHECK-LABEL: @test_deref_retval(
Sanjoy Das04071082016-01-29 00:28:57 +000038; CHECK: %a = call i8 addrspace(1)* @some_function()
Sanjoy Das353a19e2015-06-02 22:33:37 +000039entry:
40 %a = call dereferenceable(4) i8 addrspace(1)* @some_function()
Sanjoy Das04071082016-01-29 00:28:57 +000041 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Sanjoy Das353a19e2015-06-02 22:33:37 +000042 ret i8 addrspace(1)* %a
43}
44
45define i8 addrspace(1)* @test_deref_or_null_retval() gc "statepoint-example" {
46; CHECK-LABEL: @test_deref_or_null_retval(
Sanjoy Das04071082016-01-29 00:28:57 +000047; CHECK: %a = call i8 addrspace(1)* @some_function()
Sanjoy Das353a19e2015-06-02 22:33:37 +000048entry:
49 %a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function()
Sanjoy Das04071082016-01-29 00:28:57 +000050 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Igor Laevsky1ef06552015-10-26 19:06:01 +000051 ret i8 addrspace(1)* %a
52}
53
54define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" {
55; CHECK-LABEL: @test_noalias_retval(
Sanjoy Das04071082016-01-29 00:28:57 +000056; CHECK: %a = call i8 addrspace(1)* @some_function()
Igor Laevsky1ef06552015-10-26 19:06:01 +000057entry:
58 %a = call noalias i8 addrspace(1)* @some_function()
Sanjoy Das04071082016-01-29 00:28:57 +000059 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
60 ret i8 addrspace(1)* %a
61}
62
63define 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 !0
66entry:
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) ]
69 ret i8 %tmp
70}
71
72define i8 addrspace(1)* @test_decl_only_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" {
73; CHECK-LABEL: @test_decl_only_attribute(
74; No change here, but the prototype of some_function_ret_deref should have changed.
75; CHECK: call i8 addrspace(1)* @some_function_ret_deref()
76entry:
77 %a = call i8 addrspace(1)* @some_function_ret_deref()
78 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Igor Laevsky1ef06552015-10-26 19:06:01 +000079 ret i8 addrspace(1)* %a
80}
81
82define i8 addrspace(1)* @test_decl_only_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" {
83; CHECK-LABEL: @test_decl_only_noalias(
Igor Laevsky1ef06552015-10-26 19:06:01 +000084; No change here, but the prototype of some_function_ret_noalias should have changed.
85; CHECK: call i8 addrspace(1)* @some_function_ret_noalias()
Sanjoy Das04071082016-01-29 00:28:57 +000086entry:
Igor Laevsky1ef06552015-10-26 19:06:01 +000087 %a = call i8 addrspace(1)* @some_function_ret_noalias()
Sanjoy Das04071082016-01-29 00:28:57 +000088 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Igor Laevsky1ef06552015-10-26 19:06:01 +000089 ret i8 addrspace(1)* %a
90}
91
Sanjoy Das04071082016-01-29 00:28:57 +000092define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" {
93; CHECK-LABEL: @test_callsite_arg_attribute(
Igor Laevsky1ef06552015-10-26 19:06:01 +000094; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr)
Sanjoy Das353a19e2015-06-02 22:33:37 +000095; CHECK: !0 = !{!1, !1, i64 0}
96; CHECK: !1 = !{!"red", !2}
97; CHECK: !2 = !{!"blue"}
Sanjoy Das04071082016-01-29 00:28:57 +000098entry:
99 call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) noalias %ptr)
100 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
101 ret i8 addrspace(1)* %ptr
102}
103!0 = !{!1, !1, i64 0, i64 1}
104!1 = !{!"red", !2}
105!2 = !{!"blue"}