<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74466>74466</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] --convert-tensor-to-spirv crashed in TensorExtractPattern with assertion failure "only integers and floats have a bitwidth".
</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: 383e35048e16c85ab26bc46822d3ceb11fd4d3f2
system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```
reproduced with: ```mlir-opt --convert-tensor-to-spirv a.mlir```
a.mlir:
```
func.func private @func2() {
%3 = index.constant 3
%0 = arith.constant 1 : index
%from_elements = tensor.from_elements %0, %0 : tensor<2xindex>
%extracted = tensor.extract %from_elements[%3] : tensor<2xindex> // index out of bound
return
}
```
trace:
```
mlir-opt: /data/bin1/llvm-project/mlir/lib/IR/Types.cpp:124: unsigned int mlir::Type::getIntOrFloatBitWidth() const: Assertion `isIntOrFloat() && "only integers and floats have a bitwidth"' 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/bin1/llvm-project/build/bin/mlir-opt --convert-tensor-to-spirv a.mlir
#0 0x000055ef627063ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin1/llvm-project/build/bin/mlir-opt+0x16573ff)
#1 0x000055ef62703454 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f8f4bf13420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f8f4b9fe00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f8f4b9dd859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f8f4b9dd729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f8f4b9eefd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x000055ef655d95e8 mlir::Type::getIntOrFloatBitWidth() const (/data/bin1/llvm-project/build/bin/mlir-opt+0x452a5e8)
#8 0x000055ef64caf3db (anonymous namespace)::TensorExtractPattern::matchAndRewrite(mlir::tensor::ExtractOp, mlir::tensor::ExtractOpAdaptor, mlir::ConversionPatternRewriter&) const TensorToSPIRV.cpp:0:0
#9 0x000055ef64caed9e mlir::OpConversionPattern<mlir::tensor::ExtractOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const (/data/bin1/llvm-project/build/bin/mlir-opt+0x3bffd9e)
#10 0x000055ef6543e33a mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/bin1/llvm-project/build/bin/mlir-opt+0x438f33a)
#11 0x000055ef680fde98 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/bin1/llvm-project/build/bin/mlir-opt+0x704ee98)
#12 0x000055ef6544e979 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#13 0x000055ef6544f307 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#14 0x000055ef65451774 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (/data/bin1/llvm-project/build/bin/mlir-opt+0x43a2774)
#15 0x000055ef64cad2c3 (anonymous namespace)::ConvertTensorToSPIRVPass::runOnOperation() TensorToSPIRVPass.cpp:0:0
#16 0x000055ef653a6f3e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f7f3e)
#17 0x000055ef653a741a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f841a)
#18 0x000055ef653a7c44 mlir::PassManager::run(mlir::Operation*) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f8c44)
#19 0x000055ef653989b3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x000055ef65399e84 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
#21 0x000055ef6539a034 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
#22 0x000055ef65499324 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/bin1/llvm-project/build/bin/mlir-opt+0x43ea324)
#23 0x000055ef65392897 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42e3897)
#24 0x000055ef6539a181 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42eb181)
#25 0x000055ef6539a5e6 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42eb5e6)
#26 0x000055ef6263da7b main (/data/bin1/llvm-project/build/bin/mlir-opt+0x158ea7b)
#27 0x00007f8f4b9df083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#28 0x000055ef626d675e _start (/data/bin1/llvm-project/build/bin/mlir-opt+0x162775e)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWVtT4zgW_jXmRUVKlnx94CENpJaqpkgBO_uYkq1jR9uO5JVkmsyv35LtJLbDJTTM7OxMTYckPvp0vnNXxIwRpQS48MJvXnh1xhq7VvqCSSW3G9WY28uHs0zx7UUpLHoCbYSSHp0jmlCgIQ4S8KM8CVlGoiwPooQQTnPIfL_gAacF8fCVh-fdq9kaCxu32otw9_8_s0baBhE8w8EsQt8fH5BHkoXKWYUWyhjmkXQvPMTSUGvFmxw4-insegS6qYQ-V7VF5-e5kk-g7bkFaZQ-t-rc1EI_ITZzQi8i949o_3EiUzQyn7kXVGvxxCwgL8DuM_FI4pEUefG3ThIhj4QUefQKCcnheZYraSyTFtGBAG4FmBZ2fRDwkePTrhqIFlptVlDBBqQ17bKO1WzygITYI5c78Hkv5dFL8txB0use1SMhPF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