aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
diff options
context:
space:
mode:
authorMehdi Amini <joker.eph@gmail.com>2023-05-24 16:13:02 -0700
committerMehdi Amini <joker.eph@gmail.com>2023-05-25 00:27:59 -0700
commit3b0106fe9da9a3adf9bd4402c7bc6cfbb47f1ab8 (patch)
treea05720e7c6c686b3dc7796245d6f7f030f075e4b /mlir/lib/Bytecode/Reader/BytecodeReader.cpp
parentc0261eb02bb092d8842d3c57297e23f31d75cb96 (diff)
downloadllvm-3b0106fe9da9a3adf9bd4402c7bc6cfbb47f1ab8.zip
llvm-3b0106fe9da9a3adf9bd4402c7bc6cfbb47f1ab8.tar.gz
llvm-3b0106fe9da9a3adf9bd4402c7bc6cfbb47f1ab8.tar.bz2
Fix MLIR bytecode reader for unregistered dialects
At the moment we accept (in tests) unregistered dialects and in particular: "new_processor_id_and_range"() where there is no `.` separator. We probably will remove support for this from the parser, but for now we're adding compatibility support in the reader. Differential Revision: https://reviews.llvm.org/D151386
Diffstat (limited to 'mlir/lib/Bytecode/Reader/BytecodeReader.cpp')
-rw-r--r--mlir/lib/Bytecode/Reader/BytecodeReader.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index 92584d5..05a1d33 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -14,6 +14,7 @@
#include "mlir/Bytecode/Encoding.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/Verifier.h"
#include "mlir/IR/Visitors.h"
@@ -1609,8 +1610,20 @@ BytecodeReader::Impl::parseOpName(EncodingReader &reader) {
reader);
if (failed(opName->dialect->load(dialectReader, getContext())))
return failure();
- opName->opName.emplace((opName->dialect->name + "." + opName->name).str(),
- getContext());
+ // If the opName is empty, this is because we use to accept names such as
+ // `foo` without any `.` separator. We shouldn't tolerate this in textual
+ // format anymore but for now we'll be backward compatible. This can only
+ // happen with unregistered dialects.
+ if (opName->name.empty()) {
+ if (opName->dialect->getLoadedDialect())
+ return emitError(fileLoc) << "has an empty opname for dialect '"
+ << opName->dialect->name << "'\n";
+
+ opName->opName.emplace(opName->dialect->name, getContext());
+ } else {
+ opName->opName.emplace((opName->dialect->name + "." + opName->name).str(),
+ getContext());
+ }
}
return *opName->opName;
}