[flang-commits] [flang] [flang] Do not use dialect conversion in `DoConcurrentConversionPass` (PR #156169)

Matthias Springer via flang-commits flang-commits at lists.llvm.org
Sat Aug 30 10:59:01 PDT 2025


================
@@ -472,18 +476,25 @@ class DoConcurrentConversionPass
     patterns.insert<DoConcurrentConversion>(
         context, mapTo == flangomp::DoConcurrentMappingKind::DCMK_Device,
         concurrentLoopsToSkip, moduleSymbolTable);
-    mlir::ConversionTarget target(*context);
-    target.addDynamicallyLegalOp<fir::DoConcurrentOp>(
-        [&](fir::DoConcurrentOp op) {
-          return concurrentLoopsToSkip.contains(op);
-        });
-    target.markUnknownOpDynamicallyLegal(
-        [](mlir::Operation *) { return true; });
-
-    if (mlir::failed(
-            mlir::applyFullConversion(module, target, std::move(patterns)))) {
+
+    // TODO: This pass should use "walkAndApplyPatterns", but that driver does
+    // not support pre-order traversals yet.
+    if (mlir::failed(applyPatternsGreedily(module.getOperation(),
+                                           std::move(patterns)))) {
----------------
matthias-springer wrote:

I found a better solution. We can keep the dialect conversion here. Then we don't have to play [tricks](https://github.com/llvm/llvm-project/pull/156169/files#diff-a697c84d5559990d600e95e17cbe74eaaa085202f4a0086d130261755ec556c3R189) to enforce a certain traversal order.

Instead, we can [switch to the new One-Shot Dialect conversion driver](https://github.com/llvm/llvm-project/pull/155244/files#diff-a697c84d5559990d600e95e17cbe74eaaa085202f4a0086d130261755ec556c3R500) in the same commit that enables `replaceAllUsesWith`. There's still an API violation in the code (calling `eraseArgument` in the pattern), but the new driver can handle those a bit better. Can you take a look at the Flang-related changes of that PR instead?

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


More information about the flang-commits mailing list