Fix MLIR bytecode reading of i0 IntegerAttr
authorMehdi Amini <joker.eph@gmail.com>
Wed, 24 May 2023 20:30:49 +0000 (13:30 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 24 May 2023 20:45:58 +0000 (13:45 -0700)
The move of the bytecode serialization to be tablegen driven in
https://reviews.llvm.org/D144820 added a new condition in the reading
path that forbid 0-sized integer, even though we still produce them.

Fix #62920

Differential Revision: https://reviews.llvm.org/D151372

mlir/lib/IR/BuiltinDialectBytecode.cpp
mlir/test/Bytecode/empty_attr.mlir [new file with mode: 0644]

index 75457e9..b7a2784 100644 (file)
@@ -43,8 +43,6 @@ static unsigned getIntegerBitWidth(DialectBytecodeReader &reader, Type type) {
 static LogicalResult readAPIntWithKnownWidth(DialectBytecodeReader &reader,
                                              Type type, FailureOr<APInt> &val) {
   unsigned bitWidth = getIntegerBitWidth(reader, type);
-  if (bitWidth == 0)
-    return failure();
   val = reader.readAPIntWithKnownWidth(bitWidth);
   return val;
 }
diff --git a/mlir/test/Bytecode/empty_attr.mlir b/mlir/test/Bytecode/empty_attr.mlir
new file mode 100644 (file)
index 0000000..1a33cbd
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: mlir-opt -emit-bytecode %s | mlir-opt | FileCheck %s
+
+// CHECK: module
+// CHECK: foo.asdf = 0 : i0
+module attributes { foo.asdf = 0 : i0 } { }