[flang-commits] [flang] [flang] Add support to fir::cg in alias analysis (PR #127827)

via flang-commits flang-commits at lists.llvm.org
Wed Feb 19 08:55:01 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff e7bf54d62771219145171c66584578972edf0e30 89eb3b338187cb8e0ccb49e19d24d309648a0aff --extensions cpp -- flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 230f1e269c..ee43b9e155 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "flang/Optimizer/Analysis/AliasAnalysis.h"
+#include "flang/Optimizer/CodeGen/CGOps.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIROpsSupport.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
@@ -19,7 +20,6 @@
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/Value.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
-#include "flang/Optimizer/CodeGen/CGOps.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Debug.h"
@@ -592,13 +592,14 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
             followBoxData = true;
           approximateSource = true;
         })
-        .Case<fir::EmboxOp, fir::ReboxOp, fir::cg::XEmboxOp, fir::cg::XReboxOp>([&](auto op) {
-          if (followBoxData) {
-            v = op->getOperand(0);
-            defOp = v.getDefiningOp();
-          } else
-            breakFromLoop = true;
-        })
+        .Case<fir::EmboxOp, fir::ReboxOp, fir::cg::XEmboxOp, fir::cg::XReboxOp>(
+            [&](auto op) {
+              if (followBoxData) {
+                v = op->getOperand(0);
+                defOp = v.getDefiningOp();
+              } else
+                breakFromLoop = true;
+            })
         .Case<fir::LoadOp>([&](auto op) {
           // If load is inside target and it points to mapped item,
           // continue tracking.
@@ -668,7 +669,8 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
           global = llvm::cast<fir::AddrOfOp>(op).getSymbol();
           breakFromLoop = true;
         })
-        .Case<hlfir::DeclareOp, fir::DeclareOp, fir::cg::XDeclareOp>([&](auto op) {
+        .Case<hlfir::DeclareOp, fir::DeclareOp,
+              fir::cg::XDeclareOp>([&](auto op) {
           bool isPrivateItem = false;
           if (omp::BlockArgOpenMPOpInterface argIface =
                   dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp())) {
@@ -703,7 +705,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
             }
           }
           auto varIf = llvm::dyn_cast<fir::FortranVariableOpInterface>(defOp);
-          if(varIf){
+          if (varIf) {
             // While going through a declare operation collect
             // the variable attributes from it. Right now, some
             // of the attributes are duplicated, e.g. a TARGET dummy
@@ -723,7 +725,8 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
               v = defOp->getResult(0);
               // TODO: if the host associated variable is a dummy argument
               // of the host, I think, we can treat it as SourceKind::Argument
-              // for the purpose of alias analysis inside the internal procedure.
+              // for the purpose of alias analysis inside the internal
+              // procedure.
               type = SourceKind::HostAssoc;
               breakFromLoop = true;
               return;

``````````

</details>


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


More information about the flang-commits mailing list