1 ; RUN: opt < %s -enable-tbaa -tbaa -basicaa -functionattrs -S | FileCheck %s
3 ; FunctionAttrs should make use of TBAA.
5 ; Add the readnone attribute, since the only access is a store which TBAA
6 ; says is to constant memory.
8 ; It's unusual to see a store to constant memory, but it isn't necessarily
9 ; invalid, as it's possible that this only happens after optimization on a
10 ; code path which isn't ever executed.
12 ; CHECK: define void @test0_yes(i32* nocapture %p) nounwind readnone {
13 define void @test0_yes(i32* %p) nounwind {
14 store i32 0, i32* %p, !tbaa !1
18 ; CHECK: define void @test0_no(i32* nocapture %p) nounwind {
19 define void @test0_no(i32* %p) nounwind {
20 store i32 0, i32* %p, !tbaa !2
24 ; Add the readonly attribute, since there's just a call to a function which
25 ; TBAA says doesn't modify any memory.
27 ; CHECK: define void @test1_yes(i32* %p) nounwind readonly {
28 define void @test1_yes(i32* %p) nounwind {
29 call void @callee(i32* %p), !tbaa !1
33 ; CHECK: define void @test1_no(i32* %p) nounwind {
34 define void @test1_no(i32* %p) nounwind {
35 call void @callee(i32* %p), !tbaa !2
39 ; Add the readonly attribute, as above, but this time BasicAA will say
40 ; that the function accesses memory through its arguments, which TBAA
41 ; still says that the function doesn't write to memory.
43 ; This is unusual, since the function is memcpy, but as above, this
44 ; isn't necessarily invalid.
46 ; CHECK: define void @test2_yes(i8* nocapture %p, i8* nocapture %q, i64 %n) nounwind readnone {
47 define void @test2_yes(i8* %p, i8* %q, i64 %n) nounwind {
48 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 %n, i32 1, i1 false), !tbaa !1
52 ; CHECK: define void @test2_no(i8* nocapture %p, i8* nocapture %q, i64 %n) nounwind {
53 define void @test2_no(i8* %p, i8* %q, i64 %n) nounwind {
54 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %q, i64 %n, i32 1, i1 false), !tbaa !2
58 declare void @callee(i32* %p) nounwind
59 declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1) nounwind
65 !1 = metadata !{ metadata !"foo", metadata !0, i1 1 }
66 ; Not invariant memory.
67 !2 = metadata !{ metadata !"foo", metadata !0, i1 0 }