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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] --convert-scf-to-spirv crashed with assertion failure "ArrayType needs at least one element"
        </td>
    </tr>

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

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

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

<pre>
    git version: ba89749cd24950c9c51f4cc64277ce0421d86d20

system: Ubuntu 20.04.6 LTS (Focal Fossa)

reproduced with: ```mlir-opt --convert-scf-to-spirv a.mlir```

a.mlir:
```
func.func @func2() {
  %alloc_22 = memref.alloc() : memref<0xi1, #spirv.storage_class<StorageBuffer>>
  memref.dealloc %alloc_22 : memref<0xi1, #spirv.storage_class<StorageBuffer>>
 llvm.return
}
```

trace:
```
mlir-opt: /data/bin/llvm-project/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp:60: static mlir::spirv::ArrayType mlir::spirv::ArrayType::get(mlir::Type, unsigned int, unsigned int): Assertion `elementCount && "ArrayType needs at least one element"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/bin/llvm-project/build/bin/mlir-opt --convert-scf-to-spirv a.mlir
 #0 0x000055709b4bc01f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x160201f)
 #1 0x000055709b4b9074 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fc3713ec420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fc370ed700b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fc370eb6859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007fc370eb6729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007fc370ec7fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x000055709d0f3cb4 mlir::spirv::ArrayType::get(mlir::Type, unsigned int, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x3239cb4)
 #8 0x000055709fb6b0a4 std::_Function_handler<std::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&), std::enable_if<is_invocable_v<mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::'lambda6'(mlir::MemRefType), mlir::MemRefType, llvm::SmallVectorImpl<mlir::Type>&>, std::function<std::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::MemRefType, std::enable_if<is_invocable_v<mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::'lambda6'(mlir::MemRefType), mlir::MemRefType>, std::function<std::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::MemRefType, mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::'lambda6'(mlir::MemRefType)>(mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::'lambda6'(mlir::MemRefType)&&) const::'lambda'(mlir::MemRefType, llvm::SmallVectorImpl<mlir::Type>&)>(mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::'lambda6'(mlir::MemRefType)&&) const::'lambda'(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&)>::_M_invoke(std::_Any_data const&, mlir::Type&&, llvm::SmallVectorImpl<mlir::Type>&) SPIRVConversion.cpp:0:0
 #9 0x000055709e1423e9 mlir::TypeConverter::convertType(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x42883e9)
#10 0x000055709e1448d7 mlir::detail::ConversionPatternRewriterImpl::remapValues(llvm::StringRef, std::optional<mlir::Location>, mlir::PatternRewriter&, mlir::ValueRange, llvm::SmallVectorImpl<mlir::Value>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x428a8d7)
#11 0x000055709e144cca mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x428acca)
#12 0x00005570a0dce888 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6f14888)
#13 0x000055709e155329 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#14 0x000055709e155cb7 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#15 0x000055709e158124 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (/data/bin/llvm-project/build/bin/mlir-opt+0x429e124)
#16 0x000055709d93b846 (anonymous namespace)::SCFToSPIRVPass::runOnOperation() SCFToSPIRVPass.cpp:0:0
#17 0x000055709e0ad8ee mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x41f38ee)
#18 0x000055709e0addca mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41f3dca)
#19 0x000055709e0ae5f4 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41f45f4)
#20 0x000055709e09f363 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#21 0x000055709e0a0834 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#22 0x000055709e0a09e4 mlir::LogicalResult llvm::function_ref<mlir::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
#23 0x000055709e19fcd4 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data/bin/llvm-project/build/bin/mlir-opt+0x42e5cd4)
#24 0x000055709e099247 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41df247)
#25 0x000055709e0a0b31 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41e6b31)
#26 0x000055709e0a0f96 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41e6f96)
#27 0x000055709b3f35eb main (/data/bin/llvm-project/build/bin/mlir-opt+0x15395eb)
#28 0x00007fc370eb8083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x000055709b48c37e _start (/data/bin/llvm-project/build/bin/mlir-opt+0x15d237e)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWltT4zoS_jXmRUVKlhxfHnjIBFI7VUMNBex5TclyO2iPInklmRnOr9-ybBLLECZDOLc9U0wS69Lq_rrV3WqLWSs2CuAimn-K5pdnrHUP2lwwpdXTVrf2enl3Vurq6WIjHHoEY4VWEV2gkuVFlhS8Ikkxx7zg87hOOE8TkmUccELiKk8rgiN8GeFF_2mfrINtN_vfZatciwie4WSWoi_3dygi-UpzJtFKW8siUoxnGmiMrloOFfom3ENHIkpx_7eVwpzrxqHzc67VIxh3bnl97vS5bYR5RGzWjdgNH5MduujwOBlTt4rPug8UJbj7JhHJI1KgKPvUj0AoInMmpeZrQlBEL9EWtgbqmW97Hk0XQ3NEl_i7iCOyRBGhnruZddqwDay5ZNZGdHnXP39q6xpMRK-6v2GtgXYFnvpk6Y9ZQ8rH7cyAa40aIMkuX8Wm_3SGcTgE37NevLLIqmKORWRVChWRVbfOeWP0f4C7iKy8FshKijIiq0vBZN98d_P59peIrD7fPj_cPzVgZ7xpIrpIcUfZOuYER896pAsvcv9zYQx76qb8oLt_3ICLSL4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