[flang-commits] [flang] [Flang][OpenMP] Prevent unrequired implicit maps for private variables on composite directives (PR #217121)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Tue Sep 1 07:50:06 PDT 2026


================
@@ -164,14 +164,27 @@ mlir::Value mapTemporaryValue(fir::FirOpBuilder &firOpBuilder,
   return loadOp.getResult();
 }
 
-void cloneOrMapRegionOutsiders(
-    fir::FirOpBuilder &firOpBuilder, mlir::omp::TargetOp targetOp) {
+namespace {
+/// Helper function for resolving values used inside a target region but defined
+/// above it. It can resolve through cloning or generating new map info
+/// operations. It will opt for cloning when provably memory effect free,
+/// otherwise it will generate a map, however, only if requested.
+///
+/// \param mapNonClonable - When true, non-clonable outsiders are mapped into
+/// the region; when false they are left untouched.
----------------
skatrak wrote:

When a non-clonable outsider is left untouched, doesn't that cause the original value outside of the target region to be accessed illegally inside?

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


More information about the flang-commits mailing list