295 lines · plain
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics2 3// Argument attributes4 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" should be an integer attribute}}161llvm.func @invalid_alignstack_attr_type(%0 : i32 {llvm.alignstack = "foo"})162 163// -----164 165// expected-error@below {{"llvm.writeonly" attribute attached to non-pointer LLVM type}}166llvm.func @invalid_writeonly_arg_type(%0 : i32 {llvm.writeonly})167 168// -----169 170// expected-error@below {{"llvm.writeonly" should be a unit attribute}}171llvm.func @invalid_writeonly_attr_type(%0 : i32 {llvm.writeonly = i32})172 173// -----174 175 176// Result attributes177 178// 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}}179llvm.func @void_def() -> (!llvm.void {llvm.noundef})180 181// -----182 183// expected-error @below{{"llvm.align" should be an integer attribute}}184llvm.func @alignattr_ret() -> (!llvm.ptr {llvm.align = 1.0 : f32})185 186// -----187 188// expected-error @below{{"llvm.align" attribute attached to non-pointer LLVM type}}189llvm.func @alignattr_ret() -> (i32 {llvm.align = 4})190 191// -----192 193// expected-error @below{{"llvm.noalias" should be a unit attribute}}194llvm.func @noaliasattr_ret() -> (!llvm.ptr {llvm.noalias = 1})195 196// -----197 198// expected-error @below{{"llvm.noalias" attribute attached to non-pointer LLVM type}}199llvm.func @noaliasattr_ret() -> (i32 {llvm.noalias})200 201// -----202 203// expected-error @below{{"llvm.noundef" should be a unit attribute}}204llvm.func @noundefattr_ret() -> (!llvm.ptr {llvm.noundef = 1})205 206// -----207 208// expected-error @below{{"llvm.signext" should be a unit attribute}}209llvm.func @signextattr_ret() -> (i32 {llvm.signext = 1})210 211// -----212 213// expected-error @below{{"llvm.signext" attribute attached to non-integer LLVM type}}214llvm.func @signextattr_ret() -> (f32 {llvm.signext})215 216// -----217 218// expected-error @below{{"llvm.zeroext" should be a unit attribute}}219llvm.func @zeroextattr_ret() -> (i32 {llvm.zeroext = 1})220 221// -----222 223// expected-error @below{{"llvm.zeroext" attribute attached to non-integer LLVM type}}224llvm.func @zeroextattr_ret() -> (f32 {llvm.zeroext})225 226// -----227 228// expected-error @below{{"llvm.allocalign" is not a valid result attribute}}229llvm.func @allocalign_ret() -> (f32 {llvm.allocalign})230 231// -----232 233// expected-error @below{{"llvm.allocptr" is not a valid result attribute}}234llvm.func @allocptr_ret() -> (!llvm.ptr {llvm.allocptr})235 236// -----237 238// expected-error @below{{"llvm.byval" is not a valid result attribute}}239llvm.func @byval_ret() -> (!llvm.ptr {llvm.byval = i64})240 241// -----242 243// expected-error @below{{"llvm.byref" is not a valid result attribute}}244llvm.func @byref_ret() -> (!llvm.ptr {llvm.byref = i64})245 246// -----247 248// expected-error @below{{"llvm.inalloca" is not a valid result attribute}}249llvm.func @inalloca_ret() -> (!llvm.ptr {llvm.inalloca = i64})250 251// -----252 253// expected-error @below{{"llvm.nest" is not a valid result attribute}}254llvm.func @nest_ret() -> (!llvm.ptr {llvm.nest})255 256// -----257 258// expected-error @below{{"llvm.nocapture" is not a valid result attribute}}259llvm.func @nocapture_ret() -> (!llvm.ptr {llvm.nocapture})260 261// -----262 263// expected-error @below{{"llvm.nofree" is not a valid result attribute}}264llvm.func @nofree_ret() -> (!llvm.ptr {llvm.nofree})265 266// -----267 268// expected-error @below{{"llvm.preallocated" is not a valid result attribute}}269llvm.func @preallocated_ret() -> (!llvm.ptr {llvm.preallocated = i64})270 271// -----272 273// expected-error @below{{"llvm.readnone" is not a valid result attribute}}274llvm.func @readnone_ret() -> (!llvm.ptr {llvm.readnone})275 276// -----277 278// expected-error @below{{"llvm.readonly" is not a valid result attribute}}279llvm.func @readonly_ret() -> (!llvm.ptr {llvm.readonly})280 281// -----282 283// expected-error @below{{"llvm.alignstack" is not a valid result attribute}}284llvm.func @alignstack_ret() -> (!llvm.ptr {llvm.alignstack = 16 : i64})285 286// -----287 288// expected-error @below{{"llvm.sret" is not a valid result attribute}}289llvm.func @sret_ret() -> (!llvm.ptr {llvm.sret = i64})290 291// -----292 293// expected-error @below{{"llvm.writeonly" is not a valid result attribute}}294llvm.func @writeonly_ret() -> (!llvm.ptr {llvm.writeonly})295