[Mlir-commits] [mlir] 07dc906 - Fix MLIR back-deployment to version < 5 ; properties section should not be emitted.
Mehdi Amini
llvmlistbot at llvm.org
Thu May 25 20:32:07 PDT 2023
Author: Eugene Burmako
Date: 2023-05-25T20:31:47-07:00
New Revision: 07dc906883af660780cf6d0cc1044f7e74dab83e
URL: https://github.com/llvm/llvm-project/commit/07dc906883af660780cf6d0cc1044f7e74dab83e
DIFF: https://github.com/llvm/llvm-project/commit/07dc906883af660780cf6d0cc1044f7e74dab83e.diff
LOG: Fix MLIR back-deployment to version < 5 ; properties section should not be emitted.
This was an oversight in the development of bytecode version 5, which was
caught by downstream StableHLO compatibility tests.
Differential revision: https://reviews.llvm.org/D151531
Added:
Modified:
mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
index 82d81f763893..0f1395ce4a53 100644
--- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
+++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
@@ -12,6 +12,7 @@
#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/Bytecode/Encoding.h"
#include "mlir/IR/Attributes.h"
+#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/Support/LogicalResult.h"
#include "llvm/ADT/ArrayRef.h"
@@ -459,6 +460,9 @@ class PropertiesSectionBuilder {
}
}
+ /// Returns true if the section is empty.
+ bool empty() { return propertiesStorage.empty(); }
+
private:
/// Emit raw data and returns the offset in the internal buffer.
/// Data are deduplicated and will be copied in the internal buffer only if
@@ -648,7 +652,11 @@ LogicalResult BytecodeWriter::write(Operation *rootOp, raw_ostream &os) {
writeStringSection(emitter);
// Emit the properties section.
- writePropertiesSection(emitter);
+ if (config.bytecodeVersion <= 5)
+ writePropertiesSection(emitter);
+ else if (!propertiesSection.empty())
+ return rootOp->emitError(
+ "unexpected properties emitted incompatible with bytecode <5");
// Write the generated bytecode to the provided output stream.
emitter.writeTo(os);
More information about the Mlir-commits
mailing list