[flang-commits] [flang] [flang][OpenMP] incorrect handling for local variable in OpenMP parallel workshare firstprivate(P) (PR #195616)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Thu May 7 07:51:52 PDT 2026


================
@@ -356,9 +361,21 @@ static void parallelizeRegion(Region &sourceRegion, Region &targetRegion,
     if (auto reloaded = rootMapping.lookupOrNull(v))
       return nullptr;
     Type ty = v.getType();
-    Value alloc = fir::AllocaOp::create(allocaBuilder, loc, ty);
-    fir::StoreOp::create(singleBuilder, loc, singleMapping.lookup(v), alloc);
-    Value reloaded = fir::LoadOp::create(parallelBuilder, loc, ty, alloc);
+    // fir.alloca cannot wrap fir.ref, so for reference-typed values
+    // (e.g. results of dynamic fir.alloca ops) use fir.heap as the
+    // intermediary pointer type for the broadcast alloca.
----------------
luporl wrote:

I'm not sure if it is conceptually correct to use `fir.heap` for pointers that were not allocated in the heap.
Does `fir.ptr` work too?

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


More information about the flang-commits mailing list