[Mlir-commits] [mlir] [mlir][transform] Do not maintain mappings for dead handles (PR #73558)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Mon Nov 27 11:57:53 PST 2023


================
@@ -994,13 +1033,18 @@ transform::TransformState::applyTransform(TransformOpInterface transform) {
 
   // Remove the mapping for the operand if it is consumed by the operation. This
   // allows us to catch use-after-free with assertions later on.
-  for (OpOperand *opOperand : consumedOperands) {
-    Value operand = opOperand->get();
+  for (OpOperand &opOperand : transform->getOpOperands()) {
+    Value operand = opOperand.get();
+    if (getAliveUse(operand, transform) != nullptr)
+      continue;
+    bool wasConsumed = llvm::is_contained(consumedOperands, &opOperand);
     if (llvm::isa<TransformHandleTypeInterface>(operand.getType())) {
-      forgetMapping(operand, origOpFlatResults);
+      forgetMapping(operand,
+                    wasConsumed ? ValueRange(origOpFlatResults) : ValueRange());
----------------
ftynse wrote:

Nit: a comment as to why the value mapping is not also deleted (because it may have further uses) would be helpful.

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


More information about the Mlir-commits mailing list