[flang-commits] [flang] [OpenMP][Flang] Enable alias analysis inside omp target region (PR #111670)

via flang-commits flang-commits at lists.llvm.org
Wed Oct 9 08:00:42 PDT 2024


================
@@ -319,6 +330,32 @@ 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 (llvm::isa<omp::TargetOp>(op->getParentOp())) {
+            omp::TargetOp targetOp =
+                llvm::cast<omp::TargetOp>(op->getParentOp());
+            auto mapClauseOwner =
+                llvm::dyn_cast<omp::MapClauseOwningOpInterface>(
+                    targetOp.getOperation());
+            if (!mapClauseOwner) {
----------------
agozillon wrote:

I think at the moment TargetOp is always guaranteed to be a MapClauseOwningOpInterface (unless somethings changed with the definition of it or I am misunderstanding something about interfaces), so we might not require this if check unless we're worried about targetOp.getOperation() returning null! But I'll leave if you wish to keep it or not up to you as having the extra layer of safety incase something in the interface or target operation changes could be nice! :-)

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


More information about the flang-commits mailing list