[flang-commits] [flang] [flang][openacc] map data operand results to symbols inside compute region (PR #162306)

via flang-commits flang-commits at lists.llvm.org
Wed Oct 8 01:54:26 PDT 2025


================
@@ -2231,10 +2361,25 @@ buildACCLoopOp(Fortran::lower::AbstractConverter &converter,
       builder, builder.getFusedLoc(locs), currentLocation, eval, operands,
       operandSegments, /*outerCombined=*/false, retTy, yieldValue, ivTypes,
       ivLocs);
-
-  for (auto [arg, value] : llvm::zip(
-           loopOp.getLoopRegions().front()->front().getArguments(), ivPrivate))
-    fir::StoreOp::create(builder, currentLocation, arg, value);
+  // Ensure the iv symbol is mapped to private iv SSA value for the scope of
+  // the loop even if it did not appear explicitly in a PRIVATE clause (if it
+  // appeared explicitly in such clause, that is also fine because duplicates
+  // in the list are ignored).
+  dataOperandSymbolPairs.append(ivPrivate.begin(), ivPrivate.end());
+  // Remap symbols from data clauses to use data operation results
+  remapDataOperandSymbols(converter, builder, loopOp, dataOperandSymbolPairs);
+
+  for (auto [arg, iv] :
+       llvm::zip(loopOp.getLoopRegions().front()->front().getArguments(),
+                 ivPrivate)) {
+    // Store block argument to the related iv private variable.
+    auto privateValue =
+        converter.getSymbolAddress(std::get<Fortran::semantics::SymbolRef>(iv));
+    // if (auto declareOp =
+    //         mlir::dyn_cast<hlfir::DeclareOp>(privateValue.getDefiningOp()))
+    //   privateValue = declareOp.getResults()[0];
----------------
jeanPerier wrote:

Yes, removed. Thanks!

I removed it because this is not needed since https://github.com/llvm/llvm-project/commit/44261dae5b3cd330cfcbd7ada51a8ed532103e98

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


More information about the flang-commits mailing list