@@ -505,30 +505,17 @@ getAttrsFromVariable(fir::FortranVariableOpInterface var) {
505
505
}
506
506
507
507
template <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) {
511
510
if (!op.getPrivateSyms ().has_value ())
512
- return privateArg ;
511
+ return false ;
513
512
for (auto [opSym, blockArg] :
514
513
llvm::zip_equal (*op.getPrivateSyms (), argIface.getPrivateBlockArgs ())) {
515
514
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
- // TODO Extend alias analysis if omp.yield points to
521
- // block argument value
522
- if (!yieldOp.getResults ()[0 ].getDefiningOp ())
523
- return ;
524
- llvm::TypeSwitch<Operation *>(yieldOp.getResults ()[0 ].getDefiningOp ())
525
- .template Case <fir::DeclareOp, hlfir::DeclareOp>(
526
- [&](auto declOp) { privateArg = declOp.getMemref (); });
527
- });
528
- return privateArg;
515
+ return true ;
529
516
}
530
517
}
531
- return privateArg ;
518
+ return false ;
532
519
}
533
520
534
521
AliasAnalysis::Source AliasAnalysis::getSource (mlir::Value v,
@@ -631,6 +618,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
631
618
breakFromLoop = true ;
632
619
})
633
620
.Case <hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
621
+ bool isPrivateItem = false ;
634
622
if (omp::BlockArgOpenMPOpInterface argIface =
635
623
dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp ())) {
636
624
Value ompValArg;
@@ -644,19 +632,18 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
644
632
omp::MapInfoOp mapInfo =
645
633
llvm::cast<omp::MapInfoOp>(opArg.getDefiningOp ());
646
634
ompValArg = mapInfo.getVarPtr ();
647
- break ;
635
+ return ;
648
636
}
649
637
}
650
638
// If given operation does not reflect mapping item,
651
639
// check private clause
652
- if (!ompValArg)
653
- ompValArg = getPrivateArg (argIface, targetOp, op);
640
+ isPrivateItem = isPrivateArg (argIface, targetOp, op);
654
641
})
655
642
.template Case <omp::DistributeOp, omp::ParallelOp,
656
643
omp::SectionsOp, omp::SimdOp, omp::SingleOp,
657
644
omp::TaskloopOp, omp::TaskOp, omp::WsloopOp>(
658
645
[&](auto privateOp) {
659
- ompValArg = getPrivateArg (argIface, privateOp, op);
646
+ isPrivateItem = isPrivateArg (argIface, privateOp, op);
660
647
});
661
648
if (ompValArg) {
662
649
v = ompValArg;
@@ -706,6 +693,11 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
706
693
} else {
707
694
instantiationPoint = op;
708
695
}
696
+ if (isPrivateItem) {
697
+ type = SourceKind::Allocate;
698
+ breakFromLoop = true ;
699
+ return ;
700
+ }
709
701
// TODO: Look for the fortran attributes present on the operation
710
702
// Track further through the operand
711
703
v = op.getMemref ();
0 commit comments