This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix bytecode reader/writer on big-endian platforms
ClosedPublic

Authored by uweigand on Jun 22 2023, 9:00 AM.

Details

Summary

This makes the bytecode reader/writer work on big-endian platforms. The only problem was related to encoding of multi-byte integers, where both reader and writer code make implicit assumptions about endianness of the host platform.

This fixes the current test failures on s390x, and in addition allows to remove the UNSUPPORTED markers from all other bytecode-related test cases - they now also all pass on s390x.

Note that there is still one other, unrelated, endian problem regarding decoding of external resources. This is not fixed by this patch, and still causes two tests to fail:

  • test/IR/elements-attr-interface.mlir (already marked as XFAIL on s390x)
  • Bytecode/./MLIRBytecodeTests/Bytecode/MultiModuleWithResource

The latter unit test currently fails very early due to the bytecode encoding bug fixed here. After this patch, it will still fail, but later on when verifying the contents of the resource. I've now added a GFAIL_SKIP here to get the build bot green on s390x again.

Diff Detail

Event Timeline

uweigand created this revision.Jun 22 2023, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 9:00 AM
uweigand requested review of this revision.Jun 22 2023, 9:00 AM
mehdi_amini accepted this revision.Jun 22 2023, 1:57 PM

LGTM, but please wait for @rriddle to have a look as well!

This revision is now accepted and ready to land.Jun 22 2023, 1:57 PM
jpienaar accepted this revision.Jun 22 2023, 2:20 PM

Its really nice how minimal this change needed to be.

GleasonK added inline comments.
mlir/lib/Bytecode/Reader/BytecodeReader.cpp
8–9

This can probably be deleted now?

rriddle accepted this revision.Jun 22 2023, 3:22 PM

Amazing!

This revision was landed with ongoing or failed builds.Jun 23 2023, 12:23 AM
This revision was automatically updated to reflect the committed changes.
uweigand marked an inline comment as done.Jun 23 2023, 12:24 AM
uweigand added inline comments.
mlir/lib/Bytecode/Reader/BytecodeReader.cpp
8–9

Good point, I'm done this now.