@@ -505,32 +505,17 @@ getAttrsFromVariable(fir::FortranVariableOpInterface var) {
505505}
506506
507507template <typename OMPTypeOp, typename DeclTypeOp>
508- static Value getPrivateArg (omp::BlockArgOpenMPOpInterface &argIface,
509- OMPTypeOp &op, DeclTypeOp &declOp) {
510- Value privateArg;
508+ static bool isPrivateArg (omp::BlockArgOpenMPOpInterface &argIface,
509+ OMPTypeOp &op, DeclTypeOp &declOp) {
511510 if (!op.getPrivateSyms ().has_value ())
512- return privateArg ;
511+ return false ;
513512 for (auto [opSym, blockArg] :
514513 llvm::zip_equal (*op.getPrivateSyms (), argIface.getPrivateBlockArgs ())) {
515514 if (blockArg == declOp.getMemref ()) {
516- omp::PrivateClauseOp privateOp =
517- SymbolTable::lookupNearestSymbolFrom<omp::PrivateClauseOp>(
518- op, cast<SymbolRefAttr>(opSym));
519- privateOp.walk ([&](omp::YieldOp yieldOp) {
520- if (!yieldOp.getResults ().size ())
521- return ;
522- // TODO Extend alias analysis if omp.yield points to
523- // block argument value
524- if (!yieldOp.getResults ()[0 ].getDefiningOp ())
525- return ;
526- llvm::TypeSwitch<Operation *>(yieldOp.getResults ()[0 ].getDefiningOp ())
527- .template Case <fir::DeclareOp, hlfir::DeclareOp>(
528- [&](auto declOp) { privateArg = declOp.getMemref (); });
529- });
530- return privateArg;
515+ return true ;
531516 }
532517 }
533- return privateArg ;
518+ return false ;
534519}
535520
536521AliasAnalysis::Source AliasAnalysis::getSource (mlir::Value v,
@@ -632,6 +617,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
632617 breakFromLoop = true ;
633618 })
634619 .Case <hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
620+ bool isPrivateItem = false ;
635621 if (omp::BlockArgOpenMPOpInterface argIface =
636622 dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp ())) {
637623 Value ompValArg;
@@ -645,19 +631,18 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
645631 omp::MapInfoOp mapInfo =
646632 llvm::cast<omp::MapInfoOp>(opArg.getDefiningOp ());
647633 ompValArg = mapInfo.getVarPtr ();
648- break ;
634+ return ;
649635 }
650636 }
651637 // If given operation does not reflect mapping item,
652638 // check private clause
653- if (!ompValArg)
654- ompValArg = getPrivateArg (argIface, targetOp, op);
639+ isPrivateItem = isPrivateArg (argIface, targetOp, op);
655640 })
656641 .template Case <omp::DistributeOp, omp::ParallelOp,
657642 omp::SectionsOp, omp::SimdOp, omp::SingleOp,
658643 omp::TaskloopOp, omp::TaskOp, omp::WsloopOp>(
659644 [&](auto privateOp) {
660- ompValArg = getPrivateArg (argIface, privateOp, op);
645+ isPrivateItem = isPrivateArg (argIface, privateOp, op);
661646 });
662647 if (ompValArg) {
663648 v = ompValArg;
@@ -707,6 +692,11 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
707692 } else {
708693 instantiationPoint = op;
709694 }
695+ if (isPrivateItem) {
696+ type = SourceKind::Allocate;
697+ breakFromLoop = true ;
698+ return ;
699+ }
710700 // TODO: Look for the fortran attributes present on the operation
711701 // Track further through the operand
712702 v = op.getMemref ();
0 commit comments