[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:07 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.
+/// \param iterateToFixpoint - When true, the set of values-defined-above is
+/// re-queried and reprocessed until emptied. Otherwise a single pass is done.
+/// \param inScope - Predicate selecting which uses of an outsider should be
+/// rewired to the sunk/mapped replacement.
+void resolveRegionOutsiders(fir::FirOpBuilder &firOpBuilder,
+ mlir::omp::TargetOp targetOp, bool mapNonClonable, bool iterateToFixpoint,
+ llvm::function_ref<bool(mlir::OpOperand &)> inScope) {
mlir::Region ®ion = targetOp.getRegion();
mlir::Block *entryBlock = ®ion.getBlocks().front();
llvm::SetVector<mlir::Value> valuesDefinedAbove;
mlir::getUsedValuesDefinedAbove(region, valuesDefinedAbove);
- while (!valuesDefinedAbove.empty()) {
+ do {
----------------
skatrak wrote:
Nit: Is the change from `while` to `do-while` intended to make a difference?
https://github.com/llvm/llvm-project/pull/217121
More information about the flang-commits
mailing list