[Mlir-commits] [mlir] [mlir] Improve `GreedyPatternRewriteDriver` and pass documentation (PR #77614)
Matthias Springer
llvmlistbot at llvm.org
Wed Jan 10 06:56:36 PST 2024
================
@@ -23,16 +23,21 @@ further below. All passes in MLIR derive from `OperationPass` and adhere to the
following restrictions; any noncompliance will lead to problematic behavior in
multithreaded and other advanced scenarios:
-* Must not modify any state referenced or relied upon outside the current
- operation being operated on. This includes adding or removing operations
- from the parent block, changing the attributes(depending on the contract
- of the current operation)/operands/results/successors of the current operation.
-* Must not modify the state of another operation not nested within the current
- operation being operated on.
- * Other threads may be operating on these operations simultaneously.
-* Must not inspect the state of sibling operations.
+* Must not inspect the state of operations that are siblings of the operation
+ that the pass operates on. Must neither access operations nested under those
+ siblings.
* Other threads may be modifying these operations in parallel.
* Inspecting the state of ancestor/parent operations is permitted.
+* Must not modify the state of operations other than the operation that the
+ pass operates on ("current operation") and its nested operations. This
+ includes adding, modifying or removing other operations from an ancestor
+ block.
+ * Other threads may be operating on these operations simultaneously.
+ * The attributes of the current operation may be modified freely.
+ * The operands of the current operation may be modified, as long as no
----------------
matthias-springer wrote:
This is a bit sus. Example:
- Pass instance 1: `currentOp->setOperand(0, currentOp->getBlock()->getArgument(0)`
- Pass instance 2: `print(currentOp->getBlock()->getArgument(0).getUses().size()`
Instance 1 modifies the current op. That is allowed. (Or is it? The use list of a parent block argument changes. Does this count as "modifying per parent op"?).
Instance 2 reads the number of uses of a parent block argument. That is allowed. But there's a race condition if both instances run in parallel.
Maybe the only modifications that we should allow are "modifying attributes"?
https://github.com/llvm/llvm-project/pull/77614
More information about the Mlir-commits
mailing list