blob: 551da0843ad0623efa3b606855cb29d7999c00ef [file] [log] [blame]
Sanjoy Das353a19e2015-06-02 22:33:37 +00001; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
2
Sanjoy Das353a19e2015-06-02 22:33:37 +00003; CHECK: declare i8 addrspace(1)* @some_function_ret_deref()
Sanjoy Das04071082016-01-29 00:28:57 +00004; 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
8declare void @foo()
9
10declare i8 addrspace(1)* @some_function() "gc-leaf-function"
11
12declare void @some_function_consumer(i8 addrspace(1)*) "gc-leaf-function"
13
14declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() "gc-leaf-function"
15declare noalias i8 addrspace(1)* @some_function_ret_noalias() "gc-leaf-function"
Sanjoy Das353a19e2015-06-02 22:33:37 +000016
17define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" {
Sanjoy Das353a19e2015-06-02 22:33:37 +000018entry:
Sanjoy Das04071082016-01-29 00:28:57 +000019 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Sanjoy Das353a19e2015-06-02 22:33:37 +000020 ret i8 addrspace(1)* %a
21}
22
23define 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 +000024entry:
Sanjoy Das04071082016-01-29 00:28:57 +000025 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
26 ret i8 addrspace(1)* %a
27}
28
29define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" {
30entry:
31 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Sanjoy Das353a19e2015-06-02 22:33:37 +000032 ret i8 addrspace(1)* %a
33}
34
35define i8 addrspace(1)* @test_deref_retval() gc "statepoint-example" {
36; CHECK-LABEL: @test_deref_retval(
Sanjoy Das04071082016-01-29 00:28:57 +000037; CHECK: %a = call i8 addrspace(1)* @some_function()
Sanjoy Das353a19e2015-06-02 22:33:37 +000038entry:
39 %a = call dereferenceable(4) i8 addrspace(1)* @some_function()
Sanjoy Das04071082016-01-29 00:28:57 +000040 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Sanjoy Das353a19e2015-06-02 22:33:37 +000041 ret i8 addrspace(1)* %a
42}
43
44define i8 addrspace(1)* @test_deref_or_null_retval() gc "statepoint-example" {
45; CHECK-LABEL: @test_deref_or_null_retval(
Sanjoy Das04071082016-01-29 00:28:57 +000046; CHECK: %a = call i8 addrspace(1)* @some_function()
Sanjoy Das353a19e2015-06-02 22:33:37 +000047entry:
48 %a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function()
Sanjoy Das04071082016-01-29 00:28:57 +000049 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Igor Laevsky1ef06552015-10-26 19:06:01 +000050 ret i8 addrspace(1)* %a
51}
52
53define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" {
54; CHECK-LABEL: @test_noalias_retval(
Sanjoy Das04071082016-01-29 00:28:57 +000055; CHECK: %a = call i8 addrspace(1)* @some_function()
Igor Laevsky1ef06552015-10-26 19:06:01 +000056entry:
57 %a = call noalias i8 addrspace(1)* @some_function()
Sanjoy Das04071082016-01-29 00:28:57 +000058 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
59 ret i8 addrspace(1)* %a
60}
61
62define 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
65entry:
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
71define 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()
75entry:
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) ]
Igor Laevsky1ef06552015-10-26 19:06:01 +000078 ret i8 addrspace(1)* %a
79}
80
81define i8 addrspace(1)* @test_decl_only_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" {
82; CHECK-LABEL: @test_decl_only_noalias(
Igor Laevsky1ef06552015-10-26 19:06:01 +000083; No change here, but the prototype of some_function_ret_noalias should have changed.
84; CHECK: call i8 addrspace(1)* @some_function_ret_noalias()
Sanjoy Das04071082016-01-29 00:28:57 +000085entry:
Igor Laevsky1ef06552015-10-26 19:06:01 +000086 %a = call i8 addrspace(1)* @some_function_ret_noalias()
Sanjoy Das04071082016-01-29 00:28:57 +000087 call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
Igor Laevsky1ef06552015-10-26 19:06:01 +000088 ret i8 addrspace(1)* %a
89}
90
Sanjoy Das04071082016-01-29 00:28:57 +000091define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" {
92; CHECK-LABEL: @test_callsite_arg_attribute(
Igor Laevsky1ef06552015-10-26 19:06:01 +000093; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr)
Sanjoy Das353a19e2015-06-02 22:33:37 +000094; CHECK: !0 = !{!1, !1, i64 0}
95; CHECK: !1 = !{!"red", !2}
96; CHECK: !2 = !{!"blue"}
Sanjoy Das04071082016-01-29 00:28:57 +000097entry:
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"}