[flang-commits] [flang] [flang][OpenMP] Add alias analysis for omp private (PR #113566)

Dominik Adamski via flang-commits flang-commits at lists.llvm.org
Fri Oct 25 06:05:08 PDT 2024


================
@@ -470,20 +481,56 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
           breakFromLoop = true;
         })
         .Case<hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
-          // 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 argIface = getOpenMPBlockArgInterface(op->getParentOp());
+          if (argIface) {
+            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;
+                    }
+                  }
+                })
+                .template Case<omp::ParallelOp>([&](auto parallelOp) {
+                  // TODO private clause can be part of multiple
----------------
DominikAdamski wrote:

Fixed -> extended support for alias analysis for private clause for different operations even if Flang does not fully support private clause for all of these operations.

https://github.com/llvm/llvm-project/pull/113566


More information about the flang-commits mailing list