[flang-commits] [flang] [flang][hlfir][NFC] Fix mlir misuse in LowerHLFIRIntrinsics (PR #83293)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Feb 29 04:05:47 PST 2024


================
@@ -176,13 +176,9 @@ class HlfirIntrinsicConversion : public mlir::OpRewritePattern<OP> {
           rewriter.eraseOp(use);
       }
     }
-    // TODO: This entire pass should be a greedy pattern rewrite or a manual
-    // IR traversal. A dialect conversion cannot be used here because
-    // `replaceAllUsesWith` is not supported. Similarly, `replaceOp` is not
-    // suitable because "op->getResult(0)" and "base" can have different types.
-    // In such a case, the dialect conversion will attempt to convert the type,
-    // but no type converter is specified in this pass. Also note that all
-    // patterns in this pass are actually rewrite patterns.
+    // the types might not match exactly (but are safe)
+    // e.g. !hlfir.expr<?xi32> vs !hlfir.expr<2xi32>
+    // TODO: is this allowed by MLIR?
----------------
tblah wrote:

Thanks for your help.

I don't think it works. After following your suggestion I am getting null operand errors from operations referring to the replaced value. It looks like `rewriter.replaceOp(op, base)` is not replacing cases where the type changed (or maybe the old versions of the operation usage aren't removed before this check runs?).

I guess the right solution will be to use greedy pattern rewriter after all, even though this pass is conceptually performing a partial dialect conversion.

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


More information about the flang-commits mailing list