[Mlir-commits] [mlir] Fix pipeline-invalid.mlir bytecode roundtrip test (PR #82366)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Feb 20 07:02:38 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Matteo Franciolini (mfrancio)

<details>
<summary>Changes</summary>

If an op was not contained in a region when was written to bytecode,
we don't have an initialized valueScope with forward references to
define.

---
Full diff: https://github.com/llvm/llvm-project/pull/82366.diff


1 Files Affected:

- (modified) mlir/lib/Bytecode/Reader/BytecodeReader.cpp (+5-2) 


``````````diff
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index 7cf3bd83b925ca..d61634062784c6 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -2334,8 +2334,11 @@ BytecodeReader::Impl::parseOpWithoutRegions(EncodingReader &reader,
   Operation *op = Operation::create(opState);
   readState.curBlock->push_back(op);
 
-  // If the operation had results, update the value references.
-  if (op->getNumResults() && failed(defineValues(reader, op->getResults())))
+  // If the operation had results, update the value references. We don't need to
+  // do this if the current value scope is empty. That is, the op was not
+  // encoded within a parent region.
+  if (readState.numValues && op->getNumResults() &&
+      failed(defineValues(reader, op->getResults())))
     return failure();
 
   /// Store a map for every value that received a custom use-list order from the

``````````

</details>


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


More information about the Mlir-commits mailing list