@@ -254,9 +254,10 @@ class ACCImplicitData : public acc::impl::ACCImplicitDataBase<ACCImplicitData> {
254254
255255 // / Generates the implicit data ops for a compute construct.
256256 template <typename OpT>
257- void generateImplicitDataOps (
258- ModuleOp &module , OpT computeConstructOp,
259- std::optional<acc::ClauseDefaultValue> &defaultClause);
257+ void
258+ generateImplicitDataOps (ModuleOp &module , OpT computeConstructOp,
259+ std::optional<acc::ClauseDefaultValue> &defaultClause,
260+ acc::OpenACCSupport &accSupport);
260261
261262 // / Generates a private recipe for a variable.
262263 acc::PrivateRecipeOp generatePrivateRecipe (ModuleOp &module , Value var,
@@ -277,12 +278,16 @@ class ACCImplicitData : public acc::impl::ACCImplicitDataBase<ACCImplicitData> {
277278
278279// / Determines if a variable is a candidate for implicit data mapping.
279280// / Returns true if the variable is a candidate, false otherwise.
280- static bool isCandidateForImplicitData (Value val, Region &accRegion) {
281+ static bool isCandidateForImplicitData (Value val, Region &accRegion,
282+ acc::OpenACCSupport &accSupport) {
281283 // Ensure the variable is an allowed type for data clause.
282284 if (!acc::isPointerLikeType (val.getType ()) &&
283285 !acc::isMappableType (val.getType ()))
284286 return false ;
285287
288+ if (accSupport.isValidValueUse (val, accRegion))
289+ return false ;
290+
286291 // If this is already coming from a data clause, we do not need to generate
287292 // another.
288293 if (isa_and_nonnull<ACC_DATA_ENTRY_OPS>(val.getDefiningOp ()))
@@ -683,7 +688,8 @@ static void insertInSortedOrder(SmallVector<Value> &sortedDataClauseOperands,
683688template <typename OpT>
684689void ACCImplicitData::generateImplicitDataOps (
685690 ModuleOp &module , OpT computeConstructOp,
686- std::optional<acc::ClauseDefaultValue> &defaultClause) {
691+ std::optional<acc::ClauseDefaultValue> &defaultClause,
692+ acc::OpenACCSupport &accSupport) {
687693 // Implicit data attributes are only applied if "[t]here is no default(none)
688694 // clause visible at the compute construct."
689695 if (defaultClause.has_value () &&
@@ -699,7 +705,7 @@ void ACCImplicitData::generateImplicitDataOps(
699705
700706 // 2) Run the filtering to find relevant pointers that need copied.
701707 auto isCandidate{[&](Value val) -> bool {
702- return isCandidateForImplicitData (val, accRegion);
708+ return isCandidateForImplicitData (val, accRegion, accSupport );
703709 }};
704710 auto candidateVars (
705711 llvm::to_vector (llvm::make_filter_range (liveInValues, isCandidate)));
@@ -763,6 +769,9 @@ void ACCImplicitData::generateImplicitDataOps(
763769
764770void ACCImplicitData::runOnOperation () {
765771 ModuleOp module = this ->getOperation ();
772+
773+ acc::OpenACCSupport &accSupport = getAnalysis<acc::OpenACCSupport>();
774+
766775 module .walk ([&](Operation *op) {
767776 if (isa<ACC_COMPUTE_CONSTRUCT_OPS, acc::KernelEnvironmentOp>(op)) {
768777 assert (op->getNumRegions () == 1 && " must have 1 region" );
@@ -771,7 +780,7 @@ void ACCImplicitData::runOnOperation() {
771780 llvm::TypeSwitch<Operation *, void >(op)
772781 .Case <ACC_COMPUTE_CONSTRUCT_OPS, acc::KernelEnvironmentOp>(
773782 [&](auto op) {
774- generateImplicitDataOps (module , op, defaultClause);
783+ generateImplicitDataOps (module , op, defaultClause, accSupport );
775784 })
776785 .Default ([&](Operation *) {});
777786 }
0 commit comments