[Mlir-commits] [mlir] [mlir][BytecodeReader] Fix FusedLoc bytecode builder (PR #99632)
Hideto Ueno
llvmlistbot at llvm.org
Fri Jul 19 05:26:08 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);
+}
----------------
uenoku wrote:
I think this issue is not reproducible from mlir textual format since `fused[]` is converted into `unknown` in the asm parser. What do you think?
```mlir
$ cat bar.mlir
module @TestLocFused {
} loc(#loc)
#loc = loc(fused[])
$ mlir-opt bar.mlir -mlir-print-debuginfo
module @TestLocFused {
} loc(#loc)
#loc = loc(unknown)
```
https://github.com/llvm/llvm-project/pull/99632
More information about the Mlir-commits
mailing list