This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bytecode] Error if requested bytecode version is unsupported
ClosedPublic

Authored by GleasonK on May 31 2023, 1:45 PM.

Details

Summary

Currently desired bytecode version is clamped to the maximum. This allows requesting bytecode versions that do not exist. We have added callsite validation for this in StableHLO to ensure we don't pass an invalid version number, probably better if this is managed upstream. If a user wants to use the current version, then omitting setDesiredBytecodeVersion is the best way to do that (as opposed to providing a large number).

Adding this check will also properly error on older version numbers as we increment the minimum supported version. Silently claming on minimum version would likely lead to unintentional forward incompatibilities.

Separately, due to bytecode version being int64_t and using methods to read/write uints, we can generate payloads with invalid version numbers:

mlir-opt file.mlir --emit-bytecode --emit-bytecode-version=-1 | mlir-opt
<stdin>:0:0: error: bytecode version 18446744073709551615 is newer than the current version 5

This is fixed with version bounds checking as well.

Diff Detail

Event Timeline

GleasonK created this revision.May 31 2023, 1:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 31 2023, 1:45 PM
GleasonK requested review of this revision.May 31 2023, 1:45 PM
GleasonK retitled this revision from Error if requested bytecode version is unsupported to [mlir][bytecode] Error if requested bytecode version is unsupported.May 31 2023, 1:54 PM
mehdi_amini accepted this revision.May 31 2023, 1:56 PM

Thanks!

This revision is now accepted and ready to land.May 31 2023, 1:56 PM

Thanks for the quick review Mehdi! I don't have commit access, so would appreciate some help there when you get a chance!