brintos

brintos / llvm-project-archived public Read only

0
0
Text · 83.6 KiB · af24d96 Raw
3142 lines · plain
1// RUN: mlir-opt -split-input-file -verify-diagnostics %s2 3func.func @unknown_clause() {4  // expected-error@+1 {{expected '{' to begin a region}}5  omp.parallel invalid {6  }7 8  return9}10 11// -----12 13func.func @if_once(%n : i1) {14  // expected-error@+1 {{`if` clause can appear at most once in the expansion of the oilist directive}}15  omp.parallel if(%n) if(%n) {16  }17 18  return19}20 21// -----22 23func.func @num_threads_once(%n : si32) {24  // expected-error@+1 {{`num_threads` clause can appear at most once in the expansion of the oilist directive}}25  omp.parallel num_threads(%n : si32) num_threads(%n : si32) {26  }27 28  return29}30 31// -----32 33func.func @nowait_not_allowed(%n : memref<i32>) {34  // expected-error@+1 {{expected '{' to begin a region}}35  omp.parallel nowait {}36  return37}38 39// -----40 41func.func @linear_not_allowed(%data_var : memref<i32>, %linear_var : i32) {42  // expected-error@+1 {{expected '{' to begin a region}}43  omp.parallel linear(%data_var = %linear_var : memref<i32>)  {}44  return45}46 47// -----48 49func.func @schedule_not_allowed() {50  // expected-error@+1 {{expected '{' to begin a region}}51  omp.parallel schedule(static) {}52  return53}54 55// -----56 57func.func @collapse_not_allowed() {58  // expected-error@+1 {{expected '{' to begin a region}}59  omp.parallel collapse(3) {}60  return61}62 63// -----64 65func.func @order_not_allowed() {66  // expected-error@+1 {{expected '{' to begin a region}}67  omp.parallel order(concurrent) {}68  return69}70 71// -----72 73func.func @ordered_not_allowed() {74  // expected-error@+1 {{expected '{' to begin a region}}75  omp.parallel ordered(2) {}76}77 78// -----79 80func.func @proc_bind_once() {81  // expected-error@+1 {{`proc_bind` clause can appear at most once in the expansion of the oilist directive}}82  omp.parallel proc_bind(close) proc_bind(spread) {83  }84 85  return86}87 88// -----89 90func.func @invalid_parent(%lb : index, %ub : index, %step : index) {91  // expected-error@+1 {{op expects parent op to be a loop wrapper}}92  omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {93    omp.yield94  }95}96 97// -----98 99func.func @type_mismatch(%lb : index, %ub : index, %step : index) {100  omp.wsloop {101    // expected-error@+1 {{range argument type does not match corresponding IV type}}102    "omp.loop_nest" (%lb, %ub, %step) ({103    ^bb0(%iv2: i32):104      omp.yield105    }) : (index, index, index) -> ()106  }107}108 109// -----110 111func.func @iv_number_mismatch(%lb : index, %ub : index, %step : index) {112  omp.wsloop {113    // expected-error@+1 {{number of range arguments and IVs do not match}}114    "omp.loop_nest" (%lb, %ub, %step) ({115    ^bb0(%iv1 : index, %iv2 : index):116      omp.yield117    }) : (index, index, index) -> ()118  }119}120 121// -----122 123func.func @no_wrapper(%lb : index, %ub : index, %step : index) {124  // expected-error @below {{op loop wrapper does not contain exactly one nested op}}125  omp.wsloop {126    %0 = arith.constant 0 : i32127    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {128      omp.yield129    }130  }131}132 133// -----134 135func.func @invalid_nested_wrapper(%lb : index, %ub : index, %step : index) {136  // expected-error @below {{only supported nested wrapper is 'omp.simd'}}137  omp.wsloop {138    omp.distribute {139      omp.simd {140        omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {141          omp.yield142        }143      } {omp.composite}144    } {omp.composite}145  } {omp.composite}146}147 148// -----149 150func.func @no_loops(%lb : index, %ub : index, %step : index) {151  omp.wsloop {152    // expected-error@+1 {{op must represent at least one loop}}153    "omp.loop_nest" () ({154    ^bb0():155      omp.yield156    }) : () -> ()157  }158}159 160// -----161 162func.func @collapse_size(%lb : index, %ub : index, %step : index) {163  omp.wsloop {164    // expected-error@+1 {{collapse value is larger than the number of loops}}165    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) collapse(4) {166      omp.yield167    }168  }169}170 171// -----172 173func.func @tiles_length(%lb : index, %ub : index, %step : index) {174  omp.wsloop {175    // expected-error@+1 {{op too few canonical loops for tile dimensions}}176    omp.loop_nest (%iv) : index =  (%lb) to (%ub) step (%step) tiles(2, 4) {177      omp.yield178    }179  }180}181 182 183// -----184 185func.func @inclusive_not_a_clause(%lb : index, %ub : index, %step : index) {186  // expected-error @below {{expected '{'}}187  omp.wsloop nowait inclusive {188    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {189      omp.yield190    }191  }192}193 194// -----195 196func.func @order_value(%lb : index, %ub : index, %step : index) {197  // expected-error @below {{invalid clause value: 'default'}}198  omp.wsloop order(default) {199    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {200      omp.yield201    }202  }203}204 205// -----206func.func @reproducible_order(%lb : index, %ub : index, %step : index) {207  // expected-error @below {{invalid clause value: 'default'}}208  omp.wsloop order(reproducible:default) {209    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {210      omp.yield211    }212  }213}214// -----215func.func @unconstrained_order(%lb : index, %ub : index, %step : index) {216  // expected-error @below {{invalid clause value: 'default'}}217  omp.wsloop order(unconstrained:default) {218    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {219      omp.yield220    }221  }222}223// -----224 225func.func @if_not_allowed(%lb : index, %ub : index, %step : index, %bool_var : i1) {226  // expected-error @below {{expected '{'}}227  omp.wsloop if(%bool_var) {228    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {229      omp.yield230    }231  }232}233 234// -----235 236func.func @num_threads_not_allowed(%lb : index, %ub : index, %step : index, %int_var : i32) {237  // expected-error @below {{expected '{'}}238  omp.wsloop num_threads(%int_var: i32) {239    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {240      omp.yield241    }242  }243}244 245// -----246 247func.func @proc_bind_not_allowed(%lb : index, %ub : index, %step : index) {248  // expected-error @below {{expected '{'}}249  omp.wsloop proc_bind(close) {250    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {251      omp.yield252    }253  }254}255 256// -----257 258llvm.func @test_omp_wsloop_dynamic_bad_modifier(%lb : i64, %ub : i64, %step : i64) -> () {259  // expected-error @+1 {{unknown modifier type: ginandtonic}}260  omp.wsloop schedule(dynamic, ginandtonic) {261    omp.loop_nest (%iv) : i64 = (%lb) to (%ub) step (%step) {262      omp.yield263    }264  }265  llvm.return266}267 268// -----269 270llvm.func @test_omp_wsloop_dynamic_many_modifier(%lb : i64, %ub : i64, %step : i64) -> () {271  // expected-error @+1 {{unexpected modifier(s)}}272  omp.wsloop schedule(dynamic, monotonic, monotonic, monotonic) {273    omp.loop_nest (%iv) : i64 = (%lb) to (%ub) step (%step) {274      omp.yield275    }276  }277  llvm.return278}279 280// -----281 282llvm.func @test_omp_wsloop_dynamic_wrong_modifier(%lb : i64, %ub : i64, %step : i64) -> () {283  // expected-error @+1 {{incorrect modifier order}}284  omp.wsloop schedule(dynamic, simd, monotonic) {285    omp.loop_nest (%iv) : i64 = (%lb) to (%ub) step (%step) {286      omp.yield287    }288  }289  llvm.return290}291 292// -----293 294llvm.func @test_omp_wsloop_dynamic_wrong_modifier2(%lb : i64, %ub : i64, %step : i64) -> () {295  // expected-error @+1 {{incorrect modifier order}}296  omp.wsloop schedule(dynamic, monotonic, monotonic) {297    omp.loop_nest (%iv) : i64 = (%lb) to (%ub) step (%step) {298      omp.yield299    }300  }301  llvm.return302}303 304// -----305 306llvm.func @test_omp_wsloop_dynamic_wrong_modifier3(%lb : i64, %ub : i64, %step : i64) -> () {307  // expected-error @+1 {{incorrect modifier order}}308  omp.wsloop schedule(dynamic, simd, simd) {309    omp.loop_nest (%iv) : i64 = (%lb) to (%ub) step (%step) {310      omp.yield311    }312  }313  llvm.return314}315 316// -----317 318func.func @omp_simd() -> () {319  // expected-error @below {{op loop wrapper does not contain exactly one nested op}}320  omp.simd {}321  return322}323 324// -----325 326func.func @omp_simd_nested_wrapper(%lb : index, %ub : index, %step : index) -> () {327  // expected-error @below {{op must wrap an 'omp.loop_nest' directly}}328  omp.simd {329    omp.distribute {330      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {331        omp.yield332      }333    }334  }335  return336}337 338// -----339 340func.func @omp_simd_pretty_aligned(%lb : index, %ub : index, %step : index,341                                   %data_var : memref<i32>) -> () {342  //  expected-error @below {{expected '->'}}343  omp.simd aligned(%data_var : memref<i32>) {344    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {345      omp.yield346    }347  }348  return349}350 351// -----352 353func.func @omp_simd_aligned_mismatch(%arg0 : index, %arg1 : index,354                                     %arg2 : index, %arg3 : memref<i32>,355                                     %arg4 : memref<i32>) -> () {356  //  expected-error @below {{op expected as many alignment values as aligned variables}}357  "omp.simd"(%arg3, %arg4) ({358    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {359      omp.yield360    }361  }) {alignments = [128],362      operandSegmentSizes = array<i32: 2, 0, 0, 0, 0, 0, 0>} : (memref<i32>, memref<i32>) -> ()363  return364}365 366// -----367 368func.func @omp_simd_aligned_negative(%arg0 : index, %arg1 : index,369                                     %arg2 : index, %arg3 : memref<i32>,370                                     %arg4 : memref<i32>) -> () {371  //  expected-error @below {{op alignment should be greater than 0}}372  "omp.simd"(%arg3, %arg4) ({373    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {374      omp.yield375    }376  }) {alignments = [-1, 128], operandSegmentSizes = array<i32: 2, 0, 0, 0, 0, 0, 0>} : (memref<i32>, memref<i32>) -> ()377  return378}379 380// -----381 382func.func @omp_simd_unexpected_alignment(%arg0 : index, %arg1 : index,383                                         %arg2 : index, %arg3 : memref<i32>,384                                         %arg4 : memref<i32>) -> () {385  //  expected-error @below {{unexpected alignment values attribute}}386  "omp.simd"() ({387    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {388      omp.yield389    }390  }) {alignments = [1, 128]} : () -> ()391  return392}393 394// -----395 396func.func @omp_simd_aligned_float(%arg0 : index, %arg1 : index,397                                  %arg2 : index, %arg3 : memref<i32>,398                                  %arg4 : memref<i32>) -> () {399  //  expected-error @below {{failed to satisfy constraint: 64-bit integer array attribute}}400  "omp.simd"(%arg3, %arg4) ({401    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {402      omp.yield403    }404  }) {alignments = [1.5, 128], operandSegmentSizes = array<i32: 2, 0, 0, 0, 0, 0, 0>} : (memref<i32>, memref<i32>) -> ()405  return406}407 408// -----409 410func.func @omp_simd_aligned_the_same_var(%arg0 : index, %arg1 : index,411                                         %arg2 : index, %arg3 : memref<i32>,412                                         %arg4 : memref<i32>) -> () {413  //  expected-error @below {{aligned variable used more than once}}414  "omp.simd"(%arg3, %arg3) ({415    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {416      omp.yield417    }418  }) {alignments = [1, 128], operandSegmentSizes = array<i32: 2, 0, 0, 0, 0, 0, 0>} : (memref<i32>, memref<i32>) -> ()419  return420}421 422// -----423 424func.func @omp_simd_nontemporal_the_same_var(%arg0 : index,  %arg1 : index,425                                             %arg2 : index,426                                             %arg3 : memref<i32>) -> () {427  //  expected-error @below {{nontemporal variable used more than once}}428  "omp.simd"(%arg3, %arg3) ({429    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {430      omp.yield431    }432  }) {operandSegmentSizes = array<i32: 0, 0, 0, 0, 2, 0, 0>} : (memref<i32>, memref<i32>) -> ()433  return434}435 436// -----437 438func.func @omp_simd_order_value(%lb : index, %ub : index, %step : index) {439  // expected-error @below {{invalid clause value: 'default'}}440  omp.simd order(default) {441    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {442      omp.yield443    }444  }445  return446}447 448// -----449 450func.func @omp_simd_reproducible_order(%lb : index, %ub : index, %step : index) {451  // expected-error @below {{invalid clause value: 'default'}}452  omp.simd order(reproducible:default) {453    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {454      omp.yield455    }456  }457  return458}459// -----460func.func @omp_simd_unconstrained_order(%lb : index, %ub : index, %step : index) {461  // expected-error @below {{invalid clause value: 'default'}}462  omp.simd order(unconstrained:default) {463    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {464      omp.yield465    }466  }467  return468}469// -----470func.func @omp_simd_pretty_simdlen(%lb : index, %ub : index, %step : index) -> () {471  // expected-error @below {{op attribute 'simdlen' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive}}472  omp.simd simdlen(0) {473    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {474      omp.yield475    }476  }477  return478}479 480// -----481 482func.func @omp_simd_pretty_safelen(%lb : index, %ub : index, %step : index) -> () {483  // expected-error @below {{op attribute 'safelen' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive}}484  omp.simd safelen(0) {485    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {486      omp.yield487    }488  }489  return490}491 492// -----493 494func.func @omp_simd_pretty_simdlen_safelen(%lb : index, %ub : index, %step : index) -> () {495  // expected-error @below {{op simdlen clause and safelen clause are both present, but the simdlen value is not less than or equal to safelen value}}496  omp.simd simdlen(2) safelen(1) {497    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {498      omp.yield499    }500  }501  return502}503 504// -----505 506func.func @omp_simd_bad_privatizer(%lb : index, %ub : index, %step : index) {507  %0 = llvm.mlir.constant(1 : i64) : i64508  %1 = llvm.alloca %0 x i32 : (i64) -> !llvm.ptr509  // expected-error @below {{Cannot find privatizer '@not_defined'}}510  omp.simd private(@not_defined %1 -> %arg0 : !llvm.ptr) {511    omp.loop_nest (%arg2) : index = (%lb) to (%ub) inclusive step (%step) {512      omp.yield513    }514  }515}516 517// -----518 519omp.private {type = firstprivate} @_QFEp_firstprivate_i32 : i32 copy {520^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):521  %0 = llvm.load %arg0 : !llvm.ptr -> i32522  llvm.store %0, %arg1 : i32, !llvm.ptr523  omp.yield(%arg1 : !llvm.ptr)524}525func.func @omp_simd_firstprivate(%lb : index, %ub : index, %step : index) {526  %0 = llvm.mlir.constant(1 : i64) : i64527  %1 = llvm.alloca %0 x i32 : (i64) -> !llvm.ptr528  // expected-error @below {{FIRSTPRIVATE cannot be used with SIMD}}529  omp.simd private(@_QFEp_firstprivate_i32 %1 -> %arg0 : !llvm.ptr) {530    omp.loop_nest (%arg2) : index = (%lb) to (%ub) inclusive step (%step) {531      omp.yield532    }533  }534  llvm.return535}536 537// -----538 539// expected-error @below {{op expects alloc region to yield a value of the reduction type}}540omp.declare_reduction @add_f32 : f32541alloc {542^bb0(%arg: f32):543// nonsense test code544  %0 = arith.constant 0.0 : f64545  omp.yield (%0 : f64)546}547init {548^bb0(%arg0: f32, %arg1: f32):549  %0 = arith.constant 0.0 : f32550  omp.yield (%0 : f32)551}552combiner {553^bb1(%arg0: f32, %arg1: f32):554  %1 = arith.addf %arg0, %arg1 : f32555  omp.yield (%1 : f32)556}557 558// -----559 560// expected-error @below {{op expects two arguments to the initializer region when an allocation region is used}}561omp.declare_reduction @add_f32 : f32562alloc {563^bb0(%arg: f32):564// nonsense test code565  omp.yield (%arg : f32)566}567init {568^bb0(%arg0: f32):569  %0 = arith.constant 0.0 : f32570  omp.yield (%0 : f32)571}572combiner {573^bb1(%arg0: f32, %arg1: f32):574  %1 = arith.addf %arg0, %arg1 : f32575  omp.yield (%1 : f32)576}577 578// -----579 580// expected-error @below {{op expects one argument to the initializer region when no allocation region is used}}581omp.declare_reduction @add_f32 : f32582init {583^bb0(%arg: f32, %arg2: f32):584  %0 = arith.constant 0.0 : f32585  omp.yield (%0 : f32)586}587combiner {588^bb1(%arg0: f32, %arg1: f32):589  %1 = arith.addf %arg0, %arg1 : f32590  omp.yield (%1 : f32)591}592 593// -----594 595// expected-error @below {{op expects initializer region argument to match the reduction type}}596omp.declare_reduction @add_f32 : f64597init {598^bb0(%arg: f32):599  %0 = arith.constant 0.0 : f32600  omp.yield (%0 : f32)601}602combiner {603^bb1(%arg0: f32, %arg1: f32):604  %1 = arith.addf %arg0, %arg1 : f32605  omp.yield (%1 : f32)606}607 608// -----609 610// expected-error @below {{expects initializer region to yield a value of the reduction type}}611omp.declare_reduction @add_f32 : f32612init {613^bb0(%arg: f32):614  %0 = arith.constant 0.0 : f64615  omp.yield (%0 : f64)616}617combiner {618^bb1(%arg0: f32, %arg1: f32):619  %1 = arith.addf %arg0, %arg1 : f32620  omp.yield (%1 : f32)621}622 623// -----624 625// expected-error @below {{expects reduction region with two arguments of the reduction type}}626omp.declare_reduction @add_f32 : f32627init {628^bb0(%arg: f32):629  %0 = arith.constant 0.0 : f32630  omp.yield (%0 : f32)631}632combiner {633^bb1(%arg0: f64, %arg1: f64):634  %1 = arith.addf %arg0, %arg1 : f64635  omp.yield (%1 : f64)636}637 638// -----639 640// expected-error @below {{expects reduction region to yield a value of the reduction type}}641omp.declare_reduction @add_f32 : f32642init {643^bb0(%arg: f32):644  %0 = arith.constant 0.0 : f32645  omp.yield (%0 : f32)646}647combiner {648^bb1(%arg0: f32, %arg1: f32):649  %1 = arith.addf %arg0, %arg1 : f32650  %2 = arith.extf %1 : f32 to f64651  omp.yield (%2 : f64)652}653 654// -----655 656// expected-error @below {{expects atomic reduction region with two arguments of the same type}}657omp.declare_reduction @add_f32 : f32658init {659^bb0(%arg: f32):660  %0 = arith.constant 0.0 : f32661  omp.yield (%0 : f32)662}663combiner {664^bb1(%arg0: f32, %arg1: f32):665  %1 = arith.addf %arg0, %arg1 : f32666  omp.yield (%1 : f32)667}668atomic {669^bb2(%arg0: memref<f32>, %arg1: memref<f64>):670  omp.yield671}672 673// -----674 675// expected-error @below {{expects atomic reduction region arguments to be accumulators containing the reduction type}}676omp.declare_reduction @add_f32 : f32677init {678^bb0(%arg: f32):679  %0 = arith.constant 0.0 : f32680  omp.yield (%0 : f32)681}682combiner {683^bb1(%arg0: f32, %arg1: f32):684  %1 = arith.addf %arg0, %arg1 : f32685  omp.yield (%1 : f32)686}687atomic {688^bb2(%arg0: memref<f64>, %arg1: memref<f64>):689  omp.yield690}691 692// -----693 694// expected-error @below {{op expects cleanup region with one argument of the reduction type}}695omp.declare_reduction @add_f32 : f32696init {697^bb0(%arg: f32):698  %0 = arith.constant 0.0 : f32699  omp.yield (%0 : f32)700}701combiner {702^bb1(%arg0: f32, %arg1: f32):703  %1 = arith.addf %arg0, %arg1 : f32704  omp.yield (%1 : f32)705}706cleanup {707^bb0(%arg: f64):708  omp.yield709}710 711// -----712 713// expected-error @below {{op region #0 ('allocRegion') failed to verify constraint: region with at most 1 blocks}}714omp.declare_reduction @alloc_reduction : !llvm.ptr715alloc {716^bb0(%arg: !llvm.ptr):717  %c1 = arith.constant 1 : i32718  %0 = llvm.alloca %c1 x f32 : (i32) -> !llvm.ptr719  cf.br ^bb1(%0: !llvm.ptr)720^bb1(%ret: !llvm.ptr):721  omp.yield (%ret : !llvm.ptr)722}723init {724^bb0(%arg: !llvm.ptr):725  %cst = arith.constant 1.0 : f32726  llvm.store %cst, %arg : f32, !llvm.ptr727  omp.yield (%arg : !llvm.ptr)728}729combiner {730^bb1(%arg0: !llvm.ptr, %arg1: !llvm.ptr):731  %0 = llvm.load %arg0 : !llvm.ptr -> f32732  %1 = llvm.load %arg1 : !llvm.ptr -> f32733  %2 = arith.addf %0, %1 : f32734  llvm.store %2, %arg0 : f32, !llvm.ptr735  omp.yield (%arg0 : !llvm.ptr)736}737 738// -----739 740func.func @foo(%lb : index, %ub : index, %step : index) {741  %c1 = arith.constant 1 : i32742  %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr743  %1 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr744 745  // expected-error @below {{expected symbol reference @foo to point to a reduction declaration}}746  omp.wsloop reduction(@foo %0 -> %prv : !llvm.ptr) {747    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {748      %2 = arith.constant 2.0 : f32749      omp.yield750    }751  }752  return753}754 755// -----756 757omp.declare_reduction @add_f32 : f32758init {759^bb0(%arg: f32):760  %0 = arith.constant 0.0 : f32761  omp.yield (%0 : f32)762}763combiner {764^bb1(%arg0: f32, %arg1: f32):765  %1 = arith.addf %arg0, %arg1 : f32766  omp.yield (%1 : f32)767}768 769func.func @foo(%lb : index, %ub : index, %step : index) {770  %c1 = arith.constant 1 : i32771  %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr772 773  // expected-error @below {{accumulator variable used more than once}}774  omp.wsloop reduction(@add_f32 %0 -> %prv, @add_f32 %0 -> %prv1 : !llvm.ptr, !llvm.ptr) {775    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {776      %2 = arith.constant 2.0 : f32777      omp.yield778    }779  }780  return781}782 783// -----784 785omp.declare_reduction @add_f32 : f32786init {787^bb0(%arg: f32):788  %0 = arith.constant 0.0 : f32789  omp.yield (%0 : f32)790}791combiner {792^bb1(%arg0: f32, %arg1: f32):793  %1 = arith.addf %arg0, %arg1 : f32794  omp.yield (%1 : f32)795}796atomic {797^bb2(%arg2: !llvm.ptr, %arg3: !llvm.ptr):798  %2 = llvm.load %arg3 : !llvm.ptr -> f32799  llvm.atomicrmw fadd %arg2, %2 monotonic : !llvm.ptr, f32800  omp.yield801}802 803func.func @foo(%lb : index, %ub : index, %step : index, %mem : memref<1xf32>) {804  %c1 = arith.constant 1 : i32805 806  // expected-error @below {{expected accumulator ('memref<1xf32>') to be the same type as reduction declaration ('!llvm.ptr')}}807  omp.wsloop reduction(@add_f32 %mem -> %prv : memref<1xf32>) {808    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {809      %2 = arith.constant 2.0 : f32810      omp.yield811    }812  }813  return814}815 816// -----817 818func.func @omp_critical2() -> () {819  // expected-error @below {{expected symbol reference @excl to point to a critical declaration}}820  omp.critical(@excl) {821    omp.terminator822  }823  return824}825 826// -----827 828// expected-error @below {{the hints omp_sync_hint_uncontended and omp_sync_hint_contended cannot be combined}}829omp.critical.declare @mutex hint(uncontended, contended)830 831// -----832 833// expected-error @below {{the hints omp_sync_hint_nonspeculative and omp_sync_hint_speculative cannot be combined}}834omp.critical.declare @mutex hint(nonspeculative, speculative)835 836// -----837 838// expected-error @below {{invalid_hint is not a valid hint}}839omp.critical.declare @mutex hint(invalid_hint)840 841// -----842 843func.func @omp_ordered_region1(%x : i32) -> () {844  omp.distribute {845    omp.loop_nest (%i) : i32 = (%x) to (%x) step (%x) {846      // expected-error @below {{op must be nested inside of a worksharing, simd or worksharing simd loop}}847      omp.ordered.region {848        omp.terminator849      }850      omp.yield851    }852  }853  return854}855 856// -----857 858func.func @omp_ordered_region2(%x : i32) -> () {859  omp.wsloop {860    omp.loop_nest (%i) : i32 = (%x) to (%x) step (%x) {861      // expected-error @below {{the enclosing worksharing-loop region must have an ordered clause}}862      omp.ordered.region {863        omp.terminator864      }865      omp.yield866    }867  }868  return869}870 871// -----872 873func.func @omp_ordered_region3(%x : i32) -> () {874  omp.wsloop ordered(1) {875    omp.loop_nest (%i) : i32 = (%x) to (%x) step (%x) {876      // expected-error @below {{the enclosing loop's ordered clause must not have a parameter present}}877      omp.ordered.region {878        omp.terminator879      }880      omp.yield881    }882  }883  return884}885 886// -----887 888func.func @omp_ordered1(%vec0 : i64) -> () {889  // expected-error @below {{op must be nested inside of a loop}}890  omp.ordered depend_type(dependsink) depend_vec(%vec0 : i64) {doacross_num_loops = 1 : i64}891  return892}893 894// -----895 896func.func @omp_ordered2(%arg1 : i32, %arg2 : i32, %arg3 : i32, %vec0 : i64) -> () {897  omp.distribute {898    omp.loop_nest (%0) : i32 = (%arg1) to (%arg2) step (%arg3) {899      // expected-error @below {{op must be nested inside of a worksharing, simd or worksharing simd loop}}900      omp.ordered depend_type(dependsink) depend_vec(%vec0 : i64) {doacross_num_loops = 1 : i64}901      omp.yield902    }903  }904  return905}906 907// -----908 909func.func @omp_ordered3(%arg1 : i32, %arg2 : i32, %arg3 : i32, %vec0 : i64) -> () {910  omp.wsloop {911    omp.loop_nest (%0) : i32 = (%arg1) to (%arg2) step (%arg3) {912      // expected-error @below {{the enclosing worksharing-loop region must have an ordered clause}}913      omp.ordered depend_type(dependsink) depend_vec(%vec0 : i64) {doacross_num_loops = 1 : i64}914      omp.yield915    }916  }917  return918}919 920// -----921 922func.func @omp_ordered4(%arg1 : i32, %arg2 : i32, %arg3 : i32, %vec0 : i64) -> () {923  omp.wsloop ordered(0) {924    omp.loop_nest (%0) : i32 = (%arg1) to (%arg2) step (%arg3) {925      // expected-error @below {{the enclosing loop's ordered clause must have a parameter present}}926      omp.ordered depend_type(dependsink) depend_vec(%vec0 : i64) {doacross_num_loops = 1 : i64}927      omp.yield928    }929  }930  return931}932 933// -----934 935func.func @omp_ordered5(%arg1 : i32, %arg2 : i32, %arg3 : i32, %vec0 : i64, %vec1 : i64) -> () {936  omp.wsloop ordered(1) {937    omp.loop_nest (%0) : i32 = (%arg1) to (%arg2) step (%arg3) {938      // expected-error @below {{number of variables in depend clause does not match number of iteration variables in the doacross loop}}939      omp.ordered depend_type(dependsource) depend_vec(%vec0, %vec1 : i64, i64) {doacross_num_loops = 2 : i64}940      omp.yield941    }942  }943  return944}945 946// -----947 948func.func @omp_atomic_read1(%x: memref<i32>, %v: memref<i32>) {949  // expected-error @below {{the hints omp_sync_hint_nonspeculative and omp_sync_hint_speculative cannot be combined.}}950  omp.atomic.read %v = %x hint(speculative, nonspeculative) : memref<i32>, memref<i32>, i32951  return952}953 954// -----955 956func.func @omp_atomic_read2(%x: memref<i32>, %v: memref<i32>) {957  // expected-error @below {{invalid clause value: 'xyz'}}958  omp.atomic.read %v = %x memory_order(xyz) : memref<i32>, memref<i32>, i32959  return960}961 962// -----963 964func.func @omp_atomic_read3(%x: memref<i32>, %v: memref<i32>) {965  // expected-error @below {{memory-order must not be acq_rel or release for atomic reads}}966  omp.atomic.read %v = %x memory_order(acq_rel) : memref<i32>, memref<i32>, i32967  return968}969 970// -----971 972func.func @omp_atomic_read4(%x: memref<i32>, %v: memref<i32>) {973  // expected-error @below {{memory-order must not be acq_rel or release for atomic reads}}974  omp.atomic.read %v = %x memory_order(release) : memref<i32>, memref<i32>, i32975  return976}977 978// -----979 980func.func @omp_atomic_read5(%x: memref<i32>, %v: memref<i32>) {981  // expected-error @below {{`memory_order` clause can appear at most once in the expansion of the oilist directive}}982  omp.atomic.read %v = %x memory_order(acquire) memory_order(relaxed) : memref<i32>, memref<i32>, i32983  return984}985 986// -----987 988func.func @omp_atomic_read6(%x: memref<i32>, %v: memref<i32>) {989  // expected-error @below {{`hint` clause can appear at most once in the expansion of the oilist directive}}990  omp.atomic.read %v =  %x hint(speculative) hint(contended) : memref<i32>, memref<i32>, i32991  return992}993 994// -----995 996func.func @omp_atomic_read6(%x: memref<i32>, %v: memref<i32>) {997  // expected-error @below {{read and write must not be to the same location for atomic reads}}998  omp.atomic.read %x =  %x hint(speculative) : memref<i32>, memref<i32>, i32999  return1000}1001 1002// -----1003 1004func.func @omp_atomic_write1(%addr : memref<i32>, %val : i32) {1005  // expected-error @below {{the hints omp_sync_hint_uncontended and omp_sync_hint_contended cannot be combined}}1006  omp.atomic.write  %addr = %val hint(contended, uncontended) : memref<i32>, i321007  return1008}1009 1010// -----1011 1012func.func @omp_atomic_write2(%addr : memref<i32>, %val : i32) {1013  // expected-error @below {{memory-order must not be acq_rel or acquire for atomic writes}}1014  omp.atomic.write  %addr = %val memory_order(acq_rel) : memref<i32>, i321015  return1016}1017 1018// -----1019 1020func.func @omp_atomic_write3(%addr : memref<i32>, %val : i32) {1021  // expected-error @below {{memory-order must not be acq_rel or acquire for atomic writes}}1022  omp.atomic.write  %addr = %val memory_order(acquire) : memref<i32>, i321023  return1024}1025 1026// -----1027 1028func.func @omp_atomic_write4(%addr : memref<i32>, %val : i32) {1029  // expected-error @below {{`memory_order` clause can appear at most once in the expansion of the oilist directive}}1030  omp.atomic.write  %addr = %val memory_order(release) memory_order(seq_cst) : memref<i32>, i321031  return1032}1033 1034// -----1035 1036func.func @omp_atomic_write5(%addr : memref<i32>, %val : i32) {1037  // expected-error @below {{`hint` clause can appear at most once in the expansion of the oilist directive}}1038  omp.atomic.write  %addr = %val hint(contended) hint(speculative) : memref<i32>, i321039  return1040}1041 1042// -----1043 1044func.func @omp_atomic_write6(%addr : memref<i32>, %val : i32) {1045  // expected-error @below {{invalid clause value: 'xyz'}}1046  omp.atomic.write  %addr = %val memory_order(xyz) : memref<i32>, i321047  return1048}1049 1050// -----1051 1052func.func @omp_atomic_write(%addr : memref<memref<i32>>, %val : i32) {1053  // expected-error @below {{address must dereference to value type}}1054  omp.atomic.write %addr = %val : memref<memref<i32>>, i321055  return1056}1057 1058// -----1059 1060func.func @omp_atomic_update1(%x: memref<i32>, %expr: f32) {1061  // expected-error @below {{the type of the operand must be a pointer type whose element type is the same as that of the region argument}}1062  omp.atomic.update %x : memref<i32> {1063  ^bb0(%xval: f32):1064    %newval = llvm.fadd %xval, %expr : f321065    omp.yield (%newval : f32)1066  }1067  return1068}1069 1070// -----1071 1072func.func @omp_atomic_update2(%x: memref<i32>, %expr: i32) {1073  // expected-error @+2 {{op expects regions to end with 'omp.yield', found 'omp.terminator'}}1074  // expected-note @below {{in custom textual format, the absence of terminator implies 'omp.yield'}}1075  omp.atomic.update %x : memref<i32> {1076  ^bb0(%xval: i32):1077    %newval = llvm.add %xval, %expr : i321078    omp.terminator1079  }1080  return1081}1082 1083// -----1084 1085func.func @omp_atomic_update3(%x: memref<i32>, %expr: i32) {1086  // expected-error @below {{memory-order must not be acq_rel or acquire for atomic updates}}1087  omp.atomic.update memory_order(acq_rel) %x : memref<i32> {1088  ^bb0(%xval: i32):1089    %newval = llvm.add %xval, %expr : i321090    omp.yield (%newval : i32)1091  }1092  return1093}1094 1095// -----1096 1097func.func @omp_atomic_update4(%x: memref<i32>, %expr: i32) {1098  // expected-error @below {{memory-order must not be acq_rel or acquire for atomic updates}}1099  omp.atomic.update memory_order(acquire) %x : memref<i32> {1100  ^bb0(%xval: i32):1101    %newval = llvm.add %xval, %expr : i321102    omp.yield (%newval : i32)1103  }1104  return1105}1106 1107// -----1108 1109func.func @omp_atomic_update5(%x: memref<i32>, %expr: i32) {1110  // expected-error @below {{invalid kind of type specified}}1111  omp.atomic.update %x : i32 {1112  ^bb0(%xval: i32):1113    %newval = llvm.add %xval, %expr : i321114    omp.yield (%newval : i32)1115  }1116  return1117}1118 1119// -----1120 1121func.func @omp_atomic_update6(%x: memref<i32>, %expr: i32) {1122  // expected-error @below {{only updated value must be returned}}1123  omp.atomic.update %x : memref<i32> {1124  ^bb0(%xval: i32):1125    %newval = llvm.add %xval, %expr : i321126    omp.yield (%newval, %expr : i32, i32)1127  }1128  return1129}1130 1131// -----1132 1133func.func @omp_atomic_update7(%x: memref<i32>, %expr: i32, %y: f32) {1134  // expected-error @below {{input and yielded value must have the same type}}1135  omp.atomic.update %x : memref<i32> {1136  ^bb0(%xval: i32):1137    %newval = llvm.add %xval, %expr : i321138    omp.yield (%y: f32)1139  }1140  return1141}1142 1143// -----1144 1145func.func @omp_atomic_update8(%x: memref<i32>, %expr: i32) {1146  // expected-error @below {{the region must accept exactly one argument}}1147  omp.atomic.update %x : memref<i32> {1148  ^bb0(%xval: i32, %tmp: i32):1149    %newval = llvm.add %xval, %expr : i321150    omp.yield (%newval : i32)1151  }1152  return1153}1154 1155// -----1156 1157func.func @omp_atomic_update(%x: memref<i32>, %expr: i32) {1158  // expected-error @below {{the hints omp_sync_hint_uncontended and omp_sync_hint_contended cannot be combined}}1159  omp.atomic.update hint(uncontended, contended) %x : memref<i32> {1160  ^bb0(%xval: i32):1161    %newval = llvm.add %xval, %expr : i321162    omp.yield (%newval : i32)1163  }1164  return1165}1166 1167// -----1168 1169func.func @omp_atomic_update(%x: memref<i32>, %expr: i32) {1170  // expected-error @below {{the hints omp_sync_hint_nonspeculative and omp_sync_hint_speculative cannot be combined}}1171  omp.atomic.update hint(nonspeculative, speculative) %x : memref<i32> {1172  ^bb0(%xval: i32):1173    %newval = llvm.add %xval, %expr : i321174    omp.yield (%newval : i32)1175  }1176  return1177}1178 1179// -----1180 1181func.func @omp_atomic_update(%x: memref<i32>, %expr: i32) {1182  // expected-error @below {{invalid_hint is not a valid hint}}1183  omp.atomic.update hint(invalid_hint) %x : memref<i32> {1184  ^bb0(%xval: i32):1185    %newval = llvm.add %xval, %expr : i321186    omp.yield (%newval : i32)1187  }1188  return1189}1190 1191// -----1192 1193func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1194  // expected-error @below {{expected three operations in atomic.capture region}}1195  omp.atomic.capture {1196    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321197    omp.terminator1198  }1199  return1200}1201 1202// -----1203 1204func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1205  omp.atomic.capture {1206    // expected-error @below {{invalid sequence of operations in the capture region}}1207    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321208    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321209    omp.terminator1210  }1211  return1212}1213 1214// -----1215 1216func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1217  omp.atomic.capture {1218    // expected-error @below {{invalid sequence of operations in the capture region}}1219    omp.atomic.update %x : memref<i32> {1220    ^bb0(%xval: i32):1221      %newval = llvm.add %xval, %expr : i321222      omp.yield (%newval : i32)1223    }1224    omp.atomic.update %x : memref<i32> {1225    ^bb0(%xval: i32):1226      %newval = llvm.add %xval, %expr : i321227      omp.yield (%newval : i32)1228    }1229    omp.terminator1230  }1231  return1232}1233 1234// -----1235 1236func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1237  omp.atomic.capture {1238    // expected-error @below {{invalid sequence of operations in the capture region}}1239    omp.atomic.write %x = %expr : memref<i32>, i321240    omp.atomic.write %x = %expr : memref<i32>, i321241    omp.terminator1242  }1243  return1244}1245 1246// -----1247 1248func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1249  omp.atomic.capture {1250    // expected-error @below {{invalid sequence of operations in the capture region}}1251    omp.atomic.write %x = %expr : memref<i32>, i321252    omp.atomic.update %x : memref<i32> {1253    ^bb0(%xval: i32):1254      %newval = llvm.add %xval, %expr : i321255      omp.yield (%newval : i32)1256    }1257    omp.terminator1258  }1259  return1260}1261 1262// -----1263 1264func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1265  omp.atomic.capture {1266    // expected-error @below {{invalid sequence of operations in the capture region}}1267    omp.atomic.update %x : memref<i32> {1268    ^bb0(%xval: i32):1269      %newval = llvm.add %xval, %expr : i321270      omp.yield (%newval : i32)1271    }1272    omp.atomic.write %x = %expr : memref<i32>, i321273    omp.terminator1274  }1275  return1276}1277 1278// -----1279 1280func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1281  omp.atomic.capture {1282    // expected-error @below {{invalid sequence of operations in the capture region}}1283    omp.atomic.write %x = %expr : memref<i32>, i321284    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321285    omp.terminator1286  }1287  return1288}1289 1290// -----1291 1292func.func @omp_atomic_capture(%x: memref<i32>, %y: memref<i32>, %v: memref<i32>, %expr: i32) {1293  omp.atomic.capture {1294    // expected-error @below {{updated variable in atomic.update must be captured in second operation}}1295    omp.atomic.update %x : memref<i32> {1296    ^bb0(%xval: i32):1297      %newval = llvm.add %xval, %expr : i321298      omp.yield (%newval : i32)1299    }1300    omp.atomic.read %v = %y : memref<i32>, memref<i32>, i321301    omp.terminator1302  }1303}1304 1305// -----1306 1307func.func @omp_atomic_capture(%x: memref<i32>, %y: memref<i32>, %v: memref<i32>, %expr: i32) {1308  omp.atomic.capture {1309    // expected-error @below {{captured variable in atomic.read must be updated in second operation}}1310    omp.atomic.read %v = %y : memref<i32>, memref<i32>, i321311    omp.atomic.update %x : memref<i32> {1312    ^bb0(%xval: i32):1313      %newval = llvm.add %xval, %expr : i321314      omp.yield (%newval : i32)1315    }1316    omp.terminator1317  }1318}1319 1320// -----1321 1322func.func @omp_atomic_capture(%x: memref<i32>, %y: memref<i32>, %v: memref<i32>, %expr: i32) {1323  omp.atomic.capture {1324    // expected-error @below {{captured variable in atomic.read must be updated in second operation}}1325    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321326    omp.atomic.write %y = %expr : memref<i32>, i321327    omp.terminator1328  }1329}1330 1331// -----1332 1333func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1334  // expected-error @below {{the hints omp_sync_hint_uncontended and omp_sync_hint_contended cannot be combined}}1335  omp.atomic.capture hint(contended, uncontended) {1336    omp.atomic.update %x : memref<i32> {1337    ^bb0(%xval: i32):1338      %newval = llvm.add %xval, %expr : i321339      omp.yield(%newval : i32)1340    }1341    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321342  }1343  return1344}1345 1346// -----1347 1348func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1349  // expected-error @below {{the hints omp_sync_hint_nonspeculative and omp_sync_hint_speculative cannot be combined}}1350  omp.atomic.capture hint(nonspeculative, speculative) {1351    omp.atomic.update %x : memref<i32> {1352    ^bb0(%xval: i32):1353      %newval = llvm.add %xval, %expr : i321354      omp.yield(%newval : i32)1355    }1356    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321357  }1358  return1359}1360 1361// -----1362 1363func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1364  // expected-error @below {{invalid_hint is not a valid hint}}1365  omp.atomic.capture hint(invalid_hint) {1366    omp.atomic.update %x : memref<i32> {1367    ^bb0(%xval: i32):1368      %newval = llvm.add %xval, %expr : i321369      omp.yield(%newval : i32)1370    }1371    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321372  }1373  return1374}1375 1376// -----1377 1378func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1379  // expected-error @below {{operations inside capture region must not have hint clause}}1380  omp.atomic.capture {1381    omp.atomic.update hint(uncontended) %x : memref<i32> {1382    ^bb0(%xval: i32):1383      %newval = llvm.add %xval, %expr : i321384      omp.yield(%newval : i32)1385    }1386    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321387  }1388  return1389}1390 1391// -----1392 1393func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1394  // expected-error @below {{operations inside capture region must not have memory_order clause}}1395  omp.atomic.capture {1396    omp.atomic.update memory_order(seq_cst) %x : memref<i32> {1397    ^bb0(%xval: i32):1398      %newval = llvm.add %xval, %expr : i321399      omp.yield(%newval : i32)1400    }1401    omp.atomic.read %v = %x : memref<i32>, memref<i32>, i321402  }1403  return1404}1405 1406// -----1407 1408func.func @omp_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {1409  // expected-error @below {{operations inside capture region must not have memory_order clause}}1410  omp.atomic.capture {1411    omp.atomic.update %x : memref<i32> {1412    ^bb0(%xval: i32):1413      %newval = llvm.add %xval, %expr : i321414      omp.yield(%newval : i32)1415    }1416    omp.atomic.read %v = %x memory_order(seq_cst) : memref<i32>, memref<i32>, i321417  }1418  return1419}1420 1421// -----1422 1423func.func @omp_teams_parent() {1424  omp.parallel {1425    // expected-error @below {{expected to be nested inside of omp.target or not nested in any OpenMP dialect operations}}1426    omp.teams {1427      omp.terminator1428    }1429    omp.terminator1430  }1431  return1432}1433 1434// -----1435 1436func.func @omp_teams_allocate(%data_var : memref<i32>) {1437  omp.target {1438    // expected-error @below {{expected equal sizes for allocate and allocator variables}}1439    "omp.teams" (%data_var) ({1440      omp.terminator1441    }) {operandSegmentSizes = array<i32: 1,0,0,0,0,0,0,0>} : (memref<i32>) -> ()1442    omp.terminator1443  }1444  return1445}1446 1447// -----1448 1449func.func @omp_teams_num_teams1(%lb : i32) {1450  omp.target {1451    // expected-error @below {{expected num_teams upper bound to be defined if the lower bound is defined}}1452    "omp.teams" (%lb) ({1453      omp.terminator1454    }) {operandSegmentSizes = array<i32: 0,0,0,1,0,0,0,0>} : (i32) -> ()1455    omp.terminator1456  }1457  return1458}1459 1460// -----1461 1462func.func @omp_teams_num_teams2(%lb : i32, %ub : i16) {1463  omp.target {1464    // expected-error @below {{expected num_teams upper bound and lower bound to be the same type}}1465    omp.teams num_teams(%lb : i32 to %ub : i16) {1466      omp.terminator1467    }1468    omp.terminator1469  }1470  return1471}1472 1473// -----1474 1475func.func @omp_sections(%data_var : memref<i32>) -> () {1476  // expected-error @below {{expected equal sizes for allocate and allocator variables}}1477  "omp.sections" (%data_var) ({1478    omp.terminator1479  }) {operandSegmentSizes = array<i32: 1,0,0,0>} : (memref<i32>) -> ()1480  return1481}1482 1483// -----1484 1485func.func @omp_sections(%data_var : memref<i32>) -> () {1486  // expected-error @below {{expected as many reduction symbol references as reduction variables}}1487  "omp.sections" (%data_var) ({1488  ^bb0(%arg0: memref<i32>):1489    omp.terminator1490  }) {operandSegmentSizes = array<i32: 0,0,0,1>} : (memref<i32>) -> ()1491  return1492}1493 1494// -----1495 1496func.func @omp_sections(%data_var : memref<i32>) -> () {1497  // expected-error @below {{expected omp.section op or terminator op inside region}}1498  omp.sections {1499    "test.payload" () : () -> ()1500  }1501  return1502}1503 1504// -----1505 1506func.func @omp_sections(%cond : i1) {1507  // expected-error @below {{expected '{' to begin a region}}1508  omp.sections if(%cond) {1509    omp.terminator1510  }1511  return1512}1513 1514// -----1515 1516func.func @omp_sections() {1517  // expected-error @below {{expected '{' to begin a region}}1518  omp.sections num_threads(10) {1519    omp.terminator1520  }1521  return1522}1523 1524// -----1525 1526func.func @omp_sections() {1527  // expected-error @below {{expected '{' to begin a region}}1528  omp.sections proc_bind(close) {1529    omp.terminator1530  }1531  return1532}1533 1534// -----1535 1536func.func @omp_sections(%data_var : memref<i32>, %linear_var : i32) {1537  // expected-error @below {{expected '{' to begin a region}}1538  omp.sections linear(%data_var = %linear_var : memref<i32>) {1539    omp.terminator1540  }1541  return1542}1543 1544// -----1545 1546func.func @omp_sections() {1547  // expected-error @below {{expected '{' to begin a region}}1548  omp.sections schedule(static, none) {1549    omp.terminator1550  }1551  return1552}1553 1554// -----1555 1556func.func @omp_sections() {1557  // expected-error @below {{expected '{' to begin a region}}1558  omp.sections collapse(3) {1559    omp.terminator1560  }1561  return1562}1563 1564// -----1565 1566func.func @omp_sections() {1567  // expected-error @below {{expected '{' to begin a region}}1568  omp.sections ordered(2) {1569    omp.terminator1570  }1571  return1572}1573 1574// -----1575 1576func.func @omp_sections() {1577  // expected-error @below {{expected '{' to begin a region}}1578  omp.sections order(concurrent) {1579    omp.terminator1580  }1581  return1582}1583 1584// -----1585 1586func.func @omp_sections() {1587  // expected-error @below {{failed to verify constraint: region with 1 blocks}}1588  omp.sections {1589    omp.section {1590      omp.terminator1591    }1592    omp.terminator1593  ^bb2:1594    omp.terminator1595  }1596  return1597}1598 1599// -----1600 1601omp.declare_reduction @add_f32 : f321602init {1603^bb0(%arg: f32):1604  %0 = arith.constant 0.0 : f321605  omp.yield (%0 : f32)1606}1607combiner {1608^bb1(%arg0: f32, %arg1: f32):1609  %1 = arith.addf %arg0, %arg1 : f321610  omp.yield (%1 : f32)1611}1612 1613func.func @omp_sections(%x : !llvm.ptr) {1614  omp.sections reduction(@add_f32 %x -> %arg0 : !llvm.ptr) {1615    // expected-error @below {{op expected at least 1 entry block argument(s)}}1616    omp.section {1617      omp.terminator1618    }1619    omp.terminator1620  }1621  return1622}1623 1624// -----1625 1626func.func @omp_single(%data_var : memref<i32>) -> () {1627  // expected-error @below {{expected equal sizes for allocate and allocator variables}}1628  "omp.single" (%data_var) ({1629    omp.barrier1630  }) {operandSegmentSizes = array<i32: 1,0,0,0>} : (memref<i32>) -> ()1631  return1632}1633 1634// -----1635 1636func.func @omp_single_copyprivate(%data_var : memref<i32>) -> () {1637  // expected-error @below {{inconsistent number of copyprivate vars (= 1) and functions (= 0), both must be equal}}1638  "omp.single" (%data_var) ({1639    omp.barrier1640  }) {operandSegmentSizes = array<i32: 0,0,1,0>} : (memref<i32>) -> ()1641  return1642}1643 1644// -----1645 1646func.func @omp_single_copyprivate(%data_var : memref<i32>) -> () {1647  // expected-error @below {{expected symbol reference @copy_func to point to a copy function}}1648  omp.single copyprivate(%data_var -> @copy_func : memref<i32>) {1649    omp.barrier1650  }1651  return1652}1653 1654// -----1655 1656func.func private @copy_func(memref<i32>)1657 1658func.func @omp_single_copyprivate(%data_var : memref<i32>) -> () {1659  // expected-error @below {{expected copy function @copy_func to have 2 operands}}1660  omp.single copyprivate(%data_var -> @copy_func : memref<i32>) {1661    omp.barrier1662  }1663  return1664}1665 1666// -----1667 1668func.func private @copy_func(memref<i32>, memref<f32>)1669 1670func.func @omp_single_copyprivate(%data_var : memref<i32>) -> () {1671  // expected-error @below {{expected copy function @copy_func arguments to have the same type}}1672  omp.single copyprivate(%data_var -> @copy_func : memref<i32>) {1673    omp.barrier1674  }1675  return1676}1677 1678// -----1679 1680func.func private @copy_func(memref<f32>, memref<f32>)1681 1682func.func @omp_single_copyprivate(%data_var : memref<i32>) -> () {1683  // expected-error @below {{expected copy function arguments' type ('memref<f32>') to be the same as copyprivate variable's type ('memref<i32>')}}1684  omp.single copyprivate(%data_var -> @copy_func : memref<i32>) {1685    omp.barrier1686  }1687  return1688}1689 1690// -----1691 1692func.func @omp_task_depend(%data_var: memref<i32>) {1693  // expected-error @below {{'omp.task' op operand count (1) does not match with the total size (0) specified in attribute 'operandSegmentSizes'}}1694    "omp.task"(%data_var) ({1695      "omp.terminator"() : () -> ()1696    }) {depend_kinds = [], operandSegmentSizes = array<i32: 0, 0, 1, 0, 0, 0, 0, 0>} : (memref<i32>) -> ()1697   "func.return"() : () -> ()1698}1699 1700// -----1701 1702func.func @omp_task(%ptr: !llvm.ptr) {1703  // expected-error @below {{op expected symbol reference @add_f32 to point to a reduction declaration}}1704  omp.task in_reduction(@add_f32 %ptr -> %arg0 : !llvm.ptr) {1705    // CHECK: "test.foo"() : () -> ()1706    "test.foo"() : () -> ()1707    // CHECK: omp.terminator1708    omp.terminator1709  }1710}1711 1712// -----1713 1714omp.declare_reduction @add_f32 : f321715init {1716^bb0(%arg: f32):1717  %0 = arith.constant 0.0 : f321718  omp.yield (%0 : f32)1719}1720combiner {1721^bb1(%arg0: f32, %arg1: f32):1722  %1 = arith.addf %arg0, %arg1 : f321723  omp.yield (%1 : f32)1724}1725 1726func.func @omp_task(%ptr: !llvm.ptr) {1727  // expected-error @below {{op accumulator variable used more than once}}1728  omp.task in_reduction(@add_f32 %ptr -> %arg0, @add_f32 %ptr -> %arg1 : !llvm.ptr, !llvm.ptr) {1729    // CHECK: "test.foo"() : () -> ()1730    "test.foo"() : () -> ()1731    // CHECK: omp.terminator1732    omp.terminator1733  }1734}1735 1736// -----1737 1738omp.declare_reduction @add_i32 : i321739init {1740^bb0(%arg: i32):1741  %0 = arith.constant 0 : i321742  omp.yield (%0 : i32)1743}1744combiner {1745^bb1(%arg0: i32, %arg1: i32):1746  %1 = arith.addi %arg0, %arg1 : i321747  omp.yield (%1 : i32)1748}1749atomic {1750^bb2(%arg2: !llvm.ptr, %arg3: !llvm.ptr):1751  %2 = llvm.load %arg3 : !llvm.ptr -> i321752  llvm.atomicrmw add %arg2, %2 monotonic : !llvm.ptr, i321753  omp.yield1754}1755 1756func.func @omp_task(%mem: memref<1xf32>) {1757  // expected-error @below {{op expected accumulator ('memref<1xf32>') to be the same type as reduction declaration ('!llvm.ptr')}}1758  omp.task in_reduction(@add_i32 %mem -> %arg0 : memref<1xf32>) {1759    // CHECK: "test.foo"() : () -> ()1760    "test.foo"() : () -> ()1761    // CHECK: omp.terminator1762    omp.terminator1763  }1764  return1765}1766 1767// -----1768 1769func.func @omp_cancel() {1770  // expected-error @below {{Orphaned cancel construct}}1771  omp.cancel cancellation_construct_type(parallel)1772  return1773}1774 1775// -----1776 1777func.func @omp_cancel() {1778  omp.sections {1779    // expected-error @below {{cancel parallel must appear inside a parallel region}}1780    omp.cancel cancellation_construct_type(parallel)1781    // CHECK: omp.terminator1782    omp.terminator1783  }1784  return1785}1786 1787// -----1788 1789func.func @omp_cancel1() {1790  omp.parallel {1791    // expected-error @below {{cancel sections must appear inside a sections region}}1792    omp.cancel cancellation_construct_type(sections)1793    // CHECK: omp.terminator1794    omp.terminator1795  }1796  return1797}1798 1799// -----1800 1801func.func @omp_cancel2() {1802  omp.sections {1803    // expected-error @below {{cancel loop must appear inside a worksharing-loop region}}1804    omp.cancel cancellation_construct_type(loop)1805    // CHECK: omp.terminator1806    omp.terminator1807  }1808  return1809}1810 1811// -----1812 1813func.func @omp_cancel_taskloop() {1814  omp.sections {1815    // expected-error @below {{cancel taskgroup must appear inside a task region}}1816    omp.cancel cancellation_construct_type(taskgroup)1817    // CHECK: omp.terminator1818    omp.terminator1819  }1820  return1821}1822 1823// -----1824 1825func.func @omp_cancel3(%arg1 : i32, %arg2 : i32, %arg3 : i32) -> () {1826  omp.wsloop nowait {1827    omp.loop_nest (%0) : i32 = (%arg1) to (%arg2) step (%arg3) {1828      // expected-error @below {{A worksharing construct that is canceled must not have a nowait clause}}1829      omp.cancel cancellation_construct_type(loop)1830      // CHECK: omp.yield1831      omp.yield1832    }1833  }1834  return1835}1836 1837// -----1838 1839func.func @omp_cancel4(%arg1 : i32, %arg2 : i32, %arg3 : i32) -> () {1840  omp.wsloop ordered(1) {1841    omp.loop_nest (%0) : i32 = (%arg1) to (%arg2) step (%arg3) {1842      // expected-error @below {{A worksharing construct that is canceled must not have an ordered clause}}1843      omp.cancel cancellation_construct_type(loop)1844      // CHECK: omp.yield1845      omp.yield1846    }1847  }1848  return1849}1850 1851// -----1852 1853func.func @omp_cancel5() -> () {1854  omp.sections nowait {1855    omp.section {1856      // expected-error @below {{A sections construct that is canceled must not have a nowait clause}}1857      omp.cancel cancellation_construct_type(sections)1858      omp.terminator1859    }1860    // CHECK: omp.terminator1861    omp.terminator1862  }1863  return1864}1865 1866// -----1867 1868func.func @omp_cancellationpoint() {1869  // expected-error @below {{Orphaned cancellation point}}1870  omp.cancellation_point cancellation_construct_type(parallel)1871  return1872}1873 1874// -----1875 1876func.func @omp_cancellationpoint() {1877  omp.sections {1878    // expected-error @below {{cancellation point parallel must appear inside a parallel region}}1879    omp.cancellation_point cancellation_construct_type(parallel)1880    // CHECK: omp.terminator1881    omp.terminator1882  }1883  return1884}1885 1886// -----1887 1888func.func @omp_cancellationpoint1() {1889  omp.parallel {1890    // expected-error @below {{cancellation point sections must appear inside a sections region}}1891    omp.cancellation_point cancellation_construct_type(sections)1892    // CHECK: omp.terminator1893    omp.terminator1894  }1895  return1896}1897 1898// -----1899 1900func.func @omp_cancellationpoint2() {1901  omp.sections {1902    // expected-error @below {{cancellation point loop must appear inside a worksharing-loop region}}1903    omp.cancellation_point cancellation_construct_type(loop)1904    // CHECK: omp.terminator1905    omp.terminator1906  }1907  return1908}1909 1910// -----1911 1912func.func @omp_cancellationpoint_taskgroup() {1913  omp.sections {1914    // expected-error @below {{cancellation point taskgroup must appear inside a task region}}1915    omp.cancellation_point cancellation_construct_type(taskgroup)1916    // CHECK: omp.terminator1917    omp.terminator1918  }1919  return1920}1921 1922// -----1923 1924omp.declare_reduction @add_f32 : f321925init {1926 ^bb0(%arg: f32):1927  %0 = arith.constant 0.0 : f321928  omp.yield (%0 : f32)1929}1930combiner {1931  ^bb1(%arg0: f32, %arg1: f32):1932  %1 = arith.addf %arg0, %arg1 : f321933  omp.yield (%1 : f32)1934}1935 1936func.func @scan_test_2(%lb: i32, %ub: i32, %step: i32) {1937  %test1f32 = "test.f32"() : () -> (!llvm.ptr)1938  omp.wsloop reduction(mod:inscan, @add_f32 %test1f32 -> %arg1 : !llvm.ptr) {1939    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {1940  // expected-error @below {{Exactly one of EXCLUSIVE or INCLUSIVE clause is expected}}1941       omp.scan1942        omp.yield1943    }1944  }1945  return1946}1947 1948// -----1949 1950omp.declare_reduction @add_f32 : f321951init {1952 ^bb0(%arg: f32):1953  %0 = arith.constant 0.0 : f321954  omp.yield (%0 : f32)1955}1956combiner {1957  ^bb1(%arg0: f32, %arg1: f32):1958  %1 = arith.addf %arg0, %arg1 : f321959  omp.yield (%1 : f32)1960}1961 1962func.func @scan_test_2(%lb: i32, %ub: i32, %step: i32) {1963  %test1f32 = "test.f32"() : () -> (!llvm.ptr)1964  omp.wsloop reduction(mod:inscan, @add_f32 %test1f32 -> %arg1 : !llvm.ptr) {1965    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {1966  // expected-error @below {{Exactly one of EXCLUSIVE or INCLUSIVE clause is expected}}1967       omp.scan inclusive(%test1f32 : !llvm.ptr) exclusive(%test1f32: !llvm.ptr)1968        omp.yield1969    }1970  }1971  return1972}1973 1974// -----1975 1976omp.declare_reduction @add_f32 : f321977init {1978 ^bb0(%arg: f32):1979  %0 = arith.constant 0.0 : f321980  omp.yield (%0 : f32)1981}1982combiner {1983  ^bb1(%arg0: f32, %arg1: f32):1984  %1 = arith.addf %arg0, %arg1 : f321985  omp.yield (%1 : f32)1986}1987 1988func.func @scan_test_2(%lb: i32, %ub: i32, %step: i32) {1989  %test1f32 = "test.f32"() : () -> (!llvm.ptr)1990  omp.wsloop reduction(@add_f32 %test1f32 -> %arg1 : !llvm.ptr) {1991    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {1992  // expected-error @below {{SCAN directive needs to be enclosed within a parent worksharing loop construct or SIMD construct with INSCAN reduction modifier}}1993       omp.scan inclusive(%test1f32 : !llvm.ptr)1994        omp.yield1995    }1996  }1997  return1998}1999 2000// -----2001 2002omp.declare_reduction @add_f32 : f322003init {2004 ^bb0(%arg: f32):2005  %0 = arith.constant 0.0 : f322006  omp.yield (%0 : f32)2007}2008combiner {2009  ^bb1(%arg0: f32, %arg1: f32):2010  %1 = arith.addf %arg0, %arg1 : f322011  omp.yield (%1 : f32)2012}2013 2014func.func @scan_test_2(%lb: i32, %ub: i32, %step: i32) {2015  %test1f32 = "test.f32"() : () -> (!llvm.ptr)2016  omp.taskloop reduction(mod:inscan, @add_f32 %test1f32 -> %arg1 : !llvm.ptr) {2017    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2018  // expected-error @below {{SCAN directive needs to be enclosed within a parent worksharing loop construct or SIMD construct with INSCAN reduction modifier}}2019       omp.scan inclusive(%test1f32 : !llvm.ptr)2020        omp.yield2021    }2022  }2023  return2024}2025 2026// -----2027 2028func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2029  %testmemref = "test.memref"() : () -> (memref<i32>)2030  // expected-error @below {{expected equal sizes for allocate and allocator variables}}2031  "omp.taskloop"(%testmemref) ({2032    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2033      omp.yield2034    }2035  }) {operandSegmentSizes = array<i32: 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>} : (memref<i32>) -> ()2036  return2037}2038 2039// -----2040 2041func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2042  %testf32 = "test.f32"() : () -> (!llvm.ptr)2043  %testf32_2 = "test.f32"() : () -> (!llvm.ptr)2044  // expected-error @below {{expected as many reduction symbol references as reduction variables}}2045  "omp.taskloop"(%testf32, %testf32_2) ({2046  ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):2047    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2048      omp.yield2049    }2050  }) {operandSegmentSizes = array<i32: 0, 0, 0, 0, 0, 0, 0, 0, 0, 2>, reduction_syms = [@add_f32]} : (!llvm.ptr, !llvm.ptr) -> ()2051  return2052}2053 2054// -----2055 2056func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2057  %testf32 = "test.f32"() : () -> (!llvm.ptr)2058  // expected-error @below {{expected as many reduction symbol references as reduction variables}}2059  "omp.taskloop"(%testf32) ({2060  ^bb0(%arg0: !llvm.ptr):2061    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2062      omp.yield2063    }2064  }) {operandSegmentSizes = array<i32: 0, 0, 0, 0, 0, 0, 0, 0, 0, 1>, reduction_syms = [@add_f32, @add_f32]} : (!llvm.ptr) -> ()2065  return2066}2067 2068// -----2069 2070func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2071  %testf32 = "test.f32"() : () -> (!llvm.ptr)2072  %testf32_2 = "test.f32"() : () -> (!llvm.ptr)2073  // expected-error @below {{expected as many reduction symbol references as reduction variables}}2074  "omp.taskloop"(%testf32, %testf32_2) ({2075  ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):2076    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2077      omp.yield2078    }2079  }) {in_reduction_syms = [@add_f32], operandSegmentSizes = array<i32: 0, 0, 0, 0, 0, 2, 0, 0, 0, 0>} : (!llvm.ptr, !llvm.ptr) -> ()2080  return2081}2082 2083// -----2084 2085func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2086  %testf32 = "test.f32"() : () -> (!llvm.ptr)2087  // expected-error @below {{expected as many reduction symbol references as reduction variables}}2088  "omp.taskloop"(%testf32) ({2089  ^bb0(%arg0: !llvm.ptr):2090    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2091      omp.yield2092    }2093  }) {in_reduction_syms = [@add_f32, @add_f32], operandSegmentSizes = array<i32: 0, 0, 0, 0, 0, 1, 0, 0, 0, 0>} : (!llvm.ptr) -> ()2094  return2095}2096 2097// -----2098 2099omp.declare_reduction @add_f32 : f322100init {2101^bb0(%arg: f32):2102  %0 = arith.constant 0.0 : f322103  omp.yield (%0 : f32)2104}2105combiner {2106^bb1(%arg0: f32, %arg1: f32):2107  %1 = arith.addf %arg0, %arg1 : f322108  omp.yield (%1 : f32)2109}2110 2111func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2112  %testf32 = "test.f32"() : () -> (!llvm.ptr)2113  %testf32_2 = "test.f32"() : () -> (!llvm.ptr)2114  // expected-error @below {{if a reduction clause is present on the taskloop directive, the nogroup clause must not be specified}}2115  omp.taskloop nogroup reduction(@add_f32 %testf32 -> %arg0, @add_f32 %testf32_2 -> %arg1 : !llvm.ptr, !llvm.ptr) {2116    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2117      omp.yield2118    }2119  }2120  return2121}2122 2123// -----2124 2125omp.declare_reduction @add_f32 : f322126init {2127^bb0(%arg: f32):2128  %0 = arith.constant 0.0 : f322129  omp.yield (%0 : f32)2130}2131combiner {2132^bb1(%arg0: f32, %arg1: f32):2133  %1 = arith.addf %arg0, %arg1 : f322134  omp.yield (%1 : f32)2135}2136 2137func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2138  %testf32 = "test.f32"() : () -> (!llvm.ptr)2139  // expected-error @below {{the same list item cannot appear in both a reduction and an in_reduction clause}}2140  omp.taskloop in_reduction(@add_f32 %testf32 -> %arg0 : !llvm.ptr) reduction(@add_f32 %testf32 -> %arg1 : !llvm.ptr) {2141    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2142      omp.yield2143    }2144  }2145  return2146}2147 2148// -----2149 2150func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2151  %testi64 = "test.i64"() : () -> (i64)2152  // expected-error @below {{the grainsize clause and num_tasks clause are mutually exclusive and may not appear on the same taskloop directive}}2153  omp.taskloop grainsize(%testi64: i64) num_tasks(%testi64: i64) {2154    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2155      omp.yield2156    }2157  }2158  return2159}2160 2161// -----2162 2163func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2164  %testi64 = "test.i64"() : () -> (i64)2165  // expected-error @below {{invalid grainsize modifier : 'strict1'}}2166  omp.taskloop grainsize(strict1, %testi64: i64) {2167    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2168      omp.yield2169    }2170  }2171  return2172}2173// -----2174 2175func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2176  %testi64 = "test.i64"() : () -> (i64)2177  // expected-error @below {{invalid num_tasks modifier : 'default'}}2178  omp.taskloop num_tasks(default, %testi64: i64) {2179    omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {2180      omp.yield2181    }2182  }2183  return2184}2185// -----2186 2187func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2188  // expected-error @below {{op nested in loop wrapper is not another loop wrapper or `omp.loop_nest`}}2189  omp.taskloop {2190    %0 = arith.constant 0 : i322191  }2192  return2193}2194 2195// -----2196 2197func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {2198  // expected-error @below {{only supported nested wrapper is 'omp.simd'}}2199  omp.taskloop {2200    omp.distribute {2201      omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {2202        omp.yield2203      }2204    }2205  } {omp.composite}2206  return2207}2208 2209// -----2210 2211func.func @omp_threadprivate() {2212  %1 = llvm.mlir.addressof @_QFsubEx : !llvm.ptr2213  // expected-error @below {{op failed to verify that all of {sym_addr, tls_addr} have same type}}2214  %2 = omp.threadprivate %1 : !llvm.ptr -> memref<i32>2215  return2216}2217 2218// -----2219 2220func.func @omp_target(%map1: memref<?xi32>) {2221  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>)   map_clauses(delete) capture(ByRef) -> memref<?xi32> {name = ""}2222  // expected-error @below {{to, from, tofrom and alloc map types are permitted}}2223  omp.target map_entries(%mapv -> %arg0: memref<?xi32>) {2224    omp.terminator2225  }2226  return2227}2228 2229// -----2230 2231func.func @omp_target_data(%map1: memref<?xi32>) {2232  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>)  map_clauses(delete) capture(ByRef) -> memref<?xi32> {name = ""}2233  // expected-error @below {{to, from, tofrom and alloc map types are permitted}}2234  omp.target_data map_entries(%mapv : memref<?xi32>){}2235  return2236}2237 2238// -----2239 2240func.func @omp_target_data() {2241  // expected-error @below {{At least one of map, use_device_ptr_vars, or use_device_addr_vars operand must be present}}2242  omp.target_data {}2243  return2244}2245 2246// -----2247 2248func.func @omp_target_enter_data(%map1: memref<?xi32>) {2249  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>)   map_clauses(from) capture(ByRef) -> memref<?xi32> {name = ""}2250  // expected-error @below {{to and alloc map types are permitted}}2251  omp.target_enter_data map_entries(%mapv : memref<?xi32>){}2252  return2253}2254 2255// -----2256 2257func.func @omp_target_enter_data_depend(%a: memref<?xi32>) {2258  %0 = omp.map.info var_ptr(%a: memref<?xi32>, tensor<?xi32>) map_clauses(to) capture(ByRef) -> memref<?xi32>2259  // expected-error @below {{op expected as many depend values as depend variables}}2260  omp.target_enter_data map_entries(%0: memref<?xi32> ) {operandSegmentSizes = array<i32: 1, 0, 0, 0>}2261  return2262}2263 2264// -----2265 2266func.func @omp_target_exit_data(%map1: memref<?xi32>) {2267  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>)   map_clauses(to) capture(ByRef) -> memref<?xi32> {name = ""}2268  // expected-error @below {{from, release and delete map types are permitted}}2269  omp.target_exit_data map_entries(%mapv : memref<?xi32>){}2270  return2271}2272 2273// -----2274 2275func.func @omp_target_exit_data_depend(%a: memref<?xi32>) {2276  %0 = omp.map.info var_ptr(%a: memref<?xi32>, tensor<?xi32>) map_clauses(from) capture(ByRef) -> memref<?xi32>2277  // expected-error @below {{op expected as many depend values as depend variables}}2278  omp.target_exit_data map_entries(%0: memref<?xi32> ) {operandSegmentSizes = array<i32: 1, 0, 0, 0>}2279  return2280}2281 2282// -----2283 2284func.func @omp_target_update_invalid_motion_type(%map1 : memref<?xi32>) {2285  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(exit_release_or_enter_alloc) capture(ByRef) -> memref<?xi32> {name = ""}2286 2287  // expected-error @below {{at least one of to or from map types must be specified, other map types are not permitted}}2288  omp.target_update map_entries(%mapv : memref<?xi32>)2289  return2290}2291 2292// -----2293 2294func.func @omp_target_update_invalid_motion_type_2(%map1 : memref<?xi32>) {2295  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(delete) capture(ByRef) -> memref<?xi32> {name = ""}2296 2297  // expected-error @below {{at least one of to or from map types must be specified, other map types are not permitted}}2298  omp.target_update map_entries(%mapv : memref<?xi32>)2299  return2300}2301 2302// -----2303 2304func.func @omp_target_update_invalid_motion_modifier(%map1 : memref<?xi32>) {2305  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(always, to) capture(ByRef) -> memref<?xi32> {name = ""}2306 2307  // expected-error @below {{present, mapper and iterator map type modifiers are permitted}}2308  omp.target_update map_entries(%mapv : memref<?xi32>)2309  return2310}2311 2312// -----2313 2314func.func @omp_target_update_invalid_motion_modifier_2(%map1 : memref<?xi32>) {2315  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(close, to) capture(ByRef) -> memref<?xi32> {name = ""}2316 2317  // expected-error @below {{present, mapper and iterator map type modifiers are permitted}}2318  omp.target_update map_entries(%mapv : memref<?xi32>)2319  return2320}2321 2322// -----2323 2324func.func @omp_target_update_invalid_motion_modifier_3(%map1 : memref<?xi32>) {2325  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(implicit, to) capture(ByRef) -> memref<?xi32> {name = ""}2326 2327  // expected-error @below {{present, mapper and iterator map type modifiers are permitted}}2328  omp.target_update map_entries(%mapv : memref<?xi32>)2329  return2330}2331 2332// -----2333 2334func.func @omp_target_update_invalid_motion_modifier_4(%map1 : memref<?xi32>) {2335  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(implicit, tofrom) capture(ByRef) -> memref<?xi32> {name = ""}2336 2337  // expected-error @below {{either to or from map types can be specified, not both}}2338  omp.target_update map_entries(%mapv : memref<?xi32>)2339  return2340}2341 2342// -----2343 2344func.func @omp_target_update_invalid_motion_modifier_5(%map1 : memref<?xi32>) {2345  %mapv = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(to) capture(ByRef) -> memref<?xi32> {name = ""}2346  %mapv2 = omp.map.info var_ptr(%map1 : memref<?xi32>, tensor<?xi32>) map_clauses(from) capture(ByRef) -> memref<?xi32> {name = ""}2347 2348  // expected-error @below {{either to or from map types can be specified, not both}}2349  omp.target_update map_entries(%mapv, %mapv2 : memref<?xi32>, memref<?xi32>)2350  return2351}2352llvm.mlir.global internal @_QFsubEx() : i322353 2354// -----2355 2356func.func @omp_target_update_data_depend(%a: memref<?xi32>) {2357  %0 = omp.map.info var_ptr(%a: memref<?xi32>, tensor<?xi32>) map_clauses(to) capture(ByRef) -> memref<?xi32>2358  // expected-error @below {{op expected as many depend values as depend variables}}2359  omp.target_update map_entries(%0: memref<?xi32> ) {operandSegmentSizes = array<i32: 1, 0, 0, 0>}2360  return2361}2362 2363// -----2364 2365func.func @omp_target_multiple_teams() {2366  // expected-error @below {{target containing multiple 'omp.teams' nested ops}}2367  omp.target {2368    omp.teams {2369      omp.terminator2370    }2371    omp.teams {2372      omp.terminator2373    }2374    omp.terminator2375  }2376  return2377}2378 2379// -----2380 2381func.func @omp_target_host_eval(%x : !llvm.ptr) {2382  // expected-error @below {{op host_eval argument illegal use in 'llvm.load' operation}}2383  omp.target host_eval(%x -> %arg0 : !llvm.ptr) {2384    %0 = llvm.load %arg0 : !llvm.ptr -> f322385    omp.terminator2386  }2387  return2388}2389 2390// -----2391 2392func.func @omp_target_host_eval_teams(%x : i1) {2393  // expected-error @below {{op host_eval argument only legal as 'num_teams' and 'thread_limit' in 'omp.teams'}}2394  omp.target host_eval(%x -> %arg0 : i1) {2395    omp.teams if(%arg0) {2396      omp.terminator2397    }2398    omp.terminator2399  }2400  return2401}2402 2403// -----2404 2405func.func @omp_target_host_eval_parallel(%x : i32) {2406  // expected-error @below {{op host_eval argument only legal as 'num_threads' in 'omp.parallel' when representing target SPMD}}2407  omp.target host_eval(%x -> %arg0 : i32) {2408    omp.parallel num_threads(%arg0 : i32) {2409      omp.terminator2410    }2411    omp.terminator2412  }2413  return2414}2415 2416// -----2417 2418func.func @omp_target_host_eval_loop1(%x : i32) {2419  // expected-error @below {{op host_eval argument only legal as loop bounds and steps in 'omp.loop_nest' when trip count must be evaluated in the host}}2420  omp.target host_eval(%x -> %arg0 : i32) {2421    omp.wsloop {2422      omp.loop_nest (%iv) : i32 = (%arg0) to (%arg0) step (%arg0) {2423        omp.yield2424      }2425    }2426    omp.terminator2427  }2428  return2429}2430 2431// -----2432 2433func.func @omp_target_host_eval_loop2(%x : i32) {2434  // expected-error @below {{op host_eval argument only legal as loop bounds and steps in 'omp.loop_nest' when trip count must be evaluated in the host}}2435  omp.target host_eval(%x -> %arg0 : i32) {2436    omp.teams {2437    ^bb0:2438      %0 = arith.constant 0 : i12439      llvm.cond_br %0, ^bb1, ^bb22440    ^bb1:2441      omp.distribute {2442        omp.loop_nest (%iv) : i32 = (%arg0) to (%arg0) step (%arg0) {2443          omp.yield2444        }2445      }2446      llvm.br ^bb22447    ^bb2:2448      omp.terminator2449    }2450    omp.terminator2451  }2452  return2453}2454 2455// -----2456 2457func.func @omp_target_depend(%data_var: memref<i32>) {2458  // expected-error @below {{op expected as many depend values as depend variables}}2459    "omp.target"(%data_var) ({2460      "omp.terminator"() : () -> ()2461    }) {depend_kinds = [], operandSegmentSizes = array<i32: 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>} : (memref<i32>) -> ()2462   "func.return"() : () -> ()2463}2464 2465// -----2466 2467func.func @omp_distribute_schedule(%chunk_size : i32, %lb : i32, %ub : i32, %step : i32) -> () {2468  // expected-error @below {{op chunk size set without dist_schedule_static being present}}2469  "omp.distribute"(%chunk_size) <{operandSegmentSizes = array<i32: 0, 0, 1, 0>}> ({2470    omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {2471      "omp.yield"() : () -> ()2472    }2473  }) : (i32) -> ()2474}2475 2476// -----2477 2478func.func @omp_distribute_allocate(%data_var : memref<i32>, %lb : i32, %ub : i32, %step : i32) -> () {2479  // expected-error @below {{expected equal sizes for allocate and allocator variables}}2480  "omp.distribute"(%data_var) <{operandSegmentSizes = array<i32: 1, 0, 0, 0>}> ({2481    omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {2482      "omp.yield"() : () -> ()2483    }2484  }) : (memref<i32>) -> ()2485}2486 2487// -----2488 2489func.func @omp_distribute_nested_wrapper(%lb: index, %ub: index, %step: index) -> () {2490  // expected-error @below {{an 'omp.wsloop' nested wrapper is only allowed when a composite 'omp.parallel' is the direct parent}}2491  omp.distribute {2492    "omp.wsloop"() ({2493      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2494        "omp.yield"() : () -> ()2495      }2496    }) {omp.composite} : () -> ()2497  } {omp.composite}2498}2499 2500// -----2501 2502func.func @omp_distribute_nested_wrapper2(%lb: index, %ub: index, %step: index) -> () {2503  // expected-error @below {{only supported nested wrappers are 'omp.simd' and 'omp.wsloop'}}2504  omp.distribute {2505    "omp.taskloop"() ({2506      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2507        "omp.yield"() : () -> ()2508      }2509    }) : () -> ()2510  } {omp.composite}2511}2512 2513// -----2514 2515func.func @omp_distribute_nested_wrapper3(%lb: index, %ub: index, %step: index) -> () {2516  // expected-error @below {{'omp.composite' attribute missing from composite wrapper}}2517  omp.distribute {2518    "omp.simd"() ({2519      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2520        "omp.yield"() : () -> ()2521      }2522    }) {omp.composite} : () -> ()2523  }2524}2525 2526// -----2527 2528func.func @omp_distribute_nested_wrapper4(%lb: index, %ub: index, %step: index) -> () {2529  omp.parallel {2530    // expected-error @below {{an 'omp.wsloop' nested wrapper is only allowed when a composite 'omp.parallel' is the direct parent}}2531    omp.distribute {2532      "omp.wsloop"() ({2533        omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2534          "omp.yield"() : () -> ()2535        }2536      }) {omp.composite} : () -> ()2537    } {omp.composite}2538    omp.terminator2539  }2540}2541 2542// -----2543 2544func.func @omp_distribute_order() -> () {2545// expected-error @below {{invalid clause value: 'default'}}2546  omp.distribute order(default) {2547    omp.loop_nest (%iv) : i32 = (%arg0) to (%arg0) step (%arg0) {2548      omp.yield2549    }2550  }2551  return2552}2553// -----2554func.func @omp_distribute_reproducible_order() -> () {2555// expected-error @below {{invalid clause value: 'default'}}2556  omp.distribute order(reproducible:default) {2557    omp.loop_nest (%iv) : i32 = (%arg0) to (%arg0) step (%arg0) {2558      omp.yield2559    }2560  }2561  return2562}2563// -----2564func.func @omp_distribute_unconstrained_order() -> () {2565// expected-error @below {{invalid clause value: 'default'}}2566  omp.distribute order(unconstrained:default) {2567    omp.loop_nest (%iv) : i32 = (%arg0) to (%arg0) step (%arg0) {2568      omp.yield2569    }2570  }2571  return2572}2573// -----2574omp.private {type = private} @x.privatizer : i32 init {2575^bb0(%arg0: i32, %arg1: i32):2576  %0 = arith.constant 0.0 : f322577  // expected-error @below {{Invalid yielded value. Expected type: 'i32', got: 'f32'}}2578  omp.yield(%0 : f32)2579}2580 2581// -----2582 2583// expected-error @below {{Region argument type mismatch: got 'f32' expected 'i32'.}}2584omp.private {type = private} @x.privatizer : i32 init {2585^bb0(%arg0: i32, %arg1: f32):2586  omp.yield2587}2588 2589// -----2590 2591omp.private {type = private} @x.privatizer : f32 init {2592^bb0(%arg0: f32, %arg1: f32):2593  omp.yield(%arg0: f32)2594} dealloc {2595^bb0(%arg0: f32):2596  // expected-error @below {{Did not expect any values to be yielded.}}2597  omp.yield(%arg0 : f32)2598}2599 2600// -----2601 2602omp.private {type = private} @x.privatizer : i32 init {2603^bb0(%arg0: i32, %arg1: i32):2604  // expected-error @below {{expected exit block terminator to be an `omp.yield` op.}}2605  omp.terminator2606}2607 2608// -----2609 2610// expected-error @below {{`init`: expected 2 region arguments, got: 1}}2611omp.private {type = private} @x.privatizer : f32 init {2612^bb0(%arg0: f32):2613  omp.yield(%arg0 : f32)2614}2615 2616// -----2617 2618// expected-error @below {{`copy`: expected 2 region arguments, got: 1}}2619omp.private {type = firstprivate} @x.privatizer : f32 copy {2620^bb0(%arg0: f32):2621  omp.yield(%arg0 : f32)2622}2623 2624// -----2625 2626// expected-error @below {{`dealloc`: expected 1 region arguments, got: 2}}2627omp.private {type = private} @x.privatizer : f32 dealloc {2628^bb0(%arg0: f32, %arg1: f32):2629  omp.yield2630}2631 2632// -----2633 2634// expected-error @below {{`private` clauses do not require a `copy` region.}}2635omp.private {type = private} @x.privatizer : f32 copy {2636^bb0(%arg0: f32, %arg1 : f32):2637  omp.yield(%arg0 : f32)2638}2639 2640// -----2641 2642// expected-error @below {{`firstprivate` clauses require at least a `copy` region.}}2643omp.private {type = firstprivate} @x.privatizer : f32 init {2644^bb0(%arg0: f32, %arg1: f32):2645  omp.yield(%arg0 : f32)2646}2647 2648// -----2649 2650func.func @private_type_mismatch(%arg0: index) {2651// expected-error @below {{type mismatch between a private variable and its privatizer op, var type: 'index' vs. privatizer op type: '!llvm.ptr'}}2652  omp.parallel private(@var1.privatizer %arg0 -> %arg2 : index) {2653    omp.terminator2654  }2655 2656  return2657}2658 2659omp.private {type = private} @var1.privatizer : index init {2660^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):2661  omp.yield(%arg0 : !llvm.ptr)2662}2663 2664// -----2665 2666func.func @firstprivate_type_mismatch(%arg0: index) {2667  // expected-error @below {{type mismatch between a firstprivate variable and its privatizer op, var type: 'index' vs. privatizer op type: '!llvm.ptr'}}2668  omp.parallel private(@var1.privatizer %arg0 -> %arg2 : index) {2669    omp.terminator2670  }2671 2672  return2673}2674 2675omp.private {type = firstprivate} @var1.privatizer : index copy {2676^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):2677  omp.yield(%arg0 : !llvm.ptr)2678}2679 2680// -----2681 2682func.func @undefined_privatizer(%arg0: index) {2683  // expected-error @below {{failed to lookup privatizer op with symbol: '@var1.privatizer'}}2684  omp.parallel private(@var1.privatizer %arg0 -> %arg2 : index) {2685    omp.terminator2686  }2687 2688  return2689}2690 2691// -----2692func.func @undefined_privatizer(%arg0: !llvm.ptr) {2693  // expected-error @below {{inconsistent number of private variables and privatizer op symbols, private vars: 1 vs. privatizer op symbols: 2}}2694  "omp.parallel"(%arg0) <{operandSegmentSizes = array<i32: 0, 0, 0, 0, 1, 0>, private_syms = [@x.privatizer, @y.privatizer]}> ({2695    ^bb0(%arg2: !llvm.ptr):2696      omp.terminator2697    }) : (!llvm.ptr) -> ()2698  return2699}2700 2701// -----2702 2703omp.private {type = private} @var1.privatizer : !llvm.ptr copy {2704^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):2705  omp.yield(%arg0 : !llvm.ptr)2706}2707 2708func.func @byref_in_private(%arg0: index) {2709  // expected-error @below {{expected attribute value}}2710  // expected-error @below {{custom op 'omp.parallel' invalid `private` format}}2711  omp.parallel private(byref @var1.privatizer %arg0 -> %arg2 : index) {2712    omp.terminator2713  }2714 2715  return2716}2717 2718// -----2719func.func @masked_arg_type_mismatch(%arg0: f32) {2720  // expected-error @below {{'omp.masked' op operand #0 must be integer or index, but got 'f32'}}2721  "omp.masked"(%arg0) ({2722      omp.terminator2723    }) : (f32) -> ()2724  return2725}2726 2727// -----2728func.func @masked_arg_count_mismatch(%arg0: i32, %arg1: i32) {2729  // expected-error @below {{'omp.masked' op operand group starting at #0 requires 0 or 1 element, but found 2}}2730  "omp.masked"(%arg0, %arg1) ({2731      omp.terminator2732    }) : (i32, i32) -> ()2733  return2734}2735 2736// -----2737func.func @omp_parallel_missing_composite(%lb: index, %ub: index, %step: index) -> () {2738  // expected-error @below {{'omp.composite' attribute missing from composite operation}}2739  omp.parallel {2740    omp.distribute {2741      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2742        omp.yield2743      }2744    }2745    omp.terminator2746  }2747  return2748}2749 2750// -----2751func.func @omp_parallel_invalid_composite(%lb: index, %ub: index, %step: index) -> () {2752  // expected-error @below {{'omp.composite' attribute present in non-composite operation}}2753  omp.parallel {2754    omp.wsloop {2755      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2756        omp.yield2757      }2758    }2759    omp.terminator2760  } {omp.composite}2761  return2762}2763 2764// -----2765func.func @omp_parallel_invalid_composite2(%lb: index, %ub: index, %step: index) -> () {2766  // expected-error @below {{unexpected OpenMP operation inside of composite 'omp.parallel': omp.barrier}}2767  omp.parallel {2768    omp.barrier2769    omp.distribute {2770      omp.wsloop {2771        omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2772          omp.yield2773        }2774      } {omp.composite}2775    } {omp.composite}2776    omp.terminator2777  } {omp.composite}2778  return2779}2780 2781// -----2782func.func @omp_parallel_invalid_composite3(%lb: index, %ub: index, %step: index) -> () {2783  // expected-error @below {{multiple 'omp.distribute' nested inside of 'omp.parallel'}}2784  omp.parallel {2785    omp.distribute {2786      omp.wsloop {2787        omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2788          omp.yield2789        }2790      } {omp.composite}2791    } {omp.composite}2792    omp.distribute {2793      omp.wsloop {2794        omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2795          omp.yield2796        }2797      } {omp.composite}2798    } {omp.composite}2799    omp.terminator2800  } {omp.composite}2801  return2802}2803 2804// -----2805func.func @omp_wsloop_missing_composite(%lb: index, %ub: index, %step: index) -> () {2806  // expected-error @below {{'omp.composite' attribute missing from composite wrapper}}2807  omp.wsloop {2808    omp.simd {2809      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2810        omp.yield2811      }2812    } {omp.composite}2813  }2814  return2815}2816 2817// -----2818func.func @omp_wsloop_invalid_composite(%lb: index, %ub: index, %step: index) -> () {2819  // expected-error @below {{'omp.composite' attribute present in non-composite wrapper}}2820  omp.wsloop {2821    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2822      omp.yield2823    }2824  } {omp.composite}2825  return2826}2827 2828// -----2829func.func @omp_wsloop_missing_composite_2(%lb: index, %ub: index, %step: index) -> () {2830  omp.parallel {2831    omp.distribute {2832      // expected-error @below {{'omp.composite' attribute missing from composite wrapper}}2833      omp.wsloop {2834        omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2835          omp.yield2836        }2837      }2838    } {omp.composite}2839    omp.terminator2840  } {omp.composite}2841  return2842}2843 2844// -----2845func.func @omp_simd_missing_composite(%lb: index, %ub: index, %step: index) -> () {2846  omp.wsloop {2847    // expected-error @below {{'omp.composite' attribute missing from composite wrapper}}2848    omp.simd {2849      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2850        omp.yield2851      }2852    }2853  } {omp.composite}2854  return2855}2856 2857// -----2858func.func @omp_simd_invalid_composite(%lb: index, %ub: index, %step: index) -> () {2859  // expected-error @below {{'omp.composite' attribute present in non-composite wrapper}}2860  omp.simd {2861    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2862      omp.yield2863    }2864  } {omp.composite}2865  return2866}2867 2868// -----2869func.func @omp_distribute_missing_composite(%lb: index, %ub: index, %step: index) -> () {2870  omp.parallel {2871    // expected-error @below {{'omp.composite' attribute missing from composite wrapper}}2872    omp.distribute {2873      omp.wsloop {2874        omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2875          omp.yield2876        }2877      } {omp.composite}2878    }2879    omp.terminator2880  } {omp.composite}2881  return2882}2883 2884// -----2885func.func @omp_distribute_invalid_composite(%lb: index, %ub: index, %step: index) -> () {2886  // expected-error @below {{'omp.composite' attribute present in non-composite wrapper}}2887  omp.distribute {2888    omp.loop_nest (%0) : index = (%lb) to (%ub) step (%step) {2889      omp.yield2890    }2891  } {omp.composite}2892  return2893}2894 2895// -----2896func.func @omp_taskloop_missing_composite(%lb: index, %ub: index, %step: index) -> () {2897  // expected-error @below {{'omp.composite' attribute missing from composite wrapper}}2898  omp.taskloop {2899    omp.simd {2900      omp.loop_nest (%i) : index = (%lb) to (%ub) step (%step)  {2901        omp.yield2902      }2903    } {omp.composite}2904  }2905  return2906}2907 2908// -----2909func.func @omp_taskloop_invalid_composite(%lb: index, %ub: index, %step: index) -> () {2910  // expected-error @below {{'omp.composite' attribute present in non-composite wrapper}}2911  omp.taskloop {2912    omp.loop_nest (%i) : index = (%lb) to (%ub) step (%step)  {2913      omp.yield2914    }2915  } {omp.composite}2916  return2917}2918 2919// -----2920 2921func.func @omp_loop_invalid_nesting(%lb : index, %ub : index, %step : index) {2922 2923  // expected-error @below {{'omp.loop' op expected to be a standalone loop wrapper}}2924  omp.loop {2925    omp.simd {2926      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2927        omp.yield2928      }2929    } {omp.composite}2930  }2931 2932  return2933}2934 2935// -----2936 2937func.func @omp_loop_invalid_nesting2(%lb : index, %ub : index, %step : index) {2938 2939  omp.simd {2940    // expected-error @below {{'omp.loop' op expected to be a standalone loop wrapper}}2941    omp.loop {2942      omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2943        omp.yield2944      }2945    } {omp.composite}2946  }2947 2948  return2949}2950 2951// -----2952 2953func.func @omp_loop_invalid_binding(%lb : index, %ub : index, %step : index) {2954 2955  // expected-error @below {{custom op 'omp.loop' invalid clause value: 'dummy_value'}}2956  omp.loop bind(dummy_value) {2957    omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {2958      omp.yield2959    }2960  }2961  return2962}2963 2964// -----2965func.func @nested_wrapper(%idx : index) {2966  omp.workshare {2967    // expected-error @below {{'omp.workshare.loop_wrapper' op expected to be a standalone loop wrapper}}2968    omp.workshare.loop_wrapper {2969      omp.simd {2970        omp.loop_nest (%iv) : index = (%idx) to (%idx) step (%idx) {2971          omp.yield2972        }2973      } {omp.composite}2974    }2975    omp.terminator2976  }2977  return2978}2979 2980// -----2981func.func @not_wrapper() {2982  omp.workshare {2983    // expected-error @below {{op nested in loop wrapper is not another loop wrapper or `omp.loop_nest`}}2984    omp.workshare.loop_wrapper {2985      %0 = arith.constant 0 : index2986    }2987    omp.terminator2988  }2989  return2990}2991 2992// -----2993func.func @missing_workshare(%idx : index) {2994  // expected-error @below {{must be nested in an omp.workshare}}2995  omp.workshare.loop_wrapper {2996    omp.loop_nest (%iv) : index = (%idx) to (%idx) step (%idx) {2997      omp.yield2998    }2999  }3000  return3001}3002 3003// -----3004  // expected-error @below {{op expected terminator to be a DeclareMapperInfoOp}}3005  omp.declare_mapper @missing_declareMapperInfo : !llvm.struct<"mytype", (array<1024 x i32>)> {3006  ^bb0(%arg0: !llvm.ptr):3007    omp.terminator3008  }3009 3010// -----3011llvm.func @invalid_mapper(%0 : !llvm.ptr) {3012  // expected-error @below {{invalid mapper id}}3013  %1 = omp.map.info var_ptr(%0 : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(to) capture(ByRef) mapper(@my_mapper) -> !llvm.ptr {name = ""}3014  omp.target_data map_entries(%1 : !llvm.ptr) {3015    omp.terminator3016  }3017  llvm.return3018}3019 3020// -----3021func.func @invalid_allocate_align_1(%arg0 : memref<i32>) -> () {3022  // expected-error @below {{failed to satisfy constraint: 64-bit signless integer attribute whose value is positive}}3023  omp.allocate_dir (%arg0 : memref<i32>) align(-1)3024 3025  return3026}3027 3028// -----3029func.func @invalid_allocate_align_2(%arg0 : memref<i32>) -> () {3030  // expected-error @below {{must be power of 2}}3031  omp.allocate_dir (%arg0 : memref<i32>) align(3)3032 3033  return3034}3035 3036// -----3037func.func @invalid_workdistribute_empty_region() -> () {3038  omp.teams {3039    // expected-error @below {{region cannot be empty}}3040    omp.workdistribute {3041    }3042    omp.terminator3043  }3044  return3045}3046 3047// -----3048func.func @invalid_workdistribute_no_terminator() -> () {3049  omp.teams {3050    // expected-error @below {{region must be terminated with omp.terminator}}3051    omp.workdistribute {3052      %c0 = arith.constant 0 : i323053    }3054    omp.terminator3055  }3056  return3057}3058 3059// -----3060func.func @invalid_workdistribute_wrong_terminator() -> () {3061  omp.teams {3062    // expected-error @below {{region must be terminated with omp.terminator}}3063    omp.workdistribute {3064      %c0 = arith.constant 0 : i323065      func.return3066    }3067    omp.terminator3068  }3069  return3070}3071 3072// -----3073func.func @invalid_workdistribute_multiple_terminators() -> () {3074  omp.teams {3075    // expected-error @below {{region must have exactly one terminator}}3076    omp.workdistribute {3077      %cond = arith.constant true3078      cf.cond_br %cond, ^bb1, ^bb23079    ^bb1:3080      omp.terminator3081    ^bb2:3082      omp.terminator3083    }3084    omp.terminator3085  }3086  return3087}3088 3089// -----3090func.func @invalid_workdistribute_with_barrier() -> () {3091  omp.teams {3092    // expected-error @below {{explicit barriers are not allowed in workdistribute region}}3093    omp.workdistribute {3094      %c0 = arith.constant 0 : i323095      omp.barrier3096      omp.terminator3097    }3098    omp.terminator3099  }3100  return3101}3102 3103// -----3104func.func @invalid_workdistribute_nested_parallel() -> () {3105  omp.teams {3106    // expected-error @below {{nested parallel constructs not allowed in workdistribute}}3107    omp.workdistribute {3108      omp.parallel {3109        omp.terminator3110      }3111      omp.terminator3112    }3113    omp.terminator3114  }3115  return3116}3117 3118// -----3119// Test: nested teams not allowed in workdistribute3120func.func @invalid_workdistribute_nested_teams() -> () {3121  omp.teams {3122    // expected-error @below {{nested teams constructs not allowed in workdistribute}}3123    omp.workdistribute {3124      omp.teams {3125        omp.terminator3126      }3127      omp.terminator3128    }3129    omp.terminator3130  }3131  return3132}3133 3134// -----3135func.func @invalid_workdistribute() -> () {3136// expected-error @below {{workdistribute must be nested under teams}}3137  omp.workdistribute {3138    omp.terminator3139  }3140  return3141}3142