[Mlir-commits] [mlir] [mlir][BytecodeReader] Fix FusedLoc bytecode builder (PR #99632)

Mehdi Amini llvmlistbot at llvm.org
Fri Jul 19 14:48:26 PDT 2024


================
@@ -148,3 +149,24 @@ TEST(Bytecode, OpWithoutProperties) {
   EXPECT_TRUE(OperationEquivalence::computeHash(op.get()) ==
               OperationEquivalence::computeHash(roundtripped));
 }
+
+TEST(Bytecode, FusedLocCrash) {
+  MLIRContext context;
+  OpBuilder builder(&context);
+  SmallVector<Location> locs;
+  FusedLoc fusedLoc = FusedLoc::get(&context, locs, {});
+
+  auto module = builder.create<mlir::ModuleOp>(fusedLoc, "test");
+
+  // Write the module to bytecode
+  std::string buffer;
+  llvm::raw_string_ostream ostream(buffer);
+  ASSERT_TRUE(succeeded(writeBytecodeToFile(module, ostream)));
+  ostream.flush();
+
+  // Parse it back
+  ParserConfig parseConfig(&context);
+  OwningOpRef<Operation *> roundTripModule =
+      parseSourceString<Operation *>(buffer, parseConfig);
+  ASSERT_TRUE(roundTripModule);
+}
----------------
joker-eph wrote:

The in-memory IR should round-trip to both bytecode and text: if it isn't the case right now we need to fix both the bytecode and textual printer/parser.

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


More information about the Mlir-commits mailing list