<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/103062>103062</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] Crash when using --pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))"
</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() {
%0 = arith.constant 1 : i32
%1 = arith.constant 1 : i1
%2 = arith.constant 1 : i8
%c1 = arith.constant 1 : index
%73 = tensor.empty(%c1) : tensor<4x?xi1>
%901 = tosa.reshape %73 {new_shape = array<i64: -14, 4>} : (tensor<4x?xi1>) -> tensor<?x4xi1>
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-named))" test.mlir
```
And the crash backtrace is:
```
<unknown>:0: error: invalid tensor dimension size
mlir-opt: /data/tmp/v0813/llvm-project/mlir/include/mlir/IR/StorageUniquerSupport.h:179: static ConcreteT mlir::detail::StorageUserBase<ConcreteT, BaseT, StorageT, UniquerT, Traits>::get(mlir::MLIRContext*, Args&& ...) [with Args = {llvm::ArrayRef<long int>&, mlir::Type&, mlir::Attribute&}; ConcreteT = mlir::RankedTensorType; BaseT = mlir::TensorType; StorageT = mlir::detail::RankedTensorTypeStorage; UniquerT = mlir::detail::TypeUniquer; Traits = {mlir::ShapedType::Trait, mlir::ValueSemantics}]: Assertion `succeeded( ConcreteT::verifyInvariants(getDefaultDiagnosticEmitFn(ctx), args...))' 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-named)) test.mlir
#0 0x000055edd607602f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x151902f)
#1 0x000055edd60730a4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f8d6b136420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f8d6ac0300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f8d6abe2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f8d6abe2729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f8d6abf3fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x000055edd936f246 mlir::RankedTensorType mlir::detail::StorageUserBase<mlir::RankedTensorType, mlir::TensorType, mlir::detail::RankedTensorTypeStorage, mlir::detail::TypeUniquer, mlir::ShapedType::Trait, mlir::ValueSemantics>::get<llvm::ArrayRef<long>&, mlir::Type&, mlir::Attribute&>(mlir::MLIRContext*, llvm::ArrayRef<long>&, mlir::Type&, mlir::Attribute&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4812246)
#8 0x000055edd936f50d mlir::RankedTensorType::get(llvm::ArrayRef<long>, mlir::Type, mlir::Attribute) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x481250d)
#9 0x000055eddc3c976d mlir::detail::inferReturnTensorTypes(llvm::ArrayRef<mlir::ShapedTypeComponents>, llvm::SmallVectorImpl<mlir::Type>&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x786c76d)
#10 0x000055edd823e069 mlir::tosa::ReshapeOp::inferReturnTypes(mlir::MLIRContext*, std::optional<mlir::Location>, mlir::ValueRange, mlir::DictionaryAttr, mlir::OpaqueProperties, mlir::RegionRange, llvm::SmallVectorImpl<mlir::Type>&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x36e1069)
#11 0x000055edd826c339 mlir::detail::InferTypeOpInterfaceInterfaceTraits::Model<mlir::tosa::ReshapeOp>::refineReturnTypes(mlir::MLIRContext*, std::optional<mlir::Location>, mlir::ValueRange, mlir::DictionaryAttr, mlir::OpaqueProperties, mlir::RegionRange, llvm::SmallVectorImpl<mlir::Type>&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x370f339)
#12 0x000055eddc3cb800 mlir::detail::verifyInferredResultTypes(mlir::Operation*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x786e800)
#13 0x000055edd825c4ad mlir::Op<mlir::tosa::ReshapeOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::RankedTensorType>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::OneOperand, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::InferTypeOpInterface::Trait, mlir::InferShapedTypeOpInterface::Trait, mlir::OpTrait::InferShapedTypeOpAdaptor, mlir::OpTrait::InferTensorType, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::tosa::TosaOp::Trait>::verifyRegionInvariants(mlir::Operation*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x36ff4ad)
#14 0x000055edd82714bb mlir::RegisteredOperationName::Model<mlir::tosa::ReshapeOp>::verifyRegionInvariants(mlir::Operation*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x37144bb)
#15 0x000055edd940817c (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#16 0x000055edd94087fd (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#17 0x000055edd94087fd (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#18 0x000055edd9409bea mlir::verify(mlir::Operation*, bool) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x48acbea)
#19 0x000055eddc374274 mlir::parseAsmSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::AsmParserState*, mlir::AsmParserCodeCompleteContext*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x7817274)
#20 0x000055edd91b1588 mlir::parseSourceFile(std::shared_ptr<llvm::SourceMgr> const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4654588)
#21 0x000055edd91af750 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#22 0x000055edd91b09a4 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
#23 0x000055edd91b0b54 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
#24 0x000055edd92b95ae 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)
#25 0x000055edd91a83f9 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)
#26 0x000055edd91b0cc1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4653cc1)
#27 0x000055edd91b1186 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x4654186)
#28 0x000055edd5f8e5ab main (/data/tmp/v0813/llvm-project/build/bin/mlir-opt+0x14315ab)
#29 0x00007f8d6abe4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#30 0x000055edd60494ce _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/eJzsWl9v4zgO_zTqi9BAlvz3oQ9p2uIGmLkp2t4-3Esgy3SiHVvySnLb3Kc_yHYaO2ky3bnszt7hBsXUlUmK_JEUKVncWrlSAFcoukbRzQVv3VqbqxeuVhutVr8G_CLXxebqE17zZ8BuDbjUVaVfpFrhL58_PeDG6JXhNWJzRG4QmTuwblZX0ryNoJgMP92ftS7aClBy3f-Jy1aJmf8Po5D43wGiKaIZ3pEM_xCNCEbsBnMj3XomtLKOK4cDjNgcS0YPyIMT5MEBNT1BnR5Qi1PCVQGvBxwJ6zgcKKvNDOrGbTpTI29y1jH27xBbhK-I3b3KALHbAzkZ6ad22vKZAbvmDWzlJ9cKXpbDUKee4RvEFjIOvfzLIER0gUMvNrnppkQ0fXdWmuFLxG53KvlX4XsqGXCtUcMYSm4Gt789TP3_tAbMc_0Mk_jBL7KqsOCt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