[Mlir-commits] [mlir] [mlir][bytecode] Use getChecked<T>() in bytecode reading to avoid crashes (PR #186145)
Kelvin Li
llvmlistbot at llvm.org
Wed Mar 25 08:44:40 PDT 2026
kkwli wrote:
@joker-eph I have a question regarding `ArrayAttr` in `BuiltinDialectBytecode.td`. The comment in `BytecodeImplementation.h` states that for `ArrayAttr` `T::getChecked(emitError, context, params...)` will not be used. However, the definition of `ArrayAttr` leads to generate `getChecked` instead of `get<...>`. As a result, the following is generated in `BuiltinDialectBytecode.cpp.inc`,
```
static ::mlir::Attribute readArrayAttr(MLIRContext* context, DialectBytecodeReader &reader) {
SmallVector<Attribute> value;
if (succeeded(reader.readAttributes(value))) {
return getChecked<ArrayAttr>([&]() { return reader.emitError(); }, context, value);
}
return ArrayAttr();
}
```
Is it expected? The reason I ask is that somehow our downstream compiler on AIX asserts with error:
`
Assertion failed: isInitialized() && "querying uninitialized conversion", file clang/include/clang/Sema/Overload.h, line 716, Kind clang::ImplicitConversionSequence::getKind() const()
`
The following reproducer indicates that `getChecked<ArrayAttr>([&]() { return reader.emitError(); }, context, value)` has an issue.
```c++
#include "BuiltinDialectBytecode.h"
#include "AttributeDetail.h"
#include "mlir/Bytecode/BytecodeImplementation.h"
using namespace mlir;
namespace {
static ::mlir::Attribute readArrayAttr(MLIRContext* context, DialectBytecodeReader &reader) {
SmallVector<Attribute> value;
return getChecked<ArrayAttr>([&]() { return reader.emitError(); }, context, value);
}
} // namespace
```
I am not familiar with the code. Any insight or hint is much appreciated.
https://github.com/llvm/llvm-project/pull/186145
More information about the Mlir-commits
mailing list