[flang-commits] [flang] [flang][OpenMP] Fix privatization of linear in TARGET (PR #202443)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Tue Jun 9 11:59:10 PDT 2026


================
@@ -492,6 +492,22 @@ void DataSharingProcessor::collectPrivatizedSymbols(
   }
 
   auto shouldCollectSymbol = [&](const semantics::Symbol *sym) {
+    // Linear symbols are privatized by OpenMP IRBuilder, except when they are
+    // enclosed within TARGET.
+    bool inTarget = false;
+    mlir::Operation *currentOp =
+        firOpBuilder.getInsertionBlock()->getParentOp();
+    while (currentOp) {
+      if (mlir::dyn_cast<mlir::omp::TargetOp>(currentOp)) {
+        inTarget = true;
+        break;
+      }
+      currentOp = currentOp->getParentOp();
+    }
----------------
luporl wrote:

Done, thanks for the suggestion.

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


More information about the flang-commits mailing list