<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/107027>107027</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] [ACC] acc.parallel doesn't exit gracefully on invalid attribute names
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ZitongZhouEric
      </td>
    </tr>
</table>

<pre>
    To reproduce: https://godbolt.org/z/65MdaGEbE
When ```acc.parallel``` uses an unsupported attribute name, e.g. ```asyncDeviceType```, ```mlir::acc::ParallelOp::verify()``` crashes instead of exiting gracefully

```
"builtin.module"()({
  "func.func"() <{
 function_type = (memref<10x10xf32>) -> memref<10x10xf32>,
    sym_name = "compute1"
  }> ({
    ^bb0(%arg0: memref<10x10xf32>):
      %1 = "arith.constant"() <{value = 1 : i64}> : () -> i64
 "acc.parallel"(%1) <{
        asyncDeviceType = [#acc.device_type<none>],
        operandSegmentSizes = array<i32:1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>
      }> ({
      }) : (i64) -> ()
 "func.return"( %arg0) : (memref<10x10xf32>) -> ()
  }) : () -> ()
}) : () -> ()
```
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/mlir-trunk/bin/mlir-opt -o /app/example.out.mlir <source>
 #0 0x0000000001525e08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x1525e08)
 #1 0x000000000152377c SignalHandler(int) Signals.cpp:0:0
 #2 0x0000709851442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000003eb5803 mlir::ArrayAttr::getValue() const (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x3eb5803)
 #4 0x00000000027f2d33 llvm::LogicalResult verifyDeviceTypeCountMatch<mlir::acc::ParallelOp>(mlir::acc::ParallelOp, mlir::OperandRange, mlir::ArrayAttr, llvm::StringRef) (.isra.0) OpenACC.cpp:0:0
 #5 0x00000000028cd2ec mlir::acc::ParallelOp::verify() (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x28cd2ec)
 #6 0x00000000028cd517 mlir::Op<mlir::acc::ParallelOp, mlir::OpTrait::OneRegion, mlir::OpTrait::ZeroResults, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::VariadicOperands, mlir::OpTrait::AttrSizedOperandSegments, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpTrait::AutomaticAllocationScope, mlir::OpTrait::HasRecursiveMemoryEffects, mlir::acc::ComputeRegionOpInterface::Trait, mlir::MemoryEffectOpInterface::Trait>::verifyInvariants(mlir::Operation*) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x28cd517)
 #7 0x00000000027ed64e mlir::RegisteredOperationName::Model<mlir::acc::ParallelOp>::verifyInvariants(mlir::Operation*) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x27ed64e)
 #8 0x0000000003f82812 (anonymous namespace)::OperationVerifier::verifyOnEntrance(mlir::Operation&) (.isra.0) Verifier.cpp:0:0
 #9 0x0000000003f831c5 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#10 0x0000000003f83a36 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#11 0x0000000003f83a36 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#12 0x0000000003f84c66 mlir::verify(mlir::Operation*, bool) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x3f84c66)
#13 0x0000000006b13dd2 mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x6b13dd2)
#14 0x0000000003d68314 mlir::parseSourceFile(std::shared_ptr<llvm::SourceMgr> const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x3d68314)
#15 0x0000000003d665ff performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#16 0x0000000003d67963 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#17 0x0000000003d67a43 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#18 0x0000000003e68d3e mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x3e68d3e)
#19 0x0000000003d63bc5 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x3d63bc5)
#20 0x0000000003d67b70 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x3d67b70)
#21 0x0000000003d67fff mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x3d67fff)
#22 0x000000000143f5b7 main (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x143f5b7)
#23 0x0000709851429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#24 0x0000709851429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#25 0x000000000150005e _start (/opt/compiler-explorer/mlir-trunk/bin/mlir-opt+0x150005e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWVFzozgS_jXKiyoukIyNH_LgEHt3qyaXVDw1V7UvKSEarBshcZLIxvvrrwTYBhI7mZ3cztyldjMBtbq__rrVaiRmrSgUwBWKrlF0c8Fqt9Xm6nfhtCp-3-p6ZQS_SHW2u_qssYHK6KzmgOgSb52rLKJLRNaIrAudpVq6iTYFIus_EVnPotuM_bJKVyi4QcHyn1tQGM2C9j_G-aRihkkJ8vAS1xYsZgrXytZVpY2DDDPnjEhrB1ixEhBJMEyKSU-T3Sl-A0-Cw-ddBYf3XvLwUEphPFS6ZJy3f9x31u-q9vkJjMh3iMSILI6IuGF2CxYLZR2wDOscw7NwQhW4MIxDXku5ax3sfh_st4-EpLWQTqhJqbNaAiKks0FiNL9upTBGhOS14hP_6yCCEU2OMn7ICa0e3a4CjOgNRiQuoTSQI5qEwXMYPOeUILryUy8RXeETo8neKsZ2Vz56Xjt9hOuyqh2EHsMe2vzG6xrixRhF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