diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-06-02 22:33:37 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-06-02 22:33:37 +0000 |
commit | 353a19e13c2c580518b1ca8a070e6538e7353db7 (patch) | |
tree | e7cb37ab326cbd4796c3d5282d6eee92ae732565 /llvm/test/Transforms/RewriteStatepointsForGC | |
parent | ea45f0e05457a93320714d9433cc1cd2a03e293e (diff) | |
download | bcm5719-llvm-353a19e13c2c580518b1ca8a070e6538e7353db7.tar.gz bcm5719-llvm-353a19e13c2c580518b1ca8a070e6538e7353db7.zip |
[RewriteStatepointsForGC] Strip deref info after rewriting.
Summary:
Once a gc.statepoint has been rewritten to relocate live references, the
SSA values represent physical pointers instead of logical references.
Logical dereferencability does not imply physical dereferencability and
after RewriteStatepointsForGC has run any attributes that imply
dereferencability of the logical references need to be stripped.
This current approach is conservative, and can be made more precise
later if needed. For starters, we need to strip dereferencable
attributes only from pointers that live in the GC address space.
Reviewers: reames, pgavlin
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10105
llvm-svn: 238883
Diffstat (limited to 'llvm/test/Transforms/RewriteStatepointsForGC')
-rw-r--r-- | llvm/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll b/llvm/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll new file mode 100644 index 00000000000..5913db21fcf --- /dev/null +++ b/llvm/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll @@ -0,0 +1,77 @@ +; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s + +declare void @foo() +declare i8 addrspace(1)* @some_function() +declare void @some_function_consumer(i8 addrspace(1)*) +declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() +; CHECK: declare i8 addrspace(1)* @some_function_ret_deref() + +define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" { +; CHECK: define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* %a) +entry: + call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + ret i8 addrspace(1)* %a +} + +define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* dereferenceable_or_null(4) %a) gc "statepoint-example" { +; CHECK: define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* %a) +entry: + call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + ret i8 addrspace(1)* %a +} + +define i8 addrspace(1)* @test_deref_retval() gc "statepoint-example" { +; CHECK-LABEL: @test_deref_retval( +entry: + %a = call dereferenceable(4) i8 addrspace(1)* @some_function() +; CHECK: %a = call i8 addrspace(1)* @some_function() + call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + ret i8 addrspace(1)* %a +} + +define i8 addrspace(1)* @test_deref_or_null_retval() gc "statepoint-example" { +; CHECK-LABEL: @test_deref_or_null_retval( +entry: + %a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function() +; CHECK: %a = call i8 addrspace(1)* @some_function() + call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + ret i8 addrspace(1)* %a +} + +define i8 @test_md(i8 addrspace(1)* %ptr) gc "statepoint-example" { +; CHECK-LABEL: @test_md( + entry: +; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0 + %tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0 + call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + ret i8 %tmp +} + +define i8 addrspace(1)* @test_decl_only_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { +; CHECK-LABEL: @test_decl_only_attribute( +entry: +; No change here, but the prototype of some_function_ret_deref should have changed. +; CHECK: call i8 addrspace(1)* @some_function_ret_deref() + %a = call i8 addrspace(1)* @some_function_ret_deref() + call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + ret i8 addrspace(1)* %a +} + +define i8 addrspace(1)* @test_callsite_arg_attribute(i8 addrspace(1)* %ptr) gc "statepoint-example" { +; CHECK-LABEL: @test_callsite_arg_attribute( +entry: +; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr) + call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) %ptr) + call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) + ret i8 addrspace(1)* %ptr +} + +declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) + +!0 = !{!1, !1, i64 0, i64 1} +!1 = !{!"red", !2} +!2 = !{!"blue"} + +; CHECK: !0 = !{!1, !1, i64 0} +; CHECK: !1 = !{!"red", !2} +; CHECK: !2 = !{!"blue"} |