[Mlir-commits] [mlir] [mlir][Transforms][NFC] Dialect conversion: Cache `UnresolvedMaterializationRewrite` (PR #108359)

Matthias Springer llvmlistbot at llvm.org
Thu Sep 12 06:40:19 PDT 2024


================
@@ -935,8 +909,10 @@ struct ConversionPatternRewriterImpl : public RewriterBase::Listener {
   /// to modify/access them is invalid rewriter API usage.
   SetVector<Operation *> replacedOps;
 
-  /// A set of all unresolved materializations.
-  DenseSet<Operation *> unresolvedMaterializations;
+  /// A mapping of all unresolved materializations (UnrealizedConversionCastOp)
+  /// to the corresponding rewrite objects.
+  DenseMap<Operation *, UnresolvedMaterializationRewrite *>
----------------
matthias-springer wrote:

This set may contain ops that were already erased. (When ops from the set are accessed, there is an extra check to see if the op was erased.) I wanted to avoid calling `op.getOperation()` on an erased `UnrealizedConversionCastOp` (it would probably work, but looks dangerous). (The function that checks if an op was erased expects an `Operation *`.)

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


More information about the Mlir-commits mailing list