aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2025-01-09 18:43:11 +0900
committerNAKAMURA Takumi <geek4civic@gmail.com>2025-01-09 18:43:11 +0900
commit0e1a753549b29ff1f5a190aca83b803a33b51628 (patch)
treee5578f8810c65711304128d0c8add7fa1f77b9d8 /flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
parent3c6252260ee11e3a453076b4d96ffffe20d49998 (diff)
parentbdcf47e4bcb92889665825654bb80a8bbe30379e (diff)
downloadllvm-users/chapuni/cov/single/if.zip
llvm-users/chapuni/cov/single/if.tar.gz
llvm-users/chapuni/cov/single/if.tar.bz2
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/single/ifusers/chapuni/cov/single/if
Conflicts: clang/lib/CodeGen/CoverageMappingGen.cpp
Diffstat (limited to 'flang/lib/Optimizer/Analysis/AliasAnalysis.cpp')
-rw-r--r--flang/lib/Optimizer/Analysis/AliasAnalysis.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 611f212..e33d8fa 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -505,30 +505,17 @@ getAttrsFromVariable(fir::FortranVariableOpInterface var) {
}
template <typename OMPTypeOp, typename DeclTypeOp>
-static Value getPrivateArg(omp::BlockArgOpenMPOpInterface &argIface,
- OMPTypeOp &op, DeclTypeOp &declOp) {
- Value privateArg;
+static bool isPrivateArg(omp::BlockArgOpenMPOpInterface &argIface,
+ OMPTypeOp &op, DeclTypeOp &declOp) {
if (!op.getPrivateSyms().has_value())
- return privateArg;
+ return false;
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) {
- // TODO Extend alias analysis if omp.yield points to
- // block argument value
- if (!yieldOp.getResults()[0].getDefiningOp())
- return;
- llvm::TypeSwitch<Operation *>(yieldOp.getResults()[0].getDefiningOp())
- .template Case<fir::DeclareOp, hlfir::DeclareOp>(
- [&](auto declOp) { privateArg = declOp.getMemref(); });
- });
- return privateArg;
+ return true;
}
}
- return privateArg;
+ return false;
}
AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
@@ -631,6 +618,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
breakFromLoop = true;
})
.Case<hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
+ bool isPrivateItem = false;
if (omp::BlockArgOpenMPOpInterface argIface =
dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp())) {
Value ompValArg;
@@ -644,19 +632,18 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
omp::MapInfoOp mapInfo =
llvm::cast<omp::MapInfoOp>(opArg.getDefiningOp());
ompValArg = mapInfo.getVarPtr();
- break;
+ return;
}
}
// If given operation does not reflect mapping item,
// check private clause
- if (!ompValArg)
- ompValArg = getPrivateArg(argIface, targetOp, op);
+ isPrivateItem = isPrivateArg(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);
+ isPrivateItem = isPrivateArg(argIface, privateOp, op);
});
if (ompValArg) {
v = ompValArg;
@@ -706,6 +693,11 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
} else {
instantiationPoint = op;
}
+ if (isPrivateItem) {
+ type = SourceKind::Allocate;
+ breakFromLoop = true;
+ return;
+ }
// TODO: Look for the fortran attributes present on the operation
// Track further through the operand
v = op.getMemref();