Skip to content

Commit c0a7b60

Browse files
Revert "[flang][OpenMP] Add alias analysis for omp private" (#115135)
Reverts #113566 (commit id: f3025c8 ) because of regression in Fujitsu compiler test suite.
1 parent 69d0bab commit c0a7b60

File tree

3 files changed

+14
-277
lines changed

3 files changed

+14
-277
lines changed

flang/lib/Optimizer/Analysis/AliasAnalysis.cpp

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -372,29 +372,6 @@ getAttrsFromVariable(fir::FortranVariableOpInterface var) {
372372
return attrs;
373373
}
374374

375-
template <typename OMPTypeOp, typename DeclTypeOp>
376-
static Value getPrivateArg(omp::BlockArgOpenMPOpInterface &argIface,
377-
OMPTypeOp &op, DeclTypeOp &declOp) {
378-
Value privateArg;
379-
if (!op.getPrivateSyms().has_value())
380-
return privateArg;
381-
for (auto [opSym, blockArg] :
382-
llvm::zip_equal(*op.getPrivateSyms(), argIface.getPrivateBlockArgs())) {
383-
if (blockArg == declOp.getMemref()) {
384-
omp::PrivateClauseOp privateOp =
385-
SymbolTable::lookupNearestSymbolFrom<omp::PrivateClauseOp>(
386-
op, cast<SymbolRefAttr>(opSym));
387-
privateOp.walk([&](omp::YieldOp yieldOp) {
388-
llvm::TypeSwitch<Operation *>(yieldOp.getResults()[0].getDefiningOp())
389-
.template Case<fir::DeclareOp, hlfir::DeclareOp>(
390-
[&](auto declOp) { privateArg = declOp.getMemref(); });
391-
});
392-
return privateArg;
393-
}
394-
}
395-
return privateArg;
396-
}
397-
398375
AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
399376
bool getInstantiationPoint) {
400377
auto *defOp = v.getDefiningOp();
@@ -493,37 +470,20 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
493470
breakFromLoop = true;
494471
})
495472
.Case<hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
496-
if (omp::BlockArgOpenMPOpInterface argIface =
497-
dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp())) {
498-
Value ompValArg;
499-
llvm::TypeSwitch<Operation *>(op->getParentOp())
500-
.template Case<omp::TargetOp>([&](auto targetOp) {
501-
// If declare operation is inside omp target region,
502-
// continue alias analysis outside the target region
503-
for (auto [opArg, blockArg] : llvm::zip_equal(
504-
targetOp.getMapVars(), argIface.getMapBlockArgs())) {
505-
if (blockArg == op.getMemref()) {
506-
omp::MapInfoOp mapInfo =
507-
llvm::cast<omp::MapInfoOp>(opArg.getDefiningOp());
508-
ompValArg = mapInfo.getVarPtr();
509-
break;
510-
}
511-
}
512-
// If given operation does not reflect mapping item,
513-
// check private clause
514-
if (!ompValArg)
515-
ompValArg = getPrivateArg(argIface, targetOp, op);
516-
})
517-
.template Case<omp::DistributeOp, omp::ParallelOp,
518-
omp::SectionsOp, omp::SimdOp, omp::SingleOp,
519-
omp::TaskloopOp, omp::TaskOp, omp::WsloopOp>(
520-
[&](auto privateOp) {
521-
ompValArg = getPrivateArg(argIface, privateOp, op);
522-
});
523-
if (ompValArg) {
524-
v = ompValArg;
525-
defOp = ompValArg.getDefiningOp();
526-
return;
473+
// If declare operation is inside omp target region,
474+
// continue alias analysis outside the target region
475+
if (auto targetOp =
476+
llvm::dyn_cast<omp::TargetOp>(op->getParentOp())) {
477+
auto argIface = cast<omp::BlockArgOpenMPOpInterface>(*targetOp);
478+
for (auto [opArg, blockArg] : llvm::zip_equal(
479+
targetOp.getMapVars(), argIface.getMapBlockArgs())) {
480+
if (blockArg == op.getMemref()) {
481+
omp::MapInfoOp mapInfo =
482+
llvm::cast<omp::MapInfoOp>(opArg.getDefiningOp());
483+
v = mapInfo.getVarPtr();
484+
defOp = v.getDefiningOp();
485+
return;
486+
}
527487
}
528488
}
529489
auto varIf = llvm::cast<fir::FortranVariableOpInterface>(defOp);

flang/test/Analysis/AliasAnalysis/alias-analysis-omp-teams-distribute-private-ptr.mlir

Lines changed: 0 additions & 102 deletions
This file was deleted.

flang/test/Analysis/AliasAnalysis/alias-analysis-omp-teams-distribute-private.mlir

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)