1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/Transforms/RewriteStatepointsForGC/deref-pointers.ll
Eli Friedman f5d3346387 Infer alignment of unmarked loads in IR/bitcode parsing.
For IR generated by a compiler, this is really simple: you just take the
datalayout from the beginning of the file, and apply it to all the IR
later in the file. For optimization testcases that don't care about the
datalayout, this is also really simple: we just use the default
datalayout.

The complexity here comes from the fact that some LLVM tools allow
overriding the datalayout: some tools have an explicit flag for this,
some tools will infer a datalayout based on the code generation target.
Supporting this properly required plumbing through a bunch of new
machinery: we want to allow overriding the datalayout after the
datalayout is parsed from the file, but before we use any information
from it. Therefore, IR/bitcode parsing now has a callback to allow tools
to compute the datalayout at the appropriate time.

Not sure if I covered all the LLVM tools that want to use the callback.
(clang? lli? Misc IR manipulation tools like llvm-link?). But this is at
least enough for all the LLVM regression tests, and IR without a
datalayout is not something frontends should generate.

This change had some sort of weird effects for certain CodeGen
regression tests: if the datalayout is overridden with a datalayout with
a different program or stack address space, we now parse IR based on the
overridden datalayout, instead of the one written in the file (or the
default one, if none is specified). This broke a few AVR tests, and one
AMDGPU test.

Outside the CodeGen tests I mentioned, the test changes are all just
fixing CHECK lines and moving around datalayout lines in weird places.

Differential Revision: https://reviews.llvm.org/D78403
2020-05-14 13:03:50 -07:00

127 lines
5.0 KiB
LLVM

; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
; RUN: opt -S -passes=rewrite-statepoints-for-gc < %s | FileCheck %s
; CHECK: declare i8 addrspace(1)* @some_function_ret_deref()
; CHECK: define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* %a)
; CHECK: define i8 addrspace(1)* @test_deref_or_null_arg(i8 addrspace(1)* %a)
; CHECK: define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* %a)
declare void @foo()
declare i8 addrspace(1)* @some_function() "gc-leaf-function"
declare void @some_function_consumer(i8 addrspace(1)*) "gc-leaf-function"
declare dereferenceable(4) i8 addrspace(1)* @some_function_ret_deref() "gc-leaf-function"
declare noalias i8 addrspace(1)* @some_function_ret_noalias() "gc-leaf-function"
define i8 addrspace(1)* @test_deref_arg(i8 addrspace(1)* dereferenceable(4) %a) gc "statepoint-example" {
entry:
call void @foo() [ "deopt"(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" {
entry:
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
ret i8 addrspace(1)* %a
}
define i8 addrspace(1)* @test_noalias_arg(i8 addrspace(1)* noalias %a) gc "statepoint-example" {
entry:
call void @foo() [ "deopt"(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(
; CHECK: %a = call i8 addrspace(1)* @some_function()
entry:
%a = call dereferenceable(4) i8 addrspace(1)* @some_function()
call void @foo() [ "deopt"(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(
; CHECK: %a = call i8 addrspace(1)* @some_function()
entry:
%a = call dereferenceable_or_null(4) i8 addrspace(1)* @some_function()
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
ret i8 addrspace(1)* %a
}
define i8 addrspace(1)* @test_noalias_retval() gc "statepoint-example" {
; CHECK-LABEL: @test_noalias_retval(
; CHECK: %a = call i8 addrspace(1)* @some_function()
entry:
%a = call noalias i8 addrspace(1)* @some_function()
call void @foo() [ "deopt"(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(
; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, align 1, !tbaa [[TAG_old:!.*]]
entry:
%tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !0
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
ret i8 %tmp
}
; Same as test_md() above, but with new-format TBAA metadata.
define i8 @test_md_new(i8 addrspace(1)* %ptr) gc "statepoint-example" {
; CHECK-LABEL: @test_md_new(
; CHECK: %tmp = load i8, i8 addrspace(1)* %ptr, align 1, !tbaa [[TAG_new:!.*]]
entry:
%tmp = load i8, i8 addrspace(1)* %ptr, !tbaa !4
call void @foo() [ "deopt"(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(
; No change here, but the prototype of some_function_ret_deref should have changed.
; CHECK: call i8 addrspace(1)* @some_function_ret_deref()
entry:
%a = call i8 addrspace(1)* @some_function_ret_deref()
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
ret i8 addrspace(1)* %a
}
define i8 addrspace(1)* @test_decl_only_noalias(i8 addrspace(1)* %ptr) gc "statepoint-example" {
; CHECK-LABEL: @test_decl_only_noalias(
; No change here, but the prototype of some_function_ret_noalias should have changed.
; CHECK: call i8 addrspace(1)* @some_function_ret_noalias()
entry:
%a = call i8 addrspace(1)* @some_function_ret_noalias()
call void @foo() [ "deopt"(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(
; CHECK: call void @some_function_consumer(i8 addrspace(1)* %ptr)
entry:
call void @some_function_consumer(i8 addrspace(1)* dereferenceable(4) noalias %ptr)
call void @foo() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
ret i8 addrspace(1)* %ptr
}
!0 = !{!1, !2, i64 0, i64 1} ; TAG_old
!1 = !{!"type_base_old", !2, i64 0}
!2 = !{!"type_access_old", !3}
!3 = !{!"root"}
!4 = !{!5, !6, i64 0, i64 1, i64 1} ; TAG_new
!5 = !{!3, i64 1, !"type_base_new", !6, i64 0, i64 1}
!6 = !{!3, i64 1, !"type_access_new"}
; CHECK-DAG: [[ROOT:!.*]] = !{!"root"}
; CHECK-DAG: [[TYPE_access_old:!.*]] = !{!"type_access_old", [[ROOT]]}
; CHECK-DAG: [[TYPE_base_old:!.*]] = !{!"type_base_old", [[TYPE_access_old]], i64 0}
; CHECK-DAG: [[TAG_old]] = !{[[TYPE_base_old]], [[TYPE_access_old]], i64 0}
; CHECK-DAG: [[TYPE_access_new:!.*]] = !{[[ROOT]], i64 1, !"type_access_new"}
; CHECK-DAG: [[TYPE_base_new:!.*]] = !{[[ROOT]], i64 1, !"type_base_new", [[TYPE_access_new]], i64 0, i64 1}
; CHECK-DAG: [[TAG_new]] = !{[[TYPE_base_new]], [[TYPE_access_new]], i64 0, i64 1}