Skip to content

Revert "[flang][OpenMP] Add alias analysis for omp private" #115135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 14 additions & 54 deletions flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,29 +372,6 @@ getAttrsFromVariable(fir::FortranVariableOpInterface var) {
return attrs;
}

template <typename OMPTypeOp, typename DeclTypeOp>
static Value getPrivateArg(omp::BlockArgOpenMPOpInterface &argIface,
OMPTypeOp &op, DeclTypeOp &declOp) {
Value privateArg;
if (!op.getPrivateSyms().has_value())
return privateArg;
for (auto [opSym, blockArg] :
llvm::zip_equal(*op.getPrivateSyms(), argIface.getPrivateBlockArgs())) {
if (blockArg == declOp.getMemref()) {
omp::PrivateClauseOp privateOp =
SymbolTable::lookupNearestSymbolFrom<omp::PrivateClauseOp>(
op, cast<SymbolRefAttr>(opSym));
privateOp.walk([&](omp::YieldOp yieldOp) {
llvm::TypeSwitch<Operation *>(yieldOp.getResults()[0].getDefiningOp())
.template Case<fir::DeclareOp, hlfir::DeclareOp>(
[&](auto declOp) { privateArg = declOp.getMemref(); });
});
return privateArg;
}
}
return privateArg;
}

AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
bool getInstantiationPoint) {
auto *defOp = v.getDefiningOp();
Expand Down Expand Up @@ -493,37 +470,20 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
breakFromLoop = true;
})
.Case<hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
if (omp::BlockArgOpenMPOpInterface argIface =
dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp())) {
Value ompValArg;
llvm::TypeSwitch<Operation *>(op->getParentOp())
.template Case<omp::TargetOp>([&](auto targetOp) {
// If declare operation is inside omp target region,
// continue alias analysis outside the target region
for (auto [opArg, blockArg] : llvm::zip_equal(
targetOp.getMapVars(), argIface.getMapBlockArgs())) {
if (blockArg == op.getMemref()) {
omp::MapInfoOp mapInfo =
llvm::cast<omp::MapInfoOp>(opArg.getDefiningOp());
ompValArg = mapInfo.getVarPtr();
break;
}
}
// If given operation does not reflect mapping item,
// check private clause
if (!ompValArg)
ompValArg = getPrivateArg(argIface, targetOp, op);
})
.template Case<omp::DistributeOp, omp::ParallelOp,
omp::SectionsOp, omp::SimdOp, omp::SingleOp,
omp::TaskloopOp, omp::TaskOp, omp::WsloopOp>(
[&](auto privateOp) {
ompValArg = getPrivateArg(argIface, privateOp, op);
});
if (ompValArg) {
v = ompValArg;
defOp = ompValArg.getDefiningOp();
return;
// If declare operation is inside omp target region,
// continue alias analysis outside the target region
if (auto targetOp =
llvm::dyn_cast<omp::TargetOp>(op->getParentOp())) {
auto argIface = cast<omp::BlockArgOpenMPOpInterface>(*targetOp);
for (auto [opArg, blockArg] : llvm::zip_equal(
targetOp.getMapVars(), argIface.getMapBlockArgs())) {
if (blockArg == op.getMemref()) {
omp::MapInfoOp mapInfo =
llvm::cast<omp::MapInfoOp>(opArg.getDefiningOp());
v = mapInfo.getVarPtr();
defOp = v.getDefiningOp();
return;
}
}
}
auto varIf = llvm::cast<fir::FortranVariableOpInterface>(defOp);
Expand Down

This file was deleted.

This file was deleted.

Loading