Skip to content

Fix pipeline-invalid.mlir bytecode roundtrip test #82366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mfrancio
Copy link
Contributor

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.

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.
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Feb 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 20, 2024

@llvm/pr-subscribers-mlir-core

Author: Matteo Franciolini (mfrancio)

Changes

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 --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

@llvmbot
Copy link
Member

llvmbot commented Feb 20, 2024

@llvm/pr-subscribers-mlir

Author: Matteo Franciolini (mfrancio)

Changes

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 --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

@mfrancio mfrancio requested a review from joker-eph February 20, 2024 15:02
@mfrancio mfrancio merged commit 5375cbf into llvm:main Feb 21, 2024
@mfrancio mfrancio deleted the dev/mfrancio/fixMLIRPassPipelineInvalidBytecodeRoundtripTest branch February 26, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants