mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 03:56:16 +08:00
[mlir] fix bytecode writer after c1eab57673
The change in c1eab57 fixed the
behavior of `getDiscardableAttrDictionary` for ops that are not using
properties to only return discardable attributes. Bytecode writer was
relying on the wrong behavior and would assume all attributes are
discardable, without appropriate testing. Fix that and add a test.
This commit is contained in:
@@ -962,9 +962,12 @@ LogicalResult BytecodeWriter::writeOp(EncodingEmitter &emitter, Operation *op) {
|
||||
DictionaryAttr attrs = op->getDiscardableAttrDictionary();
|
||||
// Allow deployment to version <kNativePropertiesEncoding by merging inherent
|
||||
// attribute with the discardable ones. We should fail if there are any
|
||||
// conflicts.
|
||||
if (config.bytecodeVersion < bytecode::kNativePropertiesEncoding)
|
||||
// conflicts. When properties are not used by the op, also store everything as
|
||||
// attributes.
|
||||
if (config.bytecodeVersion < bytecode::kNativePropertiesEncoding ||
|
||||
!op->getPropertiesStorage()) {
|
||||
attrs = op->getAttrDictionary();
|
||||
}
|
||||
if (!attrs.empty()) {
|
||||
opEncodingMask |= bytecode::OpEncodingMask::kHasAttrs;
|
||||
emitter.emitVarInt(numberingState.getNumber(attrs));
|
||||
|
||||
@@ -425,9 +425,10 @@ void IRNumberingState::number(Operation &op) {
|
||||
|
||||
// Only number the operation's dictionary if it isn't empty.
|
||||
DictionaryAttr dictAttr = op.getDiscardableAttrDictionary();
|
||||
// Prior to version 5 we need to number also the merged dictionnary
|
||||
// containing both the inherent and discardable attribute.
|
||||
if (config.getDesiredBytecodeVersion() < 5)
|
||||
// Prior to version 5, or when properties are not used, we need to number also
|
||||
// the merged dictionary containing both the inherent and discardable
|
||||
// attribute.
|
||||
if (config.getDesiredBytecodeVersion() < 5 || !op.getPropertiesStorage())
|
||||
dictAttr = op.getAttrDictionary();
|
||||
if (!dictAttr.empty())
|
||||
number(dictAttr);
|
||||
|
||||
Reference in New Issue
Block a user