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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Crash when using --pass-pipeline="builtin.module(func.func(tosa-to-linalg))"
        </td>
    </tr>

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

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

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

<pre>
    I have the following MLIR program:
test.mlir:
```
module{
 func.func @func1() {
        %c1 = arith.constant 1 : index
 %arg0 = tensor.empty(%c1) : tensor<?x100xi8>
        %arg1 = tensor.empty() : tensor<51xi1>
        %10 = tosa.table %arg0, %arg1 : (tensor<?x100xi8>, tensor<51xi1>)  -> tensor<110x1x1x?xi8>
 return
    }
}
```
The above MLIR program will cause a crash when using the following command:
```
mlir-opt --pass-pipeline="builtin.module(func.func(tosa-to-linalg))" test.mlir
```
And the crash backtrace is:
```
mlir-opt: /data/tmp/v0813/llvm-project/build/tools/mlir/include/mlir/IR/BuiltinTypeInterfaces.h.inc:171: bool mlir::ShapedType::isDynamicDim(unsigned int) const: Assertion `idx < getRank() && "invalid index for shaped type"' 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/tmp/v0813/llvm-project/build/bin/mlir-opt --pass-pipeline=builtin.module(func.func(tosa-to-linalg)) test.mlir
 #0 0x000055cc3e6a302f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x151902f)
 #1 0x000055cc3e6a00a4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f3f25773420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f3f2524000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f3f2521f859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f3f2521f729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f3f25230fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x000055cc41092d6a (anonymous namespace)::TableConverter::matchAndRewrite(mlir::tosa::TableOp, mlir::PatternRewriter&) const TosaToLinalg.cpp:0:0
 #8 0x000055cc4107c26f mlir::detail::OpOrInterfaceRewritePatternBase<mlir::tosa::TableOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x3ef226f)
 #9 0x000055cc4492e670 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x77a4670)
#10 0x000055cc4189129b (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#11 0x000055cc4189297e mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x470897e)
#12 0x000055cc418958fb mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x470b8fb)
#13 0x000055cc41895f4d mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x470bf4d)
#14 0x000055cc41068cf3 (anonymous namespace)::TosaToLinalg::runOnOperation() TosaToLinalgPass.cpp:0:0
#15 0x000055cc417eae41 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4660e41)
#16 0x000055cc417eb219 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4661219)
#17 0x000055cc417eb58c mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#18 0x000055cc417ea395 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4660395)
#19 0x000055cc417eabc6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4660bc6)
#20 0x000055cc417eb219 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4661219)
#21 0x000055cc417ec344 mlir::PassManager::run(mlir::Operation*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4662344)
#22 0x000055cc417dcfdb performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x000055cc417dd9a4 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
#24 0x000055cc417ddb54 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
#25 0x000055cc418e65ae 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) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x475c5ae)
#26 0x000055cc417d53f9 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x464b3f9)
#27 0x000055cc417ddcc1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4653cc1)
#28 0x000055cc417de186 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4654186)
#29 0x000055cc3e5bb5ab main (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x14315ab)
#30 0x00007f3f25221083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#31 0x000055cc3e6764ce _start (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x14ec4ce)
Aborted (core dumped)
```
My git version is ed7ad0a1a0584f90a211ca5a87bc46968e169e5d.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWltP47q3_zTmxaLyJdcHHjqF6iANAgHvleM4qfc4do7tQLs__VHS0CahHWB2z-z93_qPGGhje11-6-K17DDnZKmFuALhNxBeX7DGr429emW63Bpd_oHZRWby7dUtXLMXAf1awMIoZV6lLuHd99tHWFtTWlYBOgfoGqC5F87PKiXt_gmIUP_Tfa1M3igB4m-7r7BoNJ-1vyAIUPsXA5IAksLDlP4fICHHENBryKz06xk32nmmPWwfzqHUudj0KwAJmS1RN9kL7Yydiar224502LJIuzW7MUAXgC43GKGNTAC9eceW2RIfpzUhE-KNxMco4F4W49jMs0yJNxEBWQw4tJInJ4QiiyN8SArhJaA3hyGM0QZv8KZdPNTGCt9YfRAMxNe9ffYfxoZ6XgvIMvMiRoaGr1IpyFnjBGSQW-bW8HUtNGxc6xNjD-GmqpjOT7qCkvbS1B5eXtbMucta1kJJLQC9BoRkjVRe6lnvMCTZe0qLkXHs0ptLJTVTJSBp90Pgwf2OMZzrvJNwJ3bG-A9vGRdQuo9E3JlmmTPPAFn6qgZk-YISTAFZKvVSXdbW_CG4B2TZyp23k4xRDpBlJw1ZSs1Vk4vDg9tHQJbfdko-b2txq72wBePCzdYzqTmgcxzjlnFmjIJvMUXnT2tWi7xdsvsu3fVWs0rya1kBkjS6i-kcSu1b_-jCpCUzd05YL42GIEIy30BAF7AU_pHpH2_OTCJAIggIkfqFKZnvogoWxkLXsYW-5UsIIDEsmFQin-2Qevh-M3-6ga7JKukhg1lTQitqYz30Bq69rzuQyRKQZSn9uslm3FQ9fO9RlM41ooUPMt1K0YF3zHg9-yfP-A-YN1W9NyWa7cLvofdcZsumEtq7XzBmJnVvuRMO-2VvnboqBIQiiDYIIRSGnFMRMYpIATt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