1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -functionattrs -S | FileCheck %s 3; RUN: opt < %s -aa-pipeline=basic-aa -passes='cgscc(function-attrs)' -S | FileCheck %s 4@x = global i32 0 5 6declare void @test1_1(i8* %x1_1, i8* readonly %y1_1, ...) 7 8; CHECK: define void @test1_2(i8* %x1_2, i8* readonly %y1_2, i8* %z1_2) 9define void @test1_2(i8* %x1_2, i8* %y1_2, i8* %z1_2) { 10 call void (i8*, i8*, ...) @test1_1(i8* %x1_2, i8* %y1_2, i8* %z1_2) 11 store i32 0, i32* @x 12 ret void 13} 14 15; CHECK: define i8* @test2(i8* readnone returned %p) 16define i8* @test2(i8* %p) { 17 store i32 0, i32* @x 18 ret i8* %p 19} 20 21; CHECK: define i1 @test3(i8* readnone %p, i8* readnone %q) 22define i1 @test3(i8* %p, i8* %q) { 23 %A = icmp ult i8* %p, %q 24 ret i1 %A 25} 26 27declare void @test4_1(i8* nocapture) readonly 28 29; CHECK: define void @test4_2(i8* nocapture readonly %p) 30define void @test4_2(i8* %p) { 31 call void @test4_1(i8* %p) 32 ret void 33} 34 35; CHECK: define void @test5(i8** nocapture %p, i8* %q) 36; Missed optz'n: we could make %q readnone, but don't break test6! 37define void @test5(i8** %p, i8* %q) { 38 store i8* %q, i8** %p 39 ret void 40} 41 42declare void @test6_1() 43; CHECK: define void @test6_2(i8** nocapture %p, i8* %q) 44; This is not a missed optz'n. 45define void @test6_2(i8** %p, i8* %q) { 46 store i8* %q, i8** %p 47 call void @test6_1() 48 ret void 49} 50 51; CHECK: define void @test7_1(i32* inalloca nocapture %a) 52; inalloca parameters are always considered written 53define void @test7_1(i32* inalloca %a) { 54 ret void 55} 56 57; CHECK: define i32* @test8_1(i32* readnone returned %p) 58define i32* @test8_1(i32* %p) { 59entry: 60 ret i32* %p 61} 62 63; CHECK: define void @test8_2(i32* %p) 64define void @test8_2(i32* %p) { 65entry: 66 %call = call i32* @test8_1(i32* %p) 67 store i32 10, i32* %call, align 4 68 ret void 69} 70 71; CHECK: declare void @llvm.masked.scatter 72declare void @llvm.masked.scatter.v4i32.v4p0i32(<4 x i32>%val, <4 x i32*>, i32, <4 x i1>) 73 74; CHECK-NOT: readnone 75; CHECK-NOT: readonly 76; CHECK: define void @test9 77define void @test9(<4 x i32*> %ptrs, <4 x i32>%val) { 78 call void @llvm.masked.scatter.v4i32.v4p0i32(<4 x i32>%val, <4 x i32*> %ptrs, i32 4, <4 x i1><i1 true, i1 false, i1 true, i1 false>) 79 ret void 80} 81 82; CHECK: declare <4 x i32> @llvm.masked.gather 83declare <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*>, i32, <4 x i1>, <4 x i32>) 84; CHECK: readonly 85; CHECK: define <4 x i32> @test10 86define <4 x i32> @test10(<4 x i32*> %ptrs) { 87 %res = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*> %ptrs, i32 4, <4 x i1><i1 true, i1 false, i1 true, i1 false>, <4 x i32>undef) 88 ret <4 x i32> %res 89} 90 91; CHECK: declare <4 x i32> @test11_1 92declare <4 x i32> @test11_1(<4 x i32*>) argmemonly nounwind readonly 93; CHECK: readonly 94; CHECK-NOT: readnone 95; CHECK: define <4 x i32> @test11_2 96define <4 x i32> @test11_2(<4 x i32*> %ptrs) { 97 %res = call <4 x i32> @test11_1(<4 x i32*> %ptrs) 98 ret <4 x i32> %res 99} 100 101declare <4 x i32> @test12_1(<4 x i32*>) argmemonly nounwind 102; CHECK-NOT: readnone 103; CHECK: define <4 x i32> @test12_2 104define <4 x i32> @test12_2(<4 x i32*> %ptrs) { 105 %res = call <4 x i32> @test12_1(<4 x i32*> %ptrs) 106 ret <4 x i32> %res 107} 108 109; CHECK: define i32 @volatile_load( 110; CHECK-NOT: readonly 111; CHECK: ret 112define i32 @volatile_load(i32* %p) { 113 %load = load volatile i32, i32* %p 114 ret i32 %load 115} 116