2015-01-27 02:39:52 +08:00
|
|
|
; RUN: opt -tbaa -basicaa -gvn -S < %s | FileCheck %s
|
2012-06-05 06:44:21 +08:00
|
|
|
|
|
|
|
define i32 @test1(i8* %p, i8* %q) {
|
|
|
|
; CHECK: @test1(i8* %p, i8* %q)
|
|
|
|
; CHECK: call i32 @foo(i8* %p)
|
|
|
|
; CHECK-NOT: tbaa
|
|
|
|
; CHECK: %c = add i32 %a, %a
|
|
|
|
%a = call i32 @foo(i8* %p), !tbaa !0
|
|
|
|
%b = call i32 @foo(i8* %p)
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test2(i8* %p, i8* %q) {
|
|
|
|
; CHECK: @test2(i8* %p, i8* %q)
|
2013-09-28 02:34:27 +08:00
|
|
|
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGC:!.*]]
|
2012-06-05 06:44:21 +08:00
|
|
|
; CHECK: %c = add i32 %a, %a
|
|
|
|
%a = call i32 @foo(i8* %p), !tbaa !0
|
|
|
|
%b = call i32 @foo(i8* %p), !tbaa !0
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test3(i8* %p, i8* %q) {
|
|
|
|
; CHECK: @test3(i8* %p, i8* %q)
|
2013-09-28 02:34:27 +08:00
|
|
|
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGB:!.*]]
|
2012-06-05 06:44:21 +08:00
|
|
|
; CHECK: %c = add i32 %a, %a
|
|
|
|
%a = call i32 @foo(i8* %p), !tbaa !3
|
|
|
|
%b = call i32 @foo(i8* %p), !tbaa !3
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test4(i8* %p, i8* %q) {
|
|
|
|
; CHECK: @test4(i8* %p, i8* %q)
|
2013-09-28 02:34:27 +08:00
|
|
|
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGA:!.*]]
|
2012-06-05 06:44:21 +08:00
|
|
|
; CHECK: %c = add i32 %a, %a
|
|
|
|
%a = call i32 @foo(i8* %p), !tbaa !1
|
|
|
|
%b = call i32 @foo(i8* %p), !tbaa !0
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test5(i8* %p, i8* %q) {
|
|
|
|
; CHECK: @test5(i8* %p, i8* %q)
|
2013-09-28 02:34:27 +08:00
|
|
|
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGA:!.*]]
|
2012-06-05 06:44:21 +08:00
|
|
|
; CHECK: %c = add i32 %a, %a
|
|
|
|
%a = call i32 @foo(i8* %p), !tbaa !0
|
|
|
|
%b = call i32 @foo(i8* %p), !tbaa !1
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test6(i8* %p, i8* %q) {
|
|
|
|
; CHECK: @test6(i8* %p, i8* %q)
|
2013-09-28 02:34:27 +08:00
|
|
|
; CHECK: call i32 @foo(i8* %p), !tbaa [[TAGA:!.*]]
|
2012-06-05 06:44:21 +08:00
|
|
|
; CHECK: %c = add i32 %a, %a
|
|
|
|
%a = call i32 @foo(i8* %p), !tbaa !0
|
|
|
|
%b = call i32 @foo(i8* %p), !tbaa !3
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test7(i8* %p, i8* %q) {
|
|
|
|
; CHECK: @test7(i8* %p, i8* %q)
|
|
|
|
; CHECK: call i32 @foo(i8* %p)
|
|
|
|
; CHECK-NOT: tbaa
|
|
|
|
; CHECK: %c = add i32 %a, %a
|
|
|
|
%a = call i32 @foo(i8* %p), !tbaa !4
|
|
|
|
%b = call i32 @foo(i8* %p), !tbaa !3
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
2015-01-27 02:39:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
define i32 @test8(i32* %p, i32* %q) {
|
|
|
|
; CHECK-LABEL: test8
|
|
|
|
; CHECK-NEXT: store i32 15, i32* %p
|
|
|
|
; CHECK-NEXT: ret i32 0
|
|
|
|
; Since we know the location is invariant, we can forward the
|
|
|
|
; load across the potentially aliasing store.
|
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%a = load i32, i32* %q, !tbaa !10
|
2015-01-27 02:39:52 +08:00
|
|
|
store i32 15, i32* %p
|
2015-02-28 05:17:42 +08:00
|
|
|
%b = load i32, i32* %q, !tbaa !10
|
2015-01-27 02:39:52 +08:00
|
|
|
%c = sub i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
define i32 @test9(i32* %p, i32* %q) {
|
|
|
|
; CHECK-LABEL: test9
|
|
|
|
; CHECK-NEXT: call void @clobber()
|
|
|
|
; CHECK-NEXT: ret i32 0
|
|
|
|
; Since we know the location is invariant, we can forward the
|
|
|
|
; load across the potentially aliasing store (within the call).
|
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%a = load i32, i32* %q, !tbaa !10
|
2015-01-27 02:39:52 +08:00
|
|
|
call void @clobber()
|
2015-02-28 05:17:42 +08:00
|
|
|
%b = load i32, i32* %q, !tbaa !10
|
2015-01-27 02:39:52 +08:00
|
|
|
%c = sub i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
declare void @clobber()
|
2012-06-05 06:44:21 +08:00
|
|
|
declare i32 @foo(i8*) readonly
|
|
|
|
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
|
|
|
; CHECK: [[TAGC]] = !{[[TYPEC:!.*]], [[TYPEC]], i64 0}
|
|
|
|
; CHECK: [[TYPEC]] = !{!"C", [[TYPEA:!.*]]}
|
|
|
|
; CHECK: [[TYPEA]] = !{!"A", !{{.*}}}
|
|
|
|
; CHECK: [[TAGB]] = !{[[TYPEB:!.*]], [[TYPEB]], i64 0}
|
|
|
|
; CHECK: [[TYPEB]] = !{!"B", [[TYPEA]]}
|
|
|
|
; CHECK: [[TAGA]] = !{[[TYPEA]], [[TYPEA]], i64 0}
|
|
|
|
!0 = !{!5, !5, i64 0}
|
|
|
|
!1 = !{!6, !6, i64 0}
|
[Verifier] Add verification for TBAA metadata
Summary:
This change adds some verification in the IR verifier around struct path
TBAA metadata.
Other than some basic sanity checks (e.g. we get constant integers where
we expect constant integers), this checks:
- That by the time an struct access tuple `(base-type, offset)` is
"reduced" to a scalar base type, the offset is `0`. For instance, in
C++ you can't start from, say `("struct-a", 16)`, and end up with
`("int", 4)` -- by the time the base type is `"int"`, the offset
better be zero. In particular, a variant of this invariant is needed
for `llvm::getMostGenericTBAA` to be correct.
- That there are no cycles in a struct path.
- That struct type nodes have their offsets listed in an ascending
order.
- That when generating the struct access path, you eventually reach the
access type listed in the tbaa tag node.
Reviewers: dexonsmith, chandlerc, reames, mehdi_amini, manmanren
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D26438
llvm-svn: 289402
2016-12-12 04:07:15 +08:00
|
|
|
!2 = !{!"tbaa root"}
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
|
|
|
!3 = !{!7, !7, i64 0}
|
[Verifier] Add verification for TBAA metadata
Summary:
This change adds some verification in the IR verifier around struct path
TBAA metadata.
Other than some basic sanity checks (e.g. we get constant integers where
we expect constant integers), this checks:
- That by the time an struct access tuple `(base-type, offset)` is
"reduced" to a scalar base type, the offset is `0`. For instance, in
C++ you can't start from, say `("struct-a", 16)`, and end up with
`("int", 4)` -- by the time the base type is `"int"`, the offset
better be zero. In particular, a variant of this invariant is needed
for `llvm::getMostGenericTBAA` to be correct.
- That there are no cycles in a struct path.
- That struct type nodes have their offsets listed in an ascending
order.
- That when generating the struct access path, you eventually reach the
access type listed in the tbaa tag node.
Reviewers: dexonsmith, chandlerc, reames, mehdi_amini, manmanren
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D26438
llvm-svn: 289402
2016-12-12 04:07:15 +08:00
|
|
|
!4 = !{!11, !11, i64 0}
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
|
|
|
!5 = !{!"C", !6}
|
|
|
|
!6 = !{!"A", !2}
|
|
|
|
!7 = !{!"B", !6}
|
[Verifier] Add verification for TBAA metadata
Summary:
This change adds some verification in the IR verifier around struct path
TBAA metadata.
Other than some basic sanity checks (e.g. we get constant integers where
we expect constant integers), this checks:
- That by the time an struct access tuple `(base-type, offset)` is
"reduced" to a scalar base type, the offset is `0`. For instance, in
C++ you can't start from, say `("struct-a", 16)`, and end up with
`("int", 4)` -- by the time the base type is `"int"`, the offset
better be zero. In particular, a variant of this invariant is needed
for `llvm::getMostGenericTBAA` to be correct.
- That there are no cycles in a struct path.
- That struct type nodes have their offsets listed in an ascending
order.
- That when generating the struct access path, you eventually reach the
access type listed in the tbaa tag node.
Reviewers: dexonsmith, chandlerc, reames, mehdi_amini, manmanren
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D26438
llvm-svn: 289402
2016-12-12 04:07:15 +08:00
|
|
|
!8 = !{!"another root"}
|
|
|
|
!11 = !{!"scalar type", !8}
|
2015-01-27 02:39:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
;; A TBAA structure who's only point is to have a constant location
|
|
|
|
!9 = !{!"yet another root"}
|
|
|
|
!10 = !{!"node", !9, i64 1}
|
|
|
|
|