diff --git a/mlir/test/Bytecode/roundtrip-missing-dialect.mlir b/mlir/test/Bytecode/roundtrip-missing-dialect.mlir new file mode 100644 index 0000000000000..8a93fcfd55695 --- /dev/null +++ b/mlir/test/Bytecode/roundtrip-missing-dialect.mlir @@ -0,0 +1,6 @@ +// RUN: mlir-opt %s --test-bytecode-roundtrip=test-dialect-version=2.0 | FileCheck %s + +// CHECK-LABEL: func.func @main +func.func @main() { + return +} diff --git a/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp b/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp index 4894ad5294990..f6ee97831c9dd 100644 --- a/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp +++ b/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp @@ -141,8 +141,8 @@ struct TestBytecodeRoundtripPass DialectBytecodeWriter &writer) -> LogicalResult { // Do not override anything if version greater than 2.0. auto versionOr = writer.getDialectVersion(); - assert(succeeded(versionOr) && "expected reader to be able to access " - "the version for test dialect"); + if (failed(versionOr)) + return failure(); const auto *version = reinterpret_cast(*versionOr); if (version->major_ >= 2) @@ -166,8 +166,8 @@ struct TestBytecodeRoundtripPass Type &entry) -> LogicalResult { // Get test dialect version from the version map. auto versionOr = reader.getDialectVersion(); - assert(succeeded(versionOr) && "expected reader to be able to access " - "the version for test dialect"); + if (failed(versionOr)) + return success(); const auto *version = reinterpret_cast(*versionOr); if (version->major_ >= 2)