blob: 3728a7179724381ad0a1aced5c3ec226ed9fdaf3 [file] [log] [blame]
Elad Cohenef5798a2017-05-03 12:28:54 +00001; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
Nick Lewyckyc2ec0722013-07-06 00:29:58 +00002; RUN: opt < %s -functionattrs -S | FileCheck %s
Sean Silva45835e72016-07-02 23:47:27 +00003; RUN: opt < %s -aa-pipeline=basic-aa -passes='cgscc(function-attrs)' -S | FileCheck %s
Nick Lewyckyc2ec0722013-07-06 00:29:58 +00004@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) {
David Blaikie23af6482015-04-16 23:24:18 +000010 call void (i8*, i8*, ...) @test1_1(i8* %x1_2, i8* %y1_2, i8* %z1_2)
Nick Lewyckyc2ec0722013-07-06 00:29:58 +000011 store i32 0, i32* @x
12 ret void
13}
14
David Majnemer5246e0b2016-07-19 18:50:26 +000015; CHECK: define i8* @test2(i8* readnone returned %p)
Nick Lewyckyc2ec0722013-07-06 00:29:58 +000016define 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}
Reid Kleckner26af2ca2014-01-28 02:38:36 +000050
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}
Nick Lewycky59633cb2014-05-30 02:31:27 +000056
David Majnemer5246e0b2016-07-19 18:50:26 +000057; CHECK: define i32* @test8_1(i32* readnone returned %p)
Nick Lewycky59633cb2014-05-30 02:31:27 +000058define 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}
Elena Demikhovsky3ec9e152015-11-17 19:30:51 +000070
71; CHECK: declare void @llvm.masked.scatter
Elad Cohenef5798a2017-05-03 12:28:54 +000072declare void @llvm.masked.scatter.v4i32.v4p0i32(<4 x i32>%val, <4 x i32*>, i32, <4 x i1>)
Elena Demikhovsky3ec9e152015-11-17 19:30:51 +000073
74; CHECK-NOT: readnone
75; CHECK-NOT: readonly
76; CHECK: define void @test9
77define void @test9(<4 x i32*> %ptrs, <4 x i32>%val) {
Elad Cohenef5798a2017-05-03 12:28:54 +000078 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>)
Elena Demikhovsky3ec9e152015-11-17 19:30:51 +000079 ret void
80}
81
82; CHECK: declare <4 x i32> @llvm.masked.gather
Elad Cohenef5798a2017-05-03 12:28:54 +000083declare <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*>, i32, <4 x i1>, <4 x i32>)
Elena Demikhovsky3ec9e152015-11-17 19:30:51 +000084; CHECK: readonly
85; CHECK: define <4 x i32> @test10
86define <4 x i32> @test10(<4 x i32*> %ptrs) {
Elad Cohenef5798a2017-05-03 12:28:54 +000087 %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)
Elena Demikhovsky3ec9e152015-11-17 19:30:51 +000088 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}
David Majnemer124bdb72016-05-25 05:53:04 +0000108
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}