xref: /llvm-project/mlir/test/Dialect/LLVMIR/parameter-attrs-invalid.mlir (revision 7ed96b1c0d9751efcf72591b36edd11a3ea97284)
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2
3// Argument attributes
4
5// expected-error@below {{"llvm.noalias" attribute attached to non-pointer LLVM type}}
6llvm.func @invalid_noalias_arg_type(%0 : i32 {llvm.noalias})
7
8// -----
9
10// expected-error@below {{"llvm.noalias" should be a unit attribute}}
11llvm.func @invalid_noalias_attr_type(%0 : !llvm.ptr {llvm.noalias = 10 : i32})
12
13// -----
14
15// expected-error@below {{"llvm.readonly" attribute attached to non-pointer LLVM type}}
16llvm.func @invalid_readonly_arg_type(%0 : i32 {llvm.readonly})
17
18// -----
19
20// expected-error@below {{"llvm.readonly" should be a unit attribute}}
21llvm.func @invalid_readonly_attr_type(%0 : i32 {llvm.readonly = i32})
22
23// -----
24
25// expected-error@below {{"llvm.nest" attribute attached to non-pointer LLVM type}}
26llvm.func @invalid_nest_arg_type(%0 : i32 {llvm.nest})
27
28// -----
29
30// expected-error@below {{"llvm.nest" should be a unit attribute}}
31llvm.func @invalid_nest_attr_type(%0 : i32 {llvm.nest = "foo"})
32
33// -----
34
35// expected-error@below {{"llvm.align" attribute attached to non-pointer LLVM type}}
36llvm.func @invalid_align_arg_type(%0 : i32 {llvm.align = 10 : i32})
37
38// -----
39
40// expected-error@below {{"llvm.align" should be an integer attribute}}
41llvm.func @invalid_align_attr_type(%0 : i32 {llvm.align = "foo"})
42
43// -----
44
45// expected-error@below {{"llvm.sret" attribute attached to non-pointer LLVM type}}
46llvm.func @invalid_sret_arg_type(%0 : i32 {llvm.sret = !llvm.struct<(i32)>})
47
48// -----
49
50// expected-error@below {{"llvm.byval" attribute attached to non-pointer LLVM type}}
51llvm.func @invalid_byval_arg_type(%0 : i32 {llvm.byval = !llvm.struct<(i32)>})
52
53// -----
54
55// expected-error@below {{"llvm.byref" attribute attached to non-pointer LLVM type}}
56llvm.func @invalid_byref_arg_type(%0 : i32 {llvm.byref = !llvm.struct<(i32)>})
57
58// -----
59
60// expected-error@below {{"llvm.inalloca" attribute attached to non-pointer LLVM type}}
61llvm.func @invalid_inalloca_arg_type(%0 : i32 {llvm.inalloca = !llvm.struct<(i32)>})
62
63// -----
64
65// expected-error@below {{"llvm.signext" attribute attached to non-integer LLVM type}}
66llvm.func @invalid_signext_arg_type(%0 : f32 {llvm.signext})
67
68// -----
69
70// expected-error@below {{"llvm.signext" should be a unit attribute}}
71llvm.func @invalid_signext_attr_type(%0 : i32 {llvm.signext = !llvm.struct<(i32)>})
72
73// -----
74
75// expected-error@below {{"llvm.zeroext" attribute attached to non-integer LLVM type}}
76llvm.func @invalid_zeroext_arg_type(%0 : f32 {llvm.zeroext})
77
78// -----
79
80// expected-error@below {{"llvm.zeroext" should be a unit attribute}}
81llvm.func @invalid_zeroext_attr_type(%0 : i32 {llvm.zeroext = !llvm.struct<(i32)>})
82
83// -----
84
85// expected-error@below {{"llvm.noundef" should be a unit attribute}}
86llvm.func @invalid_noundef_attr_type(%0 : i32 {llvm.noundef = !llvm.ptr})
87
88// -----
89
90// expected-error@below {{"llvm.dereferenceable" attribute attached to non-pointer LLVM type}}
91llvm.func @invalid_dereferenceable_arg_type(%0 : f32 {llvm.dereferenceable = 12 : i64})
92
93// -----
94
95// expected-error@below {{"llvm.dereferenceable" should be an integer attribute}}
96llvm.func @invalid_dereferenceable_attr_type(%0 : !llvm.ptr {llvm.dereferenceable = !llvm.struct<(i32)>})
97
98// -----
99
100// expected-error@below {{"llvm.dereferenceable_or_null" attribute attached to non-pointer LLVM type}}
101llvm.func @invalid_dereferenceable_or_null_arg_type(%0 : f32 {llvm.dereferenceable_or_null = 12 : i64})
102
103// -----
104
105// expected-error@below {{"llvm.dereferenceable_or_null" should be an integer attribute}}
106llvm.func @invalid_dereferenceable_or_null_attr_type(%0 : !llvm.ptr {llvm.dereferenceable_or_null = !llvm.struct<(i32)>})
107
108// -----
109
110// expected-error@below {{"llvm.inreg" should be a unit attribute}}
111llvm.func @invalid_inreg_attr_type(%0 : i32 {llvm.inreg = !llvm.ptr})
112
113// -----
114
115// expected-error@below {{"llvm.nocapture" attribute attached to non-pointer LLVM type}}
116llvm.func @invalid_nocapture_arg_type(%0 : f32 {llvm.nocapture})
117
118// -----
119
120// expected-error@below {{"llvm.nocapture" should be a unit attribute}}
121llvm.func @invalid_nocapture_attr_type(%0 : !llvm.ptr {llvm.nocapture = f32})
122
123// -----
124
125// expected-error@below {{"llvm.nofree" attribute attached to non-pointer LLVM type}}
126llvm.func @invalid_nofree_arg_type(%0 : f32 {llvm.nofree})
127
128// -----
129
130// expected-error@below {{"llvm.nofree" should be a unit attribute}}
131llvm.func @invalid_nofree_attr_type(%0 : !llvm.ptr {llvm.nofree = f32})
132
133// -----
134
135// expected-error@below {{"llvm.nonnull" attribute attached to non-pointer LLVM type}}
136llvm.func @invalid_nonnull_arg_type(%0 : f32 {llvm.nonnull})
137
138// -----
139
140// expected-error@below {{"llvm.nonnull" should be a unit attribute}}
141llvm.func @invalid_nonnull_attr_type(%0 : !llvm.ptr {llvm.nonnull = f32})
142
143// -----
144
145// expected-error@below {{"llvm.preallocated" attribute attached to non-pointer LLVM type}}
146llvm.func @invalid_preallocated_arg_type(%0 : f32 {llvm.preallocated = i64})
147
148// -----
149
150// expected-error@below {{"llvm.preallocated" should be a type attribute}}
151llvm.func @invalid_preallocated_attr_type(%0 : !llvm.ptr {llvm.preallocated})
152
153// -----
154
155// expected-error@below {{"llvm.returned" should be a unit attribute}}
156llvm.func @invalid_returned_attr_type(%0 : i32 {llvm.returned = !llvm.ptr})
157
158// -----
159
160// expected-error@below {{"llvm.alignstack" attribute attached to non-pointer LLVM type}}
161llvm.func @invalid_alignstack_arg_type(%0 : i32 {llvm.alignstack = 10 : i32})
162
163// -----
164
165// expected-error@below {{"llvm.alignstack" should be an integer attribute}}
166llvm.func @invalid_alignstack_attr_type(%0 : i32 {llvm.alignstack = "foo"})
167
168// -----
169
170// expected-error@below {{"llvm.writeonly" attribute attached to non-pointer LLVM type}}
171llvm.func @invalid_writeonly_arg_type(%0 : i32 {llvm.writeonly})
172
173// -----
174
175// expected-error@below {{"llvm.writeonly" should be a unit attribute}}
176llvm.func @invalid_writeonly_attr_type(%0 : i32 {llvm.writeonly = i32})
177
178// -----
179
180
181// Result attributes
182
183// expected-error@below {{expects result attribute array to have the same number of elements as the number of function results, got 1, but expected 0}}
184llvm.func @void_def() -> (!llvm.void {llvm.noundef})
185
186// -----
187
188// expected-error @below{{"llvm.align" should be an integer attribute}}
189llvm.func @alignattr_ret() -> (!llvm.ptr {llvm.align = 1.0 : f32})
190
191// -----
192
193// expected-error @below{{"llvm.align" attribute attached to non-pointer LLVM type}}
194llvm.func @alignattr_ret() -> (i32 {llvm.align = 4})
195
196// -----
197
198// expected-error @below{{"llvm.noalias" should be a unit attribute}}
199llvm.func @noaliasattr_ret() -> (!llvm.ptr {llvm.noalias = 1})
200
201// -----
202
203// expected-error @below{{"llvm.noalias" attribute attached to non-pointer LLVM type}}
204llvm.func @noaliasattr_ret() -> (i32 {llvm.noalias})
205
206// -----
207
208// expected-error @below{{"llvm.noundef" should be a unit attribute}}
209llvm.func @noundefattr_ret() -> (!llvm.ptr {llvm.noundef = 1})
210
211// -----
212
213// expected-error @below{{"llvm.signext" should be a unit attribute}}
214llvm.func @signextattr_ret() -> (i32 {llvm.signext = 1})
215
216// -----
217
218// expected-error @below{{"llvm.signext" attribute attached to non-integer LLVM type}}
219llvm.func @signextattr_ret() -> (f32 {llvm.signext})
220
221// -----
222
223// expected-error @below{{"llvm.zeroext" should be a unit attribute}}
224llvm.func @zeroextattr_ret() -> (i32 {llvm.zeroext = 1})
225
226// -----
227
228// expected-error @below{{"llvm.zeroext" attribute attached to non-integer LLVM type}}
229llvm.func @zeroextattr_ret() -> (f32 {llvm.zeroext})
230
231// -----
232
233// expected-error @below{{"llvm.allocalign" is not a valid result attribute}}
234llvm.func @allocalign_ret() -> (f32 {llvm.allocalign})
235
236// -----
237
238// expected-error @below{{"llvm.allocptr" is not a valid result attribute}}
239llvm.func @allocptr_ret() -> (!llvm.ptr {llvm.allocptr})
240
241// -----
242
243// expected-error @below{{"llvm.byval" is not a valid result attribute}}
244llvm.func @byval_ret() -> (!llvm.ptr {llvm.byval = i64})
245
246// -----
247
248// expected-error @below{{"llvm.byref" is not a valid result attribute}}
249llvm.func @byref_ret() -> (!llvm.ptr {llvm.byref = i64})
250
251// -----
252
253// expected-error @below{{"llvm.inalloca" is not a valid result attribute}}
254llvm.func @inalloca_ret() -> (!llvm.ptr {llvm.inalloca = i64})
255
256// -----
257
258// expected-error @below{{"llvm.nest" is not a valid result attribute}}
259llvm.func @nest_ret() -> (!llvm.ptr {llvm.nest})
260
261// -----
262
263// expected-error @below{{"llvm.nocapture" is not a valid result attribute}}
264llvm.func @nocapture_ret() -> (!llvm.ptr {llvm.nocapture})
265
266// -----
267
268// expected-error @below{{"llvm.nofree" is not a valid result attribute}}
269llvm.func @nofree_ret() -> (!llvm.ptr {llvm.nofree})
270
271// -----
272
273// expected-error @below{{"llvm.preallocated" is not a valid result attribute}}
274llvm.func @preallocated_ret() -> (!llvm.ptr {llvm.preallocated = i64})
275
276// -----
277
278// expected-error @below{{"llvm.readnone" is not a valid result attribute}}
279llvm.func @readnone_ret() -> (!llvm.ptr {llvm.readnone})
280
281// -----
282
283// expected-error @below{{"llvm.readonly" is not a valid result attribute}}
284llvm.func @readonly_ret() -> (!llvm.ptr {llvm.readonly})
285
286// -----
287
288// expected-error @below{{"llvm.alignstack" is not a valid result attribute}}
289llvm.func @alignstack_ret() -> (!llvm.ptr {llvm.alignstack = 16 : i64})
290
291// -----
292
293// expected-error @below{{"llvm.sret" is not a valid result attribute}}
294llvm.func @sret_ret() -> (!llvm.ptr {llvm.sret = i64})
295
296// -----
297
298// expected-error @below{{"llvm.writeonly" is not a valid result attribute}}
299llvm.func @writeonly_ret() -> (!llvm.ptr {llvm.writeonly})
300