[flang-commits] [flang] [llvm] [Flang][OpenMP] Prevent unrequired implicit maps for private variables on composite directives (PR #217121)
via flang-commits
flang-commits at lists.llvm.org
Fri Oct 23 00:54:23 PDT 2026
================
@@ -184,23 +200,26 @@ void cloneOrMapRegionOutsiders(
!mlir::isa<fir::BoxDimsOp>(valOp)) {
mlir::Operation *clonedOp = valOp->clone();
entryBlock->push_front(clonedOp);
-
- auto replace = [entryBlock](mlir::OpOperand &use) {
- return use.getOwner()->getBlock() == entryBlock;
- };
+ madeProgress = true;
valOp->getResults().replaceUsesWithIf(clonedOp->getResults(), replace);
valOp->replaceUsesWithIf(clonedOp, replace);
- } else {
+ } else if (canEmitMaps) {
mlir::Value mappedTemp = mapTemporaryValue(firOpBuilder, targetOp, val,
/*name=*/{});
- val.replaceUsesWithIf(mappedTemp, [entryBlock](mlir::OpOperand &use) {
- return use.getOwner()->getBlock() == entryBlock;
- });
+ madeProgress = true;
+ val.replaceUsesWithIf(mappedTemp, replace);
}
}
valuesDefinedAbove.clear();
mlir::getUsedValuesDefinedAbove(region, valuesDefinedAbove);
+
+ if (!canEmitMaps && !valuesDefinedAbove.empty() && !madeProgress) {
+ assert(false &&
+ "failed to clone all values used in the target region but defined "
+ "above it");
+ break;
+ }
----------------
agozillon wrote:
I think if I remember correctly at the time I was mainly concerned about the cases this gets triggered and the asserts are off in the compiler build. There's a few build bots that complain in these cases, but I am happy to make the change :-)
https://github.com/llvm/llvm-project/pull/217121
More information about the flang-commits
mailing list