[flang-commits] [flang] [flang] `do concurrent`: fix reduction symbol resolution when mapping to OpenMP (PR #155355)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Tue Aug 26 08:12:55 PDT 2025


================
@@ -368,22 +368,28 @@ class DoConcurrentConversion
 
         mlir::OpBuilder::InsertionGuard guard(rewriter);
         rewriter.setInsertionPointAfter(firReducer);
-
-        auto ompReducer = mlir::omp::DeclareReductionOp::create(
-            rewriter, firReducer.getLoc(),
-            sym.getLeafReference().str() + ".omp",
-            firReducer.getTypeAttr().getValue());
-
-        cloneFIRRegionToOMP(firReducer.getAllocRegion(),
-                            ompReducer.getAllocRegion());
-        cloneFIRRegionToOMP(firReducer.getInitializerRegion(),
-                            ompReducer.getInitializerRegion());
-        cloneFIRRegionToOMP(firReducer.getReductionRegion(),
-                            ompReducer.getReductionRegion());
-        cloneFIRRegionToOMP(firReducer.getAtomicReductionRegion(),
-                            ompReducer.getAtomicReductionRegion());
-        cloneFIRRegionToOMP(firReducer.getCleanupRegion(),
-                            ompReducer.getCleanupRegion());
+        std::string ompReducerName = sym.getLeafReference().str() + ".omp";
+
+        auto ompReducer = mlir::SymbolTable::lookupNearestSymbolFrom<
----------------
vzakhari wrote:

Thank you for the prompt fix, Kareem!

This method may be expensive.  Please use `SymbolTable` object (https://mlir.llvm.org/doxygen/classmlir_1_1SymbolTable.html) to cache the module symbol table, and then use it to insert/lookup the reducer symbols.

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


More information about the flang-commits mailing list