[all-commits] [llvm/llvm-project] 0ee487: [mlir][bytecode] Error if requested bytecode versi...
Kevin Gleason via All-commits
all-commits at lists.llvm.org
Wed May 31 19:21:02 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0ee4875ddff08ba1cdc96bc85a72a51727eb88f6
https://github.com/llvm/llvm-project/commit/0ee4875ddff08ba1cdc96bc85a72a51727eb88f6
Author: Kevin Gleason <gleasonk at google.com>
Date: 2023-05-31 (Wed, 31 May 2023)
Changed paths:
M mlir/include/mlir/Bytecode/BytecodeWriter.h
M mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
M mlir/test/Bytecode/versioning/versioned_bytecode.mlir
Log Message:
-----------
[mlir][bytecode] Error if requested bytecode version is unsupported
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.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D151838
More information about the All-commits
mailing list