[Mlir-commits] [mlir] [mlir][bytecode] Avoid crash when test dialect version is missing (PR #170173)

Akimasa Watanuki llvmlistbot at llvm.org
Tue Mar 3 05:20:57 PST 2026


================
@@ -166,8 +166,8 @@ struct TestBytecodeRoundtripPass
             Type &entry) -> LogicalResult {
           // Get test dialect version from the version map.
           auto versionOr = reader.getDialectVersion<test::TestDialect>();
-          assert(succeeded(versionOr) && "expected reader to be able to access "
-                                         "the version for test dialect");
+          if (failed(versionOr))
+            return success();
----------------
Men-cotton wrote:

I found existing code that continues by treating a missing version as the current version: https://github.com/llvm/llvm-project/blob/703649554da8f7b92873d21da7f3c51fbc7112ed/mlir/test/lib/Dialect/Test/TestDialectInterfaces.cpp#L82-L86 and https://github.com/llvm/llvm-project/blob/703649554da8f7b92873d21da7f3c51fbc7112ed/mlir/test/lib/Dialect/Test/TestOpDefs.cpp#L1415-L1416, so I believe this path should return `success()`.

I also added a comment explaining why `success()` is appropriate here. Could you please review it again?  

https://github.com/llvm/llvm-project/pull/170173


More information about the Mlir-commits mailing list