1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt < %s -aa-pipeline=basic-aa -passes='cgscc(function-attrs),rpo-function-attrs' -S | FileCheck --check-prefixes=COMMON,FNATTRS %s
3 ; RUN: opt -passes=attributor-light -S < %s | FileCheck --check-prefixes=COMMON,ATTRIBUTOR %s
7 ; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
8 ; FNATTRS-LABEL: define {{[^@]+}}@leaf
9 ; FNATTRS-SAME: () #[[ATTR0:[0-9]+]] {
10 ; FNATTRS-NEXT: ret i32 1
12 ; ATTRIBUTOR: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
13 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@leaf
14 ; ATTRIBUTOR-SAME: () #[[ATTR0:[0-9]+]] {
15 ; ATTRIBUTOR-NEXT: ret i32 1
20 define i32 @self_rec() {
21 ; FNATTRS: Function Attrs: nofree nosync nounwind memory(none)
22 ; FNATTRS-LABEL: define {{[^@]+}}@self_rec
23 ; FNATTRS-SAME: () #[[ATTR1:[0-9]+]] {
24 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @self_rec()
25 ; FNATTRS-NEXT: ret i32 4
27 ; ATTRIBUTOR: Function Attrs: nofree nosync nounwind memory(none)
28 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@self_rec
29 ; ATTRIBUTOR-SAME: () #[[ATTR1:[0-9]+]] {
30 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @self_rec() #[[ATTR1]]
31 ; ATTRIBUTOR-NEXT: ret i32 4
33 %a = call i32 @self_rec()
37 define i32 @indirect_rec() {
38 ; FNATTRS: Function Attrs: nofree nosync nounwind memory(none)
39 ; FNATTRS-LABEL: define {{[^@]+}}@indirect_rec
40 ; FNATTRS-SAME: () #[[ATTR1]] {
41 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @indirect_rec2()
42 ; FNATTRS-NEXT: ret i32 [[A]]
44 ; ATTRIBUTOR: Function Attrs: nofree nosync nounwind memory(none)
45 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@indirect_rec
46 ; ATTRIBUTOR-SAME: () #[[ATTR1]] {
47 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @indirect_rec2() #[[ATTR1]]
48 ; ATTRIBUTOR-NEXT: ret i32 [[A]]
50 %a = call i32 @indirect_rec2()
54 define i32 @indirect_rec2() {
55 ; FNATTRS: Function Attrs: nofree nosync nounwind memory(none)
56 ; FNATTRS-LABEL: define {{[^@]+}}@indirect_rec2
57 ; FNATTRS-SAME: () #[[ATTR1]] {
58 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @indirect_rec()
59 ; FNATTRS-NEXT: ret i32 [[A]]
61 ; ATTRIBUTOR: Function Attrs: nofree nosync nounwind memory(none)
62 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@indirect_rec2
63 ; ATTRIBUTOR-SAME: () #[[ATTR1]] {
64 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @indirect_rec() #[[ATTR1]]
65 ; ATTRIBUTOR-NEXT: ret i32 [[A]]
67 %a = call i32 @indirect_rec()
71 define i32 @extern() {
72 ; FNATTRS: Function Attrs: nofree nosync memory(none)
73 ; FNATTRS-LABEL: define {{[^@]+}}@extern
74 ; FNATTRS-SAME: () #[[ATTR2:[0-9]+]] {
75 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @k()
76 ; FNATTRS-NEXT: ret i32 [[A]]
78 ; ATTRIBUTOR: Function Attrs: nosync memory(none)
79 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@extern
80 ; ATTRIBUTOR-SAME: () #[[ATTR2:[0-9]+]] {
81 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @k() #[[ATTR7:[0-9]+]]
82 ; ATTRIBUTOR-NEXT: ret i32 [[A]]
88 declare i32 @k() readnone
90 define void @intrinsic(ptr %dest, ptr %src, i32 %len) {
91 ; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
92 ; FNATTRS-LABEL: define {{[^@]+}}@intrinsic
93 ; FNATTRS-SAME: (ptr nocapture writeonly [[DEST:%.*]], ptr nocapture readonly [[SRC:%.*]], i32 [[LEN:%.*]]) #[[ATTR4:[0-9]+]] {
94 ; FNATTRS-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr [[DEST]], ptr [[SRC]], i32 [[LEN]], i1 false)
95 ; FNATTRS-NEXT: ret void
97 ; ATTRIBUTOR: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
98 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@intrinsic
99 ; ATTRIBUTOR-SAME: (ptr nocapture nofree writeonly [[DEST:%.*]], ptr nocapture nofree readonly [[SRC:%.*]], i32 [[LEN:%.*]]) #[[ATTR4:[0-9]+]] {
100 ; ATTRIBUTOR-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr nocapture writeonly [[DEST]], ptr nocapture readonly [[SRC]], i32 [[LEN]], i1 false) #[[ATTR8:[0-9]+]]
101 ; ATTRIBUTOR-NEXT: ret void
103 call void @llvm.memcpy.p0.p0.i32(ptr %dest, ptr %src, i32 %len, i1 false)
107 declare void @llvm.memcpy.p0.p0.i32(ptr, ptr, i32, i1)
109 define internal i32 @called_by_norecurse() {
110 ; FNATTRS: Function Attrs: nofree norecurse nosync memory(none)
111 ; FNATTRS-LABEL: define {{[^@]+}}@called_by_norecurse
112 ; FNATTRS-SAME: () #[[ATTR6:[0-9]+]] {
113 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @k()
114 ; FNATTRS-NEXT: ret i32 [[A]]
116 ; ATTRIBUTOR: Function Attrs: norecurse nosync memory(none)
117 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@called_by_norecurse
118 ; ATTRIBUTOR-SAME: () #[[ATTR6:[0-9]+]] {
119 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @k() #[[ATTR7]]
120 ; ATTRIBUTOR-NEXT: ret i32 [[A]]
126 define void @m() norecurse {
127 ; FNATTRS: Function Attrs: nofree norecurse nosync memory(none)
128 ; FNATTRS-LABEL: define {{[^@]+}}@m
129 ; FNATTRS-SAME: () #[[ATTR6]] {
130 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @called_by_norecurse()
131 ; FNATTRS-NEXT: ret void
133 ; ATTRIBUTOR: Function Attrs: norecurse nosync memory(none)
134 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@m
135 ; ATTRIBUTOR-SAME: () #[[ATTR6]] {
136 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @called_by_norecurse() #[[ATTR2]]
137 ; ATTRIBUTOR-NEXT: ret void
139 %a = call i32 @called_by_norecurse()
143 define internal i32 @called_by_norecurse_indirectly() {
144 ; FNATTRS: Function Attrs: nofree norecurse nosync memory(none)
145 ; FNATTRS-LABEL: define {{[^@]+}}@called_by_norecurse_indirectly
146 ; FNATTRS-SAME: () #[[ATTR6]] {
147 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @k()
148 ; FNATTRS-NEXT: ret i32 [[A]]
150 ; ATTRIBUTOR: Function Attrs: norecurse nosync memory(none)
151 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@called_by_norecurse_indirectly
152 ; ATTRIBUTOR-SAME: () #[[ATTR6]] {
153 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @k() #[[ATTR7]]
154 ; ATTRIBUTOR-NEXT: ret i32 [[A]]
160 define internal void @o() {
161 ; FNATTRS: Function Attrs: nofree norecurse nosync memory(none)
162 ; FNATTRS-LABEL: define {{[^@]+}}@o
163 ; FNATTRS-SAME: () #[[ATTR6]] {
164 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @called_by_norecurse_indirectly()
165 ; FNATTRS-NEXT: ret void
167 ; ATTRIBUTOR: Function Attrs: norecurse nosync memory(none)
168 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@o
169 ; ATTRIBUTOR-SAME: () #[[ATTR6]] {
170 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @called_by_norecurse_indirectly() #[[ATTR2]]
171 ; ATTRIBUTOR-NEXT: ret void
173 %a = call i32 @called_by_norecurse_indirectly()
177 define void @p() norecurse {
178 ; FNATTRS: Function Attrs: nofree norecurse nosync memory(none)
179 ; FNATTRS-LABEL: define {{[^@]+}}@p
180 ; FNATTRS-SAME: () #[[ATTR6]] {
181 ; FNATTRS-NEXT: call void @o()
182 ; FNATTRS-NEXT: ret void
184 ; ATTRIBUTOR: Function Attrs: norecurse nosync memory(none)
185 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@p
186 ; ATTRIBUTOR-SAME: () #[[ATTR6]] {
187 ; ATTRIBUTOR-NEXT: call void @o() #[[ATTR2]]
188 ; ATTRIBUTOR-NEXT: ret void
194 define internal i32 @escapes_as_parameter(ptr %p) {
195 ; FNATTRS: Function Attrs: nofree nosync memory(none)
196 ; FNATTRS-LABEL: define {{[^@]+}}@escapes_as_parameter
197 ; FNATTRS-SAME: (ptr nocapture readnone [[P:%.*]]) #[[ATTR2]] {
198 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @k()
199 ; FNATTRS-NEXT: ret i32 [[A]]
201 ; ATTRIBUTOR: Function Attrs: nosync memory(none)
202 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@escapes_as_parameter
203 ; ATTRIBUTOR-SAME: (ptr nocapture nofree readnone [[P:%.*]]) #[[ATTR2]] {
204 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @k() #[[ATTR7]]
205 ; ATTRIBUTOR-NEXT: ret i32 [[A]]
211 define internal void @q() {
212 ; FNATTRS: Function Attrs: nofree norecurse nosync memory(none)
213 ; FNATTRS-LABEL: define {{[^@]+}}@q
214 ; FNATTRS-SAME: () #[[ATTR6]] {
215 ; FNATTRS-NEXT: [[A:%.*]] = call i32 @escapes_as_parameter(ptr @escapes_as_parameter)
216 ; FNATTRS-NEXT: ret void
218 ; ATTRIBUTOR: Function Attrs: norecurse nosync memory(none)
219 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@q
220 ; ATTRIBUTOR-SAME: () #[[ATTR6]] {
221 ; ATTRIBUTOR-NEXT: [[A:%.*]] = call i32 @escapes_as_parameter(ptr nocapture nofree nonnull readnone @escapes_as_parameter) #[[ATTR2]]
222 ; ATTRIBUTOR-NEXT: ret void
224 %a = call i32 @escapes_as_parameter(ptr @escapes_as_parameter)
228 define void @r() norecurse {
229 ; FNATTRS: Function Attrs: nofree norecurse nosync memory(none)
230 ; FNATTRS-LABEL: define {{[^@]+}}@r
231 ; FNATTRS-SAME: () #[[ATTR6]] {
232 ; FNATTRS-NEXT: call void @q()
233 ; FNATTRS-NEXT: ret void
235 ; ATTRIBUTOR: Function Attrs: norecurse nosync memory(none)
236 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@r
237 ; ATTRIBUTOR-SAME: () #[[ATTR6]] {
238 ; ATTRIBUTOR-NEXT: call void @q() #[[ATTR2]]
239 ; ATTRIBUTOR-NEXT: ret void
245 ; FNATTRS: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
246 ; FNATTRS: attributes #[[ATTR1]] = { nofree nosync nounwind memory(none) }
247 ; FNATTRS: attributes #[[ATTR2]] = { nofree nosync memory(none) }
248 ; FNATTRS: attributes #[[ATTR3:[0-9]+]] = { memory(none) }
249 ; FNATTRS: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
250 ; FNATTRS: attributes #[[ATTR5:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
251 ; FNATTRS: attributes #[[ATTR6]] = { nofree norecurse nosync memory(none) }
253 ; ATTRIBUTOR: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
254 ; ATTRIBUTOR: attributes #[[ATTR1]] = { nofree nosync nounwind memory(none) }
255 ; ATTRIBUTOR: attributes #[[ATTR2]] = { nosync memory(none) }
256 ; ATTRIBUTOR: attributes #[[ATTR3:[0-9]+]] = { memory(none) }
257 ; ATTRIBUTOR: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
258 ; ATTRIBUTOR: attributes #[[ATTR5:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
259 ; ATTRIBUTOR: attributes #[[ATTR6]] = { norecurse nosync memory(none) }
260 ; ATTRIBUTOR: attributes #[[ATTR7]] = { nosync }
261 ; ATTRIBUTOR: attributes #[[ATTR8]] = { nofree willreturn }
263 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: