<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62920>62920</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR] bytecode reader silently fails on zero-width integer attribute
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dtzSiFive
      </td>
    </tr>
</table>

<pre>
    Recently our tools cannot read bytecode for our IR, with strange behavior of:
1) No error message, just silently exits (!)
2) Tools built against recent MLIR and recent mlir-opt itself silently exit this way, but same bytecode can be read using mlir-opt from few weeks ago (or our tools built against such MLIR).
3) Bytecode built from working version are also rejected by newer-MLIR tools.

I've tracked this down to what I believe is the problem: zero-width integer attributes get parsed as a null attribute (?).  Putting together an example using builtin dialects demonstrates the same behavior.

Input ("test.mlir"):

```
module attributes { foo.asdf = 0 : i0 } { }
```

`mlir-opt test.mlir -emit-bytecode | mlir-opt` silently fails, tested using commit 334e377 .

This works with MLIR from around a month ago, I believe introduced in this range: 797594a0438f2c6188e9bb3a382f041d3addcd0d..334e3776d (but appears issue introduced no earlier than `836786a`, sorry for lack of more narrow/accurate commit window).

The NULL attribute claim is from stepping through this in a debugger, looking here (but not sure where problem itself occurs): https://github.com/llvm/llvm-project/blob/fb2c98a929aa65603e9d984307a41325e577e9d3/mlir/lib/Bytecode/Reader/BytecodeReader.cpp#L778 (impl pointer is null, etc.).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUle9q3DoTxq9G-2XI4pX898N-aLsYAnnLS07PBYytsa1Glowkx02v_iB5d9OUcuBA2GDJmpnn0W_G6L0aDdGZFZ9ZcTngGibrzjL8_Eu16pUOnZVv52fqyQT9BnZ1EKzVHno0xgZwhBK6t0C9lQSDdemVx2fGv8CmwgQ-ODQjQUcTvqq4PzDxiWUXln06Md7AVwvknHUwk_c4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