1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
5 define dso_local i32 @visible(ptr noalias %A, ptr noalias %B) #0 {
6 ; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
7 ; TUNIT-LABEL: define {{[^@]+}}@visible
8 ; TUNIT-SAME: (ptr noalias nocapture nofree readonly [[A:%.*]], ptr noalias nocapture nofree readonly [[B:%.*]]) #[[ATTR0:[0-9]+]] {
10 ; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr noalias nocapture nofree noundef readonly align 4 [[A]], ptr noalias nocapture nofree noundef readonly align 4 [[B]]) #[[ATTR4:[0-9]+]]
11 ; TUNIT-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr noalias nocapture nofree noundef readonly align 4 [[A]], ptr noalias nocapture nofree noundef readonly align 4 [[B]]) #[[ATTR4]]
12 ; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
13 ; TUNIT-NEXT: ret i32 [[ADD]]
15 ; CGSCC: Function Attrs: mustprogress nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable
16 ; CGSCC-LABEL: define {{[^@]+}}@visible
17 ; CGSCC-SAME: (ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0:[0-9]+]] {
19 ; CGSCC-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR6:[0-9]+]]
20 ; CGSCC-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR6]]
21 ; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
22 ; CGSCC-NEXT: ret i32 [[ADD]]
25 %call1 = call i32 @noalias_args(ptr %A, ptr %B)
26 %call2 = call i32 @noalias_args_argmem(ptr %A, ptr %B)
27 %add = add nsw i32 %call1, %call2
31 define private i32 @noalias_args(ptr %A, ptr %B) #0 {
32 ; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
33 ; TUNIT-LABEL: define {{[^@]+}}@noalias_args
34 ; TUNIT-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
36 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
37 ; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4
38 ; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
39 ; TUNIT-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR4]]
40 ; TUNIT-NEXT: [[ADD2:%.*]] = add nsw i32 [[ADD]], [[CALL]]
41 ; TUNIT-NEXT: ret i32 [[ADD2]]
43 ; CGSCC: Function Attrs: mustprogress nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable
44 ; CGSCC-LABEL: define {{[^@]+}}@noalias_args
45 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
47 ; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
48 ; CGSCC-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4
49 ; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
50 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR7:[0-9]+]]
51 ; CGSCC-NEXT: [[ADD2:%.*]] = add nsw i32 [[ADD]], [[CALL]]
52 ; CGSCC-NEXT: ret i32 [[ADD2]]
55 %0 = load i32, ptr %A, align 4
56 %1 = load i32, ptr %B, align 4
57 %add = add nsw i32 %0, %1
58 %call = call i32 @noalias_args_argmem(ptr %A, ptr %B)
59 %add2 = add nsw i32 %add, %call
64 define internal i32 @noalias_args_argmem(ptr %A, ptr %B) #1 {
65 ; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
66 ; TUNIT-LABEL: define {{[^@]+}}@noalias_args_argmem
67 ; TUNIT-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
69 ; TUNIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
70 ; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4
71 ; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
72 ; TUNIT-NEXT: ret i32 [[ADD]]
74 ; CGSCC: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
75 ; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem
76 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR1:[0-9]+]] {
78 ; CGSCC-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
79 ; CGSCC-NEXT: [[TMP1:%.*]] = load i32, ptr [[B]], align 4
80 ; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
81 ; CGSCC-NEXT: ret i32 [[ADD]]
84 %0 = load i32, ptr %A, align 4
85 %1 = load i32, ptr %B, align 4
86 %add = add nsw i32 %0, %1
90 define dso_local i32 @visible_local(ptr %A) #0 {
91 ; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
92 ; TUNIT-LABEL: define {{[^@]+}}@visible_local
93 ; TUNIT-SAME: (ptr nocapture nofree readonly [[A:%.*]]) #[[ATTR1:[0-9]+]] {
95 ; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4
96 ; TUNIT-NEXT: store i32 5, ptr [[B]], align 4
97 ; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr nocapture nofree noundef readonly align 4 [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR4]]
98 ; TUNIT-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr nocapture nofree noundef readonly align 4 [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR4]]
99 ; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
100 ; TUNIT-NEXT: ret i32 [[ADD]]
102 ; CGSCC: Function Attrs: mustprogress nofree noinline nosync nounwind willreturn memory(argmem: readwrite) uwtable
103 ; CGSCC-LABEL: define {{[^@]+}}@visible_local
104 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR2:[0-9]+]] {
106 ; CGSCC-NEXT: [[B:%.*]] = alloca i32, align 4
107 ; CGSCC-NEXT: store i32 5, ptr [[B]], align 4
108 ; CGSCC-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR6]]
109 ; CGSCC-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR8:[0-9]+]]
110 ; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
111 ; CGSCC-NEXT: ret i32 [[ADD]]
114 %B = alloca i32, align 4
115 store i32 5, ptr %B, align 4
116 %call1 = call i32 @noalias_args(ptr %A, ptr nonnull %B)
117 %call2 = call i32 @noalias_args_argmem(ptr %A, ptr nonnull %B)
118 %add = add nsw i32 %call1, %call2
122 define internal i32 @noalias_args_argmem_ro(ptr %A, ptr %B) #1 {
123 ; CGSCC: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) uwtable
124 ; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem_ro
125 ; CGSCC-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR3:[0-9]+]] {
126 ; CGSCC-NEXT: [[B_PRIV:%.*]] = alloca i32, align 4
127 ; CGSCC-NEXT: store i32 [[TMP1]], ptr [[B_PRIV]], align 4
128 ; CGSCC-NEXT: [[A_PRIV:%.*]] = alloca i32, align 4
129 ; CGSCC-NEXT: store i32 [[TMP0]], ptr [[A_PRIV]], align 4
130 ; CGSCC-NEXT: [[T0:%.*]] = load i32, ptr [[A_PRIV]], align 4
131 ; CGSCC-NEXT: [[T1:%.*]] = load i32, ptr [[B_PRIV]], align 4
132 ; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[T0]], [[T1]]
133 ; CGSCC-NEXT: ret i32 [[ADD]]
135 %t0 = load i32, ptr %A, align 4
136 %t1 = load i32, ptr %B, align 4
137 %add = add nsw i32 %t0, %t1
141 define i32 @visible_local_2() {
142 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
143 ; TUNIT-LABEL: define {{[^@]+}}@visible_local_2
144 ; TUNIT-SAME: () #[[ATTR2:[0-9]+]] {
145 ; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4
146 ; TUNIT-NEXT: ret i32 10
148 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
149 ; CGSCC-LABEL: define {{[^@]+}}@visible_local_2
150 ; CGSCC-SAME: () #[[ATTR4:[0-9]+]] {
151 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_ro(i32 noundef 5, i32 noundef 5) #[[ATTR9:[0-9]+]]
152 ; CGSCC-NEXT: ret i32 [[CALL]]
154 %B = alloca i32, align 4
155 store i32 5, ptr %B, align 4
156 %call = call i32 @noalias_args_argmem_ro(ptr %B, ptr %B)
160 define internal i32 @noalias_args_argmem_rn(ptr %A, ptr %B) #1 {
161 ; TUNIT: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: write) uwtable
162 ; TUNIT-LABEL: define {{[^@]+}}@noalias_args_argmem_rn
163 ; TUNIT-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR3:[0-9]+]] {
164 ; TUNIT-NEXT: ret i32 undef
166 ; CGSCC: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
167 ; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem_rn
168 ; CGSCC-SAME: (ptr noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR5:[0-9]+]] {
169 ; CGSCC-NEXT: [[T0:%.*]] = load i32, ptr [[B]], align 4
170 ; CGSCC-NEXT: store i32 0, ptr [[B]], align 4
171 ; CGSCC-NEXT: ret i32 [[T0]]
173 %t0 = load i32, ptr %B, align 4
178 define i32 @visible_local_3() {
179 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
180 ; TUNIT-LABEL: define {{[^@]+}}@visible_local_3
181 ; TUNIT-SAME: () #[[ATTR2]] {
182 ; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4
183 ; TUNIT-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_rn(ptr noalias nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[B]]) #[[ATTR5:[0-9]+]]
184 ; TUNIT-NEXT: ret i32 5
186 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
187 ; CGSCC-LABEL: define {{[^@]+}}@visible_local_3
188 ; CGSCC-SAME: () #[[ATTR4]] {
189 ; CGSCC-NEXT: [[B:%.*]] = alloca i32, align 4
190 ; CGSCC-NEXT: store i32 5, ptr [[B]], align 4
191 ; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_rn(ptr noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[B]]) #[[ATTR10:[0-9]+]]
192 ; CGSCC-NEXT: ret i32 [[CALL]]
194 %B = alloca i32, align 4
195 store i32 5, ptr %B, align 4
196 %call = call i32 @noalias_args_argmem_rn(ptr %B, ptr %B)
200 attributes #0 = { noinline nounwind uwtable willreturn }
201 attributes #1 = { argmemonly noinline nounwind uwtable willreturn}
203 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable }
204 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable }
205 ; TUNIT: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
206 ; TUNIT: attributes #[[ATTR3]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: write) uwtable }
207 ; TUNIT: attributes #[[ATTR4]] = { nofree nosync nounwind memory(read) }
208 ; TUNIT: attributes #[[ATTR5]] = { nofree nosync nounwind willreturn memory(write) }
210 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable }
211 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable }
212 ; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree noinline nosync nounwind willreturn memory(argmem: readwrite) uwtable }
213 ; CGSCC: attributes #[[ATTR3]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) uwtable }
214 ; CGSCC: attributes #[[ATTR4]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
215 ; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable }
216 ; CGSCC: attributes #[[ATTR6]] = { nofree memory(read) }
217 ; CGSCC: attributes #[[ATTR7]] = { nofree nounwind memory(read) }
218 ; CGSCC: attributes #[[ATTR8]] = { nofree }
219 ; CGSCC: attributes #[[ATTR9]] = { nofree nosync willreturn }
220 ; CGSCC: attributes #[[ATTR10]] = { nofree nounwind willreturn }
222 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: