[llvm-branch-commits] [flang] [flang][fir] Basic lowering `fir.do_concurrent` locality specs to `fir.do_loop ... unordered` (PR #138512)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 6 08:20:44 PDT 2025


================
@@ -162,7 +173,52 @@ class DoConcurrentConversion
     assert(loop.getRegion().hasOneBlock());
     mlir::Block &loopBlock = loop.getRegion().getBlocks().front();
 
-    // Collect iteration variable(s) allocations do that we can move them
+    // Handle localization
+    if (!loop.getLocalVars().empty()) {
+      mlir::OpBuilder::InsertionGuard guard(rewriter);
+      rewriter.setInsertionPointToStart(&loop.getRegion().front());
+
+      std::optional<mlir::ArrayAttr> localSyms = loop.getLocalSyms();
+
+      for (auto [localVar, localArg, localizerSym] : llvm::zip_equal(
+               loop.getLocalVars(), loop.getRegionLocalArgs(), *localSyms)) {
+        mlir::SymbolRefAttr localizerName =
+            llvm::cast<mlir::SymbolRefAttr>(localizerSym);
+        fir::LocalitySpecifierOp localizer = findLocalizer(loop, localizerName);
+
+        mlir::Value localAlloc =
+            rewriter.create<fir::AllocaOp>(loop.getLoc(), localizer.getType());
----------------
tblah wrote:

I wonder if this should be done on the heap because it will happen for every loop iteration. Does the spec say that it has to be on the stack?

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


More information about the llvm-branch-commits mailing list