Skip to content
2 changes: 1 addition & 1 deletion flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
sym, cannotHaveNonDefaultLowerBounds);
// TODO: currently there are false positives from dead uses of the mold
// arg
if (!result.getInitMoldArg().getUses().empty())
if (result.initReadsFromMold())
mightHaveReadHostSym.insert(sym);
}

Expand Down
15 changes: 13 additions & 2 deletions mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,24 @@ def PrivateClauseOp : OpenMP_Op<"private", [IsolatedFromAbove, RecipeInterface]>
return region.empty() ? nullptr : region.getArgument(0);
}

/// Returns true if the init region might read from the mold argument
bool initReadsFromMold() {
BlockArgument moldArg = getInitMoldArg();
return moldArg && !moldArg.use_empty();
}

/// Returns true if any region of this privatizer might read from the mold
/// argument
bool readsFromMold() {
return initReadsFromMold() || !getCopyRegion().empty();
}

/// needsMap returns true if the value being privatized should additionally
/// be mapped to the target region using a MapInfoOp. This is most common
/// when an allocatable is privatized. In such cases, the descriptor is used
/// in privatization and needs to be mapped on to the device.
bool needsMap() {
BlockArgument moldArg = getInitMoldArg();
return moldArg ? !moldArg.use_empty() : false;
return initReadsFromMold();
}

/// Get the type for arguments to nested regions. This should
Expand Down
Loading
Loading