<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/128317>128317</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]`-test-bytecode-roundtrip=test-kind=2` triggers Assertion Failure `isIntOrFloat() && "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>
xisang0
</td>
</tr>
</table>
<pre>
Test on commit: https://github.com/llvm/llvm-project/commit/a9882bda96228ca23e166a817f93a7dbc99763cb
steps to reproduce:
```
mlir-opt test.mlir -test-bytecode-roundtrip=test-kind=2
```
test case:
```
module {
func.func @reverse_splat() -> tensor<10xi32> {
%0 = "tosa.const"() <{value = dense<42> : tensor<10xi32>}> : () -> tensor<10xi32>
%1 = tosa.reverse %0 {axis = 0 : i32} : (tensor<10xi32>) -> tensor<10xi32>
return %1 : tensor<10xi32>
}
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/mlir/lib/IR/Types.cpp:134: 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: ./mlir-opt /home/workdir/test.mlir -test-bytecode-roundtrip=test-kind=2
#0 0x0000590e4cbd8998 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x108a998)
#1 0x0000590e4cbd64be llvm::sys::RunSignalHandlers() (./mlir-opt+0x10884be)
#2 0x0000590e4cbd93a8 SignalHandler(int) Signals.cpp:0:0
#3 0x000072f6b0e9f520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000072f6b0ef39fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000072f6b0e9f476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000072f6b0e857f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000072f6b0e8571b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000072f6b0e96e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000590e50067aa5 mlir::Type::getIntOrFloatBitWidth() const (./mlir-opt+0x4519aa5)
#10 0x0000590e4ff95464 mlir::detail::getDenseElementBitWidth(mlir::Type) (./mlir-opt+0x4447464)
#11 0x0000590e4ff99747 mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>) (./mlir-opt+0x444b747)
#12 0x0000590e4ffcccf2 (anonymous namespace)::BuiltinDialectBytecodeInterface::readAttribute(mlir::DialectBytecodeReader&) const BuiltinDialectBytecode.cpp:0:0
#13 0x0000590e51f803e4 (anonymous namespace)::AttrTypeReader::resolveAttribute(unsigned long) BytecodeReader.cpp:0:0
#14 0x0000590e51f7f777 (anonymous namespace)::DialectReader::readAttribute(mlir::Attribute&) BytecodeReader.cpp:0:0
#15 0x0000590e4f0ee0a4 llvm::LogicalResult mlir::DialectBytecodeReader::readAttribute<mlir::ElementsAttr>(mlir::ElementsAttr&) (./mlir-opt+0x35a00a4)
#16 0x0000590e4f155b38 mlir::detail::BytecodeOpInterfaceInterfaceTraits::Model<mlir::tosa::ConstOp>::readProperties(mlir::DialectBytecodeReader&, mlir::OperationState&) (./mlir-opt+0x3607b38)
#17 0x0000590e51f7d0c8 mlir::BytecodeReader::Impl::parseRegions(std::vector<mlir::BytecodeReader::Impl::RegionReadState, std::allocator<mlir::BytecodeReader::Impl::RegionReadState>>&, mlir::BytecodeReader::Impl::RegionReadState&) (./mlir-opt+0x642f0c8)
#18 0x0000590e51f78adb mlir::BytecodeReader::Impl::parseIRSection(llvm::ArrayRef<unsigned char>, mlir::Block*) (./mlir-opt+0x642aadb)
#19 0x0000590e51f75f3d mlir::BytecodeReader::Impl::read(mlir::Block*, llvm::function_ref<bool (mlir::Operation*)>) (./mlir-opt+0x6427f3d)
#20 0x0000590e51f7e8be readBytecodeFileImpl(llvm::MemoryBufferRef, mlir::Block*, mlir::ParserConfig const&, std::shared_ptr<llvm::SourceMgr> const&) BytecodeReader.cpp:0:0
#21 0x0000590e51f7e74e mlir::readBytecodeFile(llvm::MemoryBufferRef, mlir::Block*, mlir::ParserConfig const&) (./mlir-opt+0x643074e)
#22 0x0000590e4fea62ef mlir::parseSourceFile(llvm::SourceMgr const&, mlir::Block*, mlir::ParserConfig const&, mlir::LocationAttr*) (./mlir-opt+0x43582ef)
#23 0x0000590e4fea6988 mlir::parseSourceString(llvm::StringRef, mlir::Block*, mlir::ParserConfig const&, llvm::StringRef, mlir::LocationAttr*) (./mlir-opt+0x4358988)
#24 0x0000590e4fd77e74 (anonymous namespace)::TestBytecodeRoundtripPass::doRoundtripWithConfigs(mlir::Operation*, mlir::BytecodeWriterConfig const&, mlir::ParserConfig const&) TestBytecodeRoundtrip.cpp:0:0
#25 0x0000590e4fd75cb0 (anonymous namespace)::TestBytecodeRoundtripPass::runOnOperation() TestBytecodeRoundtrip.cpp:0:0
#26 0x0000590e4fea93bf mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x435b3bf)
#27 0x0000590e4fea9ba2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x435bba2)
#28 0x0000590e4feac34e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x435e34e)
#29 0x0000590e4fea4e6b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#30 0x0000590e4fea4acb 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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#31 0x0000590e4ff4ddf5 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) (./mlir-opt+0x43ffdf5)
#32 0x0000590e4fe9f9b2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x43519b2)
#33 0x0000590e4fe9fc63 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4351c63)
#34 0x0000590e4fe9fe72 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4351e72)
#35 0x0000590e4cbb7c27 main (./mlir-opt+0x1069c27)
#36 0x000072f6b0e86d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x000072f6b0e86e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000590e4cbb7795 _start (./mlir-opt+0x1069795)
Aborted (core dumped)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcWltP5DzS_jXmxqLl2DlecBGaaX1Ig0Aw0nvZcpJKtz_ScdZ2GPj3KyfpzoEEaGbfXe2O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