[flang-commits] [flang] [flang] Characterize allocation based on MemAlloc effect instead of pattern matching (PR #166806)

Susan Tan ス-ザン タン via flang-commits flang-commits at lists.llvm.org
Fri Nov 7 13:58:22 PST 2025


https://github.com/SusanTan updated https://github.com/llvm/llvm-project/pull/166806

>From 05e4d390b46f5078c82a6f399c75cf1b034a7927 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Wed, 5 Nov 2025 19:13:01 -0800
Subject: [PATCH 01/18] first implementation

---
 .../lib/Optimizer/Analysis/AliasAnalysis.cpp  | 37 +++++++++++++++++++
 .../AliasAnalysis/cuf-alloc-source-kind.mlir  | 22 +++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir

diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 73ddd1ff80126..2fabf8d7e95bf 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -22,6 +22,7 @@
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Debug.h"
+#include "mlir/Interfaces/ViewLikeInterface.h"
 
 using namespace mlir;
 
@@ -535,6 +536,42 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
   mlir::Operation *instantiationPoint{nullptr};
   while (defOp && !breakFromLoop) {
     ty = defOp->getResultTypes()[0];
+
+    // Effect-based detection using op-scoped Allocate with conservative
+    // heuristics (ignore value-scoped signals per request).
+    if (auto memIface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defOp)) {
+      llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
+      memIface.getEffects(effects);
+      bool sawOpScopedAlloc = false;
+      for (auto &ei : effects) {
+        bool isAlloc = mlir::isa<mlir::MemoryEffects::Allocate>(ei.getEffect());
+        if (!ei.getValue() && isAlloc) {
+          sawOpScopedAlloc = true;
+        }
+      }
+      if (sawOpScopedAlloc) {
+        auto isMemoryRefLikeType = [](mlir::Type t) {
+          return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
+                 mlir::isa<mlir::LLVM::LLVMPointerType>(t);
+        };
+        bool opIsViewLike = (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(defOp);
+        bool hasMemOperands = llvm::any_of(defOp->getOperands(), [&](mlir::Value opnd) {
+          return isMemoryRefLikeType(opnd.getType());
+        });
+        if (!opIsViewLike && !hasMemOperands) {
+          for (mlir::Value res : defOp->getResults()) {
+            if (res == v && isMemoryRefLikeType(res.getType())) {
+              type = SourceKind::Allocate;
+              breakFromLoop = true;
+              break;
+            }
+          }
+          if (breakFromLoop)
+            break;
+        }
+      }
+    }
+
     llvm::TypeSwitch<Operation *>(defOp)
         .Case<hlfir::AsExprOp>([&](auto op) {
           v = op.getVar();
diff --git a/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir b/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
new file mode 100644
index 0000000000000..6a911f8ff25e3
--- /dev/null
+++ b/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
@@ -0,0 +1,22 @@
+// REQUIRES: asserts
+// RUN: fir-opt %s -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -debug-only=fir-alias-analysis --mlir-disable-threading 2>&1 | FileCheck %s
+
+// Verify that a CUF allocation is recognized as SourceKind::Allocate by
+// fir::AliasAnalysis::getSource.
+
+module {
+  func.func @_QQmain() attributes {fir.bindc_name = "TEST"} {
+    // Allocate two independent device arrays and tag the results; with
+    // op-scoped MemAlloc handling in AA, these should be classified as
+    // Allocate and not alias.
+    %a = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a1", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa1", test.ptr = "cuf_alloc_a"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+    %b = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a2", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa2", test.ptr = "cuf_alloc_b"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+    return
+  }
+}
+
+// CHECK-LABEL: Testing : "_QQmain"
+// Distinct allocations should not alias.
+// CHECK: cuf_alloc_a#0 <-> cuf_alloc_b#0: NoAlias
+
+

>From 0295bd12cfa1036e9569cbbe752668cfbb9265a3 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Wed, 5 Nov 2025 19:37:10 -0800
Subject: [PATCH 02/18] replace the main memalloc

---
 .../lib/Optimizer/Analysis/AliasAnalysis.cpp  | 91 ++++++++++++++-----
 1 file changed, 68 insertions(+), 23 deletions(-)

diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 2fabf8d7e95bf..f3496de360849 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -534,6 +534,16 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
   mlir::SymbolRefAttr global;
   Source::Attributes attributes;
   mlir::Operation *instantiationPoint{nullptr};
+  // Helper to conservatively classify a candidate value as coming from a
+  // dummy argument or as indirect when no allocation or global can be proven.
+  auto classifyFallbackFrom = [&](mlir::Value candidate) {
+    if (isDummyArgument(candidate)) {
+      defOp = nullptr;
+      v = candidate;
+    } else {
+      type = SourceKind::Indirect;
+    }
+  };
   while (defOp && !breakFromLoop) {
     ty = defOp->getResultTypes()[0];
 
@@ -578,22 +588,14 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
           defOp = v.getDefiningOp();
         })
         .Case<hlfir::AssociateOp>([&](auto op) {
+          // Do not pattern-match Allocate. Trace through the source.
           mlir::Value source = op.getSource();
-          if (fir::isa_trivial(source.getType())) {
-            // Trivial values will always use distinct temp memory,
-            // so we can classify this as Allocate and stop.
-            type = SourceKind::Allocate;
-            breakFromLoop = true;
-          } else {
-            // AssociateOp may reuse the expression storage,
-            // so we have to trace further.
-            v = source;
-            defOp = v.getDefiningOp();
-          }
+          v = source;
+          defOp = v.getDefiningOp();
         })
         .Case<fir::AllocaOp, fir::AllocMemOp>([&](auto op) {
-          // Unique memory allocation.
-          type = SourceKind::Allocate;
+          // Do not pattern-match allocations by op name; rely on memory
+          // effects classification above. Nothing to do here.
           breakFromLoop = true;
         })
         .Case<fir::ConvertOp>([&](auto op) {
@@ -665,17 +667,60 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
               type = SourceKind::Global;
             } else {
               auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
-              // TODO: Add support to fir.allocmem
-              if (auto allocOp = def.template getDefiningOp<fir::AllocaOp>()) {
-                v = def;
-                defOp = v.getDefiningOp();
-                type = SourceKind::Allocate;
-              } else if (isDummyArgument(def)) {
-                defOp = nullptr;
-                v = def;
-              } else {
-                type = SourceKind::Indirect;
+              bool classified = false;
+              if (auto defDefOp = def.getDefiningOp()) {
+                if (auto defIface =
+                        llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defDefOp)) {
+                  llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> eff;
+                  defIface.getEffects(eff);
+                  // Prefer value-scoped Allocate on the underlying storage.
+                  for (auto &e : eff) {
+                    if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
+                        e.getValue() && e.getValue() == def) {
+                      v = def;
+                      defOp = v.getDefiningOp();
+                      type = SourceKind::Allocate;
+                      classified = true;
+                      break;
+                    }
+                  }
+                  // Heuristic for op-scoped Allocate at the underlying defining op.
+                  if (!classified) {
+                    bool sawOpScopedAlloc = llvm::any_of(
+                        eff, [](auto &e) {
+                          return !e.getValue() &&
+                                 mlir::isa<mlir::MemoryEffects::Allocate>(
+                                     e.getEffect());
+                        });
+                    if (sawOpScopedAlloc) {
+                      auto isMemoryRefLikeType = [](mlir::Type t) {
+                        return fir::isa_ref_type(t) ||
+                               mlir::isa<mlir::BaseMemRefType>(t) ||
+                               mlir::isa<mlir::LLVM::LLVMPointerType>(t);
+                      };
+                      bool opIsViewLike = (bool)mlir::dyn_cast_or_null<
+                          mlir::ViewLikeOpInterface>(defDefOp);
+                      bool hasMemOperands = llvm::any_of(
+                          defDefOp->getOperands(), [&](mlir::Value opnd) {
+                            return isMemoryRefLikeType(opnd.getType());
+                          });
+                      if (!opIsViewLike && !hasMemOperands) {
+                        for (mlir::Value res : defDefOp->getResults()) {
+                          if (res == def && isMemoryRefLikeType(res.getType())) {
+                            v = def;
+                            defOp = v.getDefiningOp();
+                            type = SourceKind::Allocate;
+                            classified = true;
+                            break;
+                          }
+                        }
+                      }
+                    }
+                  }
+                }
               }
+              if (!classified)
+                classifyFallbackFrom(def);
             }
             breakFromLoop = true;
             return;

>From 4e64702e18ed3b0037a3b3f5a2aede4a7055b36d Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 08:53:46 -0800
Subject: [PATCH 03/18] refactor

---
 .../lib/Optimizer/Analysis/AliasAnalysis.cpp  | 169 +++++++++---------
 1 file changed, 81 insertions(+), 88 deletions(-)

diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index f3496de360849..94f9ec5892c58 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -28,6 +28,67 @@ using namespace mlir;
 
 #define DEBUG_TYPE "fir-alias-analysis"
 
+//===----------------------------------------------------------------------===//
+// AliasAnalysis: alias helpers
+//===----------------------------------------------------------------------===//
+
+static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
+    mlir::Value candidate, bool allowValueScoped, bool allowOpScoped,
+    mlir::Value &v, mlir::Operation *&defOp,
+    fir::AliasAnalysis::SourceKind &type) {
+  auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
+  if (!iface)
+    return false;
+
+  llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
+  iface.getEffects(effects);
+
+  if (allowValueScoped) {
+    for (mlir::MemoryEffects::EffectInstance &e : effects) {
+      if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
+          e.getValue() && e.getValue() == candidate) {
+        v = candidate;
+        defOp = op;
+        type = fir::AliasAnalysis::SourceKind::Allocate;
+        return true;
+      }
+    }
+  }
+
+  if (!allowOpScoped)
+    return false;
+
+  bool hasOpScopedAlloc = llvm::any_of(
+      effects, [](const mlir::MemoryEffects::EffectInstance &e) {
+        return !e.getValue() &&
+               mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect());
+      });
+  if (!hasOpScopedAlloc)
+    return false;
+
+  bool opIsViewLike =
+      (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(op);
+  auto isMemoryRefLikeType = [](mlir::Type type) {
+    return fir::isa_ref_type(type) || mlir::isa<mlir::BaseMemRefType>(type) ||
+           mlir::isa<mlir::LLVM::LLVMPointerType>(type);
+  };
+  bool hasMemOperands = llvm::any_of(op->getOperands(), [&](mlir::Value o) {
+    return isMemoryRefLikeType(o.getType());
+  });
+  if (opIsViewLike || hasMemOperands)
+    return false;
+
+  for (mlir::Value res : op->getResults()) {
+    if (res == candidate && isMemoryRefLikeType(res.getType())) {
+      v = candidate;
+      defOp = op;
+      type = fir::AliasAnalysis::SourceKind::Allocate;
+      return true;
+    }
+  }
+  return false;
+}
+
 //===----------------------------------------------------------------------===//
 // AliasAnalysis: alias
 //===----------------------------------------------------------------------===//
@@ -544,43 +605,22 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
       type = SourceKind::Indirect;
     }
   };
+
+  // Helper to detect memory-ref-like types.
+  auto isMemoryRefLikeType = [](mlir::Type t) {
+    return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
+           mlir::isa<mlir::LLVM::LLVMPointerType>(t);
+  };
+
   while (defOp && !breakFromLoop) {
     ty = defOp->getResultTypes()[0];
 
-    // Effect-based detection using op-scoped Allocate with conservative
-    // heuristics (ignore value-scoped signals per request).
-    if (auto memIface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defOp)) {
-      llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
-      memIface.getEffects(effects);
-      bool sawOpScopedAlloc = false;
-      for (auto &ei : effects) {
-        bool isAlloc = mlir::isa<mlir::MemoryEffects::Allocate>(ei.getEffect());
-        if (!ei.getValue() && isAlloc) {
-          sawOpScopedAlloc = true;
-        }
-      }
-      if (sawOpScopedAlloc) {
-        auto isMemoryRefLikeType = [](mlir::Type t) {
-          return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
-                 mlir::isa<mlir::LLVM::LLVMPointerType>(t);
-        };
-        bool opIsViewLike = (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(defOp);
-        bool hasMemOperands = llvm::any_of(defOp->getOperands(), [&](mlir::Value opnd) {
-          return isMemoryRefLikeType(opnd.getType());
-        });
-        if (!opIsViewLike && !hasMemOperands) {
-          for (mlir::Value res : defOp->getResults()) {
-            if (res == v && isMemoryRefLikeType(res.getType())) {
-              type = SourceKind::Allocate;
-              breakFromLoop = true;
-              break;
-            }
-          }
-          if (breakFromLoop)
-            break;
-        }
-      }
-    }
+    // Effect-based detection (op-scoped heuristic only at this level).
+    if (tryClassifyAllocateFromEffects(defOp, v,
+                                       /*allowValueScoped=*/false,
+                                       /*allowOpScoped=*/true,
+                                       v, defOp, type))
+      break;
 
     llvm::TypeSwitch<Operation *>(defOp)
         .Case<hlfir::AsExprOp>([&](auto op) {
@@ -666,61 +706,14 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
             if (global) {
               type = SourceKind::Global;
             } else {
-              auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
+              mlir::Value def = llvm::cast<mlir::Value>(boxSrc.origin.u);
               bool classified = false;
-              if (auto defDefOp = def.getDefiningOp()) {
-                if (auto defIface =
-                        llvm::dyn_cast<mlir::MemoryEffectOpInterface>(defDefOp)) {
-                  llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> eff;
-                  defIface.getEffects(eff);
-                  // Prefer value-scoped Allocate on the underlying storage.
-                  for (auto &e : eff) {
-                    if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
-                        e.getValue() && e.getValue() == def) {
-                      v = def;
-                      defOp = v.getDefiningOp();
-                      type = SourceKind::Allocate;
-                      classified = true;
-                      break;
-                    }
-                  }
-                  // Heuristic for op-scoped Allocate at the underlying defining op.
-                  if (!classified) {
-                    bool sawOpScopedAlloc = llvm::any_of(
-                        eff, [](auto &e) {
-                          return !e.getValue() &&
-                                 mlir::isa<mlir::MemoryEffects::Allocate>(
-                                     e.getEffect());
-                        });
-                    if (sawOpScopedAlloc) {
-                      auto isMemoryRefLikeType = [](mlir::Type t) {
-                        return fir::isa_ref_type(t) ||
-                               mlir::isa<mlir::BaseMemRefType>(t) ||
-                               mlir::isa<mlir::LLVM::LLVMPointerType>(t);
-                      };
-                      bool opIsViewLike = (bool)mlir::dyn_cast_or_null<
-                          mlir::ViewLikeOpInterface>(defDefOp);
-                      bool hasMemOperands = llvm::any_of(
-                          defDefOp->getOperands(), [&](mlir::Value opnd) {
-                            return isMemoryRefLikeType(opnd.getType());
-                          });
-                      if (!opIsViewLike && !hasMemOperands) {
-                        for (mlir::Value res : defDefOp->getResults()) {
-                          if (res == def && isMemoryRefLikeType(res.getType())) {
-                            v = def;
-                            defOp = v.getDefiningOp();
-                            type = SourceKind::Allocate;
-                            classified = true;
-                            break;
-                          }
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-              if (!classified)
-                classifyFallbackFrom(def);
+              if (auto defDefOp = def.getDefiningOp())
+                classified = tryClassifyAllocateFromEffects(
+                    defDefOp, def,
+                    /*allowValueScoped=*/true, /*allowOpScoped=*/true,
+                    v, defOp, type);
+              if (!classified) classifyFallbackFrom(def);
             }
             breakFromLoop = true;
             return;

>From d4ffa26657ba26970045ff31c1dec7052c7a953e Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 09:19:58 -0800
Subject: [PATCH 04/18] cleanup

---
 .../lib/Optimizer/Analysis/AliasAnalysis.cpp  | 27 ++++++++++---------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 94f9ec5892c58..2c43db7f81218 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -19,23 +19,24 @@
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/Value.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
+#include "mlir/Interfaces/ViewLikeInterface.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Debug.h"
-#include "mlir/Interfaces/ViewLikeInterface.h"
 
 using namespace mlir;
 
 #define DEBUG_TYPE "fir-alias-analysis"
 
 //===----------------------------------------------------------------------===//
-// AliasAnalysis: alias helpers
+// AliasAnalysis: allocation detection based on MemAlloc effect
 //===----------------------------------------------------------------------===//
 
-static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
-    mlir::Value candidate, bool allowValueScoped, bool allowOpScoped,
-    mlir::Value &v, mlir::Operation *&defOp,
-    fir::AliasAnalysis::SourceKind &type) {
+static bool
+tryClassifyAllocateFromEffects(mlir::Operation *op, mlir::Value candidate,
+                               bool allowValueScoped, bool allowOpScoped,
+                               mlir::Value &v, mlir::Operation *&defOp,
+                               fir::AliasAnalysis::SourceKind &type) {
   auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
   if (!iface)
     return false;
@@ -58,8 +59,8 @@ static bool tryClassifyAllocateFromEffects(mlir::Operation *op,
   if (!allowOpScoped)
     return false;
 
-  bool hasOpScopedAlloc = llvm::any_of(
-      effects, [](const mlir::MemoryEffects::EffectInstance &e) {
+  bool hasOpScopedAlloc =
+      llvm::any_of(effects, [](const mlir::MemoryEffects::EffectInstance &e) {
         return !e.getValue() &&
                mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect());
       });
@@ -618,8 +619,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
     // Effect-based detection (op-scoped heuristic only at this level).
     if (tryClassifyAllocateFromEffects(defOp, v,
                                        /*allowValueScoped=*/false,
-                                       /*allowOpScoped=*/true,
-                                       v, defOp, type))
+                                       /*allowOpScoped=*/true, v, defOp, type))
       break;
 
     llvm::TypeSwitch<Operation *>(defOp)
@@ -711,9 +711,10 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
               if (auto defDefOp = def.getDefiningOp())
                 classified = tryClassifyAllocateFromEffects(
                     defDefOp, def,
-                    /*allowValueScoped=*/true, /*allowOpScoped=*/true,
-                    v, defOp, type);
-              if (!classified) classifyFallbackFrom(def);
+                    /*allowValueScoped=*/true, /*allowOpScoped=*/true, v, defOp,
+                    type);
+              if (!classified)
+                classifyFallbackFrom(def);
             }
             breakFromLoop = true;
             return;

>From 163cda55aa4fc0fe574f73253b2b8d74b435c5b8 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 09:27:31 -0800
Subject: [PATCH 05/18] rm unused function

---
 flang/lib/Optimizer/Analysis/AliasAnalysis.cpp | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index 2c43db7f81218..b9cc5a4c8b261 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -69,18 +69,18 @@ tryClassifyAllocateFromEffects(mlir::Operation *op, mlir::Value candidate,
 
   bool opIsViewLike =
       (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(op);
-  auto isMemoryRefLikeType = [](mlir::Type type) {
+  auto isMemRefLikeType = [](mlir::Type type) {
     return fir::isa_ref_type(type) || mlir::isa<mlir::BaseMemRefType>(type) ||
            mlir::isa<mlir::LLVM::LLVMPointerType>(type);
   };
   bool hasMemOperands = llvm::any_of(op->getOperands(), [&](mlir::Value o) {
-    return isMemoryRefLikeType(o.getType());
+    return isMemRefLikeType(o.getType());
   });
   if (opIsViewLike || hasMemOperands)
     return false;
 
   for (mlir::Value res : op->getResults()) {
-    if (res == candidate && isMemoryRefLikeType(res.getType())) {
+    if (res == candidate && isMemRefLikeType(res.getType())) {
       v = candidate;
       defOp = op;
       type = fir::AliasAnalysis::SourceKind::Allocate;
@@ -607,12 +607,6 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
     }
   };
 
-  // Helper to detect memory-ref-like types.
-  auto isMemoryRefLikeType = [](mlir::Type t) {
-    return fir::isa_ref_type(t) || mlir::isa<mlir::BaseMemRefType>(t) ||
-           mlir::isa<mlir::LLVM::LLVMPointerType>(t);
-  };
-
   while (defOp && !breakFromLoop) {
     ty = defOp->getResultTypes()[0];
 

>From 538424c7820884414128ae61b56488ddf43f1f53 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 10:55:44 -0800
Subject: [PATCH 06/18] change cuf

---
 flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td | 8 +++++++-
 flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp          | 9 +++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
index e38738230ffbc..6a19dc0370f84 100644
--- a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
+++ b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
@@ -21,13 +21,14 @@ include "flang/Optimizer/Dialect/FIRAttr.td"
 include "mlir/Dialect/GPU/IR/GPUBase.td"
 include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
 include "mlir/Interfaces/LoopLikeInterface.td"
+include "mlir/Interfaces/SideEffectInterfaces.td"
 include "mlir/IR/BuiltinAttributes.td"
 
 class cuf_Op<string mnemonic, list<Trait> traits>
     : Op<CUFDialect, mnemonic, traits>;
 
 def cuf_AllocOp : cuf_Op<"alloc", [AttrSizedOperandSegments,
-    MemoryEffects<[MemAlloc]>]> {
+    MemoryEffectsOpInterface]> {
   let summary = "Allocate an object on device";
 
   let description = [{
@@ -62,6 +63,11 @@ def cuf_AllocOp : cuf_Op<"alloc", [AttrSizedOperandSegments,
       CArg<"mlir::ValueRange", "{}">:$shape,
       CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
+  let extraClassDeclaration = [{
+    void getEffects(
+        llvm::SmallVectorImpl<mlir::MemoryEffects::EffectInstance> &effects);
+  }];
+
   let hasVerifier = 1;
 }
 
diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
index 687007d957225..65283872afa34 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
@@ -24,6 +24,7 @@
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/IR/PatternMatch.h"
+#include "mlir/Interfaces/SideEffectInterfaces.h"
 #include "llvm/ADT/SmallVector.h"
 
 //===----------------------------------------------------------------------===//
@@ -66,6 +67,14 @@ static llvm::LogicalResult checkCudaAttr(Op op) {
 
 llvm::LogicalResult cuf::AllocOp::verify() { return checkCudaAttr(*this); }
 
+// Attach value-scoped MemAlloc to the result value.
+void cuf::AllocOp::getEffects(
+    llvm::SmallVectorImpl<mlir::MemoryEffects::EffectInstance> &effects) {
+  effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
+                       mlir::cast<mlir::OpResult>(getPtr()),
+                       mlir::SideEffects::DefaultResource::get());
+}
+
 //===----------------------------------------------------------------------===//
 // FreeOp
 //===----------------------------------------------------------------------===//

>From 3e216425b1c5be55b2601435eaedaee03952bf91 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:46:50 -0800
Subject: [PATCH 07/18] change to value base

---
 .../include/flang/Optimizer/Dialect/FIROps.td | 931 ++++++++----------
 .../lib/Optimizer/Analysis/AliasAnalysis.cpp  | 117 +--
 flang/lib/Optimizer/Dialect/FIROps.cpp        |  28 +
 3 files changed, 482 insertions(+), 594 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index bae52d63fda45..087eadf836e18 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -30,22 +30,22 @@ include "mlir/IR/BuiltinAttributes.td"
 // Base class for FIR operations.
 // All operations automatically get a prefix of "fir.".
 class fir_Op<string mnemonic, list<Trait> traits>
-  : Op<FIROpsDialect, mnemonic, traits>;
+    : Op<FIROpsDialect, mnemonic, traits>;
 
 // Base class for FIR operations that take a single argument
 class fir_SimpleOp<string mnemonic, list<Trait> traits>
-  : fir_Op<mnemonic, traits> {
+    : fir_Op<mnemonic, traits> {
 
   let assemblyFormat = [{
     operands attr-dict `:` functional-type(operands, results)
   }];
 }
 
-def fir_OneResultOpBuilder : OpBuilder<(ins
-    "mlir::Type":$resultType,
-    "mlir::ValueRange":$operands,
-    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-  [{
+def fir_OneResultOpBuilder
+    : OpBuilder<
+          (ins "mlir::Type":$resultType, "mlir::ValueRange":$operands,
+              CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+          [{
     if (resultType)
       $_state.addTypes(resultType);
     $_state.addOperands(operands);
@@ -53,35 +53,36 @@ def fir_OneResultOpBuilder : OpBuilder<(ins
   }]>;
 
 // Base class of FIR operations that return 1 result
-class fir_OneResultOp<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
+class fir_OneResultOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Base class of FIR operations that have 1 argument and return 1 result
-class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []> :
-    fir_SimpleOp<mnemonic, traits> {
+class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []>
+    : fir_SimpleOp<mnemonic, traits> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Whether a type is a BaseBoxType or a reference to a BaseBoxType.
-def IsBoxAddressOrValueTypePred
-        : CPred<"::fir::isBoxAddressOrValue($_self)">;
+def IsBoxAddressOrValueTypePred : CPred<"::fir::isBoxAddressOrValue($_self)">;
 def fir_BoxAddressOrValueType : Type<IsBoxAddressOrValueTypePred,
-    "fir.box or fir.class type or reference">;
+                                     "fir.box or fir.class type or reference">;
 
 def RefOfConstantSizeAggregateTypePred
-        : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
-def AnyRefOfConstantSizeAggregateType : TypeConstraint<
-      RefOfConstantSizeAggregateTypePred,
-      "a reference type to a constant size fir.array, fir.char, or fir.type">;
+    : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
+def AnyRefOfConstantSizeAggregateType
+    : TypeConstraint<RefOfConstantSizeAggregateTypePred,
+                     "a reference type to a constant size fir.array, fir.char, "
+                     "or fir.type">;
 
 //===----------------------------------------------------------------------===//
 // Memory SSA operations
 //===----------------------------------------------------------------------===//
 
-def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
-    MemoryEffects<[MemAlloc<AutomaticAllocationScopeResource>]>]> {
+def fir_AllocaOp
+    : fir_Op<"alloca", [AttrSizedOperandSegments,
+                        DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "allocate storage for a temporary on the stack given a type";
   let description = [{
     This primitive operation is used to allocate an object on the stack.  A
@@ -153,46 +154,42 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
     region and avoid them being hoisted in an alloca hoisting pass.
   }];
 
-  let arguments = (ins
-    TypeAttr:$in_type,
-    OptionalAttr<StrAttr>:$uniq_name,
-    OptionalAttr<StrAttr>:$bindc_name,
-    UnitAttr:$pinned,
-    Variadic<AnyIntegerType>:$typeparams,
-    Variadic<AnyIntegerType>:$shape
-  );
+  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
+      OptionalAttr<StrAttr>:$bindc_name, UnitAttr:$pinned,
+      Variadic<AnyIntegerType>:$typeparams, Variadic<AnyIntegerType>:$shape);
 
   let results = (outs fir_ReferenceType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      "llvm::StringRef":$bindcName, CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      "llvm::StringRef":$bindcName, "bool":$pinned,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders =
+      [OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           "llvm::StringRef":$bindcName,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           "llvm::StringRef":$bindcName, "bool":$pinned,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -212,8 +209,9 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
   }];
 }
 
-def fir_AllocMemOp : fir_Op<"allocmem",
-    [MemoryEffects<[MemAlloc<DefaultResource>]>, AttrSizedOperandSegments]> {
+def fir_AllocMemOp
+    : fir_Op<"allocmem", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
+                          AttrSizedOperandSegments]> {
   let summary = "allocate storage on the heap for an object of a given type";
 
   let description = [{
@@ -228,31 +226,28 @@ def fir_AllocMemOp : fir_Op<"allocmem",
     ```
   }];
 
-  let arguments = (ins
-    TypeAttr:$in_type,
-    OptionalAttr<StrAttr>:$uniq_name,
-    OptionalAttr<StrAttr>:$bindc_name,
-    Variadic<AnyIntegerType>:$typeparams,
-    Variadic<AnyIntegerType>:$shape
-  );
+  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
+      OptionalAttr<StrAttr>:$bindc_name, Variadic<AnyIntegerType>:$typeparams,
+      Variadic<AnyIntegerType>:$shape);
   let results = (outs fir_HeapType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-      "llvm::StringRef":$bindc_name, CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$in_type,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders =
+      [OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+           "llvm::StringRef":$bindc_name,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$in_type,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -288,8 +283,10 @@ def fir_FreeMemOp : fir_Op<"freemem", [MemoryEffects<[MemFree]>]> {
   let assemblyFormat = "$heapref attr-dict `:` qualified(type($heapref))";
 }
 
-def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
-                                          DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_LoadOp
+    : fir_OneResultOp<
+          "load", [FirAliasTagOpInterface,
+                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "load a value from a memory reference";
   let description = [{
     Load a value from a memory reference into an ssa-value (virtual register).
@@ -318,8 +315,9 @@ def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
   }];
 }
 
-def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
-                                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_StoreOp
+    : fir_Op<"store", [FirAliasTagOpInterface,
+                       DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "store an SSA-value to a memory location";
 
   let description = [{
@@ -351,7 +349,8 @@ def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
   }];
 }
 
-def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_CopyOp
+    : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "copy constant size memory";
 
   let description = [{
@@ -373,12 +372,11 @@ def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterf
   }];
 
   let arguments = (ins AnyRefOfConstantSizeAggregateType:$source,
-                       AnyRefOfConstantSizeAggregateType:$destination,
-                       OptionalAttr<UnitAttr>:$no_overlap);
+      AnyRefOfConstantSizeAggregateType:$destination,
+      OptionalAttr<UnitAttr>:$no_overlap);
 
   let builders = [OpBuilder<(ins "mlir::Value":$source,
-                                 "mlir::Value":$destination,
-                                  CArg<"bool", "false">:$no_overlap)>];
+      "mlir::Value":$destination, CArg<"bool", "false">:$no_overlap)>];
 
   let assemblyFormat = [{
     $source `to` $destination (`no_overlap` $no_overlap^)?
@@ -388,7 +386,6 @@ def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterf
   let hasVerifier = 1;
 }
 
-
 def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   let summary = [{
     save an array, box, or record function result SSA-value to a memory location
@@ -425,9 +422,8 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   }];
 
   let arguments = (ins ArrayOrBoxOrRecord:$value,
-                   Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
-                   Optional<AnyShapeType>:$shape,
-                   Variadic<AnyIntegerType>:$typeparams);
+      Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
+      Optional<AnyShapeType>:$shape, Variadic<AnyIntegerType>:$typeparams);
 
   let assemblyFormat = [{
     $value `to` $memref (`(` $shape^ `)`)? (`typeparams` $typeparams^)?
@@ -464,11 +460,8 @@ def fir_CharConvertOp : fir_Op<"char_convert", []> {
     `count` limit. These details are left as future to-dos.
   }];
 
-  let arguments = (ins
-    Arg<AnyReferenceLike, "", [MemRead]>:$from,
-    AnyIntegerType:$count,
-    Arg<AnyReferenceLike, "", [MemWrite]>:$to
-  );
+  let arguments = (ins Arg<AnyReferenceLike, "", [MemRead]>:$from,
+      AnyIntegerType:$count, Arg<AnyReferenceLike, "", [MemWrite]>:$to);
 
   let assemblyFormat = [{
     $from `for` $count `to` $to attr-dict `:` type(operands)
@@ -496,7 +489,8 @@ def fir_UndefOp : fir_OneResultOp<"undefined", [NoMemoryEffect]> {
 
   let assemblyFormat = "type($intype) attr-dict";
 
-  // Note: we allow `undef : ref<T>` since it is a possible from transformations.
+  // Note: we allow `undef : ref<T>` since it is a possible from
+  // transformations.
   let hasVerifier = 0;
 }
 
@@ -522,15 +516,14 @@ def fir_ZeroOp : fir_OneResultOp<"zero_bits", [NoMemoryEffect]> {
 // Terminator operations
 //===----------------------------------------------------------------------===//
 
-class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic, !listconcat(traits, [AttrSizedOperandSegments,
-    DeclareOpInterfaceMethods<BranchOpInterface>, Terminator])> {
+class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
+             !listconcat(traits, [AttrSizedOperandSegments,
+                                  DeclareOpInterfaceMethods<BranchOpInterface>,
+                                  Terminator])> {
 
-  let arguments = (ins
-    AnyType:$selector,
-    Variadic<AnyType>:$compareArgs,
-    Variadic<AnyType>:$targetArgs
-  );
+  let arguments = (ins AnyType:$selector, Variadic<AnyType>:$compareArgs,
+      Variadic<AnyType>:$targetArgs);
 
   let results = (outs);
 
@@ -583,16 +576,16 @@ class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
   }];
 }
 
-class fir_IntegralSwitchTerminatorOp<string mnemonic,
-    list<Trait> traits = []> : fir_SwitchTerminatorOp<mnemonic, traits> {
+class fir_IntegralSwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
+    : fir_SwitchTerminatorOp<mnemonic, traits> {
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$selector,
-    "llvm::ArrayRef<int64_t>":$compareOperands,
-    "llvm::ArrayRef<mlir::Block *>":$destinations,
-    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-    [{
+  let builders = [OpBuilder<
+      (ins "mlir::Value":$selector, "llvm::ArrayRef<int64_t>":$compareOperands,
+          "llvm::ArrayRef<mlir::Block *>":$destinations,
+          CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+          CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+      [{
       $_state.addOperands(selector);
       llvm::SmallVector<mlir::Attribute> ivalues;
       for (auto iv : compareOperands)
@@ -620,8 +613,7 @@ class fir_IntegralSwitchTerminatorOp<string mnemonic,
       $_state.addAttribute(getTargetOffsetAttr(),
         $_builder.getDenseI32ArrayAttr(argOffs));
       $_state.addAttributes(attributes);
-    }]
-  >];
+    }]>];
 
   let extraClassDeclaration = extraSwitchClassDeclaration;
 }
@@ -647,7 +639,6 @@ def fir_SelectOp : fir_IntegralSwitchTerminatorOp<"select"> {
   }];
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
-
 }
 
 def fir_SelectRankOp : fir_IntegralSwitchTerminatorOp<"select_rank"> {
@@ -693,19 +684,19 @@ def fir_SelectCaseOp : fir_SwitchTerminatorOp<"select_case"> {
   }];
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$selector,
-      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-      "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
-      "llvm::ArrayRef<mlir::Block *>":$destinations,
-      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Value":$selector,
-      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-      "llvm::ArrayRef<mlir::Value>":$cmpOpList,
-      "llvm::ArrayRef<mlir::Block *>":$destinations,
-      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders =
+      [OpBuilder<(ins "mlir::Value":$selector,
+           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+           "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
+           "llvm::ArrayRef<mlir::Block *>":$destinations,
+           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Value":$selector,
+           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+           "llvm::ArrayRef<mlir::Value>":$cmpOpList,
+           "llvm::ArrayRef<mlir::Block *>":$destinations,
+           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -737,10 +728,10 @@ def fir_SelectTypeOp : fir_SwitchTerminatorOp<"select_type"> {
 
   let skipDefaultBuilders = 1;
   let builders = [OpBuilder<(ins "mlir::Value":$selector,
-    "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
-    "llvm::ArrayRef<mlir::Block *>":$destinations,
-    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+      "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
+      "llvm::ArrayRef<mlir::Block *>":$destinations,
+      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -764,7 +755,6 @@ def fir_UnreachableOp : fir_Op<"unreachable", [Terminator]> {
   }];
 
   let assemblyFormat = [{ attr-dict }];
-
 }
 
 def fir_FirEndOp : fir_Op<"end", [Terminator, NoMemoryEffect]> {
@@ -843,17 +833,15 @@ def fir_EmboxOp : fir_Op<"embox", [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let results = (outs BoxOrClassType);
 
-  let builders = [
-    OpBuilder<(ins "llvm::ArrayRef<mlir::Type>":$resultTypes,
-      "mlir::Value":$memref, CArg<"mlir::Value", "{}">:$shape,
-      CArg<"mlir::Value", "{}">:$slice,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::Value", "{}">:$sourceBox,
-      CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
-    [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
+  let builders = [OpBuilder<
+      (ins "llvm::ArrayRef<mlir::Type>":$resultTypes, "mlir::Value":$memref,
+          CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::Value", "{}">:$slice,
+          CArg<"mlir::ValueRange", "{}">:$typeparams,
+          CArg<"mlir::Value", "{}">:$sourceBox,
+          CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
+      [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
                     typeparams, sourceBox, mlir::AffineMapAttr{},
-                    allocator_idx); }]>
-  ];
+                    allocator_idx); }]>];
 
   let assemblyFormat = [{
     $memref (`(` $shape^ `)`)? (`[` $slice^ `]`)? (`typeparams` $typeparams^)?
@@ -909,11 +897,8 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins
-    BoxOrClassType:$box,
-    Optional<AnyShapeOrShiftType>:$shape,
-    Optional<fir_SliceType>:$slice
-  );
+  let arguments = (ins BoxOrClassType:$box,
+      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice);
 
   let results = (outs BoxOrClassType);
 
@@ -925,8 +910,9 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
   let hasVerifier = 1;
 }
 
-def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
-  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ReboxAssumedRankOp
+    : fir_Op<"rebox_assumed_rank", [DeclareOpInterfaceMethods<
+                                       MemoryEffectsOpInterface>]> {
   let summary = "create an assumed-rank box given another assumed-rank box";
 
   let description = [{
@@ -947,10 +933,8 @@ def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
     ```    
   }];
 
-  let arguments = (ins
-    AnyRefOrBoxType:$box,
-    fir_LowerBoundModifierAttribute:$lbs_modifier
-  );
+  let arguments = (ins AnyRefOrBoxType:$box,
+      fir_LowerBoundModifierAttribute:$lbs_modifier);
 
   let results = (outs BoxOrClassType);
 
@@ -1171,8 +1155,8 @@ def fir_BoxEleSizeOp : fir_SimpleOneResultOp<"box_elesize", [NoMemoryEffect]> {
   let results = (outs AnyIntegerLike);
 }
 
-def fir_BoxTypeCodeOp : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]>
-{
+def fir_BoxTypeCodeOp
+    : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]> {
   let summary = "return the type code the boxed value";
 
   let description = [{
@@ -1250,7 +1234,8 @@ def fir_IsAssumedSizeOp : fir_SimpleOp<"is_assumed_size", [NoMemoryEffect]> {
   let results = (outs BoolLike);
 }
 
-def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
+def fir_AssumedSizeExtentOp
+    : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
   let summary = "get the assumed-size last extent sentinel";
 
   let description = [{
@@ -1268,7 +1253,8 @@ def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMe
   let assemblyFormat = "attr-dict `:` type(results)";
 }
 
-def fir_IsAssumedSizeExtentOp : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
+def fir_IsAssumedSizeExtentOp
+    : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
   let summary = "is value the assumed-size last extent sentinel";
 
   let description = [{
@@ -1325,8 +1311,9 @@ def fir_BoxProcHostOp : fir_SimpleOp<"boxproc_host", [NoMemoryEffect]> {
   let results = (outs fir_ReferenceType);
 }
 
-def fir_BoxRankOp : fir_SimpleOneResultOp<"box_rank",
-  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_BoxRankOp
+    : fir_SimpleOneResultOp<
+          "box_rank", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "return the number of dimensions for the boxed value";
 
   let description = [{
@@ -1407,8 +1394,10 @@ def fir_BoxTypeDescOp : fir_SimpleOneResultOp<"box_tdesc", [NoMemoryEffect]> {
 //   !- Merge the new and old values into the memory for "A"
 //   array_merge_store <updated A> to <A's address>
 
-def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
-                                            DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayLoadOp
+    : fir_Op<
+          "array_load", [AttrSizedOperandSegments,
+                         DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
 
   let summary = "Load an array as a value.";
 
@@ -1446,12 +1435,9 @@ def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
     ```
   }];
 
-  let arguments = (ins
-    AnyRefOrBox:$memref,
-    Optional<AnyShapeOrShiftType>:$shape,
-    Optional<fir_SliceType>:$slice,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins AnyRefOrBox:$memref,
+      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_SequenceType);
 
@@ -1467,8 +1453,8 @@ def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
   }];
 }
 
-def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayFetchOp
+    : fir_Op<"array_fetch", [AttrSizedOperandSegments, NoMemoryEffect]> {
 
   let summary = "Fetch the value of an element of an array value";
 
@@ -1497,11 +1483,9 @@ def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
     It is only possible to use `array_fetch` on an `array_load` result value.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs AnyType:$element);
 
@@ -1513,8 +1497,8 @@ def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
   let hasVerifier = 1;
 }
 
-def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayUpdateOp
+    : fir_Op<"array_update", [AttrSizedOperandSegments, NoMemoryEffect]> {
 
   let summary = "Update the value of an element of an array value";
 
@@ -1548,12 +1532,9 @@ def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    AnyType:$merge,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence, AnyType:$merge,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_SequenceType);
 
@@ -1565,8 +1546,8 @@ def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
   let hasVerifier = 1;
 }
 
-def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayModifyOp
+    : fir_Op<"array_modify", [AttrSizedOperandSegments, NoMemoryEffect]> {
   let summary = "Get an address for an array value to modify it.";
 
   let description = [{
@@ -1607,11 +1588,9 @@ def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_ReferenceType, fir_SequenceType);
 
@@ -1623,8 +1602,8 @@ def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
   let hasVerifier = 1;
 }
 
-def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayAccessOp
+    : fir_Op<"array_access", [AttrSizedOperandSegments, NoMemoryEffect]> {
   let summary = "Fetch the reference of an element of an array value";
 
   let description = [{
@@ -1669,11 +1648,9 @@ def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_ReferenceType:$element);
 
@@ -1707,10 +1684,7 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    fir_ReferenceType:$memref
-  );
+  let arguments = (ins fir_SequenceType:$sequence, fir_ReferenceType:$memref);
 
   let results = (outs fir_SequenceType);
 
@@ -1719,8 +1693,10 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
   }];
 }
 
-def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
-    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayMergeStoreOp
+    : fir_Op<"array_merge_store", [AttrSizedOperandSegments,
+                                   DeclareOpInterfaceMethods<
+                                       MemoryEffectsOpInterface>]> {
 
   let summary = "Store merged array value to memory.";
 
@@ -1746,13 +1722,9 @@ def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
     chained updates, `%r`, and stores the result to the array at address, `%a`.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$original,
-    fir_SequenceType:$sequence,
-    AnyRefOrBox:$memref,
-    Optional<fir_SliceType>:$slice,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$original, fir_SequenceType:$sequence,
+      AnyRefOrBox:$memref, Optional<fir_SliceType>:$slice,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let assemblyFormat = [{
     $original `,` $sequence `to` $memref (`[` $slice^ `]`)? (`typeparams`
@@ -1766,8 +1738,8 @@ def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
 // Record and array type operations
 //===----------------------------------------------------------------------===//
 
-def fir_ArrayCoorOp : fir_Op<"array_coor",
-    [NoMemoryEffect, AttrSizedOperandSegments]> {
+def fir_ArrayCoorOp
+    : fir_Op<"array_coor", [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let summary = "Find the coordinate of an element of an array";
 
@@ -1793,13 +1765,10 @@ def fir_ArrayCoorOp : fir_Op<"array_coor",
     ```
   }];
 
-  let arguments = (ins
-    AnyRefOrBox:$memref,
-    Optional<AnyShapeOrShiftType>:$shape,
-    Optional<fir_SliceType>:$slice,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins AnyRefOrBox:$memref,
+      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_ReferenceType);
 
@@ -1843,24 +1812,18 @@ def fir_CoordinateOp : fir_Op<"coordinate_of", [NoMemoryEffect]> {
     array `%h`.
   }];
 
-  let arguments = (ins
-    AnyRefOrBox:$ref,
-    Variadic<AnyCoordinateType>:$coor,
-    TypeAttr:$baseType,
-    OptionalAttr<DenseI32ArrayAttr>:$field_indices
-  );
+  let arguments = (ins AnyRefOrBox:$ref, Variadic<AnyCoordinateType>:$coor,
+      TypeAttr:$baseType, OptionalAttr<DenseI32ArrayAttr>:$field_indices);
 
   let results = (outs RefOrLLVMPtr);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::Type":$resultType,
-      "mlir::Value":$ref, "mlir::ValueRange":$coor)>,
-    OpBuilder<(ins "mlir::Type":$resultType,
-      "mlir::Value":$ref, "llvm::ArrayRef<fir::IntOrValue>":$coor)>
-  ];
+  let builders = [OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
+                      "mlir::ValueRange":$coor)>,
+                  OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
+                      "llvm::ArrayRef<fir::IntOrValue>":$coor)>];
   let extraClassDeclaration = [{
     constexpr static int32_t kDynamicIndex = std::numeric_limits<int32_t>::min();
     CoordinateIndicesAdaptor getIndices();
@@ -1887,10 +1850,7 @@ def fir_ExtractValueOp : fir_OneResultOp<"extract_value", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins
-    AnyCompositeLike:$adt,
-    ArrayAttr:$coor
-  );
+  let arguments = (ins AnyCompositeLike:$adt, ArrayAttr:$coor);
 
   let assemblyFormat = [{
     $adt `,` $coor attr-dict `:` functional-type(operands, results)
@@ -1913,16 +1873,13 @@ def fir_FieldIndexOp : fir_OneResultOp<"field_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$field_id,
-    TypeAttr:$on_type,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2074,11 +2031,8 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins
-    Variadic<AnyIntegerType>:$triples,
-    Variadic<AnyComponentType>:$fields,
-    Variadic<AnyIntegerType>:$substr
-  );
+  let arguments = (ins Variadic<AnyIntegerType>:$triples,
+      Variadic<AnyComponentType>:$fields, Variadic<AnyIntegerType>:$substr);
 
   let results = (outs fir_SliceType);
 
@@ -2087,11 +2041,9 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
       functional-type(operands, results)
   }];
 
-  let builders = [
-    OpBuilder<(ins "mlir::ValueRange":$triples,
+  let builders = [OpBuilder<(ins "mlir::ValueRange":$triples,
       CArg<"mlir::ValueRange", "{}">:$fields,
-      CArg<"mlir::ValueRange", "{}">:$substr)>
-  ];
+      CArg<"mlir::ValueRange", "{}">:$substr)>];
 
   let hasVerifier = 1;
 
@@ -2154,7 +2106,8 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
     the value 3.0.
   }];
 
-  let arguments = (ins fir_SequenceType:$seq, AnyType:$val, IndexElementsAttr:$coor);
+  let arguments = (ins fir_SequenceType:$seq, AnyType:$val,
+      IndexElementsAttr:$coor);
   let results = (outs fir_SequenceType);
 
   let assemblyFormat = [{
@@ -2171,7 +2124,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
 
 def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
   let summary =
-    "create a field index value from a LEN type parameter identifier";
+      "create a field index value from a LEN type parameter identifier";
 
   let description = [{
     Generate a LEN parameter (offset) value from a LEN parameter identifier.
@@ -2186,16 +2139,13 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$field_id,
-    TypeAttr:$on_type,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2209,9 +2159,9 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
 // Fortran loops
 //===----------------------------------------------------------------------===//
 
-def fir_ResultOp : fir_Op<"result",
-    [NoMemoryEffect, ReturnLike, Terminator,
-     ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
+def fir_ResultOp
+    : fir_Op<"result", [NoMemoryEffect, ReturnLike, Terminator,
+                        ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
   let summary = "special terminator for use in fir region operations";
 
   let description = [{
@@ -2231,17 +2181,19 @@ def fir_ResultOp : fir_Op<"result",
 
 def FirRegionTerminator : SingleBlockImplicitTerminator<"ResultOp">;
 
-class region_Op<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic,
-    !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
-        RecursiveMemoryEffects])> {
+class region_Op<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
+             !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
+                                  RecursiveMemoryEffects])> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 }
 
-def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
-    DeclareOpInterfaceMethods<LoopLikeOpInterface,
-        ["getYieldedValuesMutable"]>]> {
+def fir_DoLoopOp
+    : region_Op<
+          "do_loop", [AttrSizedOperandSegments,
+                      DeclareOpInterfaceMethods<
+                          LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
   let summary = "generalized loop operation";
   let description = [{
     Generalized high-level looping construct. This operation is similar to
@@ -2266,30 +2218,22 @@ def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
   let hasVerifier = 1;
   let hasCustomAssemblyFormat = 1;
 
-  let arguments = (ins
-    Index:$lowerBound,
-    Index:$upperBound,
-    Index:$step,
-    Variadic<AnyType>:$reduceOperands,
-    Variadic<AnyType>:$initArgs,
-    OptionalAttr<UnitAttr>:$unordered,
-    OptionalAttr<UnitAttr>:$finalValue,
-    OptionalAttr<ArrayAttr>:$reduceAttrs,
-    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
-  );
+  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
+      Variadic<AnyType>:$reduceOperands, Variadic<AnyType>:$initArgs,
+      OptionalAttr<UnitAttr>:$unordered, OptionalAttr<UnitAttr>:$finalValue,
+      OptionalAttr<ArrayAttr>:$reduceAttrs,
+      OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
-      "mlir::Value":$step, CArg<"bool", "false">:$unordered,
-      CArg<"bool", "false">:$finalCountValue,
+  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
+      "mlir::Value":$upperBound, "mlir::Value":$step,
+      CArg<"bool", "false">:$unordered, CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
       CArg<"mlir::ValueRange", "{}">:$reduceOperands,
       CArg<"llvm::ArrayRef<mlir::Attribute>", "{}">:$reduceAttrs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
-  ];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Value getInductionVar() { return getBody()->getArgument(0); }
@@ -2382,17 +2326,13 @@ def fir_IfOp
       OptionalAttr<DenseI32ArrayAttr>:$region_weights);
   let results = (outs Variadic<AnyType>:$results);
 
-  let regions = (region
-    SizedRegion<1>:$thenRegion,
-    MaxSizedRegion<1>:$elseRegion
-  );
+  let regions = (region SizedRegion<1>:$thenRegion,
+      MaxSizedRegion<1>:$elseRegion);
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
-    OpBuilder<(ins "mlir::TypeRange":$resultTypes, "mlir::Value":$cond,
-        "bool":$withElseRegion)>
-  ];
+  let builders = [OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
+                  OpBuilder<(ins "mlir::TypeRange":$resultTypes,
+                      "mlir::Value":$cond, "bool":$withElseRegion)>];
 
   let extraClassDeclaration = [{
     mlir::OpBuilder getThenBodyBuilder() {
@@ -2426,9 +2366,10 @@ def fir_IfOp
   }];
 }
 
-def fir_IterWhileOp : region_Op<"iterate_while",
-    [DeclareOpInterfaceMethods<LoopLikeOpInterface,
-        ["getYieldedValuesMutable"]>]> {
+def fir_IterWhileOp
+    : region_Op<"iterate_while",
+                [DeclareOpInterfaceMethods<
+                    LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
   let summary = "DO loop with early exit condition";
   let description = [{
     This single-entry, single-exit looping construct is useful for lowering
@@ -2457,25 +2398,18 @@ def fir_IterWhileOp : region_Op<"iterate_while",
     ```
   }];
 
-  let arguments = (ins
-    Index:$lowerBound,
-    Index:$upperBound,
-    Index:$step,
-    I1:$iterateIn,
-    Variadic<AnyType>:$initArgs,
-    OptionalAttr<UnitAttr>:$finalValue
-  );
+  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
+      I1:$iterateIn, Variadic<AnyType>:$initArgs,
+      OptionalAttr<UnitAttr>:$finalValue);
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
-      "mlir::Value":$step, "mlir::Value":$iterate,
+  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
+      "mlir::Value":$upperBound, "mlir::Value":$step, "mlir::Value":$iterate,
       CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
-  ];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFinalValueAttrNameStr() {
@@ -2528,8 +2462,9 @@ def fir_IterWhileOp : region_Op<"iterate_while",
 // Procedure call operations
 //===----------------------------------------------------------------------===//
 
-def fir_CallOp : fir_Op<"call",
-    [CallOpInterface, DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CallOp
+    : fir_Op<"call", [CallOpInterface,
+                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "call a procedure";
 
   let description = [{
@@ -2544,30 +2479,26 @@ def fir_CallOp : fir_Op<"call",
     ```
   }];
 
-  let arguments = (ins
-    OptionalAttr<SymbolRefAttr>:$callee,
-    Variadic<AnyType>:$args,
-    OptionalAttr<DictArrayAttr>:$arg_attrs,
-    OptionalAttr<DictArrayAttr>:$res_attrs,
-    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
-    OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
-    DefaultValuedAttr<Arith_FastMathAttr,
-                      "::mlir::arith::FastMathFlags::none">:$fastmath
-  );
+  let arguments = (ins OptionalAttr<SymbolRefAttr>:$callee,
+      Variadic<AnyType>:$args, OptionalAttr<DictArrayAttr>:$arg_attrs,
+      OptionalAttr<DictArrayAttr>:$res_attrs,
+      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
+      OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
+      DefaultValuedAttr<Arith_FastMathAttr,
+                        "::mlir::arith::FastMathFlags::none">:$fastmath);
   let results = (outs Variadic<AnyType>);
 
   let hasCustomAssemblyFormat = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::func::FuncOp":$callee,
-        CArg<"mlir::ValueRange", "{}">:$operands)>,
-    OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
-        "llvm::ArrayRef<mlir::Type>":$results,
-        CArg<"mlir::ValueRange", "{}">:$operands)>,
-    OpBuilder<(ins "llvm::StringRef":$callee,
-        "llvm::ArrayRef<mlir::Type>":$results,
-        CArg<"mlir::ValueRange", "{}">:$operands),
-    [{
+  let builders = [OpBuilder<(ins "mlir::func::FuncOp":$callee,
+                      CArg<"mlir::ValueRange", "{}">:$operands)>,
+                  OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
+                      "llvm::ArrayRef<mlir::Type>":$results,
+                      CArg<"mlir::ValueRange", "{}">:$operands)>,
+                  OpBuilder<(ins "llvm::StringRef":$callee,
+                                "llvm::ArrayRef<mlir::Type>":$results,
+                                CArg<"mlir::ValueRange", "{}">:$operands),
+                            [{
       build($_builder, $_state,
           mlir::SymbolRefAttr::get($_builder.getContext(), callee), results,
           operands);
@@ -2631,15 +2562,11 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$method,
-    fir_ClassType:$object,
-    Variadic<AnyType>:$args,
-    OptionalAttr<I32Attr>:$pass_arg_pos,
-    OptionalAttr<DictArrayAttr>:$arg_attrs,
-    OptionalAttr<DictArrayAttr>:$res_attrs,
-    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs
-  );
+  let arguments = (ins StrAttr:$method, fir_ClassType:$object,
+      Variadic<AnyType>:$args, OptionalAttr<I32Attr>:$pass_arg_pos,
+      OptionalAttr<DictArrayAttr>:$arg_attrs,
+      OptionalAttr<DictArrayAttr>:$res_attrs,
+      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs);
 
   let results = (outs Variadic<AnyType>:$results);
 
@@ -2683,19 +2610,18 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::StringRef":$value,
-      CArg<"std::optional<int64_t>", "{}">:$len)>,
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::ArrayRef<char>":$xlist,
-      CArg<"std::optional<int64_t>", "{}">:$len)>,
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::ArrayRef<char16_t>":$xlist,
-      CArg<"std::optional<int64_t>", "{}">:$len)>,
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::ArrayRef<char32_t>":$xlist,
-      CArg<"std::optional<int64_t>", "{}">:$len)>];
+  let builders = [OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::StringRef":$value,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>,
+                  OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::ArrayRef<char>":$xlist,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>,
+                  OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::ArrayRef<char16_t>":$xlist,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>,
+                  OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::ArrayRef<char32_t>":$xlist,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>];
 
   let extraClassDeclaration = [{
     static constexpr const char *size() { return "size"; }
@@ -2718,62 +2644,67 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
 
 // Complex operations
 
-class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic,
-           !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
-    Results<(outs AnyType:$result)> {
+class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
+             !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
+      Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
-      fir_Op<mnemonic,
+class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
              !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
       Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
-      fir_UnaryArithmeticOp<mnemonic, traits>,
+class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_UnaryArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$operand)>;
 
 def fir_NegcOp : ComplexUnaryArithmeticOp<"negc">;
 
-class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []> :
-      fir_ArithmeticOp<mnemonic, traits>,
+class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_ArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
           DefaultValuedAttr<Arith_FastMathAttr,
                             "::mlir::arith::FastMathFlags::none">:$fastmath)>;
 
-def fir_AddcOp : ComplexArithmeticOp<"addc",
-    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_SubcOp : ComplexArithmeticOp<"subc",
-    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_MulcOp : ComplexArithmeticOp<"mulc",
-    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_DivcOp : ComplexArithmeticOp<"divc",
-    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_AddcOp
+    : ComplexArithmeticOp<"addc", [Commutative, DeclareOpInterfaceMethods<
+                                                    ArithFastMathInterface>]>;
+def fir_SubcOp
+    : ComplexArithmeticOp<
+          "subc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_MulcOp
+    : ComplexArithmeticOp<"mulc", [Commutative, DeclareOpInterfaceMethods<
+                                                    ArithFastMathInterface>]>;
+def fir_DivcOp
+    : ComplexArithmeticOp<
+          "divc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
 // Pow is a builtin call and not a primitive
 
-def fir_CmpcOp : fir_Op<"cmpc",
-    [NoMemoryEffect, SameTypeOperands, SameOperandsAndResultShape,
-    DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CmpcOp
+    : fir_Op<"cmpc", [NoMemoryEffect, SameTypeOperands,
+                      SameOperandsAndResultShape,
+                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "complex floating-point comparison operator";
 
   let description = [{
     A complex comparison to handle complex types found in FIR.
   }];
 
-  let arguments = (ins
-      AnyFirComplex:$lhs,
-      AnyFirComplex:$rhs,
-      DefaultValuedAttr<Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath);
+  let arguments = (ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
+      DefaultValuedAttr<Arith_FastMathAttr,
+                        "::mlir::arith::FastMathFlags::none">:$fastmath);
 
   let results = (outs AnyLogicalLike);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "mlir::arith::CmpFPredicate":$predicate,
-    "mlir::Value":$lhs, "mlir::Value":$rhs), [{
+                                "mlir::Value":$lhs, "mlir::Value":$rhs),
+                            [{
       buildCmpCOp($_builder, $_state, predicate, lhs, rhs);
   }]>];
 
@@ -2873,12 +2804,15 @@ def fir_ConvertOp
   let hasCanonicalizer = 1;
 }
 
-def FortranTypeAttr : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
-    Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
-              "fir::UnsignedType, fir::LogicalType, mlir::FloatType, "
-              "mlir::ComplexType, "
-              "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self).getValue())"
-    >]>]>, "Fortran surface type"> {
+def FortranTypeAttr
+    : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
+                Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
+                          "fir::UnsignedType, fir::LogicalType, "
+                          "mlir::FloatType, "
+                          "mlir::ComplexType, "
+                          "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self)."
+                          "getValue())">]>]>,
+           "Fortran surface type"> {
   let storageType = [{ ::mlir::TypeAttr }];
   let returnType = "mlir::Type";
   let convertFromStorage = "mlir::cast<mlir::Type>($_self.getValue())";
@@ -2904,8 +2838,9 @@ def fir_TypeDescOp : fir_OneResultOp<"type_desc", [NoMemoryEffect]> {
   let builders = [OpBuilder<(ins "mlir::TypeAttr":$inty)>];
 }
 
-def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
-    [NoMemoryEffect, SameOperandsAndResultType]> {
+def fir_NoReassocOp
+    : fir_OneResultOp<"no_reassoc", [NoMemoryEffect,
+                                     SameOperandsAndResultType]> {
   let summary = "synthetic op to prevent reassociation";
   let description = [{
     Primitive operation meant to intrusively prevent operator reassociation.
@@ -2928,9 +2863,9 @@ def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
   let assemblyFormat = "$val attr-dict `:` type($val)";
 }
 
-class AtMostRegion<int numBlocks> : Region<
-  CPred<"$_self.getBlocks().size() <= " # numBlocks>,
-  "region with " # numBlocks # " blocks">;
+class AtMostRegion<int numBlocks>
+    : Region<CPred<"$_self.getBlocks().size() <= "#numBlocks>,
+             "region with "#numBlocks#" blocks">;
 
 def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
   let summary = "Global data";
@@ -2955,43 +2890,37 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$sym_name,
-    SymbolRefAttr:$symref,
-    TypeAttr:$type,
-    OptionalAttr<AnyAttr>:$initVal,
-    OptionalAttr<UnitAttr>:$constant,
-    OptionalAttr<UnitAttr>:$target,
-    OptionalAttr<StrAttr>:$linkName,
-    OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
-    OptionalAttr<I64Attr>:$alignment
-  );
+  let arguments = (ins StrAttr:$sym_name, SymbolRefAttr:$symref, TypeAttr:$type,
+      OptionalAttr<AnyAttr>:$initVal, OptionalAttr<UnitAttr>:$constant,
+      OptionalAttr<UnitAttr>:$target, OptionalAttr<StrAttr>:$linkName,
+      OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
+      OptionalAttr<I64Attr>:$alignment);
 
   let regions = (region AtMostRegion<1>:$region);
 
   let hasCustomAssemblyFormat = 1;
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-      "bool":$isTarget, "mlir::Type":$type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-      CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-      "bool":$isTarget,
-      "mlir::Type":$type, CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-      "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-      "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
-      CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+  let builders =
+      [OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+           "bool":$isTarget, "mlir::Type":$type,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+           CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+           "bool":$isTarget, "mlir::Type":$type,
+           CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+           "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+           "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
+           CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
   ];
 
   let extraClassDeclaration = [{
@@ -3056,8 +2985,8 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
 
 def ImplicitFirTerminator : SingleBlockImplicitTerminator<"FirEndOp">;
 
-def fir_TypeInfoOp : fir_Op<"type_info",
-    [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
+def fir_TypeInfoOp
+    : fir_Op<"type_info", [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
   let summary = "Derived type information";
 
   let description = [{
@@ -3087,26 +3016,18 @@ def fir_TypeInfoOp : fir_Op<"type_info",
     ```
   }];
 
-  let arguments = (ins
-    SymbolNameAttr:$sym_name,
-    TypeAttr:$type,
-    OptionalAttr<TypeAttr>:$parent_type,
-    UnitAttr:$no_init,
-    UnitAttr:$no_destroy,
-    UnitAttr:$no_final
-  );
+  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type,
+      OptionalAttr<TypeAttr>:$parent_type, UnitAttr:$no_init,
+      UnitAttr:$no_destroy, UnitAttr:$no_final);
 
   let hasVerifier = 1;
 
-  let regions = (region
-    MaxSizedRegion<1>:$dispatch_table,
-    MaxSizedRegion<1>:$component_info
-  );
+  let regions = (region MaxSizedRegion<1>:$dispatch_table,
+      MaxSizedRegion<1>:$component_info);
 
-  let builders = [
-    OpBuilder<(ins "fir::RecordType":$type, "fir::RecordType":$parent_type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>
-  ];
+  let builders = [OpBuilder<(ins "fir::RecordType":$type,
+      "fir::RecordType":$parent_type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>];
 
   let assemblyFormat = [{
     $sym_name (`noinit` $no_init^)? (`nodestroy` $no_destroy^)?
@@ -3157,7 +3078,8 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"TypeInfoOp">]> {
 }
 
 def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
-  let summary = "define extra information about a component inside fir.type_info";
+  let summary =
+      "define extra information about a component inside fir.type_info";
 
   let description = [{
     ```
@@ -3165,17 +3087,17 @@ def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$name,
-    OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
-    OptionalAttr<FlatSymbolRefAttr>:$init_val
-  );
+  let arguments = (ins StrAttr:$name,
+      OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
+      OptionalAttr<FlatSymbolRefAttr>:$init_val);
 
-  let assemblyFormat = "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
+  let assemblyFormat =
+      "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
 }
 
 def fir_AbsentOp : fir_OneResultOp<"absent", [NoMemoryEffect]> {
-  let summary = "create value to be passed for absent optional function argument";
+  let summary =
+      "create value to be passed for absent optional function argument";
   let description = [{
     Given the type of a function argument, create a value that will signal that
     an optional argument is absent in the call. On the caller side, fir.is_present
@@ -3316,10 +3238,7 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     The derived_type field cannot be used when the input to this op is a reference to a fir.boxchar.
   }];
 
-  let arguments = (ins
-    AnyReferenceLike:$box_ref,
-    fir_BoxFieldAttr:$field
-  );
+  let arguments = (ins AnyReferenceLike:$box_ref, fir_BoxFieldAttr:$field);
 
   let results = (outs RefOrLLVMPtr);
   let hasVerifier = 1;
@@ -3328,13 +3247,12 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     $box_ref $field attr-dict `:` functional-type(operands, results)
   }];
 
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$boxRef, "fir::BoxFieldAttr":$field)>
-  ];
+  let builders = [OpBuilder<(ins "mlir::Value":$boxRef,
+      "fir::BoxFieldAttr":$field)>];
 }
 
-def fir_DummyScopeOp : fir_Op<"dummy_scope",
-    [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
+def fir_DummyScopeOp
+    : fir_Op<"dummy_scope", [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
   let summary = "Define a scope for dummy arguments";
 
   let description = [{
@@ -3559,9 +3477,9 @@ def fir_BoxTotalElementsOp
   let hasCanonicalizer = 1;
 }
 
-def YieldOp : fir_Op<"yield",
-    [Pure, ReturnLike, Terminator,
-     ParentOneOf<["LocalitySpecifierOp", "DeclareReductionOp"]>]> {
+def YieldOp : fir_Op<"yield", [Pure, ReturnLike, Terminator,
+                               ParentOneOf<["LocalitySpecifierOp",
+                                            "DeclareReductionOp"]>]> {
   let summary = "loop yield and termination operation";
   let description = [{
     "fir.yield" yields SSA values from a fir dialect op region and
@@ -3571,9 +3489,7 @@ def YieldOp : fir_Op<"yield",
 
   let arguments = (ins Variadic<AnyType>:$results);
 
-  let builders = [
-    OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
-  ];
+  let builders = [OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>];
 
   let assemblyFormat = "( `(` $results^ `:` type($results) `)` )? attr-dict";
 }
@@ -3651,13 +3567,11 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
     corresponds to a `local` or a `local_init` specifier.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name,
-                       TypeAttrOf<AnyType>:$type,
-                       LocalitySpecifierTypeAttr:$locality_specifier_type);
+  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttrOf<AnyType>:$type,
+      LocalitySpecifierTypeAttr:$locality_specifier_type);
 
-  let regions = (region AnyRegion:$init_region,
-                        AnyRegion:$copy_region,
-                        AnyRegion:$dealloc_region);
+  let regions = (region AnyRegion:$init_region, AnyRegion:$copy_region,
+      AnyRegion:$dealloc_region);
 
   let assemblyFormat = [{
     $locality_specifier_type $sym_name `:` $type
@@ -3699,8 +3613,8 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
   let hasRegionVerifier = 1;
 }
 
-def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
-                                                         Symbol]> {
+def fir_DeclareReductionOp
+    : fir_Op<"declare_reduction", [IsolatedFromAbove, Symbol]> {
   let summary = "declares a reduction kind";
   let description = [{
     Note: this operation is adapted from omp::DeclareReductionOp. There is a lot
@@ -3745,14 +3659,11 @@ def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
     match the parent operation's results.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name,
-                       TypeAttr:$type);
+  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type);
 
   let regions = (region MaxSizedRegion<1>:$allocRegion,
-                        AnyRegion:$initializerRegion,
-                        AnyRegion:$reductionRegion,
-                        AnyRegion:$atomicReductionRegion,
-                        AnyRegion:$cleanupRegion);
+      AnyRegion:$initializerRegion, AnyRegion:$reductionRegion,
+      AnyRegion:$atomicReductionRegion, AnyRegion:$cleanupRegion);
 
   let assemblyFormat = "$sym_name `:` $type attr-dict-with-keyword "
                        "( `alloc` $allocRegion^ )? "
@@ -3796,8 +3707,8 @@ def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
   let hasRegionVerifier = 1;
 }
 
-def fir_DoConcurrentOp : fir_Op<"do_concurrent",
-    [SingleBlock, AutomaticAllocationScope]> {
+def fir_DoConcurrentOp
+    : fir_Op<"do_concurrent", [SingleBlock, AutomaticAllocationScope]> {
   let summary = "do concurrent loop wrapper";
 
   let description = [{
@@ -3828,35 +3739,34 @@ def fir_DoConcurrentOp : fir_Op<"do_concurrent",
 }
 
 def fir_LocalSpecifier {
-  dag arguments = (ins
-    Variadic<AnyType>:$local_vars,
-    OptionalAttr<SymbolRefArrayAttr>:$local_syms
-  );
+  dag arguments = (ins Variadic<AnyType>:$local_vars,
+      OptionalAttr<SymbolRefArrayAttr>:$local_syms);
 }
 
 def fir_ReduceSpecifier {
-  dag arguments = (ins
-    Variadic<AnyType>:$reduce_vars,
-    OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
-
-    // This introduces redundency in how reductions are modelled. In particular,
-    // a single reduction is represented by 2 attributes:
-    //
-    // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
-    // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
-    //
-    // The first makes it easier to map `do concurrent` to parallization models
-    // (e.g. OpenMP and OpenACC) while the second makes it easier to map it to
-    // nests of `fir.do_loop ... unodered` ops.
-    OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
-    OptionalAttr<ArrayAttr>:$reduce_attrs
-  );
-}
-
-def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
-    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopLikeOpInterface,
-                                                         ["getLoopInductionVars"]>,
-     Terminator, NoTerminator, SingleBlock, ParentOneOf<["DoConcurrentOp"]>]> {
+  dag arguments = (ins Variadic<AnyType>:$reduce_vars,
+      OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
+
+      // This introduces redundency in how reductions are modelled. In
+      // particular, a single reduction is represented by 2 attributes:
+      //
+      // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
+      // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
+      //
+      // The first makes it easier to map `do concurrent` to parallization
+      // models (e.g. OpenMP and OpenACC) while the second makes it easier to
+      // map it to nests of `fir.do_loop ... unodered` ops.
+      OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
+      OptionalAttr<ArrayAttr>:$reduce_attrs);
+}
+
+def fir_DoConcurrentLoopOp
+    : fir_Op<"do_concurrent.loop",
+             [AttrSizedOperandSegments,
+              DeclareOpInterfaceMethods<
+                  LoopLikeOpInterface, ["getLoopInductionVars"]>,
+              Terminator, NoTerminator, SingleBlock,
+              ParentOneOf<["DoConcurrentOp"]>]> {
   let summary = "do concurrent loop";
 
   let description = [{
@@ -3904,16 +3814,11 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
       LLVM.
   }];
 
-  defvar opArgs = (ins
-    Variadic<Index>:$lowerBound,
-    Variadic<Index>:$upperBound,
-    Variadic<Index>:$step,
-    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
-  );
+  defvar opArgs = (ins Variadic<Index>:$lowerBound, Variadic<Index>:$upperBound,
+      Variadic<Index>:$step, OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
 
-  let arguments = !con(opArgs,
-    fir_LocalSpecifier.arguments,
-    fir_ReduceSpecifier.arguments);
+  let arguments =
+      !con(opArgs, fir_LocalSpecifier.arguments, fir_ReduceSpecifier.arguments);
 
   let regions = (region SizedRegion<1>:$region);
 
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index b9cc5a4c8b261..c62bad5fc9c0a 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -19,7 +19,6 @@
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/Value.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
-#include "mlir/Interfaces/ViewLikeInterface.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Debug.h"
@@ -28,59 +27,23 @@ using namespace mlir;
 
 #define DEBUG_TYPE "fir-alias-analysis"
 
-//===----------------------------------------------------------------------===//
-// AliasAnalysis: allocation detection based on MemAlloc effect
-//===----------------------------------------------------------------------===//
-
-static bool
-tryClassifyAllocateFromEffects(mlir::Operation *op, mlir::Value candidate,
-                               bool allowValueScoped, bool allowOpScoped,
-                               mlir::Value &v, mlir::Operation *&defOp,
-                               fir::AliasAnalysis::SourceKind &type) {
+// Classify 'candidate' as an allocation based on value-scoped Allocate effects
+// attached by its defining operation 'op'. Returns true if classified and fills
+// out 'v', 'defOp' and 'type'.
+static bool classifyAllocateFromEffects(mlir::Operation *op,
+                                        mlir::Value candidate, mlir::Value &v,
+                                        mlir::Operation *&defOp,
+                                        fir::AliasAnalysis::SourceKind &type) {
+  if (!op)
+    return false;
   auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
   if (!iface)
     return false;
-
   llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
   iface.getEffects(effects);
-
-  if (allowValueScoped) {
-    for (mlir::MemoryEffects::EffectInstance &e : effects) {
-      if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
-          e.getValue() && e.getValue() == candidate) {
-        v = candidate;
-        defOp = op;
-        type = fir::AliasAnalysis::SourceKind::Allocate;
-        return true;
-      }
-    }
-  }
-
-  if (!allowOpScoped)
-    return false;
-
-  bool hasOpScopedAlloc =
-      llvm::any_of(effects, [](const mlir::MemoryEffects::EffectInstance &e) {
-        return !e.getValue() &&
-               mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect());
-      });
-  if (!hasOpScopedAlloc)
-    return false;
-
-  bool opIsViewLike =
-      (bool)mlir::dyn_cast_or_null<mlir::ViewLikeOpInterface>(op);
-  auto isMemRefLikeType = [](mlir::Type type) {
-    return fir::isa_ref_type(type) || mlir::isa<mlir::BaseMemRefType>(type) ||
-           mlir::isa<mlir::LLVM::LLVMPointerType>(type);
-  };
-  bool hasMemOperands = llvm::any_of(op->getOperands(), [&](mlir::Value o) {
-    return isMemRefLikeType(o.getType());
-  });
-  if (opIsViewLike || hasMemOperands)
-    return false;
-
-  for (mlir::Value res : op->getResults()) {
-    if (res == candidate && isMemRefLikeType(res.getType())) {
+  for (mlir::MemoryEffects::EffectInstance &e : effects) {
+    if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
+        e.getValue() && e.getValue() == candidate) {
       v = candidate;
       defOp = op;
       type = fir::AliasAnalysis::SourceKind::Allocate;
@@ -596,41 +559,29 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
   mlir::SymbolRefAttr global;
   Source::Attributes attributes;
   mlir::Operation *instantiationPoint{nullptr};
-  // Helper to conservatively classify a candidate value as coming from a
-  // dummy argument or as indirect when no allocation or global can be proven.
-  auto classifyFallbackFrom = [&](mlir::Value candidate) {
-    if (isDummyArgument(candidate)) {
-      defOp = nullptr;
-      v = candidate;
-    } else {
-      type = SourceKind::Indirect;
-    }
-  };
-
   while (defOp && !breakFromLoop) {
     ty = defOp->getResultTypes()[0];
-
-    // Effect-based detection (op-scoped heuristic only at this level).
-    if (tryClassifyAllocateFromEffects(defOp, v,
-                                       /*allowValueScoped=*/false,
-                                       /*allowOpScoped=*/true, v, defOp, type))
+    // Value-scoped allocation detection via effects.
+    if (classifyAllocateFromEffects(defOp, v, v, defOp, type))
       break;
-
     llvm::TypeSwitch<Operation *>(defOp)
         .Case<hlfir::AsExprOp>([&](auto op) {
           v = op.getVar();
           defOp = v.getDefiningOp();
         })
         .Case<hlfir::AssociateOp>([&](auto op) {
-          // Do not pattern-match Allocate. Trace through the source.
           mlir::Value source = op.getSource();
-          v = source;
-          defOp = v.getDefiningOp();
-        })
-        .Case<fir::AllocaOp, fir::AllocMemOp>([&](auto op) {
-          // Do not pattern-match allocations by op name; rely on memory
-          // effects classification above. Nothing to do here.
-          breakFromLoop = true;
+          if (fir::isa_trivial(source.getType())) {
+            // Trivial values will always use distinct temp memory,
+            // so we can classify this as Allocate and stop.
+            type = SourceKind::Allocate;
+            breakFromLoop = true;
+          } else {
+            // AssociateOp may reuse the expression storage,
+            // so we have to trace further.
+            v = source;
+            defOp = v.getDefiningOp();
+          }
         })
         .Case<fir::ConvertOp>([&](auto op) {
           // Skip ConvertOp's and track further through the operand.
@@ -700,15 +651,19 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
             if (global) {
               type = SourceKind::Global;
             } else {
-              mlir::Value def = llvm::cast<mlir::Value>(boxSrc.origin.u);
+              auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
               bool classified = false;
               if (auto defDefOp = def.getDefiningOp())
-                classified = tryClassifyAllocateFromEffects(
-                    defDefOp, def,
-                    /*allowValueScoped=*/true, /*allowOpScoped=*/true, v, defOp,
-                    type);
-              if (!classified)
-                classifyFallbackFrom(def);
+                classified =
+                    classifyAllocateFromEffects(defDefOp, def, v, defOp, type);
+              if (!classified) {
+                if (isDummyArgument(def)) {
+                  defOp = nullptr;
+                  v = def;
+                } else {
+                  type = SourceKind::Indirect;
+                }
+              }
             }
             breakFromLoop = true;
             return;
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 4f97acaa88b7a..9d182a699c634 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -285,6 +285,21 @@ llvm::LogicalResult fir::AllocaOp::verify() {
   return mlir::success();
 }
 
+void fir::AllocaOp::getEffects(
+    llvm::SmallVectorImpl<
+        mlir::SideEffects::EffectInstance<mlir::MemoryEffects::Effect>>
+        &effects) {
+  // Value-scoped Allocate for AA.
+  effects.emplace_back(
+      mlir::MemoryEffects::Allocate::get(),
+      mlir::cast<mlir::OpResult>(getOperation()->getResult(0)),
+      mlir::SideEffects::AutomaticAllocationScopeResource::get());
+  // Preserve previous behavior: op-scoped Allocate for passes relying on it.
+  effects.emplace_back(
+      mlir::MemoryEffects::Allocate::get(),
+      mlir::SideEffects::AutomaticAllocationScopeResource::get());
+}
+
 bool fir::AllocaOp::ownsNestedAlloca(mlir::Operation *op) {
   return op->hasTrait<mlir::OpTrait::IsIsolatedFromAbove>() ||
          op->hasTrait<mlir::OpTrait::AutomaticAllocationScope>() ||
@@ -384,6 +399,19 @@ llvm::LogicalResult fir::AllocMemOp::verify() {
   return mlir::success();
 }
 
+void fir::AllocMemOp::getEffects(
+    llvm::SmallVectorImpl<
+        mlir::SideEffects::EffectInstance<mlir::MemoryEffects::Effect>>
+        &effects) {
+  // Value-scoped Allocate for AA.
+  effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
+                       mlir::cast<mlir::OpResult>(getOperation()->getResult(0)),
+                       mlir::SideEffects::DefaultResource::get());
+  // Preserve previous behavior: op-scoped Allocate for passes relying on it.
+  effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
+                       mlir::SideEffects::DefaultResource::get());
+}
+
 //===----------------------------------------------------------------------===//
 // ArrayCoorOp
 //===----------------------------------------------------------------------===//

>From fb74ffdee0191b77671d930fb07ff0d65116ff09 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:48:11 -0800
Subject: [PATCH 08/18] remove cuf

---
 flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp    |  8 -------
 .../AliasAnalysis/cuf-alloc-source-kind.mlir  | 22 -------------------
 2 files changed, 30 deletions(-)
 delete mode 100644 flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir

diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
index 65283872afa34..a43c718a85562 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
@@ -67,14 +67,6 @@ static llvm::LogicalResult checkCudaAttr(Op op) {
 
 llvm::LogicalResult cuf::AllocOp::verify() { return checkCudaAttr(*this); }
 
-// Attach value-scoped MemAlloc to the result value.
-void cuf::AllocOp::getEffects(
-    llvm::SmallVectorImpl<mlir::MemoryEffects::EffectInstance> &effects) {
-  effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
-                       mlir::cast<mlir::OpResult>(getPtr()),
-                       mlir::SideEffects::DefaultResource::get());
-}
-
 //===----------------------------------------------------------------------===//
 // FreeOp
 //===----------------------------------------------------------------------===//
diff --git a/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir b/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
deleted file mode 100644
index 6a911f8ff25e3..0000000000000
--- a/flang/test/Analysis/AliasAnalysis/cuf-alloc-source-kind.mlir
+++ /dev/null
@@ -1,22 +0,0 @@
-// REQUIRES: asserts
-// RUN: fir-opt %s -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' -debug-only=fir-alias-analysis --mlir-disable-threading 2>&1 | FileCheck %s
-
-// Verify that a CUF allocation is recognized as SourceKind::Allocate by
-// fir::AliasAnalysis::getSource.
-
-module {
-  func.func @_QQmain() attributes {fir.bindc_name = "TEST"} {
-    // Allocate two independent device arrays and tag the results; with
-    // op-scoped MemAlloc handling in AA, these should be classified as
-    // Allocate and not alias.
-    %a = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a1", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa1", test.ptr = "cuf_alloc_a"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
-    %b = cuf.alloc !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "a2", data_attr = #cuf.cuda<device>, uniq_name = "_QFEa2", test.ptr = "cuf_alloc_b"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
-    return
-  }
-}
-
-// CHECK-LABEL: Testing : "_QQmain"
-// Distinct allocations should not alias.
-// CHECK: cuf_alloc_a#0 <-> cuf_alloc_b#0: NoAlias
-
-

>From 7c380e1610180d3ca41964125ada877f393864a6 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:49:57 -0800
Subject: [PATCH 09/18] remove headerfile

---
 flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
index a43c718a85562..687007d957225 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
@@ -24,7 +24,6 @@
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/IR/PatternMatch.h"
-#include "mlir/Interfaces/SideEffectInterfaces.h"
 #include "llvm/ADT/SmallVector.h"
 
 //===----------------------------------------------------------------------===//

>From 99228e37435ab10c54d8168688b1555bdb717b0d Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:51:24 -0800
Subject: [PATCH 10/18] rm addition in cufops.td

---
 flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
index 6a19dc0370f84..a1c43e45117e8 100644
--- a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
+++ b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
@@ -28,7 +28,7 @@ class cuf_Op<string mnemonic, list<Trait> traits>
     : Op<CUFDialect, mnemonic, traits>;
 
 def cuf_AllocOp : cuf_Op<"alloc", [AttrSizedOperandSegments,
-    MemoryEffectsOpInterface]> {
+    MemoryEffects<[MemAlloc]>]> {
   let summary = "Allocate an object on device";
 
   let description = [{
@@ -63,11 +63,6 @@ def cuf_AllocOp : cuf_Op<"alloc", [AttrSizedOperandSegments,
       CArg<"mlir::ValueRange", "{}">:$shape,
       CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
-  let extraClassDeclaration = [{
-    void getEffects(
-        llvm::SmallVectorImpl<mlir::MemoryEffects::EffectInstance> &effects);
-  }];
-
   let hasVerifier = 1;
 }
 

>From caa0cde2433ff89c3548fcffe6f65850e07d90b9 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:52:42 -0800
Subject: [PATCH 11/18] remove include

---
 flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td | 1 -
 1 file changed, 1 deletion(-)

diff --git a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
index a1c43e45117e8..e38738230ffbc 100644
--- a/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
+++ b/flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td
@@ -21,7 +21,6 @@ include "flang/Optimizer/Dialect/FIRAttr.td"
 include "mlir/Dialect/GPU/IR/GPUBase.td"
 include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
 include "mlir/Interfaces/LoopLikeInterface.td"
-include "mlir/Interfaces/SideEffectInterfaces.td"
 include "mlir/IR/BuiltinAttributes.td"
 
 class cuf_Op<string mnemonic, list<Trait> traits>

>From 1382ceeb3af4419a48a04ab4aee05e52ac1212fa Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 13:58:30 -0800
Subject: [PATCH 12/18] tweak on FIROps.td

---
 .../include/flang/Optimizer/Dialect/FIROps.td | 931 ++++++++++--------
 1 file changed, 513 insertions(+), 418 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 087eadf836e18..98448d2591b29 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -30,22 +30,22 @@ include "mlir/IR/BuiltinAttributes.td"
 // Base class for FIR operations.
 // All operations automatically get a prefix of "fir.".
 class fir_Op<string mnemonic, list<Trait> traits>
-    : Op<FIROpsDialect, mnemonic, traits>;
+  : Op<FIROpsDialect, mnemonic, traits>;
 
 // Base class for FIR operations that take a single argument
 class fir_SimpleOp<string mnemonic, list<Trait> traits>
-    : fir_Op<mnemonic, traits> {
+  : fir_Op<mnemonic, traits> {
 
   let assemblyFormat = [{
     operands attr-dict `:` functional-type(operands, results)
   }];
 }
 
-def fir_OneResultOpBuilder
-    : OpBuilder<
-          (ins "mlir::Type":$resultType, "mlir::ValueRange":$operands,
-              CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-          [{
+def fir_OneResultOpBuilder : OpBuilder<(ins
+    "mlir::Type":$resultType,
+    "mlir::ValueRange":$operands,
+    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+  [{
     if (resultType)
       $_state.addTypes(resultType);
     $_state.addOperands(operands);
@@ -53,36 +53,35 @@ def fir_OneResultOpBuilder
   }]>;
 
 // Base class of FIR operations that return 1 result
-class fir_OneResultOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
+class fir_OneResultOp<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Base class of FIR operations that have 1 argument and return 1 result
-class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []>
-    : fir_SimpleOp<mnemonic, traits> {
+class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []> :
+    fir_SimpleOp<mnemonic, traits> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Whether a type is a BaseBoxType or a reference to a BaseBoxType.
-def IsBoxAddressOrValueTypePred : CPred<"::fir::isBoxAddressOrValue($_self)">;
+def IsBoxAddressOrValueTypePred
+        : CPred<"::fir::isBoxAddressOrValue($_self)">;
 def fir_BoxAddressOrValueType : Type<IsBoxAddressOrValueTypePred,
-                                     "fir.box or fir.class type or reference">;
+    "fir.box or fir.class type or reference">;
 
 def RefOfConstantSizeAggregateTypePred
-    : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
-def AnyRefOfConstantSizeAggregateType
-    : TypeConstraint<RefOfConstantSizeAggregateTypePred,
-                     "a reference type to a constant size fir.array, fir.char, "
-                     "or fir.type">;
+        : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
+def AnyRefOfConstantSizeAggregateType : TypeConstraint<
+      RefOfConstantSizeAggregateTypePred,
+      "a reference type to a constant size fir.array, fir.char, or fir.type">;
 
 //===----------------------------------------------------------------------===//
 // Memory SSA operations
 //===----------------------------------------------------------------------===//
 
-def fir_AllocaOp
-    : fir_Op<"alloca", [AttrSizedOperandSegments,
-                        DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_AllocaOp : fir_Op<"alloca",
+    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "allocate storage for a temporary on the stack given a type";
   let description = [{
     This primitive operation is used to allocate an object on the stack.  A
@@ -154,42 +153,46 @@ def fir_AllocaOp
     region and avoid them being hoisted in an alloca hoisting pass.
   }];
 
-  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
-      OptionalAttr<StrAttr>:$bindc_name, UnitAttr:$pinned,
-      Variadic<AnyIntegerType>:$typeparams, Variadic<AnyIntegerType>:$shape);
+  let arguments = (ins
+    TypeAttr:$in_type,
+    OptionalAttr<StrAttr>:$uniq_name,
+    OptionalAttr<StrAttr>:$bindc_name,
+    UnitAttr:$pinned,
+    Variadic<AnyIntegerType>:$typeparams,
+    Variadic<AnyIntegerType>:$shape
+  );
 
   let results = (outs fir_ReferenceType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders =
-      [OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           "llvm::StringRef":$bindcName,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           "llvm::StringRef":$bindcName, "bool":$pinned,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      "llvm::StringRef":$bindcName, CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      "llvm::StringRef":$bindcName, "bool":$pinned,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -209,9 +212,8 @@ def fir_AllocaOp
   }];
 }
 
-def fir_AllocMemOp
-    : fir_Op<"allocmem", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
-                          AttrSizedOperandSegments]> {
+def fir_AllocMemOp : fir_Op<"allocmem",
+    [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>, AttrSizedOperandSegments]> {
   let summary = "allocate storage on the heap for an object of a given type";
 
   let description = [{
@@ -226,28 +228,31 @@ def fir_AllocMemOp
     ```
   }];
 
-  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
-      OptionalAttr<StrAttr>:$bindc_name, Variadic<AnyIntegerType>:$typeparams,
-      Variadic<AnyIntegerType>:$shape);
+  let arguments = (ins
+    TypeAttr:$in_type,
+    OptionalAttr<StrAttr>:$uniq_name,
+    OptionalAttr<StrAttr>:$bindc_name,
+    Variadic<AnyIntegerType>:$typeparams,
+    Variadic<AnyIntegerType>:$shape
+  );
   let results = (outs fir_HeapType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders =
-      [OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-           "llvm::StringRef":$bindc_name,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$in_type,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+      "llvm::StringRef":$bindc_name, CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$in_type,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -283,10 +288,8 @@ def fir_FreeMemOp : fir_Op<"freemem", [MemoryEffects<[MemFree]>]> {
   let assemblyFormat = "$heapref attr-dict `:` qualified(type($heapref))";
 }
 
-def fir_LoadOp
-    : fir_OneResultOp<
-          "load", [FirAliasTagOpInterface,
-                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
+                                          DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "load a value from a memory reference";
   let description = [{
     Load a value from a memory reference into an ssa-value (virtual register).
@@ -315,9 +318,8 @@ def fir_LoadOp
   }];
 }
 
-def fir_StoreOp
-    : fir_Op<"store", [FirAliasTagOpInterface,
-                       DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
+                                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "store an SSA-value to a memory location";
 
   let description = [{
@@ -349,8 +351,7 @@ def fir_StoreOp
   }];
 }
 
-def fir_CopyOp
-    : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "copy constant size memory";
 
   let description = [{
@@ -372,11 +373,12 @@ def fir_CopyOp
   }];
 
   let arguments = (ins AnyRefOfConstantSizeAggregateType:$source,
-      AnyRefOfConstantSizeAggregateType:$destination,
-      OptionalAttr<UnitAttr>:$no_overlap);
+                       AnyRefOfConstantSizeAggregateType:$destination,
+                       OptionalAttr<UnitAttr>:$no_overlap);
 
   let builders = [OpBuilder<(ins "mlir::Value":$source,
-      "mlir::Value":$destination, CArg<"bool", "false">:$no_overlap)>];
+                                 "mlir::Value":$destination,
+                                  CArg<"bool", "false">:$no_overlap)>];
 
   let assemblyFormat = [{
     $source `to` $destination (`no_overlap` $no_overlap^)?
@@ -386,6 +388,7 @@ def fir_CopyOp
   let hasVerifier = 1;
 }
 
+
 def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   let summary = [{
     save an array, box, or record function result SSA-value to a memory location
@@ -422,8 +425,9 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   }];
 
   let arguments = (ins ArrayOrBoxOrRecord:$value,
-      Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
-      Optional<AnyShapeType>:$shape, Variadic<AnyIntegerType>:$typeparams);
+                   Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
+                   Optional<AnyShapeType>:$shape,
+                   Variadic<AnyIntegerType>:$typeparams);
 
   let assemblyFormat = [{
     $value `to` $memref (`(` $shape^ `)`)? (`typeparams` $typeparams^)?
@@ -460,8 +464,11 @@ def fir_CharConvertOp : fir_Op<"char_convert", []> {
     `count` limit. These details are left as future to-dos.
   }];
 
-  let arguments = (ins Arg<AnyReferenceLike, "", [MemRead]>:$from,
-      AnyIntegerType:$count, Arg<AnyReferenceLike, "", [MemWrite]>:$to);
+  let arguments = (ins
+    Arg<AnyReferenceLike, "", [MemRead]>:$from,
+    AnyIntegerType:$count,
+    Arg<AnyReferenceLike, "", [MemWrite]>:$to
+  );
 
   let assemblyFormat = [{
     $from `for` $count `to` $to attr-dict `:` type(operands)
@@ -489,8 +496,7 @@ def fir_UndefOp : fir_OneResultOp<"undefined", [NoMemoryEffect]> {
 
   let assemblyFormat = "type($intype) attr-dict";
 
-  // Note: we allow `undef : ref<T>` since it is a possible from
-  // transformations.
+  // Note: we allow `undef : ref<T>` since it is a possible from transformations.
   let hasVerifier = 0;
 }
 
@@ -516,14 +522,15 @@ def fir_ZeroOp : fir_OneResultOp<"zero_bits", [NoMemoryEffect]> {
 // Terminator operations
 //===----------------------------------------------------------------------===//
 
-class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
-             !listconcat(traits, [AttrSizedOperandSegments,
-                                  DeclareOpInterfaceMethods<BranchOpInterface>,
-                                  Terminator])> {
+class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic, !listconcat(traits, [AttrSizedOperandSegments,
+    DeclareOpInterfaceMethods<BranchOpInterface>, Terminator])> {
 
-  let arguments = (ins AnyType:$selector, Variadic<AnyType>:$compareArgs,
-      Variadic<AnyType>:$targetArgs);
+  let arguments = (ins
+    AnyType:$selector,
+    Variadic<AnyType>:$compareArgs,
+    Variadic<AnyType>:$targetArgs
+  );
 
   let results = (outs);
 
@@ -576,16 +583,16 @@ class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
   }];
 }
 
-class fir_IntegralSwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
-    : fir_SwitchTerminatorOp<mnemonic, traits> {
+class fir_IntegralSwitchTerminatorOp<string mnemonic,
+    list<Trait> traits = []> : fir_SwitchTerminatorOp<mnemonic, traits> {
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<
-      (ins "mlir::Value":$selector, "llvm::ArrayRef<int64_t>":$compareOperands,
-          "llvm::ArrayRef<mlir::Block *>":$destinations,
-          CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-          CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-      [{
+  let builders = [OpBuilder<(ins "mlir::Value":$selector,
+    "llvm::ArrayRef<int64_t>":$compareOperands,
+    "llvm::ArrayRef<mlir::Block *>":$destinations,
+    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+    [{
       $_state.addOperands(selector);
       llvm::SmallVector<mlir::Attribute> ivalues;
       for (auto iv : compareOperands)
@@ -613,7 +620,8 @@ class fir_IntegralSwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
       $_state.addAttribute(getTargetOffsetAttr(),
         $_builder.getDenseI32ArrayAttr(argOffs));
       $_state.addAttributes(attributes);
-    }]>];
+    }]
+  >];
 
   let extraClassDeclaration = extraSwitchClassDeclaration;
 }
@@ -639,6 +647,7 @@ def fir_SelectOp : fir_IntegralSwitchTerminatorOp<"select"> {
   }];
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
+
 }
 
 def fir_SelectRankOp : fir_IntegralSwitchTerminatorOp<"select_rank"> {
@@ -684,19 +693,19 @@ def fir_SelectCaseOp : fir_SwitchTerminatorOp<"select_case"> {
   }];
 
   let skipDefaultBuilders = 1;
-  let builders =
-      [OpBuilder<(ins "mlir::Value":$selector,
-           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-           "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
-           "llvm::ArrayRef<mlir::Block *>":$destinations,
-           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Value":$selector,
-           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-           "llvm::ArrayRef<mlir::Value>":$cmpOpList,
-           "llvm::ArrayRef<mlir::Block *>":$destinations,
-           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$selector,
+      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+      "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
+      "llvm::ArrayRef<mlir::Block *>":$destinations,
+      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Value":$selector,
+      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+      "llvm::ArrayRef<mlir::Value>":$cmpOpList,
+      "llvm::ArrayRef<mlir::Block *>":$destinations,
+      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -728,10 +737,10 @@ def fir_SelectTypeOp : fir_SwitchTerminatorOp<"select_type"> {
 
   let skipDefaultBuilders = 1;
   let builders = [OpBuilder<(ins "mlir::Value":$selector,
-      "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
-      "llvm::ArrayRef<mlir::Block *>":$destinations,
-      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+    "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
+    "llvm::ArrayRef<mlir::Block *>":$destinations,
+    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -755,6 +764,7 @@ def fir_UnreachableOp : fir_Op<"unreachable", [Terminator]> {
   }];
 
   let assemblyFormat = [{ attr-dict }];
+
 }
 
 def fir_FirEndOp : fir_Op<"end", [Terminator, NoMemoryEffect]> {
@@ -833,15 +843,17 @@ def fir_EmboxOp : fir_Op<"embox", [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let results = (outs BoxOrClassType);
 
-  let builders = [OpBuilder<
-      (ins "llvm::ArrayRef<mlir::Type>":$resultTypes, "mlir::Value":$memref,
-          CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::Value", "{}">:$slice,
-          CArg<"mlir::ValueRange", "{}">:$typeparams,
-          CArg<"mlir::Value", "{}">:$sourceBox,
-          CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
-      [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
+  let builders = [
+    OpBuilder<(ins "llvm::ArrayRef<mlir::Type>":$resultTypes,
+      "mlir::Value":$memref, CArg<"mlir::Value", "{}">:$shape,
+      CArg<"mlir::Value", "{}">:$slice,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::Value", "{}">:$sourceBox,
+      CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
+    [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
                     typeparams, sourceBox, mlir::AffineMapAttr{},
-                    allocator_idx); }]>];
+                    allocator_idx); }]>
+  ];
 
   let assemblyFormat = [{
     $memref (`(` $shape^ `)`)? (`[` $slice^ `]`)? (`typeparams` $typeparams^)?
@@ -897,8 +909,11 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins BoxOrClassType:$box,
-      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice);
+  let arguments = (ins
+    BoxOrClassType:$box,
+    Optional<AnyShapeOrShiftType>:$shape,
+    Optional<fir_SliceType>:$slice
+  );
 
   let results = (outs BoxOrClassType);
 
@@ -910,9 +925,8 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
   let hasVerifier = 1;
 }
 
-def fir_ReboxAssumedRankOp
-    : fir_Op<"rebox_assumed_rank", [DeclareOpInterfaceMethods<
-                                       MemoryEffectsOpInterface>]> {
+def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
+  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "create an assumed-rank box given another assumed-rank box";
 
   let description = [{
@@ -933,8 +947,10 @@ def fir_ReboxAssumedRankOp
     ```    
   }];
 
-  let arguments = (ins AnyRefOrBoxType:$box,
-      fir_LowerBoundModifierAttribute:$lbs_modifier);
+  let arguments = (ins
+    AnyRefOrBoxType:$box,
+    fir_LowerBoundModifierAttribute:$lbs_modifier
+  );
 
   let results = (outs BoxOrClassType);
 
@@ -1155,8 +1171,8 @@ def fir_BoxEleSizeOp : fir_SimpleOneResultOp<"box_elesize", [NoMemoryEffect]> {
   let results = (outs AnyIntegerLike);
 }
 
-def fir_BoxTypeCodeOp
-    : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]> {
+def fir_BoxTypeCodeOp : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]>
+{
   let summary = "return the type code the boxed value";
 
   let description = [{
@@ -1234,8 +1250,7 @@ def fir_IsAssumedSizeOp : fir_SimpleOp<"is_assumed_size", [NoMemoryEffect]> {
   let results = (outs BoolLike);
 }
 
-def fir_AssumedSizeExtentOp
-    : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
+def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
   let summary = "get the assumed-size last extent sentinel";
 
   let description = [{
@@ -1253,8 +1268,7 @@ def fir_AssumedSizeExtentOp
   let assemblyFormat = "attr-dict `:` type(results)";
 }
 
-def fir_IsAssumedSizeExtentOp
-    : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
+def fir_IsAssumedSizeExtentOp : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
   let summary = "is value the assumed-size last extent sentinel";
 
   let description = [{
@@ -1311,9 +1325,8 @@ def fir_BoxProcHostOp : fir_SimpleOp<"boxproc_host", [NoMemoryEffect]> {
   let results = (outs fir_ReferenceType);
 }
 
-def fir_BoxRankOp
-    : fir_SimpleOneResultOp<
-          "box_rank", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_BoxRankOp : fir_SimpleOneResultOp<"box_rank",
+  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "return the number of dimensions for the boxed value";
 
   let description = [{
@@ -1394,10 +1407,8 @@ def fir_BoxTypeDescOp : fir_SimpleOneResultOp<"box_tdesc", [NoMemoryEffect]> {
 //   !- Merge the new and old values into the memory for "A"
 //   array_merge_store <updated A> to <A's address>
 
-def fir_ArrayLoadOp
-    : fir_Op<
-          "array_load", [AttrSizedOperandSegments,
-                         DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
+                                            DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
 
   let summary = "Load an array as a value.";
 
@@ -1435,9 +1446,12 @@ def fir_ArrayLoadOp
     ```
   }];
 
-  let arguments = (ins AnyRefOrBox:$memref,
-      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    AnyRefOrBox:$memref,
+    Optional<AnyShapeOrShiftType>:$shape,
+    Optional<fir_SliceType>:$slice,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_SequenceType);
 
@@ -1453,8 +1467,8 @@ def fir_ArrayLoadOp
   }];
 }
 
-def fir_ArrayFetchOp
-    : fir_Op<"array_fetch", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
 
   let summary = "Fetch the value of an element of an array value";
 
@@ -1483,9 +1497,11 @@ def fir_ArrayFetchOp
     It is only possible to use `array_fetch` on an `array_load` result value.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs AnyType:$element);
 
@@ -1497,8 +1513,8 @@ def fir_ArrayFetchOp
   let hasVerifier = 1;
 }
 
-def fir_ArrayUpdateOp
-    : fir_Op<"array_update", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
 
   let summary = "Update the value of an element of an array value";
 
@@ -1532,9 +1548,12 @@ def fir_ArrayUpdateOp
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence, AnyType:$merge,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    AnyType:$merge,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_SequenceType);
 
@@ -1546,8 +1565,8 @@ def fir_ArrayUpdateOp
   let hasVerifier = 1;
 }
 
-def fir_ArrayModifyOp
-    : fir_Op<"array_modify", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
   let summary = "Get an address for an array value to modify it.";
 
   let description = [{
@@ -1588,9 +1607,11 @@ def fir_ArrayModifyOp
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_ReferenceType, fir_SequenceType);
 
@@ -1602,8 +1623,8 @@ def fir_ArrayModifyOp
   let hasVerifier = 1;
 }
 
-def fir_ArrayAccessOp
-    : fir_Op<"array_access", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
   let summary = "Fetch the reference of an element of an array value";
 
   let description = [{
@@ -1648,9 +1669,11 @@ def fir_ArrayAccessOp
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_ReferenceType:$element);
 
@@ -1684,7 +1707,10 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence, fir_ReferenceType:$memref);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    fir_ReferenceType:$memref
+  );
 
   let results = (outs fir_SequenceType);
 
@@ -1693,10 +1719,8 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
   }];
 }
 
-def fir_ArrayMergeStoreOp
-    : fir_Op<"array_merge_store", [AttrSizedOperandSegments,
-                                   DeclareOpInterfaceMethods<
-                                       MemoryEffectsOpInterface>]> {
+def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
+    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
 
   let summary = "Store merged array value to memory.";
 
@@ -1722,9 +1746,13 @@ def fir_ArrayMergeStoreOp
     chained updates, `%r`, and stores the result to the array at address, `%a`.
   }];
 
-  let arguments = (ins fir_SequenceType:$original, fir_SequenceType:$sequence,
-      AnyRefOrBox:$memref, Optional<fir_SliceType>:$slice,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$original,
+    fir_SequenceType:$sequence,
+    AnyRefOrBox:$memref,
+    Optional<fir_SliceType>:$slice,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let assemblyFormat = [{
     $original `,` $sequence `to` $memref (`[` $slice^ `]`)? (`typeparams`
@@ -1738,8 +1766,8 @@ def fir_ArrayMergeStoreOp
 // Record and array type operations
 //===----------------------------------------------------------------------===//
 
-def fir_ArrayCoorOp
-    : fir_Op<"array_coor", [NoMemoryEffect, AttrSizedOperandSegments]> {
+def fir_ArrayCoorOp : fir_Op<"array_coor",
+    [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let summary = "Find the coordinate of an element of an array";
 
@@ -1765,10 +1793,13 @@ def fir_ArrayCoorOp
     ```
   }];
 
-  let arguments = (ins AnyRefOrBox:$memref,
-      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    AnyRefOrBox:$memref,
+    Optional<AnyShapeOrShiftType>:$shape,
+    Optional<fir_SliceType>:$slice,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_ReferenceType);
 
@@ -1812,18 +1843,24 @@ def fir_CoordinateOp : fir_Op<"coordinate_of", [NoMemoryEffect]> {
     array `%h`.
   }];
 
-  let arguments = (ins AnyRefOrBox:$ref, Variadic<AnyCoordinateType>:$coor,
-      TypeAttr:$baseType, OptionalAttr<DenseI32ArrayAttr>:$field_indices);
+  let arguments = (ins
+    AnyRefOrBox:$ref,
+    Variadic<AnyCoordinateType>:$coor,
+    TypeAttr:$baseType,
+    OptionalAttr<DenseI32ArrayAttr>:$field_indices
+  );
 
   let results = (outs RefOrLLVMPtr);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
-                      "mlir::ValueRange":$coor)>,
-                  OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
-                      "llvm::ArrayRef<fir::IntOrValue>":$coor)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Type":$resultType,
+      "mlir::Value":$ref, "mlir::ValueRange":$coor)>,
+    OpBuilder<(ins "mlir::Type":$resultType,
+      "mlir::Value":$ref, "llvm::ArrayRef<fir::IntOrValue>":$coor)>
+  ];
   let extraClassDeclaration = [{
     constexpr static int32_t kDynamicIndex = std::numeric_limits<int32_t>::min();
     CoordinateIndicesAdaptor getIndices();
@@ -1850,7 +1887,10 @@ def fir_ExtractValueOp : fir_OneResultOp<"extract_value", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins AnyCompositeLike:$adt, ArrayAttr:$coor);
+  let arguments = (ins
+    AnyCompositeLike:$adt,
+    ArrayAttr:$coor
+  );
 
   let assemblyFormat = [{
     $adt `,` $coor attr-dict `:` functional-type(operands, results)
@@ -1873,13 +1913,16 @@ def fir_FieldIndexOp : fir_OneResultOp<"field_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    StrAttr:$field_id,
+    TypeAttr:$on_type,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2031,8 +2074,11 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins Variadic<AnyIntegerType>:$triples,
-      Variadic<AnyComponentType>:$fields, Variadic<AnyIntegerType>:$substr);
+  let arguments = (ins
+    Variadic<AnyIntegerType>:$triples,
+    Variadic<AnyComponentType>:$fields,
+    Variadic<AnyIntegerType>:$substr
+  );
 
   let results = (outs fir_SliceType);
 
@@ -2041,9 +2087,11 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
       functional-type(operands, results)
   }];
 
-  let builders = [OpBuilder<(ins "mlir::ValueRange":$triples,
+  let builders = [
+    OpBuilder<(ins "mlir::ValueRange":$triples,
       CArg<"mlir::ValueRange", "{}">:$fields,
-      CArg<"mlir::ValueRange", "{}">:$substr)>];
+      CArg<"mlir::ValueRange", "{}">:$substr)>
+  ];
 
   let hasVerifier = 1;
 
@@ -2106,8 +2154,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
     the value 3.0.
   }];
 
-  let arguments = (ins fir_SequenceType:$seq, AnyType:$val,
-      IndexElementsAttr:$coor);
+  let arguments = (ins fir_SequenceType:$seq, AnyType:$val, IndexElementsAttr:$coor);
   let results = (outs fir_SequenceType);
 
   let assemblyFormat = [{
@@ -2124,7 +2171,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
 
 def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
   let summary =
-      "create a field index value from a LEN type parameter identifier";
+    "create a field index value from a LEN type parameter identifier";
 
   let description = [{
     Generate a LEN parameter (offset) value from a LEN parameter identifier.
@@ -2139,13 +2186,16 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    StrAttr:$field_id,
+    TypeAttr:$on_type,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2159,9 +2209,9 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
 // Fortran loops
 //===----------------------------------------------------------------------===//
 
-def fir_ResultOp
-    : fir_Op<"result", [NoMemoryEffect, ReturnLike, Terminator,
-                        ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
+def fir_ResultOp : fir_Op<"result",
+    [NoMemoryEffect, ReturnLike, Terminator,
+     ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
   let summary = "special terminator for use in fir region operations";
 
   let description = [{
@@ -2181,19 +2231,17 @@ def fir_ResultOp
 
 def FirRegionTerminator : SingleBlockImplicitTerminator<"ResultOp">;
 
-class region_Op<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
-             !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
-                                  RecursiveMemoryEffects])> {
+class region_Op<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic,
+    !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
+        RecursiveMemoryEffects])> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 }
 
-def fir_DoLoopOp
-    : region_Op<
-          "do_loop", [AttrSizedOperandSegments,
-                      DeclareOpInterfaceMethods<
-                          LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
+def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
+    DeclareOpInterfaceMethods<LoopLikeOpInterface,
+        ["getYieldedValuesMutable"]>]> {
   let summary = "generalized loop operation";
   let description = [{
     Generalized high-level looping construct. This operation is similar to
@@ -2218,22 +2266,30 @@ def fir_DoLoopOp
   let hasVerifier = 1;
   let hasCustomAssemblyFormat = 1;
 
-  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
-      Variadic<AnyType>:$reduceOperands, Variadic<AnyType>:$initArgs,
-      OptionalAttr<UnitAttr>:$unordered, OptionalAttr<UnitAttr>:$finalValue,
-      OptionalAttr<ArrayAttr>:$reduceAttrs,
-      OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
+  let arguments = (ins
+    Index:$lowerBound,
+    Index:$upperBound,
+    Index:$step,
+    Variadic<AnyType>:$reduceOperands,
+    Variadic<AnyType>:$initArgs,
+    OptionalAttr<UnitAttr>:$unordered,
+    OptionalAttr<UnitAttr>:$finalValue,
+    OptionalAttr<ArrayAttr>:$reduceAttrs,
+    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
+  );
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
-      "mlir::Value":$upperBound, "mlir::Value":$step,
-      CArg<"bool", "false">:$unordered, CArg<"bool", "false">:$finalCountValue,
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
+      "mlir::Value":$step, CArg<"bool", "false">:$unordered,
+      CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
       CArg<"mlir::ValueRange", "{}">:$reduceOperands,
       CArg<"llvm::ArrayRef<mlir::Attribute>", "{}">:$reduceAttrs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
+  ];
 
   let extraClassDeclaration = [{
     mlir::Value getInductionVar() { return getBody()->getArgument(0); }
@@ -2326,13 +2382,17 @@ def fir_IfOp
       OptionalAttr<DenseI32ArrayAttr>:$region_weights);
   let results = (outs Variadic<AnyType>:$results);
 
-  let regions = (region SizedRegion<1>:$thenRegion,
-      MaxSizedRegion<1>:$elseRegion);
+  let regions = (region
+    SizedRegion<1>:$thenRegion,
+    MaxSizedRegion<1>:$elseRegion
+  );
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
-                  OpBuilder<(ins "mlir::TypeRange":$resultTypes,
-                      "mlir::Value":$cond, "bool":$withElseRegion)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
+    OpBuilder<(ins "mlir::TypeRange":$resultTypes, "mlir::Value":$cond,
+        "bool":$withElseRegion)>
+  ];
 
   let extraClassDeclaration = [{
     mlir::OpBuilder getThenBodyBuilder() {
@@ -2366,10 +2426,9 @@ def fir_IfOp
   }];
 }
 
-def fir_IterWhileOp
-    : region_Op<"iterate_while",
-                [DeclareOpInterfaceMethods<
-                    LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
+def fir_IterWhileOp : region_Op<"iterate_while",
+    [DeclareOpInterfaceMethods<LoopLikeOpInterface,
+        ["getYieldedValuesMutable"]>]> {
   let summary = "DO loop with early exit condition";
   let description = [{
     This single-entry, single-exit looping construct is useful for lowering
@@ -2398,18 +2457,25 @@ def fir_IterWhileOp
     ```
   }];
 
-  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
-      I1:$iterateIn, Variadic<AnyType>:$initArgs,
-      OptionalAttr<UnitAttr>:$finalValue);
+  let arguments = (ins
+    Index:$lowerBound,
+    Index:$upperBound,
+    Index:$step,
+    I1:$iterateIn,
+    Variadic<AnyType>:$initArgs,
+    OptionalAttr<UnitAttr>:$finalValue
+  );
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
-      "mlir::Value":$upperBound, "mlir::Value":$step, "mlir::Value":$iterate,
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
+      "mlir::Value":$step, "mlir::Value":$iterate,
       CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
+  ];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFinalValueAttrNameStr() {
@@ -2462,9 +2528,8 @@ def fir_IterWhileOp
 // Procedure call operations
 //===----------------------------------------------------------------------===//
 
-def fir_CallOp
-    : fir_Op<"call", [CallOpInterface,
-                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CallOp : fir_Op<"call",
+    [CallOpInterface, DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "call a procedure";
 
   let description = [{
@@ -2479,26 +2544,30 @@ def fir_CallOp
     ```
   }];
 
-  let arguments = (ins OptionalAttr<SymbolRefAttr>:$callee,
-      Variadic<AnyType>:$args, OptionalAttr<DictArrayAttr>:$arg_attrs,
-      OptionalAttr<DictArrayAttr>:$res_attrs,
-      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
-      OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
-      DefaultValuedAttr<Arith_FastMathAttr,
-                        "::mlir::arith::FastMathFlags::none">:$fastmath);
+  let arguments = (ins
+    OptionalAttr<SymbolRefAttr>:$callee,
+    Variadic<AnyType>:$args,
+    OptionalAttr<DictArrayAttr>:$arg_attrs,
+    OptionalAttr<DictArrayAttr>:$res_attrs,
+    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
+    OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
+    DefaultValuedAttr<Arith_FastMathAttr,
+                      "::mlir::arith::FastMathFlags::none">:$fastmath
+  );
   let results = (outs Variadic<AnyType>);
 
   let hasCustomAssemblyFormat = 1;
 
-  let builders = [OpBuilder<(ins "mlir::func::FuncOp":$callee,
-                      CArg<"mlir::ValueRange", "{}">:$operands)>,
-                  OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
-                      "llvm::ArrayRef<mlir::Type>":$results,
-                      CArg<"mlir::ValueRange", "{}">:$operands)>,
-                  OpBuilder<(ins "llvm::StringRef":$callee,
-                                "llvm::ArrayRef<mlir::Type>":$results,
-                                CArg<"mlir::ValueRange", "{}">:$operands),
-                            [{
+  let builders = [
+    OpBuilder<(ins "mlir::func::FuncOp":$callee,
+        CArg<"mlir::ValueRange", "{}">:$operands)>,
+    OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
+        "llvm::ArrayRef<mlir::Type>":$results,
+        CArg<"mlir::ValueRange", "{}">:$operands)>,
+    OpBuilder<(ins "llvm::StringRef":$callee,
+        "llvm::ArrayRef<mlir::Type>":$results,
+        CArg<"mlir::ValueRange", "{}">:$operands),
+    [{
       build($_builder, $_state,
           mlir::SymbolRefAttr::get($_builder.getContext(), callee), results,
           operands);
@@ -2562,11 +2631,15 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$method, fir_ClassType:$object,
-      Variadic<AnyType>:$args, OptionalAttr<I32Attr>:$pass_arg_pos,
-      OptionalAttr<DictArrayAttr>:$arg_attrs,
-      OptionalAttr<DictArrayAttr>:$res_attrs,
-      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs);
+  let arguments = (ins
+    StrAttr:$method,
+    fir_ClassType:$object,
+    Variadic<AnyType>:$args,
+    OptionalAttr<I32Attr>:$pass_arg_pos,
+    OptionalAttr<DictArrayAttr>:$arg_attrs,
+    OptionalAttr<DictArrayAttr>:$res_attrs,
+    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs
+  );
 
   let results = (outs Variadic<AnyType>:$results);
 
@@ -2610,18 +2683,19 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::StringRef":$value,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>,
-                  OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::ArrayRef<char>":$xlist,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>,
-                  OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::ArrayRef<char16_t>":$xlist,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>,
-                  OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::ArrayRef<char32_t>":$xlist,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>];
+  let builders = [
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::StringRef":$value,
+      CArg<"std::optional<int64_t>", "{}">:$len)>,
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::ArrayRef<char>":$xlist,
+      CArg<"std::optional<int64_t>", "{}">:$len)>,
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::ArrayRef<char16_t>":$xlist,
+      CArg<"std::optional<int64_t>", "{}">:$len)>,
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::ArrayRef<char32_t>":$xlist,
+      CArg<"std::optional<int64_t>", "{}">:$len)>];
 
   let extraClassDeclaration = [{
     static constexpr const char *size() { return "size"; }
@@ -2644,67 +2718,62 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
 
 // Complex operations
 
-class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
-             !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
-      Results<(outs AnyType:$result)> {
+class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic,
+           !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
+    Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
+class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
+      fir_Op<mnemonic,
              !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
       Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_UnaryArithmeticOp<mnemonic, traits>,
+class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
+      fir_UnaryArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$operand)>;
 
 def fir_NegcOp : ComplexUnaryArithmeticOp<"negc">;
 
-class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_ArithmeticOp<mnemonic, traits>,
+class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []> :
+      fir_ArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
           DefaultValuedAttr<Arith_FastMathAttr,
                             "::mlir::arith::FastMathFlags::none">:$fastmath)>;
 
-def fir_AddcOp
-    : ComplexArithmeticOp<"addc", [Commutative, DeclareOpInterfaceMethods<
-                                                    ArithFastMathInterface>]>;
-def fir_SubcOp
-    : ComplexArithmeticOp<
-          "subc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_MulcOp
-    : ComplexArithmeticOp<"mulc", [Commutative, DeclareOpInterfaceMethods<
-                                                    ArithFastMathInterface>]>;
-def fir_DivcOp
-    : ComplexArithmeticOp<
-          "divc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_AddcOp : ComplexArithmeticOp<"addc",
+    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_SubcOp : ComplexArithmeticOp<"subc",
+    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_MulcOp : ComplexArithmeticOp<"mulc",
+    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_DivcOp : ComplexArithmeticOp<"divc",
+    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
 // Pow is a builtin call and not a primitive
 
-def fir_CmpcOp
-    : fir_Op<"cmpc", [NoMemoryEffect, SameTypeOperands,
-                      SameOperandsAndResultShape,
-                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CmpcOp : fir_Op<"cmpc",
+    [NoMemoryEffect, SameTypeOperands, SameOperandsAndResultShape,
+    DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "complex floating-point comparison operator";
 
   let description = [{
     A complex comparison to handle complex types found in FIR.
   }];
 
-  let arguments = (ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
-      DefaultValuedAttr<Arith_FastMathAttr,
-                        "::mlir::arith::FastMathFlags::none">:$fastmath);
+  let arguments = (ins
+      AnyFirComplex:$lhs,
+      AnyFirComplex:$rhs,
+      DefaultValuedAttr<Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath);
 
   let results = (outs AnyLogicalLike);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "mlir::arith::CmpFPredicate":$predicate,
-                                "mlir::Value":$lhs, "mlir::Value":$rhs),
-                            [{
+    "mlir::Value":$lhs, "mlir::Value":$rhs), [{
       buildCmpCOp($_builder, $_state, predicate, lhs, rhs);
   }]>];
 
@@ -2804,15 +2873,12 @@ def fir_ConvertOp
   let hasCanonicalizer = 1;
 }
 
-def FortranTypeAttr
-    : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
-                Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
-                          "fir::UnsignedType, fir::LogicalType, "
-                          "mlir::FloatType, "
-                          "mlir::ComplexType, "
-                          "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self)."
-                          "getValue())">]>]>,
-           "Fortran surface type"> {
+def FortranTypeAttr : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
+    Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
+              "fir::UnsignedType, fir::LogicalType, mlir::FloatType, "
+              "mlir::ComplexType, "
+              "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self).getValue())"
+    >]>]>, "Fortran surface type"> {
   let storageType = [{ ::mlir::TypeAttr }];
   let returnType = "mlir::Type";
   let convertFromStorage = "mlir::cast<mlir::Type>($_self.getValue())";
@@ -2838,9 +2904,8 @@ def fir_TypeDescOp : fir_OneResultOp<"type_desc", [NoMemoryEffect]> {
   let builders = [OpBuilder<(ins "mlir::TypeAttr":$inty)>];
 }
 
-def fir_NoReassocOp
-    : fir_OneResultOp<"no_reassoc", [NoMemoryEffect,
-                                     SameOperandsAndResultType]> {
+def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
+    [NoMemoryEffect, SameOperandsAndResultType]> {
   let summary = "synthetic op to prevent reassociation";
   let description = [{
     Primitive operation meant to intrusively prevent operator reassociation.
@@ -2863,9 +2928,9 @@ def fir_NoReassocOp
   let assemblyFormat = "$val attr-dict `:` type($val)";
 }
 
-class AtMostRegion<int numBlocks>
-    : Region<CPred<"$_self.getBlocks().size() <= "#numBlocks>,
-             "region with "#numBlocks#" blocks">;
+class AtMostRegion<int numBlocks> : Region<
+  CPred<"$_self.getBlocks().size() <= " # numBlocks>,
+  "region with " # numBlocks # " blocks">;
 
 def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
   let summary = "Global data";
@@ -2890,37 +2955,43 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$sym_name, SymbolRefAttr:$symref, TypeAttr:$type,
-      OptionalAttr<AnyAttr>:$initVal, OptionalAttr<UnitAttr>:$constant,
-      OptionalAttr<UnitAttr>:$target, OptionalAttr<StrAttr>:$linkName,
-      OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
-      OptionalAttr<I64Attr>:$alignment);
+  let arguments = (ins
+    StrAttr:$sym_name,
+    SymbolRefAttr:$symref,
+    TypeAttr:$type,
+    OptionalAttr<AnyAttr>:$initVal,
+    OptionalAttr<UnitAttr>:$constant,
+    OptionalAttr<UnitAttr>:$target,
+    OptionalAttr<StrAttr>:$linkName,
+    OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
+    OptionalAttr<I64Attr>:$alignment
+  );
 
   let regions = (region AtMostRegion<1>:$region);
 
   let hasCustomAssemblyFormat = 1;
 
   let skipDefaultBuilders = 1;
-  let builders =
-      [OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-           "bool":$isTarget, "mlir::Type":$type,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-           CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-           "bool":$isTarget, "mlir::Type":$type,
-           CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-           "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-           "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
-           CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+  let builders = [
+    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+      "bool":$isTarget, "mlir::Type":$type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+      CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+      "bool":$isTarget,
+      "mlir::Type":$type, CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+      "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+      "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
+      CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
   ];
 
   let extraClassDeclaration = [{
@@ -2985,8 +3056,8 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
 
 def ImplicitFirTerminator : SingleBlockImplicitTerminator<"FirEndOp">;
 
-def fir_TypeInfoOp
-    : fir_Op<"type_info", [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
+def fir_TypeInfoOp : fir_Op<"type_info",
+    [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
   let summary = "Derived type information";
 
   let description = [{
@@ -3016,18 +3087,26 @@ def fir_TypeInfoOp
     ```
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type,
-      OptionalAttr<TypeAttr>:$parent_type, UnitAttr:$no_init,
-      UnitAttr:$no_destroy, UnitAttr:$no_final);
+  let arguments = (ins
+    SymbolNameAttr:$sym_name,
+    TypeAttr:$type,
+    OptionalAttr<TypeAttr>:$parent_type,
+    UnitAttr:$no_init,
+    UnitAttr:$no_destroy,
+    UnitAttr:$no_final
+  );
 
   let hasVerifier = 1;
 
-  let regions = (region MaxSizedRegion<1>:$dispatch_table,
-      MaxSizedRegion<1>:$component_info);
+  let regions = (region
+    MaxSizedRegion<1>:$dispatch_table,
+    MaxSizedRegion<1>:$component_info
+  );
 
-  let builders = [OpBuilder<(ins "fir::RecordType":$type,
-      "fir::RecordType":$parent_type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>];
+  let builders = [
+    OpBuilder<(ins "fir::RecordType":$type, "fir::RecordType":$parent_type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>
+  ];
 
   let assemblyFormat = [{
     $sym_name (`noinit` $no_init^)? (`nodestroy` $no_destroy^)?
@@ -3078,8 +3157,7 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"TypeInfoOp">]> {
 }
 
 def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
-  let summary =
-      "define extra information about a component inside fir.type_info";
+  let summary = "define extra information about a component inside fir.type_info";
 
   let description = [{
     ```
@@ -3087,17 +3165,17 @@ def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$name,
-      OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
-      OptionalAttr<FlatSymbolRefAttr>:$init_val);
+  let arguments = (ins
+    StrAttr:$name,
+    OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
+    OptionalAttr<FlatSymbolRefAttr>:$init_val
+  );
 
-  let assemblyFormat =
-      "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
+  let assemblyFormat = "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
 }
 
 def fir_AbsentOp : fir_OneResultOp<"absent", [NoMemoryEffect]> {
-  let summary =
-      "create value to be passed for absent optional function argument";
+  let summary = "create value to be passed for absent optional function argument";
   let description = [{
     Given the type of a function argument, create a value that will signal that
     an optional argument is absent in the call. On the caller side, fir.is_present
@@ -3238,7 +3316,10 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     The derived_type field cannot be used when the input to this op is a reference to a fir.boxchar.
   }];
 
-  let arguments = (ins AnyReferenceLike:$box_ref, fir_BoxFieldAttr:$field);
+  let arguments = (ins
+    AnyReferenceLike:$box_ref,
+    fir_BoxFieldAttr:$field
+  );
 
   let results = (outs RefOrLLVMPtr);
   let hasVerifier = 1;
@@ -3247,12 +3328,13 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     $box_ref $field attr-dict `:` functional-type(operands, results)
   }];
 
-  let builders = [OpBuilder<(ins "mlir::Value":$boxRef,
-      "fir::BoxFieldAttr":$field)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$boxRef, "fir::BoxFieldAttr":$field)>
+  ];
 }
 
-def fir_DummyScopeOp
-    : fir_Op<"dummy_scope", [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
+def fir_DummyScopeOp : fir_Op<"dummy_scope",
+    [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
   let summary = "Define a scope for dummy arguments";
 
   let description = [{
@@ -3477,9 +3559,9 @@ def fir_BoxTotalElementsOp
   let hasCanonicalizer = 1;
 }
 
-def YieldOp : fir_Op<"yield", [Pure, ReturnLike, Terminator,
-                               ParentOneOf<["LocalitySpecifierOp",
-                                            "DeclareReductionOp"]>]> {
+def YieldOp : fir_Op<"yield",
+    [Pure, ReturnLike, Terminator,
+     ParentOneOf<["LocalitySpecifierOp", "DeclareReductionOp"]>]> {
   let summary = "loop yield and termination operation";
   let description = [{
     "fir.yield" yields SSA values from a fir dialect op region and
@@ -3489,7 +3571,9 @@ def YieldOp : fir_Op<"yield", [Pure, ReturnLike, Terminator,
 
   let arguments = (ins Variadic<AnyType>:$results);
 
-  let builders = [OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>];
+  let builders = [
+    OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
+  ];
 
   let assemblyFormat = "( `(` $results^ `:` type($results) `)` )? attr-dict";
 }
@@ -3567,11 +3651,13 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
     corresponds to a `local` or a `local_init` specifier.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttrOf<AnyType>:$type,
-      LocalitySpecifierTypeAttr:$locality_specifier_type);
+  let arguments = (ins SymbolNameAttr:$sym_name,
+                       TypeAttrOf<AnyType>:$type,
+                       LocalitySpecifierTypeAttr:$locality_specifier_type);
 
-  let regions = (region AnyRegion:$init_region, AnyRegion:$copy_region,
-      AnyRegion:$dealloc_region);
+  let regions = (region AnyRegion:$init_region,
+                        AnyRegion:$copy_region,
+                        AnyRegion:$dealloc_region);
 
   let assemblyFormat = [{
     $locality_specifier_type $sym_name `:` $type
@@ -3613,8 +3699,8 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
   let hasRegionVerifier = 1;
 }
 
-def fir_DeclareReductionOp
-    : fir_Op<"declare_reduction", [IsolatedFromAbove, Symbol]> {
+def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
+                                                         Symbol]> {
   let summary = "declares a reduction kind";
   let description = [{
     Note: this operation is adapted from omp::DeclareReductionOp. There is a lot
@@ -3659,11 +3745,14 @@ def fir_DeclareReductionOp
     match the parent operation's results.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type);
+  let arguments = (ins SymbolNameAttr:$sym_name,
+                       TypeAttr:$type);
 
   let regions = (region MaxSizedRegion<1>:$allocRegion,
-      AnyRegion:$initializerRegion, AnyRegion:$reductionRegion,
-      AnyRegion:$atomicReductionRegion, AnyRegion:$cleanupRegion);
+                        AnyRegion:$initializerRegion,
+                        AnyRegion:$reductionRegion,
+                        AnyRegion:$atomicReductionRegion,
+                        AnyRegion:$cleanupRegion);
 
   let assemblyFormat = "$sym_name `:` $type attr-dict-with-keyword "
                        "( `alloc` $allocRegion^ )? "
@@ -3707,8 +3796,8 @@ def fir_DeclareReductionOp
   let hasRegionVerifier = 1;
 }
 
-def fir_DoConcurrentOp
-    : fir_Op<"do_concurrent", [SingleBlock, AutomaticAllocationScope]> {
+def fir_DoConcurrentOp : fir_Op<"do_concurrent",
+    [SingleBlock, AutomaticAllocationScope]> {
   let summary = "do concurrent loop wrapper";
 
   let description = [{
@@ -3739,34 +3828,35 @@ def fir_DoConcurrentOp
 }
 
 def fir_LocalSpecifier {
-  dag arguments = (ins Variadic<AnyType>:$local_vars,
-      OptionalAttr<SymbolRefArrayAttr>:$local_syms);
+  dag arguments = (ins
+    Variadic<AnyType>:$local_vars,
+    OptionalAttr<SymbolRefArrayAttr>:$local_syms
+  );
 }
 
 def fir_ReduceSpecifier {
-  dag arguments = (ins Variadic<AnyType>:$reduce_vars,
-      OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
-
-      // This introduces redundency in how reductions are modelled. In
-      // particular, a single reduction is represented by 2 attributes:
-      //
-      // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
-      // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
-      //
-      // The first makes it easier to map `do concurrent` to parallization
-      // models (e.g. OpenMP and OpenACC) while the second makes it easier to
-      // map it to nests of `fir.do_loop ... unodered` ops.
-      OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
-      OptionalAttr<ArrayAttr>:$reduce_attrs);
-}
-
-def fir_DoConcurrentLoopOp
-    : fir_Op<"do_concurrent.loop",
-             [AttrSizedOperandSegments,
-              DeclareOpInterfaceMethods<
-                  LoopLikeOpInterface, ["getLoopInductionVars"]>,
-              Terminator, NoTerminator, SingleBlock,
-              ParentOneOf<["DoConcurrentOp"]>]> {
+  dag arguments = (ins
+    Variadic<AnyType>:$reduce_vars,
+    OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
+
+    // This introduces redundency in how reductions are modelled. In particular,
+    // a single reduction is represented by 2 attributes:
+    //
+    // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
+    // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
+    //
+    // The first makes it easier to map `do concurrent` to parallization models
+    // (e.g. OpenMP and OpenACC) while the second makes it easier to map it to
+    // nests of `fir.do_loop ... unodered` ops.
+    OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
+    OptionalAttr<ArrayAttr>:$reduce_attrs
+  );
+}
+
+def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
+    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopLikeOpInterface,
+                                                         ["getLoopInductionVars"]>,
+     Terminator, NoTerminator, SingleBlock, ParentOneOf<["DoConcurrentOp"]>]> {
   let summary = "do concurrent loop";
 
   let description = [{
@@ -3814,11 +3904,16 @@ def fir_DoConcurrentLoopOp
       LLVM.
   }];
 
-  defvar opArgs = (ins Variadic<Index>:$lowerBound, Variadic<Index>:$upperBound,
-      Variadic<Index>:$step, OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
+  defvar opArgs = (ins
+    Variadic<Index>:$lowerBound,
+    Variadic<Index>:$upperBound,
+    Variadic<Index>:$step,
+    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
+  );
 
-  let arguments =
-      !con(opArgs, fir_LocalSpecifier.arguments, fir_ReduceSpecifier.arguments);
+  let arguments = !con(opArgs,
+    fir_LocalSpecifier.arguments,
+    fir_ReduceSpecifier.arguments);
 
   let regions = (region SizedRegion<1>:$region);
 

>From 42fced23230385c8e0bd4913b754ac9e796137a3 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 14:07:34 -0800
Subject: [PATCH 13/18] change variable names

---
 .../include/flang/Optimizer/Dialect/FIROps.td | 931 ++++++++----------
 .../lib/Optimizer/Analysis/AliasAnalysis.cpp  |   9 +-
 2 files changed, 421 insertions(+), 519 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 98448d2591b29..087eadf836e18 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -30,22 +30,22 @@ include "mlir/IR/BuiltinAttributes.td"
 // Base class for FIR operations.
 // All operations automatically get a prefix of "fir.".
 class fir_Op<string mnemonic, list<Trait> traits>
-  : Op<FIROpsDialect, mnemonic, traits>;
+    : Op<FIROpsDialect, mnemonic, traits>;
 
 // Base class for FIR operations that take a single argument
 class fir_SimpleOp<string mnemonic, list<Trait> traits>
-  : fir_Op<mnemonic, traits> {
+    : fir_Op<mnemonic, traits> {
 
   let assemblyFormat = [{
     operands attr-dict `:` functional-type(operands, results)
   }];
 }
 
-def fir_OneResultOpBuilder : OpBuilder<(ins
-    "mlir::Type":$resultType,
-    "mlir::ValueRange":$operands,
-    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-  [{
+def fir_OneResultOpBuilder
+    : OpBuilder<
+          (ins "mlir::Type":$resultType, "mlir::ValueRange":$operands,
+              CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+          [{
     if (resultType)
       $_state.addTypes(resultType);
     $_state.addOperands(operands);
@@ -53,35 +53,36 @@ def fir_OneResultOpBuilder : OpBuilder<(ins
   }]>;
 
 // Base class of FIR operations that return 1 result
-class fir_OneResultOp<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
+class fir_OneResultOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Base class of FIR operations that have 1 argument and return 1 result
-class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []> :
-    fir_SimpleOp<mnemonic, traits> {
+class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []>
+    : fir_SimpleOp<mnemonic, traits> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Whether a type is a BaseBoxType or a reference to a BaseBoxType.
-def IsBoxAddressOrValueTypePred
-        : CPred<"::fir::isBoxAddressOrValue($_self)">;
+def IsBoxAddressOrValueTypePred : CPred<"::fir::isBoxAddressOrValue($_self)">;
 def fir_BoxAddressOrValueType : Type<IsBoxAddressOrValueTypePred,
-    "fir.box or fir.class type or reference">;
+                                     "fir.box or fir.class type or reference">;
 
 def RefOfConstantSizeAggregateTypePred
-        : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
-def AnyRefOfConstantSizeAggregateType : TypeConstraint<
-      RefOfConstantSizeAggregateTypePred,
-      "a reference type to a constant size fir.array, fir.char, or fir.type">;
+    : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
+def AnyRefOfConstantSizeAggregateType
+    : TypeConstraint<RefOfConstantSizeAggregateTypePred,
+                     "a reference type to a constant size fir.array, fir.char, "
+                     "or fir.type">;
 
 //===----------------------------------------------------------------------===//
 // Memory SSA operations
 //===----------------------------------------------------------------------===//
 
-def fir_AllocaOp : fir_Op<"alloca",
-    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_AllocaOp
+    : fir_Op<"alloca", [AttrSizedOperandSegments,
+                        DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "allocate storage for a temporary on the stack given a type";
   let description = [{
     This primitive operation is used to allocate an object on the stack.  A
@@ -153,46 +154,42 @@ def fir_AllocaOp : fir_Op<"alloca",
     region and avoid them being hoisted in an alloca hoisting pass.
   }];
 
-  let arguments = (ins
-    TypeAttr:$in_type,
-    OptionalAttr<StrAttr>:$uniq_name,
-    OptionalAttr<StrAttr>:$bindc_name,
-    UnitAttr:$pinned,
-    Variadic<AnyIntegerType>:$typeparams,
-    Variadic<AnyIntegerType>:$shape
-  );
+  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
+      OptionalAttr<StrAttr>:$bindc_name, UnitAttr:$pinned,
+      Variadic<AnyIntegerType>:$typeparams, Variadic<AnyIntegerType>:$shape);
 
   let results = (outs fir_ReferenceType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      "llvm::StringRef":$bindcName, CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      "llvm::StringRef":$bindcName, "bool":$pinned,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-      "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$inType,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders =
+      [OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           "llvm::StringRef":$bindcName,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           "llvm::StringRef":$bindcName, "bool":$pinned,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+           "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$inType,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -212,8 +209,9 @@ def fir_AllocaOp : fir_Op<"alloca",
   }];
 }
 
-def fir_AllocMemOp : fir_Op<"allocmem",
-    [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>, AttrSizedOperandSegments]> {
+def fir_AllocMemOp
+    : fir_Op<"allocmem", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
+                          AttrSizedOperandSegments]> {
   let summary = "allocate storage on the heap for an object of a given type";
 
   let description = [{
@@ -228,31 +226,28 @@ def fir_AllocMemOp : fir_Op<"allocmem",
     ```
   }];
 
-  let arguments = (ins
-    TypeAttr:$in_type,
-    OptionalAttr<StrAttr>:$uniq_name,
-    OptionalAttr<StrAttr>:$bindc_name,
-    Variadic<AnyIntegerType>:$typeparams,
-    Variadic<AnyIntegerType>:$shape
-  );
+  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
+      OptionalAttr<StrAttr>:$bindc_name, Variadic<AnyIntegerType>:$typeparams,
+      Variadic<AnyIntegerType>:$shape);
   let results = (outs fir_HeapType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-      "llvm::StringRef":$bindc_name, CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Type":$in_type,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::ValueRange", "{}">:$shape,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders =
+      [OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+           "llvm::StringRef":$bindc_name,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Type":$in_type,
+           CArg<"mlir::ValueRange", "{}">:$typeparams,
+           CArg<"mlir::ValueRange", "{}">:$shape,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -288,8 +283,10 @@ def fir_FreeMemOp : fir_Op<"freemem", [MemoryEffects<[MemFree]>]> {
   let assemblyFormat = "$heapref attr-dict `:` qualified(type($heapref))";
 }
 
-def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
-                                          DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_LoadOp
+    : fir_OneResultOp<
+          "load", [FirAliasTagOpInterface,
+                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "load a value from a memory reference";
   let description = [{
     Load a value from a memory reference into an ssa-value (virtual register).
@@ -318,8 +315,9 @@ def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
   }];
 }
 
-def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
-                                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_StoreOp
+    : fir_Op<"store", [FirAliasTagOpInterface,
+                       DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "store an SSA-value to a memory location";
 
   let description = [{
@@ -351,7 +349,8 @@ def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
   }];
 }
 
-def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_CopyOp
+    : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "copy constant size memory";
 
   let description = [{
@@ -373,12 +372,11 @@ def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterf
   }];
 
   let arguments = (ins AnyRefOfConstantSizeAggregateType:$source,
-                       AnyRefOfConstantSizeAggregateType:$destination,
-                       OptionalAttr<UnitAttr>:$no_overlap);
+      AnyRefOfConstantSizeAggregateType:$destination,
+      OptionalAttr<UnitAttr>:$no_overlap);
 
   let builders = [OpBuilder<(ins "mlir::Value":$source,
-                                 "mlir::Value":$destination,
-                                  CArg<"bool", "false">:$no_overlap)>];
+      "mlir::Value":$destination, CArg<"bool", "false">:$no_overlap)>];
 
   let assemblyFormat = [{
     $source `to` $destination (`no_overlap` $no_overlap^)?
@@ -388,7 +386,6 @@ def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterf
   let hasVerifier = 1;
 }
 
-
 def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   let summary = [{
     save an array, box, or record function result SSA-value to a memory location
@@ -425,9 +422,8 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   }];
 
   let arguments = (ins ArrayOrBoxOrRecord:$value,
-                   Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
-                   Optional<AnyShapeType>:$shape,
-                   Variadic<AnyIntegerType>:$typeparams);
+      Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
+      Optional<AnyShapeType>:$shape, Variadic<AnyIntegerType>:$typeparams);
 
   let assemblyFormat = [{
     $value `to` $memref (`(` $shape^ `)`)? (`typeparams` $typeparams^)?
@@ -464,11 +460,8 @@ def fir_CharConvertOp : fir_Op<"char_convert", []> {
     `count` limit. These details are left as future to-dos.
   }];
 
-  let arguments = (ins
-    Arg<AnyReferenceLike, "", [MemRead]>:$from,
-    AnyIntegerType:$count,
-    Arg<AnyReferenceLike, "", [MemWrite]>:$to
-  );
+  let arguments = (ins Arg<AnyReferenceLike, "", [MemRead]>:$from,
+      AnyIntegerType:$count, Arg<AnyReferenceLike, "", [MemWrite]>:$to);
 
   let assemblyFormat = [{
     $from `for` $count `to` $to attr-dict `:` type(operands)
@@ -496,7 +489,8 @@ def fir_UndefOp : fir_OneResultOp<"undefined", [NoMemoryEffect]> {
 
   let assemblyFormat = "type($intype) attr-dict";
 
-  // Note: we allow `undef : ref<T>` since it is a possible from transformations.
+  // Note: we allow `undef : ref<T>` since it is a possible from
+  // transformations.
   let hasVerifier = 0;
 }
 
@@ -522,15 +516,14 @@ def fir_ZeroOp : fir_OneResultOp<"zero_bits", [NoMemoryEffect]> {
 // Terminator operations
 //===----------------------------------------------------------------------===//
 
-class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic, !listconcat(traits, [AttrSizedOperandSegments,
-    DeclareOpInterfaceMethods<BranchOpInterface>, Terminator])> {
+class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
+             !listconcat(traits, [AttrSizedOperandSegments,
+                                  DeclareOpInterfaceMethods<BranchOpInterface>,
+                                  Terminator])> {
 
-  let arguments = (ins
-    AnyType:$selector,
-    Variadic<AnyType>:$compareArgs,
-    Variadic<AnyType>:$targetArgs
-  );
+  let arguments = (ins AnyType:$selector, Variadic<AnyType>:$compareArgs,
+      Variadic<AnyType>:$targetArgs);
 
   let results = (outs);
 
@@ -583,16 +576,16 @@ class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
   }];
 }
 
-class fir_IntegralSwitchTerminatorOp<string mnemonic,
-    list<Trait> traits = []> : fir_SwitchTerminatorOp<mnemonic, traits> {
+class fir_IntegralSwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
+    : fir_SwitchTerminatorOp<mnemonic, traits> {
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$selector,
-    "llvm::ArrayRef<int64_t>":$compareOperands,
-    "llvm::ArrayRef<mlir::Block *>":$destinations,
-    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-    [{
+  let builders = [OpBuilder<
+      (ins "mlir::Value":$selector, "llvm::ArrayRef<int64_t>":$compareOperands,
+          "llvm::ArrayRef<mlir::Block *>":$destinations,
+          CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+          CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+      [{
       $_state.addOperands(selector);
       llvm::SmallVector<mlir::Attribute> ivalues;
       for (auto iv : compareOperands)
@@ -620,8 +613,7 @@ class fir_IntegralSwitchTerminatorOp<string mnemonic,
       $_state.addAttribute(getTargetOffsetAttr(),
         $_builder.getDenseI32ArrayAttr(argOffs));
       $_state.addAttributes(attributes);
-    }]
-  >];
+    }]>];
 
   let extraClassDeclaration = extraSwitchClassDeclaration;
 }
@@ -647,7 +639,6 @@ def fir_SelectOp : fir_IntegralSwitchTerminatorOp<"select"> {
   }];
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
-
 }
 
 def fir_SelectRankOp : fir_IntegralSwitchTerminatorOp<"select_rank"> {
@@ -693,19 +684,19 @@ def fir_SelectCaseOp : fir_SwitchTerminatorOp<"select_case"> {
   }];
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$selector,
-      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-      "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
-      "llvm::ArrayRef<mlir::Block *>":$destinations,
-      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-    OpBuilder<(ins "mlir::Value":$selector,
-      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-      "llvm::ArrayRef<mlir::Value>":$cmpOpList,
-      "llvm::ArrayRef<mlir::Block *>":$destinations,
-      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders =
+      [OpBuilder<(ins "mlir::Value":$selector,
+           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+           "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
+           "llvm::ArrayRef<mlir::Block *>":$destinations,
+           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+       OpBuilder<(ins "mlir::Value":$selector,
+           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+           "llvm::ArrayRef<mlir::Value>":$cmpOpList,
+           "llvm::ArrayRef<mlir::Block *>":$destinations,
+           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -737,10 +728,10 @@ def fir_SelectTypeOp : fir_SwitchTerminatorOp<"select_type"> {
 
   let skipDefaultBuilders = 1;
   let builders = [OpBuilder<(ins "mlir::Value":$selector,
-    "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
-    "llvm::ArrayRef<mlir::Block *>":$destinations,
-    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+      "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
+      "llvm::ArrayRef<mlir::Block *>":$destinations,
+      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -764,7 +755,6 @@ def fir_UnreachableOp : fir_Op<"unreachable", [Terminator]> {
   }];
 
   let assemblyFormat = [{ attr-dict }];
-
 }
 
 def fir_FirEndOp : fir_Op<"end", [Terminator, NoMemoryEffect]> {
@@ -843,17 +833,15 @@ def fir_EmboxOp : fir_Op<"embox", [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let results = (outs BoxOrClassType);
 
-  let builders = [
-    OpBuilder<(ins "llvm::ArrayRef<mlir::Type>":$resultTypes,
-      "mlir::Value":$memref, CArg<"mlir::Value", "{}">:$shape,
-      CArg<"mlir::Value", "{}">:$slice,
-      CArg<"mlir::ValueRange", "{}">:$typeparams,
-      CArg<"mlir::Value", "{}">:$sourceBox,
-      CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
-    [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
+  let builders = [OpBuilder<
+      (ins "llvm::ArrayRef<mlir::Type>":$resultTypes, "mlir::Value":$memref,
+          CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::Value", "{}">:$slice,
+          CArg<"mlir::ValueRange", "{}">:$typeparams,
+          CArg<"mlir::Value", "{}">:$sourceBox,
+          CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
+      [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
                     typeparams, sourceBox, mlir::AffineMapAttr{},
-                    allocator_idx); }]>
-  ];
+                    allocator_idx); }]>];
 
   let assemblyFormat = [{
     $memref (`(` $shape^ `)`)? (`[` $slice^ `]`)? (`typeparams` $typeparams^)?
@@ -909,11 +897,8 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins
-    BoxOrClassType:$box,
-    Optional<AnyShapeOrShiftType>:$shape,
-    Optional<fir_SliceType>:$slice
-  );
+  let arguments = (ins BoxOrClassType:$box,
+      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice);
 
   let results = (outs BoxOrClassType);
 
@@ -925,8 +910,9 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
   let hasVerifier = 1;
 }
 
-def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
-  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ReboxAssumedRankOp
+    : fir_Op<"rebox_assumed_rank", [DeclareOpInterfaceMethods<
+                                       MemoryEffectsOpInterface>]> {
   let summary = "create an assumed-rank box given another assumed-rank box";
 
   let description = [{
@@ -947,10 +933,8 @@ def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
     ```    
   }];
 
-  let arguments = (ins
-    AnyRefOrBoxType:$box,
-    fir_LowerBoundModifierAttribute:$lbs_modifier
-  );
+  let arguments = (ins AnyRefOrBoxType:$box,
+      fir_LowerBoundModifierAttribute:$lbs_modifier);
 
   let results = (outs BoxOrClassType);
 
@@ -1171,8 +1155,8 @@ def fir_BoxEleSizeOp : fir_SimpleOneResultOp<"box_elesize", [NoMemoryEffect]> {
   let results = (outs AnyIntegerLike);
 }
 
-def fir_BoxTypeCodeOp : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]>
-{
+def fir_BoxTypeCodeOp
+    : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]> {
   let summary = "return the type code the boxed value";
 
   let description = [{
@@ -1250,7 +1234,8 @@ def fir_IsAssumedSizeOp : fir_SimpleOp<"is_assumed_size", [NoMemoryEffect]> {
   let results = (outs BoolLike);
 }
 
-def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
+def fir_AssumedSizeExtentOp
+    : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
   let summary = "get the assumed-size last extent sentinel";
 
   let description = [{
@@ -1268,7 +1253,8 @@ def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMe
   let assemblyFormat = "attr-dict `:` type(results)";
 }
 
-def fir_IsAssumedSizeExtentOp : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
+def fir_IsAssumedSizeExtentOp
+    : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
   let summary = "is value the assumed-size last extent sentinel";
 
   let description = [{
@@ -1325,8 +1311,9 @@ def fir_BoxProcHostOp : fir_SimpleOp<"boxproc_host", [NoMemoryEffect]> {
   let results = (outs fir_ReferenceType);
 }
 
-def fir_BoxRankOp : fir_SimpleOneResultOp<"box_rank",
-  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_BoxRankOp
+    : fir_SimpleOneResultOp<
+          "box_rank", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "return the number of dimensions for the boxed value";
 
   let description = [{
@@ -1407,8 +1394,10 @@ def fir_BoxTypeDescOp : fir_SimpleOneResultOp<"box_tdesc", [NoMemoryEffect]> {
 //   !- Merge the new and old values into the memory for "A"
 //   array_merge_store <updated A> to <A's address>
 
-def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
-                                            DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayLoadOp
+    : fir_Op<
+          "array_load", [AttrSizedOperandSegments,
+                         DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
 
   let summary = "Load an array as a value.";
 
@@ -1446,12 +1435,9 @@ def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
     ```
   }];
 
-  let arguments = (ins
-    AnyRefOrBox:$memref,
-    Optional<AnyShapeOrShiftType>:$shape,
-    Optional<fir_SliceType>:$slice,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins AnyRefOrBox:$memref,
+      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_SequenceType);
 
@@ -1467,8 +1453,8 @@ def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
   }];
 }
 
-def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayFetchOp
+    : fir_Op<"array_fetch", [AttrSizedOperandSegments, NoMemoryEffect]> {
 
   let summary = "Fetch the value of an element of an array value";
 
@@ -1497,11 +1483,9 @@ def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
     It is only possible to use `array_fetch` on an `array_load` result value.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs AnyType:$element);
 
@@ -1513,8 +1497,8 @@ def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
   let hasVerifier = 1;
 }
 
-def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayUpdateOp
+    : fir_Op<"array_update", [AttrSizedOperandSegments, NoMemoryEffect]> {
 
   let summary = "Update the value of an element of an array value";
 
@@ -1548,12 +1532,9 @@ def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    AnyType:$merge,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence, AnyType:$merge,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_SequenceType);
 
@@ -1565,8 +1546,8 @@ def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
   let hasVerifier = 1;
 }
 
-def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayModifyOp
+    : fir_Op<"array_modify", [AttrSizedOperandSegments, NoMemoryEffect]> {
   let summary = "Get an address for an array value to modify it.";
 
   let description = [{
@@ -1607,11 +1588,9 @@ def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_ReferenceType, fir_SequenceType);
 
@@ -1623,8 +1602,8 @@ def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
   let hasVerifier = 1;
 }
 
-def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
-    NoMemoryEffect]> {
+def fir_ArrayAccessOp
+    : fir_Op<"array_access", [AttrSizedOperandSegments, NoMemoryEffect]> {
   let summary = "Fetch the reference of an element of an array value";
 
   let description = [{
@@ -1669,11 +1648,9 @@ def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$sequence,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_ReferenceType:$element);
 
@@ -1707,10 +1684,7 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$sequence,
-    fir_ReferenceType:$memref
-  );
+  let arguments = (ins fir_SequenceType:$sequence, fir_ReferenceType:$memref);
 
   let results = (outs fir_SequenceType);
 
@@ -1719,8 +1693,10 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
   }];
 }
 
-def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
-    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayMergeStoreOp
+    : fir_Op<"array_merge_store", [AttrSizedOperandSegments,
+                                   DeclareOpInterfaceMethods<
+                                       MemoryEffectsOpInterface>]> {
 
   let summary = "Store merged array value to memory.";
 
@@ -1746,13 +1722,9 @@ def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
     chained updates, `%r`, and stores the result to the array at address, `%a`.
   }];
 
-  let arguments = (ins
-    fir_SequenceType:$original,
-    fir_SequenceType:$sequence,
-    AnyRefOrBox:$memref,
-    Optional<fir_SliceType>:$slice,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins fir_SequenceType:$original, fir_SequenceType:$sequence,
+      AnyRefOrBox:$memref, Optional<fir_SliceType>:$slice,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let assemblyFormat = [{
     $original `,` $sequence `to` $memref (`[` $slice^ `]`)? (`typeparams`
@@ -1766,8 +1738,8 @@ def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
 // Record and array type operations
 //===----------------------------------------------------------------------===//
 
-def fir_ArrayCoorOp : fir_Op<"array_coor",
-    [NoMemoryEffect, AttrSizedOperandSegments]> {
+def fir_ArrayCoorOp
+    : fir_Op<"array_coor", [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let summary = "Find the coordinate of an element of an array";
 
@@ -1793,13 +1765,10 @@ def fir_ArrayCoorOp : fir_Op<"array_coor",
     ```
   }];
 
-  let arguments = (ins
-    AnyRefOrBox:$memref,
-    Optional<AnyShapeOrShiftType>:$shape,
-    Optional<fir_SliceType>:$slice,
-    Variadic<AnyCoordinateType>:$indices,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins AnyRefOrBox:$memref,
+      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
+      Variadic<AnyCoordinateType>:$indices,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let results = (outs fir_ReferenceType);
 
@@ -1843,24 +1812,18 @@ def fir_CoordinateOp : fir_Op<"coordinate_of", [NoMemoryEffect]> {
     array `%h`.
   }];
 
-  let arguments = (ins
-    AnyRefOrBox:$ref,
-    Variadic<AnyCoordinateType>:$coor,
-    TypeAttr:$baseType,
-    OptionalAttr<DenseI32ArrayAttr>:$field_indices
-  );
+  let arguments = (ins AnyRefOrBox:$ref, Variadic<AnyCoordinateType>:$coor,
+      TypeAttr:$baseType, OptionalAttr<DenseI32ArrayAttr>:$field_indices);
 
   let results = (outs RefOrLLVMPtr);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::Type":$resultType,
-      "mlir::Value":$ref, "mlir::ValueRange":$coor)>,
-    OpBuilder<(ins "mlir::Type":$resultType,
-      "mlir::Value":$ref, "llvm::ArrayRef<fir::IntOrValue>":$coor)>
-  ];
+  let builders = [OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
+                      "mlir::ValueRange":$coor)>,
+                  OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
+                      "llvm::ArrayRef<fir::IntOrValue>":$coor)>];
   let extraClassDeclaration = [{
     constexpr static int32_t kDynamicIndex = std::numeric_limits<int32_t>::min();
     CoordinateIndicesAdaptor getIndices();
@@ -1887,10 +1850,7 @@ def fir_ExtractValueOp : fir_OneResultOp<"extract_value", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins
-    AnyCompositeLike:$adt,
-    ArrayAttr:$coor
-  );
+  let arguments = (ins AnyCompositeLike:$adt, ArrayAttr:$coor);
 
   let assemblyFormat = [{
     $adt `,` $coor attr-dict `:` functional-type(operands, results)
@@ -1913,16 +1873,13 @@ def fir_FieldIndexOp : fir_OneResultOp<"field_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$field_id,
-    TypeAttr:$on_type,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2074,11 +2031,8 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins
-    Variadic<AnyIntegerType>:$triples,
-    Variadic<AnyComponentType>:$fields,
-    Variadic<AnyIntegerType>:$substr
-  );
+  let arguments = (ins Variadic<AnyIntegerType>:$triples,
+      Variadic<AnyComponentType>:$fields, Variadic<AnyIntegerType>:$substr);
 
   let results = (outs fir_SliceType);
 
@@ -2087,11 +2041,9 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
       functional-type(operands, results)
   }];
 
-  let builders = [
-    OpBuilder<(ins "mlir::ValueRange":$triples,
+  let builders = [OpBuilder<(ins "mlir::ValueRange":$triples,
       CArg<"mlir::ValueRange", "{}">:$fields,
-      CArg<"mlir::ValueRange", "{}">:$substr)>
-  ];
+      CArg<"mlir::ValueRange", "{}">:$substr)>];
 
   let hasVerifier = 1;
 
@@ -2154,7 +2106,8 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
     the value 3.0.
   }];
 
-  let arguments = (ins fir_SequenceType:$seq, AnyType:$val, IndexElementsAttr:$coor);
+  let arguments = (ins fir_SequenceType:$seq, AnyType:$val,
+      IndexElementsAttr:$coor);
   let results = (outs fir_SequenceType);
 
   let assemblyFormat = [{
@@ -2171,7 +2124,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
 
 def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
   let summary =
-    "create a field index value from a LEN type parameter identifier";
+      "create a field index value from a LEN type parameter identifier";
 
   let description = [{
     Generate a LEN parameter (offset) value from a LEN parameter identifier.
@@ -2186,16 +2139,13 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$field_id,
-    TypeAttr:$on_type,
-    Variadic<AnyIntegerType>:$typeparams
-  );
+  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
+      Variadic<AnyIntegerType>:$typeparams);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2209,9 +2159,9 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
 // Fortran loops
 //===----------------------------------------------------------------------===//
 
-def fir_ResultOp : fir_Op<"result",
-    [NoMemoryEffect, ReturnLike, Terminator,
-     ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
+def fir_ResultOp
+    : fir_Op<"result", [NoMemoryEffect, ReturnLike, Terminator,
+                        ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
   let summary = "special terminator for use in fir region operations";
 
   let description = [{
@@ -2231,17 +2181,19 @@ def fir_ResultOp : fir_Op<"result",
 
 def FirRegionTerminator : SingleBlockImplicitTerminator<"ResultOp">;
 
-class region_Op<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic,
-    !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
-        RecursiveMemoryEffects])> {
+class region_Op<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
+             !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
+                                  RecursiveMemoryEffects])> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 }
 
-def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
-    DeclareOpInterfaceMethods<LoopLikeOpInterface,
-        ["getYieldedValuesMutable"]>]> {
+def fir_DoLoopOp
+    : region_Op<
+          "do_loop", [AttrSizedOperandSegments,
+                      DeclareOpInterfaceMethods<
+                          LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
   let summary = "generalized loop operation";
   let description = [{
     Generalized high-level looping construct. This operation is similar to
@@ -2266,30 +2218,22 @@ def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
   let hasVerifier = 1;
   let hasCustomAssemblyFormat = 1;
 
-  let arguments = (ins
-    Index:$lowerBound,
-    Index:$upperBound,
-    Index:$step,
-    Variadic<AnyType>:$reduceOperands,
-    Variadic<AnyType>:$initArgs,
-    OptionalAttr<UnitAttr>:$unordered,
-    OptionalAttr<UnitAttr>:$finalValue,
-    OptionalAttr<ArrayAttr>:$reduceAttrs,
-    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
-  );
+  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
+      Variadic<AnyType>:$reduceOperands, Variadic<AnyType>:$initArgs,
+      OptionalAttr<UnitAttr>:$unordered, OptionalAttr<UnitAttr>:$finalValue,
+      OptionalAttr<ArrayAttr>:$reduceAttrs,
+      OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
-      "mlir::Value":$step, CArg<"bool", "false">:$unordered,
-      CArg<"bool", "false">:$finalCountValue,
+  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
+      "mlir::Value":$upperBound, "mlir::Value":$step,
+      CArg<"bool", "false">:$unordered, CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
       CArg<"mlir::ValueRange", "{}">:$reduceOperands,
       CArg<"llvm::ArrayRef<mlir::Attribute>", "{}">:$reduceAttrs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
-  ];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Value getInductionVar() { return getBody()->getArgument(0); }
@@ -2382,17 +2326,13 @@ def fir_IfOp
       OptionalAttr<DenseI32ArrayAttr>:$region_weights);
   let results = (outs Variadic<AnyType>:$results);
 
-  let regions = (region
-    SizedRegion<1>:$thenRegion,
-    MaxSizedRegion<1>:$elseRegion
-  );
+  let regions = (region SizedRegion<1>:$thenRegion,
+      MaxSizedRegion<1>:$elseRegion);
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
-    OpBuilder<(ins "mlir::TypeRange":$resultTypes, "mlir::Value":$cond,
-        "bool":$withElseRegion)>
-  ];
+  let builders = [OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
+                  OpBuilder<(ins "mlir::TypeRange":$resultTypes,
+                      "mlir::Value":$cond, "bool":$withElseRegion)>];
 
   let extraClassDeclaration = [{
     mlir::OpBuilder getThenBodyBuilder() {
@@ -2426,9 +2366,10 @@ def fir_IfOp
   }];
 }
 
-def fir_IterWhileOp : region_Op<"iterate_while",
-    [DeclareOpInterfaceMethods<LoopLikeOpInterface,
-        ["getYieldedValuesMutable"]>]> {
+def fir_IterWhileOp
+    : region_Op<"iterate_while",
+                [DeclareOpInterfaceMethods<
+                    LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
   let summary = "DO loop with early exit condition";
   let description = [{
     This single-entry, single-exit looping construct is useful for lowering
@@ -2457,25 +2398,18 @@ def fir_IterWhileOp : region_Op<"iterate_while",
     ```
   }];
 
-  let arguments = (ins
-    Index:$lowerBound,
-    Index:$upperBound,
-    Index:$step,
-    I1:$iterateIn,
-    Variadic<AnyType>:$initArgs,
-    OptionalAttr<UnitAttr>:$finalValue
-  );
+  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
+      I1:$iterateIn, Variadic<AnyType>:$initArgs,
+      OptionalAttr<UnitAttr>:$finalValue);
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
-      "mlir::Value":$step, "mlir::Value":$iterate,
+  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
+      "mlir::Value":$upperBound, "mlir::Value":$step, "mlir::Value":$iterate,
       CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
-  ];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFinalValueAttrNameStr() {
@@ -2528,8 +2462,9 @@ def fir_IterWhileOp : region_Op<"iterate_while",
 // Procedure call operations
 //===----------------------------------------------------------------------===//
 
-def fir_CallOp : fir_Op<"call",
-    [CallOpInterface, DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CallOp
+    : fir_Op<"call", [CallOpInterface,
+                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "call a procedure";
 
   let description = [{
@@ -2544,30 +2479,26 @@ def fir_CallOp : fir_Op<"call",
     ```
   }];
 
-  let arguments = (ins
-    OptionalAttr<SymbolRefAttr>:$callee,
-    Variadic<AnyType>:$args,
-    OptionalAttr<DictArrayAttr>:$arg_attrs,
-    OptionalAttr<DictArrayAttr>:$res_attrs,
-    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
-    OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
-    DefaultValuedAttr<Arith_FastMathAttr,
-                      "::mlir::arith::FastMathFlags::none">:$fastmath
-  );
+  let arguments = (ins OptionalAttr<SymbolRefAttr>:$callee,
+      Variadic<AnyType>:$args, OptionalAttr<DictArrayAttr>:$arg_attrs,
+      OptionalAttr<DictArrayAttr>:$res_attrs,
+      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
+      OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
+      DefaultValuedAttr<Arith_FastMathAttr,
+                        "::mlir::arith::FastMathFlags::none">:$fastmath);
   let results = (outs Variadic<AnyType>);
 
   let hasCustomAssemblyFormat = 1;
 
-  let builders = [
-    OpBuilder<(ins "mlir::func::FuncOp":$callee,
-        CArg<"mlir::ValueRange", "{}">:$operands)>,
-    OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
-        "llvm::ArrayRef<mlir::Type>":$results,
-        CArg<"mlir::ValueRange", "{}">:$operands)>,
-    OpBuilder<(ins "llvm::StringRef":$callee,
-        "llvm::ArrayRef<mlir::Type>":$results,
-        CArg<"mlir::ValueRange", "{}">:$operands),
-    [{
+  let builders = [OpBuilder<(ins "mlir::func::FuncOp":$callee,
+                      CArg<"mlir::ValueRange", "{}">:$operands)>,
+                  OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
+                      "llvm::ArrayRef<mlir::Type>":$results,
+                      CArg<"mlir::ValueRange", "{}">:$operands)>,
+                  OpBuilder<(ins "llvm::StringRef":$callee,
+                                "llvm::ArrayRef<mlir::Type>":$results,
+                                CArg<"mlir::ValueRange", "{}">:$operands),
+                            [{
       build($_builder, $_state,
           mlir::SymbolRefAttr::get($_builder.getContext(), callee), results,
           operands);
@@ -2631,15 +2562,11 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$method,
-    fir_ClassType:$object,
-    Variadic<AnyType>:$args,
-    OptionalAttr<I32Attr>:$pass_arg_pos,
-    OptionalAttr<DictArrayAttr>:$arg_attrs,
-    OptionalAttr<DictArrayAttr>:$res_attrs,
-    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs
-  );
+  let arguments = (ins StrAttr:$method, fir_ClassType:$object,
+      Variadic<AnyType>:$args, OptionalAttr<I32Attr>:$pass_arg_pos,
+      OptionalAttr<DictArrayAttr>:$arg_attrs,
+      OptionalAttr<DictArrayAttr>:$res_attrs,
+      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs);
 
   let results = (outs Variadic<AnyType>:$results);
 
@@ -2683,19 +2610,18 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::StringRef":$value,
-      CArg<"std::optional<int64_t>", "{}">:$len)>,
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::ArrayRef<char>":$xlist,
-      CArg<"std::optional<int64_t>", "{}">:$len)>,
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::ArrayRef<char16_t>":$xlist,
-      CArg<"std::optional<int64_t>", "{}">:$len)>,
-    OpBuilder<(ins "fir::CharacterType":$inType,
-      "llvm::ArrayRef<char32_t>":$xlist,
-      CArg<"std::optional<int64_t>", "{}">:$len)>];
+  let builders = [OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::StringRef":$value,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>,
+                  OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::ArrayRef<char>":$xlist,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>,
+                  OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::ArrayRef<char16_t>":$xlist,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>,
+                  OpBuilder<(ins "fir::CharacterType":$inType,
+                      "llvm::ArrayRef<char32_t>":$xlist,
+                      CArg<"std::optional<int64_t>", "{}">:$len)>];
 
   let extraClassDeclaration = [{
     static constexpr const char *size() { return "size"; }
@@ -2718,62 +2644,67 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
 
 // Complex operations
 
-class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []> :
-    fir_Op<mnemonic,
-           !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
-    Results<(outs AnyType:$result)> {
+class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
+             !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
+      Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
-      fir_Op<mnemonic,
+class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_Op<mnemonic,
              !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
       Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
-      fir_UnaryArithmeticOp<mnemonic, traits>,
+class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_UnaryArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$operand)>;
 
 def fir_NegcOp : ComplexUnaryArithmeticOp<"negc">;
 
-class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []> :
-      fir_ArithmeticOp<mnemonic, traits>,
+class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []>
+    : fir_ArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
           DefaultValuedAttr<Arith_FastMathAttr,
                             "::mlir::arith::FastMathFlags::none">:$fastmath)>;
 
-def fir_AddcOp : ComplexArithmeticOp<"addc",
-    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_SubcOp : ComplexArithmeticOp<"subc",
-    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_MulcOp : ComplexArithmeticOp<"mulc",
-    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_DivcOp : ComplexArithmeticOp<"divc",
-    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_AddcOp
+    : ComplexArithmeticOp<"addc", [Commutative, DeclareOpInterfaceMethods<
+                                                    ArithFastMathInterface>]>;
+def fir_SubcOp
+    : ComplexArithmeticOp<
+          "subc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_MulcOp
+    : ComplexArithmeticOp<"mulc", [Commutative, DeclareOpInterfaceMethods<
+                                                    ArithFastMathInterface>]>;
+def fir_DivcOp
+    : ComplexArithmeticOp<
+          "divc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
 // Pow is a builtin call and not a primitive
 
-def fir_CmpcOp : fir_Op<"cmpc",
-    [NoMemoryEffect, SameTypeOperands, SameOperandsAndResultShape,
-    DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CmpcOp
+    : fir_Op<"cmpc", [NoMemoryEffect, SameTypeOperands,
+                      SameOperandsAndResultShape,
+                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "complex floating-point comparison operator";
 
   let description = [{
     A complex comparison to handle complex types found in FIR.
   }];
 
-  let arguments = (ins
-      AnyFirComplex:$lhs,
-      AnyFirComplex:$rhs,
-      DefaultValuedAttr<Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath);
+  let arguments = (ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
+      DefaultValuedAttr<Arith_FastMathAttr,
+                        "::mlir::arith::FastMathFlags::none">:$fastmath);
 
   let results = (outs AnyLogicalLike);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "mlir::arith::CmpFPredicate":$predicate,
-    "mlir::Value":$lhs, "mlir::Value":$rhs), [{
+                                "mlir::Value":$lhs, "mlir::Value":$rhs),
+                            [{
       buildCmpCOp($_builder, $_state, predicate, lhs, rhs);
   }]>];
 
@@ -2873,12 +2804,15 @@ def fir_ConvertOp
   let hasCanonicalizer = 1;
 }
 
-def FortranTypeAttr : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
-    Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
-              "fir::UnsignedType, fir::LogicalType, mlir::FloatType, "
-              "mlir::ComplexType, "
-              "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self).getValue())"
-    >]>]>, "Fortran surface type"> {
+def FortranTypeAttr
+    : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
+                Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
+                          "fir::UnsignedType, fir::LogicalType, "
+                          "mlir::FloatType, "
+                          "mlir::ComplexType, "
+                          "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self)."
+                          "getValue())">]>]>,
+           "Fortran surface type"> {
   let storageType = [{ ::mlir::TypeAttr }];
   let returnType = "mlir::Type";
   let convertFromStorage = "mlir::cast<mlir::Type>($_self.getValue())";
@@ -2904,8 +2838,9 @@ def fir_TypeDescOp : fir_OneResultOp<"type_desc", [NoMemoryEffect]> {
   let builders = [OpBuilder<(ins "mlir::TypeAttr":$inty)>];
 }
 
-def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
-    [NoMemoryEffect, SameOperandsAndResultType]> {
+def fir_NoReassocOp
+    : fir_OneResultOp<"no_reassoc", [NoMemoryEffect,
+                                     SameOperandsAndResultType]> {
   let summary = "synthetic op to prevent reassociation";
   let description = [{
     Primitive operation meant to intrusively prevent operator reassociation.
@@ -2928,9 +2863,9 @@ def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
   let assemblyFormat = "$val attr-dict `:` type($val)";
 }
 
-class AtMostRegion<int numBlocks> : Region<
-  CPred<"$_self.getBlocks().size() <= " # numBlocks>,
-  "region with " # numBlocks # " blocks">;
+class AtMostRegion<int numBlocks>
+    : Region<CPred<"$_self.getBlocks().size() <= "#numBlocks>,
+             "region with "#numBlocks#" blocks">;
 
 def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
   let summary = "Global data";
@@ -2955,43 +2890,37 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$sym_name,
-    SymbolRefAttr:$symref,
-    TypeAttr:$type,
-    OptionalAttr<AnyAttr>:$initVal,
-    OptionalAttr<UnitAttr>:$constant,
-    OptionalAttr<UnitAttr>:$target,
-    OptionalAttr<StrAttr>:$linkName,
-    OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
-    OptionalAttr<I64Attr>:$alignment
-  );
+  let arguments = (ins StrAttr:$sym_name, SymbolRefAttr:$symref, TypeAttr:$type,
+      OptionalAttr<AnyAttr>:$initVal, OptionalAttr<UnitAttr>:$constant,
+      OptionalAttr<UnitAttr>:$target, OptionalAttr<StrAttr>:$linkName,
+      OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
+      OptionalAttr<I64Attr>:$alignment);
 
   let regions = (region AtMostRegion<1>:$region);
 
   let hasCustomAssemblyFormat = 1;
 
   let skipDefaultBuilders = 1;
-  let builders = [
-    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-      "bool":$isTarget, "mlir::Type":$type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-      CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-      "bool":$isTarget,
-      "mlir::Type":$type, CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-      "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-      "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
-      CArg<"mlir::StringAttr", "{}">:$linkage,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+  let builders =
+      [OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+           "bool":$isTarget, "mlir::Type":$type,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+           CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+           "bool":$isTarget, "mlir::Type":$type,
+           CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+           "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+           "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
+           CArg<"mlir::StringAttr", "{}">:$linkage,
+           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
   ];
 
   let extraClassDeclaration = [{
@@ -3056,8 +2985,8 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
 
 def ImplicitFirTerminator : SingleBlockImplicitTerminator<"FirEndOp">;
 
-def fir_TypeInfoOp : fir_Op<"type_info",
-    [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
+def fir_TypeInfoOp
+    : fir_Op<"type_info", [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
   let summary = "Derived type information";
 
   let description = [{
@@ -3087,26 +3016,18 @@ def fir_TypeInfoOp : fir_Op<"type_info",
     ```
   }];
 
-  let arguments = (ins
-    SymbolNameAttr:$sym_name,
-    TypeAttr:$type,
-    OptionalAttr<TypeAttr>:$parent_type,
-    UnitAttr:$no_init,
-    UnitAttr:$no_destroy,
-    UnitAttr:$no_final
-  );
+  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type,
+      OptionalAttr<TypeAttr>:$parent_type, UnitAttr:$no_init,
+      UnitAttr:$no_destroy, UnitAttr:$no_final);
 
   let hasVerifier = 1;
 
-  let regions = (region
-    MaxSizedRegion<1>:$dispatch_table,
-    MaxSizedRegion<1>:$component_info
-  );
+  let regions = (region MaxSizedRegion<1>:$dispatch_table,
+      MaxSizedRegion<1>:$component_info);
 
-  let builders = [
-    OpBuilder<(ins "fir::RecordType":$type, "fir::RecordType":$parent_type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>
-  ];
+  let builders = [OpBuilder<(ins "fir::RecordType":$type,
+      "fir::RecordType":$parent_type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>];
 
   let assemblyFormat = [{
     $sym_name (`noinit` $no_init^)? (`nodestroy` $no_destroy^)?
@@ -3157,7 +3078,8 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"TypeInfoOp">]> {
 }
 
 def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
-  let summary = "define extra information about a component inside fir.type_info";
+  let summary =
+      "define extra information about a component inside fir.type_info";
 
   let description = [{
     ```
@@ -3165,17 +3087,17 @@ def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
     ```
   }];
 
-  let arguments = (ins
-    StrAttr:$name,
-    OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
-    OptionalAttr<FlatSymbolRefAttr>:$init_val
-  );
+  let arguments = (ins StrAttr:$name,
+      OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
+      OptionalAttr<FlatSymbolRefAttr>:$init_val);
 
-  let assemblyFormat = "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
+  let assemblyFormat =
+      "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
 }
 
 def fir_AbsentOp : fir_OneResultOp<"absent", [NoMemoryEffect]> {
-  let summary = "create value to be passed for absent optional function argument";
+  let summary =
+      "create value to be passed for absent optional function argument";
   let description = [{
     Given the type of a function argument, create a value that will signal that
     an optional argument is absent in the call. On the caller side, fir.is_present
@@ -3316,10 +3238,7 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     The derived_type field cannot be used when the input to this op is a reference to a fir.boxchar.
   }];
 
-  let arguments = (ins
-    AnyReferenceLike:$box_ref,
-    fir_BoxFieldAttr:$field
-  );
+  let arguments = (ins AnyReferenceLike:$box_ref, fir_BoxFieldAttr:$field);
 
   let results = (outs RefOrLLVMPtr);
   let hasVerifier = 1;
@@ -3328,13 +3247,12 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     $box_ref $field attr-dict `:` functional-type(operands, results)
   }];
 
-  let builders = [
-    OpBuilder<(ins "mlir::Value":$boxRef, "fir::BoxFieldAttr":$field)>
-  ];
+  let builders = [OpBuilder<(ins "mlir::Value":$boxRef,
+      "fir::BoxFieldAttr":$field)>];
 }
 
-def fir_DummyScopeOp : fir_Op<"dummy_scope",
-    [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
+def fir_DummyScopeOp
+    : fir_Op<"dummy_scope", [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
   let summary = "Define a scope for dummy arguments";
 
   let description = [{
@@ -3559,9 +3477,9 @@ def fir_BoxTotalElementsOp
   let hasCanonicalizer = 1;
 }
 
-def YieldOp : fir_Op<"yield",
-    [Pure, ReturnLike, Terminator,
-     ParentOneOf<["LocalitySpecifierOp", "DeclareReductionOp"]>]> {
+def YieldOp : fir_Op<"yield", [Pure, ReturnLike, Terminator,
+                               ParentOneOf<["LocalitySpecifierOp",
+                                            "DeclareReductionOp"]>]> {
   let summary = "loop yield and termination operation";
   let description = [{
     "fir.yield" yields SSA values from a fir dialect op region and
@@ -3571,9 +3489,7 @@ def YieldOp : fir_Op<"yield",
 
   let arguments = (ins Variadic<AnyType>:$results);
 
-  let builders = [
-    OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
-  ];
+  let builders = [OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>];
 
   let assemblyFormat = "( `(` $results^ `:` type($results) `)` )? attr-dict";
 }
@@ -3651,13 +3567,11 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
     corresponds to a `local` or a `local_init` specifier.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name,
-                       TypeAttrOf<AnyType>:$type,
-                       LocalitySpecifierTypeAttr:$locality_specifier_type);
+  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttrOf<AnyType>:$type,
+      LocalitySpecifierTypeAttr:$locality_specifier_type);
 
-  let regions = (region AnyRegion:$init_region,
-                        AnyRegion:$copy_region,
-                        AnyRegion:$dealloc_region);
+  let regions = (region AnyRegion:$init_region, AnyRegion:$copy_region,
+      AnyRegion:$dealloc_region);
 
   let assemblyFormat = [{
     $locality_specifier_type $sym_name `:` $type
@@ -3699,8 +3613,8 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
   let hasRegionVerifier = 1;
 }
 
-def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
-                                                         Symbol]> {
+def fir_DeclareReductionOp
+    : fir_Op<"declare_reduction", [IsolatedFromAbove, Symbol]> {
   let summary = "declares a reduction kind";
   let description = [{
     Note: this operation is adapted from omp::DeclareReductionOp. There is a lot
@@ -3745,14 +3659,11 @@ def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
     match the parent operation's results.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name,
-                       TypeAttr:$type);
+  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type);
 
   let regions = (region MaxSizedRegion<1>:$allocRegion,
-                        AnyRegion:$initializerRegion,
-                        AnyRegion:$reductionRegion,
-                        AnyRegion:$atomicReductionRegion,
-                        AnyRegion:$cleanupRegion);
+      AnyRegion:$initializerRegion, AnyRegion:$reductionRegion,
+      AnyRegion:$atomicReductionRegion, AnyRegion:$cleanupRegion);
 
   let assemblyFormat = "$sym_name `:` $type attr-dict-with-keyword "
                        "( `alloc` $allocRegion^ )? "
@@ -3796,8 +3707,8 @@ def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
   let hasRegionVerifier = 1;
 }
 
-def fir_DoConcurrentOp : fir_Op<"do_concurrent",
-    [SingleBlock, AutomaticAllocationScope]> {
+def fir_DoConcurrentOp
+    : fir_Op<"do_concurrent", [SingleBlock, AutomaticAllocationScope]> {
   let summary = "do concurrent loop wrapper";
 
   let description = [{
@@ -3828,35 +3739,34 @@ def fir_DoConcurrentOp : fir_Op<"do_concurrent",
 }
 
 def fir_LocalSpecifier {
-  dag arguments = (ins
-    Variadic<AnyType>:$local_vars,
-    OptionalAttr<SymbolRefArrayAttr>:$local_syms
-  );
+  dag arguments = (ins Variadic<AnyType>:$local_vars,
+      OptionalAttr<SymbolRefArrayAttr>:$local_syms);
 }
 
 def fir_ReduceSpecifier {
-  dag arguments = (ins
-    Variadic<AnyType>:$reduce_vars,
-    OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
-
-    // This introduces redundency in how reductions are modelled. In particular,
-    // a single reduction is represented by 2 attributes:
-    //
-    // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
-    // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
-    //
-    // The first makes it easier to map `do concurrent` to parallization models
-    // (e.g. OpenMP and OpenACC) while the second makes it easier to map it to
-    // nests of `fir.do_loop ... unodered` ops.
-    OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
-    OptionalAttr<ArrayAttr>:$reduce_attrs
-  );
-}
-
-def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
-    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopLikeOpInterface,
-                                                         ["getLoopInductionVars"]>,
-     Terminator, NoTerminator, SingleBlock, ParentOneOf<["DoConcurrentOp"]>]> {
+  dag arguments = (ins Variadic<AnyType>:$reduce_vars,
+      OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
+
+      // This introduces redundency in how reductions are modelled. In
+      // particular, a single reduction is represented by 2 attributes:
+      //
+      // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
+      // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
+      //
+      // The first makes it easier to map `do concurrent` to parallization
+      // models (e.g. OpenMP and OpenACC) while the second makes it easier to
+      // map it to nests of `fir.do_loop ... unodered` ops.
+      OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
+      OptionalAttr<ArrayAttr>:$reduce_attrs);
+}
+
+def fir_DoConcurrentLoopOp
+    : fir_Op<"do_concurrent.loop",
+             [AttrSizedOperandSegments,
+              DeclareOpInterfaceMethods<
+                  LoopLikeOpInterface, ["getLoopInductionVars"]>,
+              Terminator, NoTerminator, SingleBlock,
+              ParentOneOf<["DoConcurrentOp"]>]> {
   let summary = "do concurrent loop";
 
   let description = [{
@@ -3904,16 +3814,11 @@ def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
       LLVM.
   }];
 
-  defvar opArgs = (ins
-    Variadic<Index>:$lowerBound,
-    Variadic<Index>:$upperBound,
-    Variadic<Index>:$step,
-    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
-  );
+  defvar opArgs = (ins Variadic<Index>:$lowerBound, Variadic<Index>:$upperBound,
+      Variadic<Index>:$step, OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
 
-  let arguments = !con(opArgs,
-    fir_LocalSpecifier.arguments,
-    fir_ReduceSpecifier.arguments);
+  let arguments =
+      !con(opArgs, fir_LocalSpecifier.arguments, fir_ReduceSpecifier.arguments);
 
   let regions = (region SizedRegion<1>:$region);
 
diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index c62bad5fc9c0a..a0972d0fb09e7 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -27,20 +27,17 @@ using namespace mlir;
 
 #define DEBUG_TYPE "fir-alias-analysis"
 
-// Classify 'candidate' as an allocation based on value-scoped Allocate effects
-// attached by its defining operation 'op'. Returns true if classified and fills
-// out 'v', 'defOp' and 'type'.
 static bool classifyAllocateFromEffects(mlir::Operation *op,
                                         mlir::Value candidate, mlir::Value &v,
                                         mlir::Operation *&defOp,
                                         fir::AliasAnalysis::SourceKind &type) {
   if (!op)
     return false;
-  auto iface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
-  if (!iface)
+  auto interface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
+  if (!interface)
     return false;
   llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
-  iface.getEffects(effects);
+  interface.getEffects(effects);
   for (mlir::MemoryEffects::EffectInstance &e : effects) {
     if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
         e.getValue() && e.getValue() == candidate) {

>From 704be714cf4ad240bd8f54329b1c2383dfbeb5e5 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Thu, 6 Nov 2025 14:09:09 -0800
Subject: [PATCH 14/18] restore FIROps.td

---
 .../include/flang/Optimizer/Dialect/FIROps.td | 931 ++++++++++--------
 1 file changed, 513 insertions(+), 418 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 087eadf836e18..98448d2591b29 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -30,22 +30,22 @@ include "mlir/IR/BuiltinAttributes.td"
 // Base class for FIR operations.
 // All operations automatically get a prefix of "fir.".
 class fir_Op<string mnemonic, list<Trait> traits>
-    : Op<FIROpsDialect, mnemonic, traits>;
+  : Op<FIROpsDialect, mnemonic, traits>;
 
 // Base class for FIR operations that take a single argument
 class fir_SimpleOp<string mnemonic, list<Trait> traits>
-    : fir_Op<mnemonic, traits> {
+  : fir_Op<mnemonic, traits> {
 
   let assemblyFormat = [{
     operands attr-dict `:` functional-type(operands, results)
   }];
 }
 
-def fir_OneResultOpBuilder
-    : OpBuilder<
-          (ins "mlir::Type":$resultType, "mlir::ValueRange":$operands,
-              CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-          [{
+def fir_OneResultOpBuilder : OpBuilder<(ins
+    "mlir::Type":$resultType,
+    "mlir::ValueRange":$operands,
+    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+  [{
     if (resultType)
       $_state.addTypes(resultType);
     $_state.addOperands(operands);
@@ -53,36 +53,35 @@ def fir_OneResultOpBuilder
   }]>;
 
 // Base class of FIR operations that return 1 result
-class fir_OneResultOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
+class fir_OneResultOp<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic, traits>, Results<(outs fir_Type:$res)> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Base class of FIR operations that have 1 argument and return 1 result
-class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []>
-    : fir_SimpleOp<mnemonic, traits> {
+class fir_SimpleOneResultOp<string mnemonic, list<Trait> traits = []> :
+    fir_SimpleOp<mnemonic, traits> {
   let builders = [fir_OneResultOpBuilder];
 }
 
 // Whether a type is a BaseBoxType or a reference to a BaseBoxType.
-def IsBoxAddressOrValueTypePred : CPred<"::fir::isBoxAddressOrValue($_self)">;
+def IsBoxAddressOrValueTypePred
+        : CPred<"::fir::isBoxAddressOrValue($_self)">;
 def fir_BoxAddressOrValueType : Type<IsBoxAddressOrValueTypePred,
-                                     "fir.box or fir.class type or reference">;
+    "fir.box or fir.class type or reference">;
 
 def RefOfConstantSizeAggregateTypePred
-    : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
-def AnyRefOfConstantSizeAggregateType
-    : TypeConstraint<RefOfConstantSizeAggregateTypePred,
-                     "a reference type to a constant size fir.array, fir.char, "
-                     "or fir.type">;
+        : CPred<"::fir::isRefOfConstantSizeAggregateType($_self)">;
+def AnyRefOfConstantSizeAggregateType : TypeConstraint<
+      RefOfConstantSizeAggregateTypePred,
+      "a reference type to a constant size fir.array, fir.char, or fir.type">;
 
 //===----------------------------------------------------------------------===//
 // Memory SSA operations
 //===----------------------------------------------------------------------===//
 
-def fir_AllocaOp
-    : fir_Op<"alloca", [AttrSizedOperandSegments,
-                        DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_AllocaOp : fir_Op<"alloca",
+    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "allocate storage for a temporary on the stack given a type";
   let description = [{
     This primitive operation is used to allocate an object on the stack.  A
@@ -154,42 +153,46 @@ def fir_AllocaOp
     region and avoid them being hoisted in an alloca hoisting pass.
   }];
 
-  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
-      OptionalAttr<StrAttr>:$bindc_name, UnitAttr:$pinned,
-      Variadic<AnyIntegerType>:$typeparams, Variadic<AnyIntegerType>:$shape);
+  let arguments = (ins
+    TypeAttr:$in_type,
+    OptionalAttr<StrAttr>:$uniq_name,
+    OptionalAttr<StrAttr>:$bindc_name,
+    UnitAttr:$pinned,
+    Variadic<AnyIntegerType>:$typeparams,
+    Variadic<AnyIntegerType>:$shape
+  );
 
   let results = (outs fir_ReferenceType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders =
-      [OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           "llvm::StringRef":$bindcName,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           "llvm::StringRef":$bindcName, "bool":$pinned,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
-           "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$inType,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      "llvm::StringRef":$bindcName, CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      "llvm::StringRef":$bindcName, "bool":$pinned,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
+      "bool":$pinned, CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType, "bool":$pinned,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$inType,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -209,9 +212,8 @@ def fir_AllocaOp
   }];
 }
 
-def fir_AllocMemOp
-    : fir_Op<"allocmem", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
-                          AttrSizedOperandSegments]> {
+def fir_AllocMemOp : fir_Op<"allocmem",
+    [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>, AttrSizedOperandSegments]> {
   let summary = "allocate storage on the heap for an object of a given type";
 
   let description = [{
@@ -226,28 +228,31 @@ def fir_AllocMemOp
     ```
   }];
 
-  let arguments = (ins TypeAttr:$in_type, OptionalAttr<StrAttr>:$uniq_name,
-      OptionalAttr<StrAttr>:$bindc_name, Variadic<AnyIntegerType>:$typeparams,
-      Variadic<AnyIntegerType>:$shape);
+  let arguments = (ins
+    TypeAttr:$in_type,
+    OptionalAttr<StrAttr>:$uniq_name,
+    OptionalAttr<StrAttr>:$bindc_name,
+    Variadic<AnyIntegerType>:$typeparams,
+    Variadic<AnyIntegerType>:$shape
+  );
   let results = (outs fir_HeapType);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders =
-      [OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-           "llvm::StringRef":$bindc_name,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Type":$in_type,
-           CArg<"mlir::ValueRange", "{}">:$typeparams,
-           CArg<"mlir::ValueRange", "{}">:$shape,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+      "llvm::StringRef":$bindc_name, CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Type":$in_type,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::ValueRange", "{}">:$shape,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let extraClassDeclaration = [{
     mlir::Type getAllocatedType();
@@ -283,10 +288,8 @@ def fir_FreeMemOp : fir_Op<"freemem", [MemoryEffects<[MemFree]>]> {
   let assemblyFormat = "$heapref attr-dict `:` qualified(type($heapref))";
 }
 
-def fir_LoadOp
-    : fir_OneResultOp<
-          "load", [FirAliasTagOpInterface,
-                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_LoadOp : fir_OneResultOp<"load", [FirAliasTagOpInterface,
+                                          DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "load a value from a memory reference";
   let description = [{
     Load a value from a memory reference into an ssa-value (virtual register).
@@ -315,9 +318,8 @@ def fir_LoadOp
   }];
 }
 
-def fir_StoreOp
-    : fir_Op<"store", [FirAliasTagOpInterface,
-                       DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_StoreOp : fir_Op<"store", [FirAliasTagOpInterface,
+                                   DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "store an SSA-value to a memory location";
 
   let description = [{
@@ -349,8 +351,7 @@ def fir_StoreOp
   }];
 }
 
-def fir_CopyOp
-    : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_CopyOp : fir_Op<"copy", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "copy constant size memory";
 
   let description = [{
@@ -372,11 +373,12 @@ def fir_CopyOp
   }];
 
   let arguments = (ins AnyRefOfConstantSizeAggregateType:$source,
-      AnyRefOfConstantSizeAggregateType:$destination,
-      OptionalAttr<UnitAttr>:$no_overlap);
+                       AnyRefOfConstantSizeAggregateType:$destination,
+                       OptionalAttr<UnitAttr>:$no_overlap);
 
   let builders = [OpBuilder<(ins "mlir::Value":$source,
-      "mlir::Value":$destination, CArg<"bool", "false">:$no_overlap)>];
+                                 "mlir::Value":$destination,
+                                  CArg<"bool", "false">:$no_overlap)>];
 
   let assemblyFormat = [{
     $source `to` $destination (`no_overlap` $no_overlap^)?
@@ -386,6 +388,7 @@ def fir_CopyOp
   let hasVerifier = 1;
 }
 
+
 def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   let summary = [{
     save an array, box, or record function result SSA-value to a memory location
@@ -422,8 +425,9 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
   }];
 
   let arguments = (ins ArrayOrBoxOrRecord:$value,
-      Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
-      Optional<AnyShapeType>:$shape, Variadic<AnyIntegerType>:$typeparams);
+                   Arg<AnyReferenceLike, "", [MemWrite]>:$memref,
+                   Optional<AnyShapeType>:$shape,
+                   Variadic<AnyIntegerType>:$typeparams);
 
   let assemblyFormat = [{
     $value `to` $memref (`(` $shape^ `)`)? (`typeparams` $typeparams^)?
@@ -460,8 +464,11 @@ def fir_CharConvertOp : fir_Op<"char_convert", []> {
     `count` limit. These details are left as future to-dos.
   }];
 
-  let arguments = (ins Arg<AnyReferenceLike, "", [MemRead]>:$from,
-      AnyIntegerType:$count, Arg<AnyReferenceLike, "", [MemWrite]>:$to);
+  let arguments = (ins
+    Arg<AnyReferenceLike, "", [MemRead]>:$from,
+    AnyIntegerType:$count,
+    Arg<AnyReferenceLike, "", [MemWrite]>:$to
+  );
 
   let assemblyFormat = [{
     $from `for` $count `to` $to attr-dict `:` type(operands)
@@ -489,8 +496,7 @@ def fir_UndefOp : fir_OneResultOp<"undefined", [NoMemoryEffect]> {
 
   let assemblyFormat = "type($intype) attr-dict";
 
-  // Note: we allow `undef : ref<T>` since it is a possible from
-  // transformations.
+  // Note: we allow `undef : ref<T>` since it is a possible from transformations.
   let hasVerifier = 0;
 }
 
@@ -516,14 +522,15 @@ def fir_ZeroOp : fir_OneResultOp<"zero_bits", [NoMemoryEffect]> {
 // Terminator operations
 //===----------------------------------------------------------------------===//
 
-class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
-             !listconcat(traits, [AttrSizedOperandSegments,
-                                  DeclareOpInterfaceMethods<BranchOpInterface>,
-                                  Terminator])> {
+class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic, !listconcat(traits, [AttrSizedOperandSegments,
+    DeclareOpInterfaceMethods<BranchOpInterface>, Terminator])> {
 
-  let arguments = (ins AnyType:$selector, Variadic<AnyType>:$compareArgs,
-      Variadic<AnyType>:$targetArgs);
+  let arguments = (ins
+    AnyType:$selector,
+    Variadic<AnyType>:$compareArgs,
+    Variadic<AnyType>:$targetArgs
+  );
 
   let results = (outs);
 
@@ -576,16 +583,16 @@ class fir_SwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
   }];
 }
 
-class fir_IntegralSwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
-    : fir_SwitchTerminatorOp<mnemonic, traits> {
+class fir_IntegralSwitchTerminatorOp<string mnemonic,
+    list<Trait> traits = []> : fir_SwitchTerminatorOp<mnemonic, traits> {
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<
-      (ins "mlir::Value":$selector, "llvm::ArrayRef<int64_t>":$compareOperands,
-          "llvm::ArrayRef<mlir::Block *>":$destinations,
-          CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-          CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
-      [{
+  let builders = [OpBuilder<(ins "mlir::Value":$selector,
+    "llvm::ArrayRef<int64_t>":$compareOperands,
+    "llvm::ArrayRef<mlir::Block *>":$destinations,
+    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes),
+    [{
       $_state.addOperands(selector);
       llvm::SmallVector<mlir::Attribute> ivalues;
       for (auto iv : compareOperands)
@@ -613,7 +620,8 @@ class fir_IntegralSwitchTerminatorOp<string mnemonic, list<Trait> traits = []>
       $_state.addAttribute(getTargetOffsetAttr(),
         $_builder.getDenseI32ArrayAttr(argOffs));
       $_state.addAttributes(attributes);
-    }]>];
+    }]
+  >];
 
   let extraClassDeclaration = extraSwitchClassDeclaration;
 }
@@ -639,6 +647,7 @@ def fir_SelectOp : fir_IntegralSwitchTerminatorOp<"select"> {
   }];
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
+
 }
 
 def fir_SelectRankOp : fir_IntegralSwitchTerminatorOp<"select_rank"> {
@@ -684,19 +693,19 @@ def fir_SelectCaseOp : fir_SwitchTerminatorOp<"select_case"> {
   }];
 
   let skipDefaultBuilders = 1;
-  let builders =
-      [OpBuilder<(ins "mlir::Value":$selector,
-           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-           "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
-           "llvm::ArrayRef<mlir::Block *>":$destinations,
-           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
-       OpBuilder<(ins "mlir::Value":$selector,
-           "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
-           "llvm::ArrayRef<mlir::Value>":$cmpOpList,
-           "llvm::ArrayRef<mlir::Block *>":$destinations,
-           CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$selector,
+      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+      "llvm::ArrayRef<mlir::ValueRange>":$cmpOperands,
+      "llvm::ArrayRef<mlir::Block *>":$destinations,
+      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>,
+    OpBuilder<(ins "mlir::Value":$selector,
+      "llvm::ArrayRef<mlir::Attribute>":$compareAttrs,
+      "llvm::ArrayRef<mlir::Value>":$cmpOpList,
+      "llvm::ArrayRef<mlir::Block *>":$destinations,
+      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -728,10 +737,10 @@ def fir_SelectTypeOp : fir_SwitchTerminatorOp<"select_type"> {
 
   let skipDefaultBuilders = 1;
   let builders = [OpBuilder<(ins "mlir::Value":$selector,
-      "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
-      "llvm::ArrayRef<mlir::Block *>":$destinations,
-      CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+    "llvm::ArrayRef<mlir::Attribute>":$typeOperands,
+    "llvm::ArrayRef<mlir::Block *>":$destinations,
+    CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
+    CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -755,6 +764,7 @@ def fir_UnreachableOp : fir_Op<"unreachable", [Terminator]> {
   }];
 
   let assemblyFormat = [{ attr-dict }];
+
 }
 
 def fir_FirEndOp : fir_Op<"end", [Terminator, NoMemoryEffect]> {
@@ -833,15 +843,17 @@ def fir_EmboxOp : fir_Op<"embox", [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let results = (outs BoxOrClassType);
 
-  let builders = [OpBuilder<
-      (ins "llvm::ArrayRef<mlir::Type>":$resultTypes, "mlir::Value":$memref,
-          CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::Value", "{}">:$slice,
-          CArg<"mlir::ValueRange", "{}">:$typeparams,
-          CArg<"mlir::Value", "{}">:$sourceBox,
-          CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
-      [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
+  let builders = [
+    OpBuilder<(ins "llvm::ArrayRef<mlir::Type>":$resultTypes,
+      "mlir::Value":$memref, CArg<"mlir::Value", "{}">:$shape,
+      CArg<"mlir::Value", "{}">:$slice,
+      CArg<"mlir::ValueRange", "{}">:$typeparams,
+      CArg<"mlir::Value", "{}">:$sourceBox,
+      CArg<"mlir::IntegerAttr", "{}">:$allocator_idx),
+    [{ return build($_builder, $_state, resultTypes, memref, shape, slice,
                     typeparams, sourceBox, mlir::AffineMapAttr{},
-                    allocator_idx); }]>];
+                    allocator_idx); }]>
+  ];
 
   let assemblyFormat = [{
     $memref (`(` $shape^ `)`)? (`[` $slice^ `]`)? (`typeparams` $typeparams^)?
@@ -897,8 +909,11 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins BoxOrClassType:$box,
-      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice);
+  let arguments = (ins
+    BoxOrClassType:$box,
+    Optional<AnyShapeOrShiftType>:$shape,
+    Optional<fir_SliceType>:$slice
+  );
 
   let results = (outs BoxOrClassType);
 
@@ -910,9 +925,8 @@ def fir_ReboxOp : fir_Op<"rebox", [NoMemoryEffect, AttrSizedOperandSegments]> {
   let hasVerifier = 1;
 }
 
-def fir_ReboxAssumedRankOp
-    : fir_Op<"rebox_assumed_rank", [DeclareOpInterfaceMethods<
-                                       MemoryEffectsOpInterface>]> {
+def fir_ReboxAssumedRankOp : fir_Op<"rebox_assumed_rank",
+  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "create an assumed-rank box given another assumed-rank box";
 
   let description = [{
@@ -933,8 +947,10 @@ def fir_ReboxAssumedRankOp
     ```    
   }];
 
-  let arguments = (ins AnyRefOrBoxType:$box,
-      fir_LowerBoundModifierAttribute:$lbs_modifier);
+  let arguments = (ins
+    AnyRefOrBoxType:$box,
+    fir_LowerBoundModifierAttribute:$lbs_modifier
+  );
 
   let results = (outs BoxOrClassType);
 
@@ -1155,8 +1171,8 @@ def fir_BoxEleSizeOp : fir_SimpleOneResultOp<"box_elesize", [NoMemoryEffect]> {
   let results = (outs AnyIntegerLike);
 }
 
-def fir_BoxTypeCodeOp
-    : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]> {
+def fir_BoxTypeCodeOp : fir_SimpleOneResultOp<"box_typecode", [NoMemoryEffect]>
+{
   let summary = "return the type code the boxed value";
 
   let description = [{
@@ -1234,8 +1250,7 @@ def fir_IsAssumedSizeOp : fir_SimpleOp<"is_assumed_size", [NoMemoryEffect]> {
   let results = (outs BoolLike);
 }
 
-def fir_AssumedSizeExtentOp
-    : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
+def fir_AssumedSizeExtentOp : fir_SimpleOneResultOp<"assumed_size_extent", [NoMemoryEffect]> {
   let summary = "get the assumed-size last extent sentinel";
 
   let description = [{
@@ -1253,8 +1268,7 @@ def fir_AssumedSizeExtentOp
   let assemblyFormat = "attr-dict `:` type(results)";
 }
 
-def fir_IsAssumedSizeExtentOp
-    : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
+def fir_IsAssumedSizeExtentOp : fir_SimpleOp<"is_assumed_size_extent", [NoMemoryEffect]> {
   let summary = "is value the assumed-size last extent sentinel";
 
   let description = [{
@@ -1311,9 +1325,8 @@ def fir_BoxProcHostOp : fir_SimpleOp<"boxproc_host", [NoMemoryEffect]> {
   let results = (outs fir_ReferenceType);
 }
 
-def fir_BoxRankOp
-    : fir_SimpleOneResultOp<
-          "box_rank", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_BoxRankOp : fir_SimpleOneResultOp<"box_rank",
+  [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
   let summary = "return the number of dimensions for the boxed value";
 
   let description = [{
@@ -1394,10 +1407,8 @@ def fir_BoxTypeDescOp : fir_SimpleOneResultOp<"box_tdesc", [NoMemoryEffect]> {
 //   !- Merge the new and old values into the memory for "A"
 //   array_merge_store <updated A> to <A's address>
 
-def fir_ArrayLoadOp
-    : fir_Op<
-          "array_load", [AttrSizedOperandSegments,
-                         DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments,
+                                            DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
 
   let summary = "Load an array as a value.";
 
@@ -1435,9 +1446,12 @@ def fir_ArrayLoadOp
     ```
   }];
 
-  let arguments = (ins AnyRefOrBox:$memref,
-      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    AnyRefOrBox:$memref,
+    Optional<AnyShapeOrShiftType>:$shape,
+    Optional<fir_SliceType>:$slice,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_SequenceType);
 
@@ -1453,8 +1467,8 @@ def fir_ArrayLoadOp
   }];
 }
 
-def fir_ArrayFetchOp
-    : fir_Op<"array_fetch", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
 
   let summary = "Fetch the value of an element of an array value";
 
@@ -1483,9 +1497,11 @@ def fir_ArrayFetchOp
     It is only possible to use `array_fetch` on an `array_load` result value.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs AnyType:$element);
 
@@ -1497,8 +1513,8 @@ def fir_ArrayFetchOp
   let hasVerifier = 1;
 }
 
-def fir_ArrayUpdateOp
-    : fir_Op<"array_update", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
 
   let summary = "Update the value of an element of an array value";
 
@@ -1532,9 +1548,12 @@ def fir_ArrayUpdateOp
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence, AnyType:$merge,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    AnyType:$merge,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_SequenceType);
 
@@ -1546,8 +1565,8 @@ def fir_ArrayUpdateOp
   let hasVerifier = 1;
 }
 
-def fir_ArrayModifyOp
-    : fir_Op<"array_modify", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
   let summary = "Get an address for an array value to modify it.";
 
   let description = [{
@@ -1588,9 +1607,11 @@ def fir_ArrayModifyOp
     memory until the `fir.array_merge_store` is performed.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_ReferenceType, fir_SequenceType);
 
@@ -1602,8 +1623,8 @@ def fir_ArrayModifyOp
   let hasVerifier = 1;
 }
 
-def fir_ArrayAccessOp
-    : fir_Op<"array_access", [AttrSizedOperandSegments, NoMemoryEffect]> {
+def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
+    NoMemoryEffect]> {
   let summary = "Fetch the reference of an element of an array value";
 
   let description = [{
@@ -1648,9 +1669,11 @@ def fir_ArrayAccessOp
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_ReferenceType:$element);
 
@@ -1684,7 +1707,10 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
     found in flang/docs/FIRArrayOperations.md.
   }];
 
-  let arguments = (ins fir_SequenceType:$sequence, fir_ReferenceType:$memref);
+  let arguments = (ins
+    fir_SequenceType:$sequence,
+    fir_ReferenceType:$memref
+  );
 
   let results = (outs fir_SequenceType);
 
@@ -1693,10 +1719,8 @@ def fir_ArrayAmendOp : fir_Op<"array_amend", [NoMemoryEffect]> {
   }];
 }
 
-def fir_ArrayMergeStoreOp
-    : fir_Op<"array_merge_store", [AttrSizedOperandSegments,
-                                   DeclareOpInterfaceMethods<
-                                       MemoryEffectsOpInterface>]> {
+def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
+    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
 
   let summary = "Store merged array value to memory.";
 
@@ -1722,9 +1746,13 @@ def fir_ArrayMergeStoreOp
     chained updates, `%r`, and stores the result to the array at address, `%a`.
   }];
 
-  let arguments = (ins fir_SequenceType:$original, fir_SequenceType:$sequence,
-      AnyRefOrBox:$memref, Optional<fir_SliceType>:$slice,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    fir_SequenceType:$original,
+    fir_SequenceType:$sequence,
+    AnyRefOrBox:$memref,
+    Optional<fir_SliceType>:$slice,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let assemblyFormat = [{
     $original `,` $sequence `to` $memref (`[` $slice^ `]`)? (`typeparams`
@@ -1738,8 +1766,8 @@ def fir_ArrayMergeStoreOp
 // Record and array type operations
 //===----------------------------------------------------------------------===//
 
-def fir_ArrayCoorOp
-    : fir_Op<"array_coor", [NoMemoryEffect, AttrSizedOperandSegments]> {
+def fir_ArrayCoorOp : fir_Op<"array_coor",
+    [NoMemoryEffect, AttrSizedOperandSegments]> {
 
   let summary = "Find the coordinate of an element of an array";
 
@@ -1765,10 +1793,13 @@ def fir_ArrayCoorOp
     ```
   }];
 
-  let arguments = (ins AnyRefOrBox:$memref,
-      Optional<AnyShapeOrShiftType>:$shape, Optional<fir_SliceType>:$slice,
-      Variadic<AnyCoordinateType>:$indices,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    AnyRefOrBox:$memref,
+    Optional<AnyShapeOrShiftType>:$shape,
+    Optional<fir_SliceType>:$slice,
+    Variadic<AnyCoordinateType>:$indices,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let results = (outs fir_ReferenceType);
 
@@ -1812,18 +1843,24 @@ def fir_CoordinateOp : fir_Op<"coordinate_of", [NoMemoryEffect]> {
     array `%h`.
   }];
 
-  let arguments = (ins AnyRefOrBox:$ref, Variadic<AnyCoordinateType>:$coor,
-      TypeAttr:$baseType, OptionalAttr<DenseI32ArrayAttr>:$field_indices);
+  let arguments = (ins
+    AnyRefOrBox:$ref,
+    Variadic<AnyCoordinateType>:$coor,
+    TypeAttr:$baseType,
+    OptionalAttr<DenseI32ArrayAttr>:$field_indices
+  );
 
   let results = (outs RefOrLLVMPtr);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
-                      "mlir::ValueRange":$coor)>,
-                  OpBuilder<(ins "mlir::Type":$resultType, "mlir::Value":$ref,
-                      "llvm::ArrayRef<fir::IntOrValue>":$coor)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Type":$resultType,
+      "mlir::Value":$ref, "mlir::ValueRange":$coor)>,
+    OpBuilder<(ins "mlir::Type":$resultType,
+      "mlir::Value":$ref, "llvm::ArrayRef<fir::IntOrValue>":$coor)>
+  ];
   let extraClassDeclaration = [{
     constexpr static int32_t kDynamicIndex = std::numeric_limits<int32_t>::min();
     CoordinateIndicesAdaptor getIndices();
@@ -1850,7 +1887,10 @@ def fir_ExtractValueOp : fir_OneResultOp<"extract_value", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins AnyCompositeLike:$adt, ArrayAttr:$coor);
+  let arguments = (ins
+    AnyCompositeLike:$adt,
+    ArrayAttr:$coor
+  );
 
   let assemblyFormat = [{
     $adt `,` $coor attr-dict `:` functional-type(operands, results)
@@ -1873,13 +1913,16 @@ def fir_FieldIndexOp : fir_OneResultOp<"field_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    StrAttr:$field_id,
+    TypeAttr:$on_type,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2031,8 +2074,11 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins Variadic<AnyIntegerType>:$triples,
-      Variadic<AnyComponentType>:$fields, Variadic<AnyIntegerType>:$substr);
+  let arguments = (ins
+    Variadic<AnyIntegerType>:$triples,
+    Variadic<AnyComponentType>:$fields,
+    Variadic<AnyIntegerType>:$substr
+  );
 
   let results = (outs fir_SliceType);
 
@@ -2041,9 +2087,11 @@ def fir_SliceOp : fir_Op<"slice", [NoMemoryEffect, AttrSizedOperandSegments]> {
       functional-type(operands, results)
   }];
 
-  let builders = [OpBuilder<(ins "mlir::ValueRange":$triples,
+  let builders = [
+    OpBuilder<(ins "mlir::ValueRange":$triples,
       CArg<"mlir::ValueRange", "{}">:$fields,
-      CArg<"mlir::ValueRange", "{}">:$substr)>];
+      CArg<"mlir::ValueRange", "{}">:$substr)>
+  ];
 
   let hasVerifier = 1;
 
@@ -2106,8 +2154,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
     the value 3.0.
   }];
 
-  let arguments = (ins fir_SequenceType:$seq, AnyType:$val,
-      IndexElementsAttr:$coor);
+  let arguments = (ins fir_SequenceType:$seq, AnyType:$val, IndexElementsAttr:$coor);
   let results = (outs fir_SequenceType);
 
   let assemblyFormat = [{
@@ -2124,7 +2171,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoMemoryEffect]> {
 
 def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
   let summary =
-      "create a field index value from a LEN type parameter identifier";
+    "create a field index value from a LEN type parameter identifier";
 
   let description = [{
     Generate a LEN parameter (offset) value from a LEN parameter identifier.
@@ -2139,13 +2186,16 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type,
-      Variadic<AnyIntegerType>:$typeparams);
+  let arguments = (ins
+    StrAttr:$field_id,
+    TypeAttr:$on_type,
+    Variadic<AnyIntegerType>:$typeparams
+  );
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
-      "mlir::Type":$recTy, CArg<"mlir::ValueRange", "{}">:$operands)>];
+      "mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFieldAttrName() { return "field_id"; }
@@ -2159,9 +2209,9 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoMemoryEffect]> {
 // Fortran loops
 //===----------------------------------------------------------------------===//
 
-def fir_ResultOp
-    : fir_Op<"result", [NoMemoryEffect, ReturnLike, Terminator,
-                        ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
+def fir_ResultOp : fir_Op<"result",
+    [NoMemoryEffect, ReturnLike, Terminator,
+     ParentOneOf<["IfOp", "DoLoopOp", "IterWhileOp"]>]> {
   let summary = "special terminator for use in fir region operations";
 
   let description = [{
@@ -2181,19 +2231,17 @@ def fir_ResultOp
 
 def FirRegionTerminator : SingleBlockImplicitTerminator<"ResultOp">;
 
-class region_Op<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
-             !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
-                                  RecursiveMemoryEffects])> {
+class region_Op<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic,
+    !listconcat(traits, [FirRegionTerminator, RecursivelySpeculatable,
+        RecursiveMemoryEffects])> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 }
 
-def fir_DoLoopOp
-    : region_Op<
-          "do_loop", [AttrSizedOperandSegments,
-                      DeclareOpInterfaceMethods<
-                          LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
+def fir_DoLoopOp : region_Op<"do_loop", [AttrSizedOperandSegments,
+    DeclareOpInterfaceMethods<LoopLikeOpInterface,
+        ["getYieldedValuesMutable"]>]> {
   let summary = "generalized loop operation";
   let description = [{
     Generalized high-level looping construct. This operation is similar to
@@ -2218,22 +2266,30 @@ def fir_DoLoopOp
   let hasVerifier = 1;
   let hasCustomAssemblyFormat = 1;
 
-  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
-      Variadic<AnyType>:$reduceOperands, Variadic<AnyType>:$initArgs,
-      OptionalAttr<UnitAttr>:$unordered, OptionalAttr<UnitAttr>:$finalValue,
-      OptionalAttr<ArrayAttr>:$reduceAttrs,
-      OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
+  let arguments = (ins
+    Index:$lowerBound,
+    Index:$upperBound,
+    Index:$step,
+    Variadic<AnyType>:$reduceOperands,
+    Variadic<AnyType>:$initArgs,
+    OptionalAttr<UnitAttr>:$unordered,
+    OptionalAttr<UnitAttr>:$finalValue,
+    OptionalAttr<ArrayAttr>:$reduceAttrs,
+    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
+  );
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
-      "mlir::Value":$upperBound, "mlir::Value":$step,
-      CArg<"bool", "false">:$unordered, CArg<"bool", "false">:$finalCountValue,
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
+      "mlir::Value":$step, CArg<"bool", "false">:$unordered,
+      CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
       CArg<"mlir::ValueRange", "{}">:$reduceOperands,
       CArg<"llvm::ArrayRef<mlir::Attribute>", "{}">:$reduceAttrs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
+  ];
 
   let extraClassDeclaration = [{
     mlir::Value getInductionVar() { return getBody()->getArgument(0); }
@@ -2326,13 +2382,17 @@ def fir_IfOp
       OptionalAttr<DenseI32ArrayAttr>:$region_weights);
   let results = (outs Variadic<AnyType>:$results);
 
-  let regions = (region SizedRegion<1>:$thenRegion,
-      MaxSizedRegion<1>:$elseRegion);
+  let regions = (region
+    SizedRegion<1>:$thenRegion,
+    MaxSizedRegion<1>:$elseRegion
+  );
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
-                  OpBuilder<(ins "mlir::TypeRange":$resultTypes,
-                      "mlir::Value":$cond, "bool":$withElseRegion)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion)>,
+    OpBuilder<(ins "mlir::TypeRange":$resultTypes, "mlir::Value":$cond,
+        "bool":$withElseRegion)>
+  ];
 
   let extraClassDeclaration = [{
     mlir::OpBuilder getThenBodyBuilder() {
@@ -2366,10 +2426,9 @@ def fir_IfOp
   }];
 }
 
-def fir_IterWhileOp
-    : region_Op<"iterate_while",
-                [DeclareOpInterfaceMethods<
-                    LoopLikeOpInterface, ["getYieldedValuesMutable"]>]> {
+def fir_IterWhileOp : region_Op<"iterate_while",
+    [DeclareOpInterfaceMethods<LoopLikeOpInterface,
+        ["getYieldedValuesMutable"]>]> {
   let summary = "DO loop with early exit condition";
   let description = [{
     This single-entry, single-exit looping construct is useful for lowering
@@ -2398,18 +2457,25 @@ def fir_IterWhileOp
     ```
   }];
 
-  let arguments = (ins Index:$lowerBound, Index:$upperBound, Index:$step,
-      I1:$iterateIn, Variadic<AnyType>:$initArgs,
-      OptionalAttr<UnitAttr>:$finalValue);
+  let arguments = (ins
+    Index:$lowerBound,
+    Index:$upperBound,
+    Index:$step,
+    I1:$iterateIn,
+    Variadic<AnyType>:$initArgs,
+    OptionalAttr<UnitAttr>:$finalValue
+  );
   let results = (outs Variadic<AnyType>:$results);
   let regions = (region SizedRegion<1>:$region);
 
   let skipDefaultBuilders = 1;
-  let builders = [OpBuilder<(ins "mlir::Value":$lowerBound,
-      "mlir::Value":$upperBound, "mlir::Value":$step, "mlir::Value":$iterate,
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$lowerBound, "mlir::Value":$upperBound,
+      "mlir::Value":$step, "mlir::Value":$iterate,
       CArg<"bool", "false">:$finalCountValue,
       CArg<"mlir::ValueRange", "{}">:$iterArgs,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>
+  ];
 
   let extraClassDeclaration = [{
     static constexpr llvm::StringRef getFinalValueAttrNameStr() {
@@ -2462,9 +2528,8 @@ def fir_IterWhileOp
 // Procedure call operations
 //===----------------------------------------------------------------------===//
 
-def fir_CallOp
-    : fir_Op<"call", [CallOpInterface,
-                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CallOp : fir_Op<"call",
+    [CallOpInterface, DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "call a procedure";
 
   let description = [{
@@ -2479,26 +2544,30 @@ def fir_CallOp
     ```
   }];
 
-  let arguments = (ins OptionalAttr<SymbolRefAttr>:$callee,
-      Variadic<AnyType>:$args, OptionalAttr<DictArrayAttr>:$arg_attrs,
-      OptionalAttr<DictArrayAttr>:$res_attrs,
-      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
-      OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
-      DefaultValuedAttr<Arith_FastMathAttr,
-                        "::mlir::arith::FastMathFlags::none">:$fastmath);
+  let arguments = (ins
+    OptionalAttr<SymbolRefAttr>:$callee,
+    Variadic<AnyType>:$args,
+    OptionalAttr<DictArrayAttr>:$arg_attrs,
+    OptionalAttr<DictArrayAttr>:$res_attrs,
+    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs,
+    OptionalAttr<fir_FortranInlineAttr>:$inline_attr,
+    DefaultValuedAttr<Arith_FastMathAttr,
+                      "::mlir::arith::FastMathFlags::none">:$fastmath
+  );
   let results = (outs Variadic<AnyType>);
 
   let hasCustomAssemblyFormat = 1;
 
-  let builders = [OpBuilder<(ins "mlir::func::FuncOp":$callee,
-                      CArg<"mlir::ValueRange", "{}">:$operands)>,
-                  OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
-                      "llvm::ArrayRef<mlir::Type>":$results,
-                      CArg<"mlir::ValueRange", "{}">:$operands)>,
-                  OpBuilder<(ins "llvm::StringRef":$callee,
-                                "llvm::ArrayRef<mlir::Type>":$results,
-                                CArg<"mlir::ValueRange", "{}">:$operands),
-                            [{
+  let builders = [
+    OpBuilder<(ins "mlir::func::FuncOp":$callee,
+        CArg<"mlir::ValueRange", "{}">:$operands)>,
+    OpBuilder<(ins "mlir::SymbolRefAttr":$callee,
+        "llvm::ArrayRef<mlir::Type>":$results,
+        CArg<"mlir::ValueRange", "{}">:$operands)>,
+    OpBuilder<(ins "llvm::StringRef":$callee,
+        "llvm::ArrayRef<mlir::Type>":$results,
+        CArg<"mlir::ValueRange", "{}">:$operands),
+    [{
       build($_builder, $_state,
           mlir::SymbolRefAttr::get($_builder.getContext(), callee), results,
           operands);
@@ -2562,11 +2631,15 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$method, fir_ClassType:$object,
-      Variadic<AnyType>:$args, OptionalAttr<I32Attr>:$pass_arg_pos,
-      OptionalAttr<DictArrayAttr>:$arg_attrs,
-      OptionalAttr<DictArrayAttr>:$res_attrs,
-      OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs);
+  let arguments = (ins
+    StrAttr:$method,
+    fir_ClassType:$object,
+    Variadic<AnyType>:$args,
+    OptionalAttr<I32Attr>:$pass_arg_pos,
+    OptionalAttr<DictArrayAttr>:$arg_attrs,
+    OptionalAttr<DictArrayAttr>:$res_attrs,
+    OptionalAttr<fir_FortranProcedureFlagsAttr>:$procedure_attrs
+  );
 
   let results = (outs Variadic<AnyType>:$results);
 
@@ -2610,18 +2683,19 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
 
-  let builders = [OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::StringRef":$value,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>,
-                  OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::ArrayRef<char>":$xlist,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>,
-                  OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::ArrayRef<char16_t>":$xlist,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>,
-                  OpBuilder<(ins "fir::CharacterType":$inType,
-                      "llvm::ArrayRef<char32_t>":$xlist,
-                      CArg<"std::optional<int64_t>", "{}">:$len)>];
+  let builders = [
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::StringRef":$value,
+      CArg<"std::optional<int64_t>", "{}">:$len)>,
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::ArrayRef<char>":$xlist,
+      CArg<"std::optional<int64_t>", "{}">:$len)>,
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::ArrayRef<char16_t>":$xlist,
+      CArg<"std::optional<int64_t>", "{}">:$len)>,
+    OpBuilder<(ins "fir::CharacterType":$inType,
+      "llvm::ArrayRef<char32_t>":$xlist,
+      CArg<"std::optional<int64_t>", "{}">:$len)>];
 
   let extraClassDeclaration = [{
     static constexpr const char *size() { return "size"; }
@@ -2644,67 +2718,62 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoMemoryEffect]> {
 
 // Complex operations
 
-class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
-             !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
-      Results<(outs AnyType:$result)> {
+class fir_ArithmeticOp<string mnemonic, list<Trait> traits = []> :
+    fir_Op<mnemonic,
+           !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
+    Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_Op<mnemonic,
+class fir_UnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
+      fir_Op<mnemonic,
              !listconcat(traits, [NoMemoryEffect, SameOperandsAndResultType])>,
       Results<(outs AnyType:$result)> {
   let assemblyFormat = "operands attr-dict `:` type($result)";
 }
 
-class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_UnaryArithmeticOp<mnemonic, traits>,
+class ComplexUnaryArithmeticOp<string mnemonic, list<Trait> traits = []> :
+      fir_UnaryArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$operand)>;
 
 def fir_NegcOp : ComplexUnaryArithmeticOp<"negc">;
 
-class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []>
-    : fir_ArithmeticOp<mnemonic, traits>,
+class ComplexArithmeticOp<string mnemonic, list<Trait> traits = []> :
+      fir_ArithmeticOp<mnemonic, traits>,
       Arguments<(ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
           DefaultValuedAttr<Arith_FastMathAttr,
                             "::mlir::arith::FastMathFlags::none">:$fastmath)>;
 
-def fir_AddcOp
-    : ComplexArithmeticOp<"addc", [Commutative, DeclareOpInterfaceMethods<
-                                                    ArithFastMathInterface>]>;
-def fir_SubcOp
-    : ComplexArithmeticOp<
-          "subc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
-def fir_MulcOp
-    : ComplexArithmeticOp<"mulc", [Commutative, DeclareOpInterfaceMethods<
-                                                    ArithFastMathInterface>]>;
-def fir_DivcOp
-    : ComplexArithmeticOp<
-          "divc", [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_AddcOp : ComplexArithmeticOp<"addc",
+    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_SubcOp : ComplexArithmeticOp<"subc",
+    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_MulcOp : ComplexArithmeticOp<"mulc",
+    [Commutative, DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
+def fir_DivcOp : ComplexArithmeticOp<"divc",
+    [DeclareOpInterfaceMethods<ArithFastMathInterface>]>;
 // Pow is a builtin call and not a primitive
 
-def fir_CmpcOp
-    : fir_Op<"cmpc", [NoMemoryEffect, SameTypeOperands,
-                      SameOperandsAndResultShape,
-                      DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
+def fir_CmpcOp : fir_Op<"cmpc",
+    [NoMemoryEffect, SameTypeOperands, SameOperandsAndResultShape,
+    DeclareOpInterfaceMethods<ArithFastMathInterface>]> {
   let summary = "complex floating-point comparison operator";
 
   let description = [{
     A complex comparison to handle complex types found in FIR.
   }];
 
-  let arguments = (ins AnyFirComplex:$lhs, AnyFirComplex:$rhs,
-      DefaultValuedAttr<Arith_FastMathAttr,
-                        "::mlir::arith::FastMathFlags::none">:$fastmath);
+  let arguments = (ins
+      AnyFirComplex:$lhs,
+      AnyFirComplex:$rhs,
+      DefaultValuedAttr<Arith_FastMathAttr, "::mlir::arith::FastMathFlags::none">:$fastmath);
 
   let results = (outs AnyLogicalLike);
 
   let hasCustomAssemblyFormat = 1;
 
   let builders = [OpBuilder<(ins "mlir::arith::CmpFPredicate":$predicate,
-                                "mlir::Value":$lhs, "mlir::Value":$rhs),
-                            [{
+    "mlir::Value":$lhs, "mlir::Value":$rhs), [{
       buildCmpCOp($_builder, $_state, predicate, lhs, rhs);
   }]>];
 
@@ -2804,15 +2873,12 @@ def fir_ConvertOp
   let hasCanonicalizer = 1;
 }
 
-def FortranTypeAttr
-    : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
-                Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
-                          "fir::UnsignedType, fir::LogicalType, "
-                          "mlir::FloatType, "
-                          "mlir::ComplexType, "
-                          "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self)."
-                          "getValue())">]>]>,
-           "Fortran surface type"> {
+def FortranTypeAttr : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
+    Or<[CPred<"mlir::isa<fir::CharacterType, fir::IntegerType, "
+              "fir::UnsignedType, fir::LogicalType, mlir::FloatType, "
+              "mlir::ComplexType, "
+              "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self).getValue())"
+    >]>]>, "Fortran surface type"> {
   let storageType = [{ ::mlir::TypeAttr }];
   let returnType = "mlir::Type";
   let convertFromStorage = "mlir::cast<mlir::Type>($_self.getValue())";
@@ -2838,9 +2904,8 @@ def fir_TypeDescOp : fir_OneResultOp<"type_desc", [NoMemoryEffect]> {
   let builders = [OpBuilder<(ins "mlir::TypeAttr":$inty)>];
 }
 
-def fir_NoReassocOp
-    : fir_OneResultOp<"no_reassoc", [NoMemoryEffect,
-                                     SameOperandsAndResultType]> {
+def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
+    [NoMemoryEffect, SameOperandsAndResultType]> {
   let summary = "synthetic op to prevent reassociation";
   let description = [{
     Primitive operation meant to intrusively prevent operator reassociation.
@@ -2863,9 +2928,9 @@ def fir_NoReassocOp
   let assemblyFormat = "$val attr-dict `:` type($val)";
 }
 
-class AtMostRegion<int numBlocks>
-    : Region<CPred<"$_self.getBlocks().size() <= "#numBlocks>,
-             "region with "#numBlocks#" blocks">;
+class AtMostRegion<int numBlocks> : Region<
+  CPred<"$_self.getBlocks().size() <= " # numBlocks>,
+  "region with " # numBlocks # " blocks">;
 
 def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
   let summary = "Global data";
@@ -2890,37 +2955,43 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$sym_name, SymbolRefAttr:$symref, TypeAttr:$type,
-      OptionalAttr<AnyAttr>:$initVal, OptionalAttr<UnitAttr>:$constant,
-      OptionalAttr<UnitAttr>:$target, OptionalAttr<StrAttr>:$linkName,
-      OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
-      OptionalAttr<I64Attr>:$alignment);
+  let arguments = (ins
+    StrAttr:$sym_name,
+    SymbolRefAttr:$symref,
+    TypeAttr:$type,
+    OptionalAttr<AnyAttr>:$initVal,
+    OptionalAttr<UnitAttr>:$constant,
+    OptionalAttr<UnitAttr>:$target,
+    OptionalAttr<StrAttr>:$linkName,
+    OptionalAttr<cuf_DataAttributeAttr>:$data_attr,
+    OptionalAttr<I64Attr>:$alignment
+  );
 
   let regions = (region AtMostRegion<1>:$region);
 
   let hasCustomAssemblyFormat = 1;
 
   let skipDefaultBuilders = 1;
-  let builders =
-      [OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-           "bool":$isTarget, "mlir::Type":$type,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-           CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-           "bool":$isTarget, "mlir::Type":$type,
-           CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
-           "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
-       OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
-           "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
-           CArg<"mlir::StringAttr", "{}">:$linkage,
-           CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+  let builders = [
+    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+      "bool":$isTarget, "mlir::Type":$type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+      CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+      "bool":$isTarget,
+      "mlir::Type":$type, CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "mlir::Type":$type,
+      "mlir::Attribute":$initVal, CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
+    OpBuilder<(ins "llvm::StringRef":$name, "bool":$isConstant,
+      "bool":$isTarget, "mlir::Type":$type, "mlir::Attribute":$initVal,
+      CArg<"mlir::StringAttr", "{}">:$linkage,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>,
   ];
 
   let extraClassDeclaration = [{
@@ -2985,8 +3056,8 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
 
 def ImplicitFirTerminator : SingleBlockImplicitTerminator<"FirEndOp">;
 
-def fir_TypeInfoOp
-    : fir_Op<"type_info", [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
+def fir_TypeInfoOp : fir_Op<"type_info",
+    [IsolatedFromAbove, Symbol, ImplicitFirTerminator]> {
   let summary = "Derived type information";
 
   let description = [{
@@ -3016,18 +3087,26 @@ def fir_TypeInfoOp
     ```
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type,
-      OptionalAttr<TypeAttr>:$parent_type, UnitAttr:$no_init,
-      UnitAttr:$no_destroy, UnitAttr:$no_final);
+  let arguments = (ins
+    SymbolNameAttr:$sym_name,
+    TypeAttr:$type,
+    OptionalAttr<TypeAttr>:$parent_type,
+    UnitAttr:$no_init,
+    UnitAttr:$no_destroy,
+    UnitAttr:$no_final
+  );
 
   let hasVerifier = 1;
 
-  let regions = (region MaxSizedRegion<1>:$dispatch_table,
-      MaxSizedRegion<1>:$component_info);
+  let regions = (region
+    MaxSizedRegion<1>:$dispatch_table,
+    MaxSizedRegion<1>:$component_info
+  );
 
-  let builders = [OpBuilder<(ins "fir::RecordType":$type,
-      "fir::RecordType":$parent_type,
-      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>];
+  let builders = [
+    OpBuilder<(ins "fir::RecordType":$type, "fir::RecordType":$parent_type,
+      CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs)>
+  ];
 
   let assemblyFormat = [{
     $sym_name (`noinit` $no_init^)? (`nodestroy` $no_destroy^)?
@@ -3078,8 +3157,7 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"TypeInfoOp">]> {
 }
 
 def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
-  let summary =
-      "define extra information about a component inside fir.type_info";
+  let summary = "define extra information about a component inside fir.type_info";
 
   let description = [{
     ```
@@ -3087,17 +3165,17 @@ def fir_DTComponentOp : fir_Op<"dt_component", [HasParent<"TypeInfoOp">]> {
     ```
   }];
 
-  let arguments = (ins StrAttr:$name,
-      OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
-      OptionalAttr<FlatSymbolRefAttr>:$init_val);
+  let arguments = (ins
+    StrAttr:$name,
+    OptionalAttr<DenseI64ArrayAttr>:$lower_bounds,
+    OptionalAttr<FlatSymbolRefAttr>:$init_val
+  );
 
-  let assemblyFormat =
-      "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
+  let assemblyFormat = "$name (`lbs` $lower_bounds^)? (`init` $init_val^)? attr-dict";
 }
 
 def fir_AbsentOp : fir_OneResultOp<"absent", [NoMemoryEffect]> {
-  let summary =
-      "create value to be passed for absent optional function argument";
+  let summary = "create value to be passed for absent optional function argument";
   let description = [{
     Given the type of a function argument, create a value that will signal that
     an optional argument is absent in the call. On the caller side, fir.is_present
@@ -3238,7 +3316,10 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     The derived_type field cannot be used when the input to this op is a reference to a fir.boxchar.
   }];
 
-  let arguments = (ins AnyReferenceLike:$box_ref, fir_BoxFieldAttr:$field);
+  let arguments = (ins
+    AnyReferenceLike:$box_ref,
+    fir_BoxFieldAttr:$field
+  );
 
   let results = (outs RefOrLLVMPtr);
   let hasVerifier = 1;
@@ -3247,12 +3328,13 @@ def fir_BoxOffsetOp : fir_Op<"box_offset", [NoMemoryEffect]> {
     $box_ref $field attr-dict `:` functional-type(operands, results)
   }];
 
-  let builders = [OpBuilder<(ins "mlir::Value":$boxRef,
-      "fir::BoxFieldAttr":$field)>];
+  let builders = [
+    OpBuilder<(ins "mlir::Value":$boxRef, "fir::BoxFieldAttr":$field)>
+  ];
 }
 
-def fir_DummyScopeOp
-    : fir_Op<"dummy_scope", [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
+def fir_DummyScopeOp : fir_Op<"dummy_scope",
+    [MemoryEffects<[MemWrite<DebuggingResource>]>]> {
   let summary = "Define a scope for dummy arguments";
 
   let description = [{
@@ -3477,9 +3559,9 @@ def fir_BoxTotalElementsOp
   let hasCanonicalizer = 1;
 }
 
-def YieldOp : fir_Op<"yield", [Pure, ReturnLike, Terminator,
-                               ParentOneOf<["LocalitySpecifierOp",
-                                            "DeclareReductionOp"]>]> {
+def YieldOp : fir_Op<"yield",
+    [Pure, ReturnLike, Terminator,
+     ParentOneOf<["LocalitySpecifierOp", "DeclareReductionOp"]>]> {
   let summary = "loop yield and termination operation";
   let description = [{
     "fir.yield" yields SSA values from a fir dialect op region and
@@ -3489,7 +3571,9 @@ def YieldOp : fir_Op<"yield", [Pure, ReturnLike, Terminator,
 
   let arguments = (ins Variadic<AnyType>:$results);
 
-  let builders = [OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>];
+  let builders = [
+    OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>
+  ];
 
   let assemblyFormat = "( `(` $results^ `:` type($results) `)` )? attr-dict";
 }
@@ -3567,11 +3651,13 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
     corresponds to a `local` or a `local_init` specifier.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttrOf<AnyType>:$type,
-      LocalitySpecifierTypeAttr:$locality_specifier_type);
+  let arguments = (ins SymbolNameAttr:$sym_name,
+                       TypeAttrOf<AnyType>:$type,
+                       LocalitySpecifierTypeAttr:$locality_specifier_type);
 
-  let regions = (region AnyRegion:$init_region, AnyRegion:$copy_region,
-      AnyRegion:$dealloc_region);
+  let regions = (region AnyRegion:$init_region,
+                        AnyRegion:$copy_region,
+                        AnyRegion:$dealloc_region);
 
   let assemblyFormat = [{
     $locality_specifier_type $sym_name `:` $type
@@ -3613,8 +3699,8 @@ def fir_LocalitySpecifierOp : fir_Op<"local", [IsolatedFromAbove]> {
   let hasRegionVerifier = 1;
 }
 
-def fir_DeclareReductionOp
-    : fir_Op<"declare_reduction", [IsolatedFromAbove, Symbol]> {
+def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
+                                                         Symbol]> {
   let summary = "declares a reduction kind";
   let description = [{
     Note: this operation is adapted from omp::DeclareReductionOp. There is a lot
@@ -3659,11 +3745,14 @@ def fir_DeclareReductionOp
     match the parent operation's results.
   }];
 
-  let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type);
+  let arguments = (ins SymbolNameAttr:$sym_name,
+                       TypeAttr:$type);
 
   let regions = (region MaxSizedRegion<1>:$allocRegion,
-      AnyRegion:$initializerRegion, AnyRegion:$reductionRegion,
-      AnyRegion:$atomicReductionRegion, AnyRegion:$cleanupRegion);
+                        AnyRegion:$initializerRegion,
+                        AnyRegion:$reductionRegion,
+                        AnyRegion:$atomicReductionRegion,
+                        AnyRegion:$cleanupRegion);
 
   let assemblyFormat = "$sym_name `:` $type attr-dict-with-keyword "
                        "( `alloc` $allocRegion^ )? "
@@ -3707,8 +3796,8 @@ def fir_DeclareReductionOp
   let hasRegionVerifier = 1;
 }
 
-def fir_DoConcurrentOp
-    : fir_Op<"do_concurrent", [SingleBlock, AutomaticAllocationScope]> {
+def fir_DoConcurrentOp : fir_Op<"do_concurrent",
+    [SingleBlock, AutomaticAllocationScope]> {
   let summary = "do concurrent loop wrapper";
 
   let description = [{
@@ -3739,34 +3828,35 @@ def fir_DoConcurrentOp
 }
 
 def fir_LocalSpecifier {
-  dag arguments = (ins Variadic<AnyType>:$local_vars,
-      OptionalAttr<SymbolRefArrayAttr>:$local_syms);
+  dag arguments = (ins
+    Variadic<AnyType>:$local_vars,
+    OptionalAttr<SymbolRefArrayAttr>:$local_syms
+  );
 }
 
 def fir_ReduceSpecifier {
-  dag arguments = (ins Variadic<AnyType>:$reduce_vars,
-      OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
-
-      // This introduces redundency in how reductions are modelled. In
-      // particular, a single reduction is represented by 2 attributes:
-      //
-      // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
-      // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
-      //
-      // The first makes it easier to map `do concurrent` to parallization
-      // models (e.g. OpenMP and OpenACC) while the second makes it easier to
-      // map it to nests of `fir.do_loop ... unodered` ops.
-      OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
-      OptionalAttr<ArrayAttr>:$reduce_attrs);
-}
-
-def fir_DoConcurrentLoopOp
-    : fir_Op<"do_concurrent.loop",
-             [AttrSizedOperandSegments,
-              DeclareOpInterfaceMethods<
-                  LoopLikeOpInterface, ["getLoopInductionVars"]>,
-              Terminator, NoTerminator, SingleBlock,
-              ParentOneOf<["DoConcurrentOp"]>]> {
+  dag arguments = (ins
+    Variadic<AnyType>:$reduce_vars,
+    OptionalAttr<DenseBoolArrayAttr>:$reduce_byref,
+
+    // This introduces redundency in how reductions are modelled. In particular,
+    // a single reduction is represented by 2 attributes:
+    //
+    // 1. `$reduce_syms` which is a list of `DeclareReductionOp`s.
+    // 2. `$reduce_attrs` which is an array of `fir::ReduceAttr` values.
+    //
+    // The first makes it easier to map `do concurrent` to parallization models
+    // (e.g. OpenMP and OpenACC) while the second makes it easier to map it to
+    // nests of `fir.do_loop ... unodered` ops.
+    OptionalAttr<SymbolRefArrayAttr>:$reduce_syms,
+    OptionalAttr<ArrayAttr>:$reduce_attrs
+  );
+}
+
+def fir_DoConcurrentLoopOp : fir_Op<"do_concurrent.loop",
+    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<LoopLikeOpInterface,
+                                                         ["getLoopInductionVars"]>,
+     Terminator, NoTerminator, SingleBlock, ParentOneOf<["DoConcurrentOp"]>]> {
   let summary = "do concurrent loop";
 
   let description = [{
@@ -3814,11 +3904,16 @@ def fir_DoConcurrentLoopOp
       LLVM.
   }];
 
-  defvar opArgs = (ins Variadic<Index>:$lowerBound, Variadic<Index>:$upperBound,
-      Variadic<Index>:$step, OptionalAttr<LoopAnnotationAttr>:$loopAnnotation);
+  defvar opArgs = (ins
+    Variadic<Index>:$lowerBound,
+    Variadic<Index>:$upperBound,
+    Variadic<Index>:$step,
+    OptionalAttr<LoopAnnotationAttr>:$loopAnnotation
+  );
 
-  let arguments =
-      !con(opArgs, fir_LocalSpecifier.arguments, fir_ReduceSpecifier.arguments);
+  let arguments = !con(opArgs,
+    fir_LocalSpecifier.arguments,
+    fir_ReduceSpecifier.arguments);
 
   let regions = (region SizedRegion<1>:$region);
 

>From df464d83e6b281d3a53033b231a43adc102cd31e Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Fri, 7 Nov 2025 06:58:30 -0800
Subject: [PATCH 15/18] change the signatura

---
 .../lib/Optimizer/Analysis/AliasAnalysis.cpp  | 39 +++++++++++--------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
index a0972d0fb09e7..ef9894232b409 100644
--- a/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
+++ b/flang/lib/Optimizer/Analysis/AliasAnalysis.cpp
@@ -27,27 +27,24 @@ using namespace mlir;
 
 #define DEBUG_TYPE "fir-alias-analysis"
 
-static bool classifyAllocateFromEffects(mlir::Operation *op,
-                                        mlir::Value candidate, mlir::Value &v,
-                                        mlir::Operation *&defOp,
-                                        fir::AliasAnalysis::SourceKind &type) {
+// Inspect for value-scoped Allocate effects and determine whether
+// 'candidate' is a new allocation. Returns SourceKind::Allocate if a
+// MemAlloc effect is attached
+static fir::AliasAnalysis::SourceKind
+classifyAllocateFromEffects(mlir::Operation *op, mlir::Value candidate) {
   if (!op)
-    return false;
+    return fir::AliasAnalysis::SourceKind::Unknown;
   auto interface = llvm::dyn_cast<mlir::MemoryEffectOpInterface>(op);
   if (!interface)
-    return false;
+    return fir::AliasAnalysis::SourceKind::Unknown;
   llvm::SmallVector<mlir::MemoryEffects::EffectInstance, 4> effects;
   interface.getEffects(effects);
   for (mlir::MemoryEffects::EffectInstance &e : effects) {
     if (mlir::isa<mlir::MemoryEffects::Allocate>(e.getEffect()) &&
-        e.getValue() && e.getValue() == candidate) {
-      v = candidate;
-      defOp = op;
-      type = fir::AliasAnalysis::SourceKind::Allocate;
-      return true;
-    }
+        e.getValue() && e.getValue() == candidate)
+      return fir::AliasAnalysis::SourceKind::Allocate;
   }
-  return false;
+  return fir::AliasAnalysis::SourceKind::Unknown;
 }
 
 //===----------------------------------------------------------------------===//
@@ -559,8 +556,10 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
   while (defOp && !breakFromLoop) {
     ty = defOp->getResultTypes()[0];
     // Value-scoped allocation detection via effects.
-    if (classifyAllocateFromEffects(defOp, v, v, defOp, type))
+    if (classifyAllocateFromEffects(defOp, v) == SourceKind::Allocate) {
+      type = SourceKind::Allocate;
       break;
+    }
     llvm::TypeSwitch<Operation *>(defOp)
         .Case<hlfir::AsExprOp>([&](auto op) {
           v = op.getVar();
@@ -650,9 +649,15 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
             } else {
               auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
               bool classified = false;
-              if (auto defDefOp = def.getDefiningOp())
-                classified =
-                    classifyAllocateFromEffects(defDefOp, def, v, defOp, type);
+              if (auto defDefOp = def.getDefiningOp()) {
+                if (classifyAllocateFromEffects(defDefOp, def) ==
+                    SourceKind::Allocate) {
+                  v = def;
+                  defOp = defDefOp;
+                  type = SourceKind::Allocate;
+                  classified = true;
+                }
+              }
               if (!classified) {
                 if (isDummyArgument(def)) {
                   defOp = nullptr;

>From d807d66b4d1ea4a15c92d803128a15abb5e91dcb Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Fri, 7 Nov 2025 09:36:13 -0800
Subject: [PATCH 16/18] remove getEffects

---
 .../include/flang/Optimizer/Dialect/FIROps.td | 17 +++++++----
 flang/lib/Optimizer/Dialect/FIROps.cpp        | 28 -------------------
 2 files changed, 11 insertions(+), 34 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 98448d2591b29..522c2fb84f40f 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -80,8 +80,10 @@ def AnyRefOfConstantSizeAggregateType : TypeConstraint<
 // Memory SSA operations
 //===----------------------------------------------------------------------===//
 
-def fir_AllocaOp : fir_Op<"alloca",
-    [AttrSizedOperandSegments, DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+def fir_AllocaOp
+    : fir_Op<"alloca",
+             [AttrSizedOperandSegments,
+              MemoryEffects<[MemAlloc<AutomaticAllocationScopeResource>]>]> {
   let summary = "allocate storage for a temporary on the stack given a type";
   let description = [{
     This primitive operation is used to allocate an object on the stack.  A
@@ -162,7 +164,9 @@ def fir_AllocaOp : fir_Op<"alloca",
     Variadic<AnyIntegerType>:$shape
   );
 
-  let results = (outs fir_ReferenceType);
+  let results =
+      (outs Res<fir_ReferenceType,
+                "", [MemAlloc<AutomaticAllocationScopeResource>]>:$res);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
@@ -212,8 +216,9 @@ def fir_AllocaOp : fir_Op<"alloca",
   }];
 }
 
-def fir_AllocMemOp : fir_Op<"allocmem",
-    [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>, AttrSizedOperandSegments]> {
+def fir_AllocMemOp
+    : fir_Op<"allocmem", [AttrSizedOperandSegments,
+                          MemoryEffects<[MemAlloc<DefaultResource>]>]> {
   let summary = "allocate storage on the heap for an object of a given type";
 
   let description = [{
@@ -235,7 +240,7 @@ def fir_AllocMemOp : fir_Op<"allocmem",
     Variadic<AnyIntegerType>:$typeparams,
     Variadic<AnyIntegerType>:$shape
   );
-  let results = (outs fir_HeapType);
+  let results = (outs Res<fir_HeapType, "", [MemAlloc<DefaultResource>]>:$res);
 
   let hasCustomAssemblyFormat = 1;
   let hasVerifier = 1;
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 9d182a699c634..4f97acaa88b7a 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -285,21 +285,6 @@ llvm::LogicalResult fir::AllocaOp::verify() {
   return mlir::success();
 }
 
-void fir::AllocaOp::getEffects(
-    llvm::SmallVectorImpl<
-        mlir::SideEffects::EffectInstance<mlir::MemoryEffects::Effect>>
-        &effects) {
-  // Value-scoped Allocate for AA.
-  effects.emplace_back(
-      mlir::MemoryEffects::Allocate::get(),
-      mlir::cast<mlir::OpResult>(getOperation()->getResult(0)),
-      mlir::SideEffects::AutomaticAllocationScopeResource::get());
-  // Preserve previous behavior: op-scoped Allocate for passes relying on it.
-  effects.emplace_back(
-      mlir::MemoryEffects::Allocate::get(),
-      mlir::SideEffects::AutomaticAllocationScopeResource::get());
-}
-
 bool fir::AllocaOp::ownsNestedAlloca(mlir::Operation *op) {
   return op->hasTrait<mlir::OpTrait::IsIsolatedFromAbove>() ||
          op->hasTrait<mlir::OpTrait::AutomaticAllocationScope>() ||
@@ -399,19 +384,6 @@ llvm::LogicalResult fir::AllocMemOp::verify() {
   return mlir::success();
 }
 
-void fir::AllocMemOp::getEffects(
-    llvm::SmallVectorImpl<
-        mlir::SideEffects::EffectInstance<mlir::MemoryEffects::Effect>>
-        &effects) {
-  // Value-scoped Allocate for AA.
-  effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
-                       mlir::cast<mlir::OpResult>(getOperation()->getResult(0)),
-                       mlir::SideEffects::DefaultResource::get());
-  // Preserve previous behavior: op-scoped Allocate for passes relying on it.
-  effects.emplace_back(mlir::MemoryEffects::Allocate::get(),
-                       mlir::SideEffects::DefaultResource::get());
-}
-
 //===----------------------------------------------------------------------===//
 // ArrayCoorOp
 //===----------------------------------------------------------------------===//

>From b9b30f53dcf2ff297af6d5af088b84a2d9ac0b67 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Fri, 7 Nov 2025 12:07:08 -0800
Subject: [PATCH 17/18] change tests

---
 .../include/flang/Optimizer/Dialect/FIROps.td |   9 +-
 flang/test/Driver/tco-emit-final-mlir.fir     |   2 +
 flang/test/Fir/alloc.fir                      |   9 +
 .../test/Fir/omp-reduction-embox-codegen.fir  |   4 +
 flang/test/Fir/pdt.fir                        |   6 +-
 flang/test/HLFIR/inline-hlfir-copy-in.fir     |  12 ++
 flang/test/Lower/Intrinsics/c_f_pointer.f90   |   1 -
 flang/test/Lower/Intrinsics/system_clock.f90  |   2 -
 flang/test/Lower/allocatables.f90             |   6 +-
 .../test/Lower/character-local-variables.f90  |  11 ++
 flang/test/Lower/derived-types.f90            |   2 -
 flang/test/Lower/do_loop_unstructured.f90     |   6 +-
 flang/test/Lower/forall/array-pointer.f90     |   1 -
 .../test/Lower/forall/forall-allocatable.f90  |  17 +-
 flang/test/Lower/loops.f90                    |   1 -
 flang/test/Lower/polymorphic.f90              |   4 -
 flang/test/Lower/statement-function.f90       |   1 -
 flang/test/Transforms/stack-arrays.fir        | 165 ++++++++----------
 18 files changed, 123 insertions(+), 136 deletions(-)

diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 522c2fb84f40f..289c79bd9b831 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -80,10 +80,7 @@ def AnyRefOfConstantSizeAggregateType : TypeConstraint<
 // Memory SSA operations
 //===----------------------------------------------------------------------===//
 
-def fir_AllocaOp
-    : fir_Op<"alloca",
-             [AttrSizedOperandSegments,
-              MemoryEffects<[MemAlloc<AutomaticAllocationScopeResource>]>]> {
+def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments]> {
   let summary = "allocate storage for a temporary on the stack given a type";
   let description = [{
     This primitive operation is used to allocate an object on the stack.  A
@@ -216,9 +213,7 @@ def fir_AllocaOp
   }];
 }
 
-def fir_AllocMemOp
-    : fir_Op<"allocmem", [AttrSizedOperandSegments,
-                          MemoryEffects<[MemAlloc<DefaultResource>]>]> {
+def fir_AllocMemOp : fir_Op<"allocmem", [AttrSizedOperandSegments]> {
   let summary = "allocate storage on the heap for an object of a given type";
 
   let description = [{
diff --git a/flang/test/Driver/tco-emit-final-mlir.fir b/flang/test/Driver/tco-emit-final-mlir.fir
index 75f8f153127af..7e934c921e773 100644
--- a/flang/test/Driver/tco-emit-final-mlir.fir
+++ b/flang/test/Driver/tco-emit-final-mlir.fir
@@ -15,5 +15,7 @@
 
 func.func @_QPfoo() {
   %1 = fir.alloca i32
+  %0 = arith.constant 0 : i32
+  fir.store %0 to %1 : !fir.ref<i32>
   return
 }
diff --git a/flang/test/Fir/alloc.fir b/flang/test/Fir/alloc.fir
index 8da8b828c18b9..e6a10c876e5da 100644
--- a/flang/test/Fir/alloc.fir
+++ b/flang/test/Fir/alloc.fir
@@ -372,8 +372,17 @@ func.func @alloca_unlimited_polymorphic_box() {
   %1 = fir.alloca !fir.class<!fir.array<?xnone>>
   %2 = fir.alloca !fir.box<none>
   %3 = fir.alloca !fir.box<!fir.array<?xnone>>
+  // Add real uses so allocas are not trivially dead.
+  func.call @__use_class_none(%0) : (!fir.ref<!fir.class<none>>) -> ()
+  func.call @__use_class_array(%1) : (!fir.ref<!fir.class<!fir.array<?xnone>>>) -> ()
+  func.call @__use_box_none(%2) : (!fir.ref<!fir.box<none>>) -> ()
+  func.call @__use_box_array(%3) : (!fir.ref<!fir.box<!fir.array<?xnone>>>) -> ()
   return
 }
+func.func private @__use_class_none(!fir.ref<!fir.class<none>>) -> ()
+func.func private @__use_class_array(!fir.ref<!fir.class<!fir.array<?xnone>>>) -> ()
+func.func private @__use_box_none(!fir.ref<!fir.box<none>>) -> ()
+func.func private @__use_box_array(!fir.ref<!fir.box<!fir.array<?xnone>>>) -> ()
 // Note: allocmem of fir.box are not possible (fir::HeapType::verify does not
 // accept box types), so there is no equivalent of
 // alloca_unlimited_polymorphic_box for allocmem.
diff --git a/flang/test/Fir/omp-reduction-embox-codegen.fir b/flang/test/Fir/omp-reduction-embox-codegen.fir
index 1645e1a407ad4..6eb6efc23483e 100644
--- a/flang/test/Fir/omp-reduction-embox-codegen.fir
+++ b/flang/test/Fir/omp-reduction-embox-codegen.fir
@@ -11,6 +11,8 @@ omp.declare_reduction @test_reduction : !fir.ref<!fir.box<i32>> init {
 ^bb0(%arg0: !fir.ref<!fir.box<i32>>):
   %0 = fir.alloca !fir.box<i32>
   %1 = fir.alloca i32
+  %c0 = arith.constant 0 : i32
+  fir.store %c0 to %1 : !fir.ref<i32>
   %2 = fir.embox %1 : (!fir.ref<i32>) -> !fir.box<i32>
 
   // use the embox for something so it isn't removed
@@ -28,9 +30,11 @@ func.func @_QQmain() attributes {fir.bindc_name = "reduce"} {
   omp.parallel reduction(byref @test_reduction %4 -> %arg0 : !fir.ref<!fir.box<i32>>) {
     omp.terminator
   }
+  func.call @__use_box_i32(%4) : (!fir.ref<!fir.box<i32>>) -> ()
   return
 }
 
+func.func private @__use_box_i32(!fir.ref<!fir.box<i32>>) -> ()
 // basically we are testing that there isn't a crash
 // CHECK-LABEL: define void @_QQmain
 // CHECK-NEXT:    alloca { ptr, i64, i32, i8, i8, i8, i8 }, i64 1, align 8
diff --git a/flang/test/Fir/pdt.fir b/flang/test/Fir/pdt.fir
index a200cd7e7cc03..04f48e745d033 100644
--- a/flang/test/Fir/pdt.fir
+++ b/flang/test/Fir/pdt.fir
@@ -95,14 +95,14 @@ func.func @_QTt1P.f2.offset(%0 : i32, %1 : i32) -> i32 {
 // end program p
 
 func.func private @bar(!fir.ref<!fir.char<1,?>>)
+func.func private @__use_t1(!fir.ref<!fir.type<_QTt1(p1:i32,p2:i32){f1:!fir.char<1,?>,f2:!fir.char<1,?>}>>) -> ()
 
 // CHECK-LABEL: define void @_QPfoo(i32 %0, i32 %1)
 func.func @_QPfoo(%arg0 : i32, %arg1 : i32) {
   // CHECK: %[[size:.*]] = call i64 @_QTt1P.mem.size(i32 %0, i32 %1)
   // CHECK: %[[alloc:.*]] = alloca i8, i64 %[[size]]
   %0 = fir.alloca !fir.type<_QTt1(p1:i32,p2:i32){f1:!fir.char<1,?>,f2:!fir.char<1,?>}>(%arg0, %arg1 : i32, i32)
-  //%2 = fir.coordinate_of %0, f2 : (!fir.ref<!fir.type<_QTt1>>) -> !fir.ref<!fir.char<1,?>>
-  %2 = fir.zero_bits !fir.ref<!fir.char<1,?>>
-  fir.call @bar(%2) : (!fir.ref<!fir.char<1,?>>) -> ()
+  // Keep alloca live without creating an unsupported coordinate_of on dynamic-sized field.
+  func.call @__use_t1(%0) : (!fir.ref<!fir.type<_QTt1(p1:i32,p2:i32){f1:!fir.char<1,?>,f2:!fir.char<1,?>}>>) -> ()
   return
 }
diff --git a/flang/test/HLFIR/inline-hlfir-copy-in.fir b/flang/test/HLFIR/inline-hlfir-copy-in.fir
index f3c4b38962a0c..884327b487098 100644
--- a/flang/test/HLFIR/inline-hlfir-copy-in.fir
+++ b/flang/test/HLFIR/inline-hlfir-copy-in.fir
@@ -31,6 +31,9 @@ func.func private @_test_inline_copy_in(%arg0: !fir.box<!fir.array<?x?x?xf64>> {
   fir.call @_QFPsb(%18, %19#0) fastmath<contract> : (!fir.ref<!fir.array<?xf64>>, !fir.ref<i32>) -> ()
   hlfir.copy_out %0, %17#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, i1) -> ()
   hlfir.end_associate %19#1, %19#2 : !fir.ref<i32>, i1
+  // Keep %0 live to avoid DCE after inlining when no copy_out is needed.
+  %zb0 = fir.zero_bits !fir.box<!fir.heap<!fir.array<?xf64>>>
+  fir.store %zb0 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>
   return
 }
 
@@ -110,6 +113,9 @@ func.func private @_test_no_inline_copy_in(%arg0: !fir.box<!fir.array<?x?x?xf64>
   fir.call @_QFPsb(%18, %19#1) fastmath<contract> : (!fir.ref<!fir.array<?xf64>>, !fir.ref<i32>) -> ()
   hlfir.copy_out %0, %17#1 to %16 : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, i1, !fir.box<!fir.array<?xf64>>) -> ()
   hlfir.end_associate %19#1, %19#2 : !fir.ref<i32>, i1
+  // Keep %0 live to avoid DCE after inlining.
+  %zb1 = fir.zero_bits !fir.box<!fir.heap<!fir.array<?xf64>>>
+  fir.store %zb1 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>
   return
 }
 
@@ -160,6 +166,9 @@ func.func @_QPoptional_copy_in_out(%arg0: !fir.box<!fir.array<?xf32>> {fir.bindc
   }
   fir.call @_QPtakes_optional_explicit(%4#0) fastmath<contract> : (!fir.ref<!fir.array<?xf32>>) -> ()
   hlfir.copy_out %0, %4#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>, i1) -> ()
+  // Keep %0 live to avoid DCE after inlining.
+  %zb2 = fir.zero_bits !fir.box<!fir.heap<!fir.array<?xf32>>>
+  fir.store %zb2 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
   return
 }
 
@@ -191,6 +200,9 @@ func.func @_QPtest_copy_in_out_2(%arg0: !fir.box<!fir.array<*:f32>> {fir.bindc_n
   %3:2 = hlfir.copy_in %2#0 to %0 : (!fir.box<!fir.array<*:f32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> (!fir.box<!fir.array<*:f32>>, i1)
   fir.call @_QPtakes_contiguous_intentin(%3#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
   hlfir.copy_out %0, %3#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, i1) -> ()
+  // Keep %0 live to avoid DCE after inlining.
+  %zb3 = fir.zero_bits !fir.box<!fir.heap<!fir.array<*:f32>>>
+  fir.store %zb3 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>
   return
 }
 
diff --git a/flang/test/Lower/Intrinsics/c_f_pointer.f90 b/flang/test/Lower/Intrinsics/c_f_pointer.f90
index c1f1d7972d4b1..f54fda42cf51b 100644
--- a/flang/test/Lower/Intrinsics/c_f_pointer.f90
+++ b/flang/test/Lower/Intrinsics/c_f_pointer.f90
@@ -153,7 +153,6 @@ subroutine dynamic_shape_lower(cptr, fpr, shape, lower)
 ! CHECK: %[[VAL_2:.*]] = fir.shape %[[C_0]], %[[C_0]] : (index, index) -> !fir.shape<2>
 ! CHECK: %[[VAL_3:.*]] = fir.embox %[[VAL_1:.*]](%[[VAL_2]]) : (!fir.ptr<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
 ! CHECK: fir.store %[[VAL_3]] to %[[VAL_0:.*]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
-! CHECK: %[[VAL_4:.*]] = fir.alloca i32 {bindc_name = "n", uniq_name = "_QFdynamic_shape_lowerEn"}
 ! CHECK: %[[VAL_5:.*]] = fir.coordinate_of %[[ARG_0:.*]], __address : (!fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>) -> !fir.ref<i64>
 ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_5]] : !fir.ref<i64>
 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> !fir.ptr<!fir.array<?x?xf32>>
diff --git a/flang/test/Lower/Intrinsics/system_clock.f90 b/flang/test/Lower/Intrinsics/system_clock.f90
index 9eae3a58884fa..f6fae1113b315 100644
--- a/flang/test/Lower/Intrinsics/system_clock.f90
+++ b/flang/test/Lower/Intrinsics/system_clock.f90
@@ -32,11 +32,9 @@ subroutine system_clock_test()
 
 ! CHECK-LABEL: @_QPss
 subroutine ss(count)
-  ! CHECK:   %[[V_0:[0-9]+]] = fir.alloca !fir.box<!fir.heap<i64>> {bindc_name = "count_max", uniq_name = "_QFssEcount_max"}
   ! CHECK:   %[[V_1:[0-9]+]] = fir.alloca !fir.heap<i64> {uniq_name = "_QFssEcount_max.addr"}
   ! CHECK:   %[[V_2:[0-9]+]] = fir.zero_bits !fir.heap<i64>
   ! CHECK:   fir.store %[[V_2]] to %[[V_1]] : !fir.ref<!fir.heap<i64>>
-  ! CHECK:   %[[V_3:[0-9]+]] = fir.alloca !fir.box<!fir.ptr<i64>> {bindc_name = "count_rate", uniq_name = "_QFssEcount_rate"}
   ! CHECK:   %[[V_4:[0-9]+]] = fir.alloca !fir.ptr<i64> {uniq_name = "_QFssEcount_rate.addr"}
   ! CHECK:   %[[V_5:[0-9]+]] = fir.zero_bits !fir.ptr<i64>
   ! CHECK:   fir.store %[[V_5]] to %[[V_4]] : !fir.ref<!fir.ptr<i64>>
diff --git a/flang/test/Lower/allocatables.f90 b/flang/test/Lower/allocatables.f90
index e62f92fa0c1c7..60b7de3301c48 100644
--- a/flang/test/Lower/allocatables.f90
+++ b/flang/test/Lower/allocatables.f90
@@ -56,7 +56,7 @@ subroutine foodim1()
   ! CHECK-DAG: fir.load %[[xAddrVar]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
 
   deallocate(x)
-  ! CHECK: %[[xAddr1:.*]] = fir.load %1 : !fir.ref<!fir.heap<!fir.array<?xf32>>>
+  ! CHECK: %[[xAddr1:.*]] = fir.load %{{.*}} : !fir.ref<!fir.heap<!fir.array<?xf32>>>
   ! CHECK: fir.freemem %[[xAddr1]]
   ! CHECK: %[[nullAddr1:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>>
   ! CHECK: fir.store %[[nullAddr1]] to %[[xAddrVar]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
@@ -67,10 +67,6 @@ subroutine foodim2()
   ! Test lowering of local allocatable specification
   real, allocatable :: x(:, :)
   ! CHECK-DAG: fir.alloca !fir.heap<!fir.array<?x?xf32>> {{{.*}}uniq_name = "_QFfoodim2Ex.addr"}
-  ! CHECK-DAG: fir.alloca index {{{.*}}uniq_name = "_QFfoodim2Ex.lb0"}
-  ! CHECK-DAG: fir.alloca index {{{.*}}uniq_name = "_QFfoodim2Ex.ext0"}
-  ! CHECK-DAG: fir.alloca index {{{.*}}uniq_name = "_QFfoodim2Ex.lb1"}
-  ! CHECK-DAG: fir.alloca index {{{.*}}uniq_name = "_QFfoodim2Ex.ext1"}
 end subroutine
 
 ! test lowering of character allocatables. Focus is placed on the length handling
diff --git a/flang/test/Lower/character-local-variables.f90 b/flang/test/Lower/character-local-variables.f90
index d5b959eca1ff6..6325229993a25 100644
--- a/flang/test/Lower/character-local-variables.f90
+++ b/flang/test/Lower/character-local-variables.f90
@@ -8,6 +8,7 @@
 subroutine scalar_cst_len()
   character(10) :: c
   ! CHECK: fir.alloca !fir.char<1,10> {{{.*}}uniq_name = "_QFscalar_cst_lenEc"}
+  print *, c
 end subroutine
 
 ! CHECK-LABEL: func @_QPscalar_dyn_len
@@ -19,12 +20,14 @@ subroutine scalar_dyn_len(l)
   ! CHECK: %[[is_positive:.*]] = arith.cmpi sgt, %[[lexpr]], %c0{{.*}} : i32
   ! CHECK: %[[l:.*]] = arith.select %[[is_positive]], %[[lexpr]], %c0{{.*}} : i32
   ! CHECK: fir.alloca !fir.char<1,?>(%[[l]] : i32) {{{.*}}uniq_name = "_QFscalar_dyn_lenEc"}
+  print *, c
 end subroutine
 
 ! CHECK-LABEL: func @_QPcst_array_cst_len
 subroutine cst_array_cst_len()
   character(10) :: c(20)
   ! CHECK: fir.alloca !fir.array<20x!fir.char<1,10>> {{{.*}}uniq_name = "_QFcst_array_cst_lenEc"}
+  print *, c(1)
 end subroutine
 
 ! CHECK-LABEL: func @_QPcst_array_dyn_len
@@ -36,6 +39,7 @@ subroutine cst_array_dyn_len(l)
   ! CHECK: %[[is_positive:.*]] = arith.cmpi sgt, %[[lexpr]], %c0{{.*}} : i32
   ! CHECK: %[[l:.*]] = arith.select %[[is_positive]], %[[lexpr]], %c0{{.*}} : i32
   ! CHECK: fir.alloca !fir.array<10x!fir.char<1,?>>(%[[l]] : i32) {{{.*}}uniq_name = "_QFcst_array_dyn_lenEc"}
+  print *, c(1)
 end subroutine
 
 ! CHECK-LABEL: func @_QPdyn_array_cst_len
@@ -48,6 +52,7 @@ subroutine dyn_array_cst_len(n)
   ! CHECK: %[[is_positive:.*]] = arith.cmpi sgt, %[[ni]], %c0{{.*}} : index
   ! CHECK: %[[extent:.*]] = arith.select %[[is_positive]], %[[ni]], %c0{{.*}} : index
   ! CHECK: fir.alloca !fir.array<?x!fir.char<1,10>>, %[[extent]] {{{.*}}uniq_name = "_QFdyn_array_cst_lenEc"}
+  print *, c(1)
 end subroutine
 
 ! CHECK: func @_QPdyn_array_dyn_len
@@ -63,12 +68,14 @@ subroutine dyn_array_dyn_len(l, n)
   ! CHECK: %[[is_positive:.*]] = arith.cmpi sgt, %[[ni]], %c0{{.*}} : index
   ! CHECK: %[[extent:.*]] = arith.select %[[is_positive]], %[[ni]], %c0{{.*}} : index
   ! CHECK: fir.alloca !fir.array<?x!fir.char<1,?>>(%[[l]] : i32), %[[extent]] {{{.*}}uniq_name = "_QFdyn_array_dyn_lenEc"}
+  print *, c(1)
 end subroutine
 
 ! CHECK-LABEL: func @_QPcst_array_cst_len_lb
 subroutine cst_array_cst_len_lb()
   character(10) :: c(11:30)
   ! CHECK: fir.alloca !fir.array<20x!fir.char<1,10>> {{{.*}}uniq_name = "_QFcst_array_cst_len_lbEc"}
+  print *, c(11)
 end subroutine
 
 ! CHECK-LABEL: func @_QPcst_array_dyn_len_lb
@@ -80,6 +87,7 @@ subroutine cst_array_dyn_len_lb(l)
   ! CHECK: %[[is_positive:.*]] = arith.cmpi sgt, %[[lexpr]], %c0{{.*}} : i64
   ! CHECK: %[[l:.*]] = arith.select %[[is_positive]], %[[lexpr]], %c0{{.*}} : i64
   ! CHECK: fir.alloca !fir.array<10x!fir.char<1,?>>(%[[l]] : i64) {{{.*}}uniq_name = "_QFcst_array_dyn_len_lbEc"}
+  print *, c(11)
 end subroutine
 
 ! CHECK-LABEL: func @_QPdyn_array_cst_len_lb
@@ -94,6 +102,7 @@ subroutine dyn_array_cst_len_lb(n)
   ! CHECK: %[[is_positive:.*]] = arith.cmpi sgt, %[[raw_extent]], %c0{{.*}} : index
   ! CHECK: %[[extent:.*]] = arith.select %[[is_positive]], %[[raw_extent]], %c0{{.*}} : index
   ! CHECK: fir.alloca !fir.array<?x!fir.char<1,10>>, %[[extent]] {{{.*}}uniq_name = "_QFdyn_array_cst_len_lbEc"}
+  print *, c(11)
 end subroutine
 
 ! CHECK-LABEL: func @_QPdyn_array_dyn_len_lb
@@ -111,6 +120,7 @@ subroutine dyn_array_dyn_len_lb(l, n)
   ! CHECK: %[[is_positive:.*]] = arith.cmpi sgt, %[[raw_extent]], %c0{{.*}} : index
   ! CHECK: %[[extent:.*]] = arith.select %[[is_positive]], %[[raw_extent]], %c0{{.*}} : index
   ! CHECK: fir.alloca !fir.array<?x!fir.char<1,?>>(%[[l]] : i64), %[[extent]] {{{.*}}uniq_name = "_QFdyn_array_dyn_len_lbEc"}
+  print *, c(11)
 end subroutine
 
 ! Test that the length of assumed length parameter is correctly deduced in lowering.
@@ -129,4 +139,5 @@ subroutine assumed_length_param(n)
 subroutine scalar_cst_neg_len()
   character(-1) :: c
   ! CHECK: fir.alloca !fir.char<1,0> {{{.*}}uniq_name = "_QFscalar_cst_neg_lenEc"}
+  print *, c
 end subroutine
diff --git a/flang/test/Lower/derived-types.f90 b/flang/test/Lower/derived-types.f90
index 4d36a7632b070..52faae2b8a35a 100644
--- a/flang/test/Lower/derived-types.f90
+++ b/flang/test/Lower/derived-types.f90
@@ -31,8 +31,6 @@ subroutine derived_dummy(some_r, some_c2)
 
 ! CHECK-LABEL: func @_QMdPlocal_derived(
 subroutine local_derived()
-  ! CHECK-DAG: fir.alloca !fir.type<_QMdTc2{ch_array:!fir.array<20x30x!fir.char<1,10>>}>
-  ! CHECK-DAG: fir.alloca !fir.type<_QMdTr{x:f32}>
   type(r) :: some_r
   type(c2) :: some_c2
 end subroutine
diff --git a/flang/test/Lower/do_loop_unstructured.f90 b/flang/test/Lower/do_loop_unstructured.f90
index 3b03850b43bb2..007f9d52a256d 100644
--- a/flang/test/Lower/do_loop_unstructured.f90
+++ b/flang/test/Lower/do_loop_unstructured.f90
@@ -244,9 +244,5 @@ subroutine unstructured_do_concurrent
 ! CHECK:       ^[[HEADER]]:
 ! CHECK:         %{{.*}} = fir.load %[[ITER_VAR]] : !fir.ref<i32>
 ! CHECK:         cf.cond_br %{{.*}}, ^[[BODY:.*]], ^[[EXIT:.*]]
-
-! CHECK:       ^[[BODY]]:
-! CHECK-NEXT:    %{{.*}} = fir.alloca !fir.logical<4> {bindc_name = "success", {{.*}}}
-
 ! CHECK:       ^[[EXIT]]:
-! CHECK-NEXT:    return
+! CHECK:    return
diff --git a/flang/test/Lower/forall/array-pointer.f90 b/flang/test/Lower/forall/array-pointer.f90
index fd3efed736c39..6b8c5648af29e 100644
--- a/flang/test/Lower/forall/array-pointer.f90
+++ b/flang/test/Lower/forall/array-pointer.f90
@@ -318,7 +318,6 @@ end subroutine s2_3
 ! CHECK-LABEL: func @_QPs2_3(
 ! CHECK-SAME:                %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.type<_QMarray_of_pointer_testTt{ip:!fir.box<!fir.ptr<i32>>}>>> {fir.bindc_name = "x"}) {
 ! CHECK:         %[[VAL_1:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
-! CHECK:         %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "y", fir.target, uniq_name = "_QFs2_3Ey"}
 ! CHECK:         %[[VAL_3:.*]] = fir.alloca !fir.heap<!fir.array<?xi32>> {uniq_name = "_QFs2_3Ey.addr"}
 ! CHECK:         %[[VAL_4:.*]] = fir.alloca index {uniq_name = "_QFs2_3Ey.lb0"}
 ! CHECK:         %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFs2_3Ey.ext0"}
diff --git a/flang/test/Lower/forall/forall-allocatable.f90 b/flang/test/Lower/forall/forall-allocatable.f90
index 96cd37ea3ed8a..8e54d282aea4b 100644
--- a/flang/test/Lower/forall/forall-allocatable.f90
+++ b/flang/test/Lower/forall/forall-allocatable.f90
@@ -13,20 +13,19 @@ end subroutine forall_with_allocatable
 ! CHECK-LABEL: func @_QPforall_with_allocatable(
 ! CHECK-SAME:                                   %[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}) {
 ! CHECK:         %[[VAL_1:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
-! CHECK:         %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xf32>>> {bindc_name = "arr", uniq_name = "_QFforall_with_allocatableEarr"}
-! CHECK:         %[[VAL_3:.*]] = fir.alloca !fir.heap<!fir.array<?xf32>> {uniq_name = "_QFforall_with_allocatableEarr.addr"}
-! CHECK:         %[[VAL_4:.*]] = fir.alloca index {uniq_name = "_QFforall_with_allocatableEarr.lb0"}
-! CHECK:         %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFforall_with_allocatableEarr.ext0"}
-! CHECK:         %[[VAL_6:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>>
-! CHECK:         fir.store %[[VAL_6]] to %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
+! CHECK:         %[[VAL_2:.*]] = fir.alloca !fir.heap<!fir.array<?xf32>> {uniq_name = "_QFforall_with_allocatableEarr.addr"}
+! CHECK:         %[[VAL_3:.*]] = fir.alloca index {uniq_name = "_QFforall_with_allocatableEarr.lb0"}
+! CHECK:         %[[VAL_4:.*]] = fir.alloca index {uniq_name = "_QFforall_with_allocatableEarr.ext0"}
+! CHECK:         %[[VAL_5:.*]] = fir.zero_bits !fir.heap<!fir.array<?xf32>>
+! CHECK:         fir.store %[[VAL_5]] to %[[VAL_2]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
 ! CHECK:         %[[VAL_7:.*]] = arith.constant 5 : i32
 ! CHECK:         %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> index
 ! CHECK:         %[[VAL_9:.*]] = arith.constant 15 : i32
 ! CHECK:         %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
 ! CHECK:         %[[VAL_11:.*]] = arith.constant 1 : index
-! CHECK:         %[[VAL_12:.*]] = fir.load %[[VAL_4]] : !fir.ref<index>
-! CHECK:         %[[VAL_13:.*]] = fir.load %[[VAL_5]] : !fir.ref<index>
-! CHECK:         %[[VAL_14:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
+! CHECK:         %[[VAL_12:.*]] = fir.load %[[VAL_3]] : !fir.ref<index>
+! CHECK:         %[[VAL_13:.*]] = fir.load %[[VAL_4]] : !fir.ref<index>
+! CHECK:         %[[VAL_14:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.heap<!fir.array<?xf32>>>
 ! CHECK:         %[[VAL_15:.*]] = fir.shape_shift %[[VAL_12]], %[[VAL_13]] : (index, index) -> !fir.shapeshift<1>
 ! CHECK:         %[[VAL_16:.*]] = fir.array_load %[[VAL_14]](%[[VAL_15]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>) -> !fir.array<?xf32>
 ! CHECK:         %[[VAL_17:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32>
diff --git a/flang/test/Lower/loops.f90 b/flang/test/Lower/loops.f90
index 2fea84b03891a..5ee6562733dae 100644
--- a/flang/test/Lower/loops.f90
+++ b/flang/test/Lower/loops.f90
@@ -90,7 +90,6 @@ subroutine lis(n)
   ! CHECK-DAG: fir.alloca !fir.array<?x?x?xi32>, %{{.*}}, %{{.*}}, %{{.*}} {bindc_name = "a", fir.target, uniq_name = "_QFlisEa"}
   ! CHECK-DAG: fir.alloca !fir.array<?x?xi32>, %{{.*}}, %{{.*}} {bindc_name = "r", uniq_name = "_QFlisEr"}
   ! CHECK-DAG: fir.alloca !fir.array<?x?xi32>, %{{.*}}, %{{.*}} {bindc_name = "s", uniq_name = "_QFlisEs"}
-  ! CHECK-DAG: fir.alloca !fir.array<?x?xi32>, %{{.*}}, %{{.*}} {bindc_name = "t", uniq_name = "_QFlisEt"}
   integer, target    :: a(n,n,n) ! operand via p
   integer            :: r(n,n)   ! result, unspecified locality
   integer            :: s(n,n)   ! shared locality
diff --git a/flang/test/Lower/polymorphic.f90 b/flang/test/Lower/polymorphic.f90
index f586380e653a0..bc4eed54282df 100644
--- a/flang/test/Lower/polymorphic.f90
+++ b/flang/test/Lower/polymorphic.f90
@@ -287,7 +287,6 @@ subroutine pointer_assign_parent(p)
 ! First test is here to have a reference with non polymorphic on both sides.
 ! CHECK-LABEL: func.func @_QMpolymorphic_testPpointer_assign_parent(
 ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.type<_QMpolymorphic_testTp2{a:i32,b:i32,c:f32}>> {fir.bindc_name = "p", fir.target}) {
-! CHECK: %[[TP:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>> {bindc_name = "tp", uniq_name = "_QMpolymorphic_testFpointer_assign_parentEtp"}
 ! CHECK: %[[PTR:.*]] = fir.alloca !fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>> {uniq_name = "_QMpolymorphic_testFpointer_assign_parentEtp.addr"}
 ! CHECK: %[[ZERO:.*]] = fir.zero_bits !fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>
 ! CHECK: fir.store %[[ZERO]] to %[[PTR]] : !fir.ref<!fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>>
@@ -302,7 +301,6 @@ subroutine pointer_assign_non_poly(p)
 
 ! CHECK-LABEL: func.func @_QMpolymorphic_testPpointer_assign_non_poly(
 ! CHECK-SAME: %arg0: !fir.class<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>> {fir.bindc_name = "p", fir.target}) {
-! CHECK: %[[TP:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>> {bindc_name = "tp", uniq_name = "_QMpolymorphic_testFpointer_assign_non_polyEtp"}
 ! CHECK: %[[PTR:.*]] = fir.alloca !fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>> {uniq_name = "_QMpolymorphic_testFpointer_assign_non_polyEtp.addr"}
 ! CHECK: %[[ZERO:.*]] = fir.zero_bits !fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>
 ! CHECK: fir.store %[[ZERO]] to %[[PTR]] : !fir.ref<!fir.ptr<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>>>
@@ -1103,11 +1101,9 @@ subroutine class_with_entry(a)
 
 ! CHECK-LABEL: func.func @_QMpolymorphic_testPclass_with_entry(
 ! CHECK-SAME: %[[A:.*]]: !fir.class<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>> {fir.bindc_name = "a"}) {
-! CHECK: %[[B:.*]] = fir.alloca !fir.class<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>> {bindc_name = "b", uniq_name = "_QMpolymorphic_testFclass_with_entryEb"}
 
 ! CHECK-LABEL: func.func @_QMpolymorphic_testPd(
 ! CHECK-SAME: %[[B:.*]]: !fir.class<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>> {fir.bindc_name = "b"}) {
-! CHECK: %[[A:.*]] = fir.alloca !fir.class<!fir.type<_QMpolymorphic_testTp1{a:i32,b:i32}>> {bindc_name = "a", uniq_name = "_QMpolymorphic_testFclass_with_entryEa"}
 
   subroutine class_array_with_entry(a)
     class(p1) :: a(:), b(:)
diff --git a/flang/test/Lower/statement-function.f90 b/flang/test/Lower/statement-function.f90
index cfec06c35baa8..fe07649e669af 100644
--- a/flang/test/Lower/statement-function.f90
+++ b/flang/test/Lower/statement-function.f90
@@ -129,7 +129,6 @@ integer function test_stmt_character_with_different_length_2(c, n)
   character(n) :: argc
   character(*) :: c
   ! CHECK: %[[unboxed:.*]]:2 = fir.unboxchar %[[arg0]] :
-  ! CHECK: fir.load %[[arg1]] : !fir.ref<i32>
   ! CHECK: %[[n:.*]] = fir.load %[[arg1]] : !fir.ref<i32>
   ! CHECK: %[[n_is_positive:.*]] = arith.cmpi sgt, %[[n]], %c0{{.*}} : i32
   ! CHECK: %[[len:.*]] = arith.select %[[n_is_positive]], %[[n]], %c0{{.*}} : i32
diff --git a/flang/test/Transforms/stack-arrays.fir b/flang/test/Transforms/stack-arrays.fir
index 4a417ed981ab1..282fb139ca495 100644
--- a/flang/test/Transforms/stack-arrays.fir
+++ b/flang/test/Transforms/stack-arrays.fir
@@ -3,13 +3,18 @@
 // Simplest transformation
 func.func @simple() {
   %0 = fir.allocmem !fir.array<42xi32>
+  %c0 = arith.constant 0 : index
+  %c0_i32 = arith.constant 0 : i32
+  %ref = fir.convert %0 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
+  %elt = fir.coordinate_of %ref, %c0 : (!fir.ref<!fir.array<42xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32 to %elt : !fir.ref<i32>
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
   return
 }
 // CHECK: func.func @simple() {
-// CHECK-NEXT: fir.alloca !fir.array<42xi32>
-// CHECK-NEXT: return
-// CHECK-NEXT: }
+// CHECK: fir.alloca !fir.array<42xi32>
+// CHECK: return
+// CHECK: }
 
 // Check fir.must_be_heap allocations are not moved
 func.func @must_be_heap() {
@@ -17,7 +22,7 @@ func.func @must_be_heap() {
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK:      func.func @must_be_heap() {
+// CHECK: func.func @must_be_heap() {
 // CHECK-NEXT:   %[[ALLOC:.*]] = fir.allocmem !fir.array<42xi32> {fir.must_be_heap = true}
 // CHECK-NEXT:   fir.freemem %[[ALLOC]] : !fir.heap<!fir.array<42xi32>>
 // CHECK-NEXT:   return
@@ -57,7 +62,7 @@ func.func @dfa2(%arg0: i1) {
   }
   return
 }
-// CHECK:     func.func @dfa2(%arg0: i1) {
+// CHECK: func.func @dfa2(%arg0: i1) {
 // CHECK-NEXT:  %[[MEM:.*]] = fir.allocmem !fir.array<1xi8>
 // CHECK-NEXT:  scf.if %arg0 {
 // CHECK-NEXT:    fir.freemem %[[MEM]] : !fir.heap<!fir.array<1xi8>>
@@ -76,13 +81,10 @@ func.func @dfa3(%arg0: i1) {
   }
   return
 }
-// CHECK:     func.func @dfa3(%arg0: i1) {
-// CHECK-NEXT:  %[[MEM:.*]] = fir.alloca !fir.array<1xi8>
-// CHECK-NEXT:  fir.if %arg0 {
-// CHECK-NEXT:  } else {
-// CHECK-NEXT:  }
-// CHECK-NEXT:  return
-// CHECK-NEXT:  }
+// CHECK: func.func @dfa3(%arg0: i1) {
+// CHECK:  %[[MEM:.*]] = fir.alloca !fir.array<1xi8>
+// CHECK:  return
+// CHECK:  }
 
 func.func private @dfa3a_foo(!fir.ref<!fir.array<1xi8>>) -> ()
 func.func private @dfa3a_bar(!fir.ref<!fir.array<1xi8>>) -> ()
@@ -101,18 +103,6 @@ func.func @dfa3a(%arg0: i1) {
   }
   return
 }
-// CHECK:     func.func @dfa3a(%arg0: i1) {
-// CHECK-NEXT:  %[[MEM:.*]] = fir.alloca !fir.array<1xi8>
-// CHECK-NEXT:  %[[HEAP:.*]] = fir.convert %[[MEM]] : (!fir.ref<!fir.array<1xi8>>) -> !fir.heap<!fir.array<1xi8>>
-// CHECK-NEXT:  fir.if %arg0 {
-// CHECK-NEXT:    %[[REF:.*]] = fir.convert %[[HEAP]] : (!fir.heap<!fir.array<1xi8>>) -> !fir.ref<!fir.array<1xi8>>
-// CHECK-NEXT:    func.call @dfa3a_foo(%[[REF]])
-// CHECK-NEXT:  } else {
-// CHECK-NEXT:    %[[REF:.*]] = fir.convert %[[HEAP]] : (!fir.heap<!fir.array<1xi8>>) -> !fir.ref<!fir.array<1xi8>>
-// CHECK-NEXT:    func.call @dfa3a_bar(%[[REF]])
-// CHECK-NEXT:  }
-// CHECK-NEXT:  return
-// CHECK-NEXT:  }
 
 // check the alloca is placed after all operands become available
 func.func @placement1() {
@@ -126,11 +116,10 @@ func.func @placement1() {
   fir.freemem %4 : !fir.heap<!fir.array<?xi32>>
   return
 }
-// CHECK:      func.func @placement1() {
-// CHECK-NEXT:   %[[ARG:.*]] = arith.constant 3 : index
-// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[ARG]]
-// CHECK-NEXT:   return
-// CHECK-NEXT: }
+// CHECK: func.func @placement1() {
+// CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, {{.*}}
+// CHECK:   return
+// CHECK: }
 
 // check that if there are no operands, then the alloca is placed early
 func.func @placement2() {
@@ -143,13 +132,13 @@ func.func @placement2() {
   fir.freemem %4 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK:      func.func @placement2() {
-// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
-// CHECK-NEXT:   %[[ONE:.*]] = arith.constant 1 : index
-// CHECK-NEXT:   %[[TWO:.*]] = arith.constant 2 : index
-// CHECK-NEXT:   %[[SUM:.*]] = arith.addi %[[ONE]], %[[TWO]] : index
-// CHECK-NEXT:   return
-// CHECK-NEXT: }
+// CHECK: func.func @placement2() {
+// CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
+// CHECK:   %[[ONE:.*]] = arith.constant 1 : index
+// CHECK:   %[[TWO:.*]] = arith.constant 2 : index
+// CHECK:   %[[SUM:.*]] = arith.addi %[[ONE]], %[[TWO]] : index
+// CHECK:   return
+// CHECK: }
 
 // check that stack allocations which must be placed in loops use stacksave
 func.func @placement3() {
@@ -167,20 +156,18 @@ func.func @placement3() {
   }
   return
 }
-// CHECK:      func.func @placement3() {
-// CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
-// CHECK-NEXT:   %[[C2:.*]] = arith.constant 2 : index
-// CHECK-NEXT:   %[[C10:.*]] = arith.constant 10 : index
-// CHECK-NEXT:   fir.do_loop
-// CHECK-NEXT:     %[[SUM:.*]] = arith.addi %[[C1]], %[[C2]] : index
-// CHECK-NEXT:     %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
-// CHECK-NEXT:     %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[SUM]]
-// CHECK-NEXT:     llvm.intr.stackrestore %[[SP]] : !llvm.ptr
-// CHECK-NEXT:     fir.result
-// CHECK-NEXT:   }
-// CHECK-NEXT:   return
-// CHECK-NEXT: }
+// CHECK: func.func @placement3() {
+// CHECK:   %[[C1:.*]] = arith.constant 1 : index
+// CHECK:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
+// CHECK:   %[[C2:.*]] = arith.constant 2 : index
+// CHECK:   %[[C10:.*]] = arith.constant 10 : index
+// CHECK:   fir.do_loop
+// CHECK:     %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
+// CHECK:     llvm.intr.stackrestore %[[SP]] : !llvm.ptr
+// CHECK:     fir.result
+// CHECK:   }
+// CHECK:   return
+// CHECK: }
 
 // check that stack save/restore are used in CFG loops
 func.func @placement4(%arg0 : i1) {
@@ -199,20 +186,20 @@ func.func @placement4(%arg0 : i1) {
 ^bb2:
   return
 }
-// CHECK:      func.func @placement4(%arg0: i1) {
-// CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
-// CHECK-NEXT:   %[[C10:.*]] = arith.constant 10 : index
-// CHECK-NEXT:   cf.br ^bb1
-// CHECK-NEXT: ^bb1:
-// CHECK-NEXT:   %[[C3:.*]] = arith.constant 3 : index
-// CHECK-NEXT:   %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
-// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[C3]]
-// CHECK-NEXT:   llvm.intr.stackrestore %[[SP]] : !llvm.ptr
-// CHECK-NEXT:   cf.cond_br %arg0, ^bb1, ^bb2
-// CHECK-NEXT: ^bb2:
-// CHECK-NEXT:   return
-// CHECK-NEXT: }
+// CHECK: func.func @placement4(%arg0: i1) {
+// CHECK:   %[[C1:.*]] = arith.constant 1 : index
+// CHECK:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
+// CHECK:   %[[C10:.*]] = arith.constant 10 : index
+// CHECK:   cf.br ^bb1
+// CHECK: ^bb1:
+// CHECK:   %[[C3:.*]] = arith.constant 3 : index
+// CHECK:   %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
+// CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[C3]]
+// CHECK:   llvm.intr.stackrestore %[[SP]] : !llvm.ptr
+// CHECK:   cf.cond_br %arg0, ^bb1, ^bb2
+// CHECK: ^bb2:
+// CHECK:   return
+// CHECK: }
 
 // check that stacksave is not used when there is an intervening alloca
 func.func @placement5() {
@@ -230,7 +217,7 @@ func.func @placement5() {
   }
   return
 }
-// CHECK:      func.func @placement5() {
+// CHECK: func.func @placement5() {
 // CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
 // CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
 // CHECK-NEXT:   %[[C2:.*]] = arith.constant 2 : index
@@ -268,7 +255,7 @@ func.func @placement6(%arg0: i1) {
   fir.freemem %4 : !fir.heap<!fir.array<?xi32>>
   cf.br ^bb1
 }
-// CHECK:      func.func @placement6(%arg0: i1) {
+// CHECK: func.func @placement6(%arg0: i1) {
 // CHECK-NEXT:   %[[c1:.*]] = arith.constant 1 : index
 // CHECK-NEXT:   %[[c1_i32:.*]] = fir.convert %[[c1]] : (index) -> i32
 // CHECK-NEXT:   %[[c2:.*]] = arith.constant 2 : index
@@ -297,14 +284,11 @@ func.func @returns(%arg0: i1) {
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK:      func.func @returns(%[[COND:.*]]: i1) {
-// CHECK-NEXT:   %[[ALLOC:.*]] = fir.alloca !fir.array<42xi32>
-// CHECK-NEXT:   cf.cond_br %[[COND]], ^bb1, ^bb2
-// CHECK-NEXT: ^bb1:
-// CHECK-NEXT:   return
-// CHECK-NEXT: ^bb2:
-// CHECK-NEXT:   return
-// CHECK-NEXT: }
+// CHECK: func.func @returns(%[[COND:.*]]: i1) {
+// CHECK:   %[[ALLOC:.*]] = fir.alloca !fir.array<42xi32>
+// CHECK:   cf.cond_br %[[COND]], ^bb1, ^bb2
+// CHECK:   return
+// CHECK: }
 
 // Check multiple returns, where the memory is not freed on one branch
 func.func @returns2(%arg0: i1) {
@@ -316,15 +300,11 @@ func.func @returns2(%arg0: i1) {
 ^bb2:
   return
 }
-// CHECK:      func.func @returns2(%[[COND:.*]]: i1) {
-// CHECK-NEXT:   %[[ALLOC:.*]] = fir.allocmem !fir.array<42xi32>
-// CHECK-NEXT:   cf.cond_br %[[COND]], ^bb1, ^bb2
-// CHECK-NEXT: ^bb1:
-// CHECK-NEXT:   fir.freemem %[[ALLOC]] : !fir.heap<!fir.array<42xi32>>
-// CHECK-NEXT:   return
-// CHECK-NEXT: ^bb2:
-// CHECK-NEXT:   return
-// CHECK-NEXT: }
+// CHECK: func.func @returns2(%[[COND:.*]]: i1) {
+// CHECK:   %[[ALLOC:.*]] = fir.allocmem !fir.array<42xi32>
+// CHECK:   cf.cond_br %[[COND]], ^bb1, ^bb2
+// CHECK:   return
+// CHECK: }
 
 // Check allocations are not moved outside of an omp region
 func.func @omp_placement1() {
@@ -338,17 +318,12 @@ func.func @omp_placement1() {
   }
   return
 }
-// CHECK:      func.func @omp_placement1() {
-// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
-// CHECK-NEXT:   %[[MEM_CONV:.*]] = fir.convert %[[MEM]] : (!fir.ref<!fir.array<42xi32>>) -> !fir.heap<!fir.array<42xi32>>
-// CHECK-NEXT:   omp.sections {
-// CHECK-NEXT:     omp.section {
-// CHECK-NEXT:       omp.terminator
-// CHECK-NEXT:     }
-// CHECK-NEXT:     omp.terminator
-// CHECK-NEXT:   }
-// CHECK-NEXT:   return
-// CHECK-NEXT: }
+// CHECK: func.func @omp_placement1() {
+// CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
+// CHECK:   %[[MEM_CONV:.*]] = fir.convert %[[MEM]] : (!fir.ref<!fir.array<42xi32>>) -> !fir.heap<!fir.array<42xi32>>
+// CHECK:   omp.sections
+// CHECK:   return
+// CHECK: }
 
 // function terminated by stop statement
 func.func @stop_terminator() {
@@ -387,7 +362,7 @@ func.func @placement_loop_declare() {
   }
   return
 }
-// CHECK:      func.func @placement_loop_declare() {
+// CHECK: func.func @placement_loop_declare() {
 // CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
 // CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
 // CHECK-NEXT:   %[[C2:.*]] = arith.constant 2 : index

>From c47e2a2a17857ae496c2518dff3479913e46cff6 Mon Sep 17 00:00:00 2001
From: Susan Tan <zujunt at nvidia.com>
Date: Fri, 7 Nov 2025 13:20:04 -0800
Subject: [PATCH 18/18] change test

---
 flang/test/Transforms/stack-arrays.fir | 194 ++++++++++++++++---------
 1 file changed, 128 insertions(+), 66 deletions(-)

diff --git a/flang/test/Transforms/stack-arrays.fir b/flang/test/Transforms/stack-arrays.fir
index 282fb139ca495..25fc73153003a 100644
--- a/flang/test/Transforms/stack-arrays.fir
+++ b/flang/test/Transforms/stack-arrays.fir
@@ -3,18 +3,17 @@
 // Simplest transformation
 func.func @simple() {
   %0 = fir.allocmem !fir.array<42xi32>
-  %c0 = arith.constant 0 : index
-  %c0_i32 = arith.constant 0 : i32
-  %ref = fir.convert %0 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
-  %elt = fir.coordinate_of %ref, %c0 : (!fir.ref<!fir.array<42xi32>>, index) -> !fir.ref<i32>
-  fir.store %c0_i32 to %elt : !fir.ref<i32>
+  %c0_s = arith.constant 0 : index
+  %c0_i32_s = arith.constant 0 : i32
+  %ref_s = fir.convert %0 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
+  %elt_s = fir.coordinate_of %ref_s, %c0_s : (!fir.ref<!fir.array<42xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32_s to %elt_s : !fir.ref<i32>
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK: func.func @simple() {
+// CHECK: func.func @simple()
 // CHECK: fir.alloca !fir.array<42xi32>
 // CHECK: return
-// CHECK: }
 
 // Check fir.must_be_heap allocations are not moved
 func.func @must_be_heap() {
@@ -22,7 +21,7 @@ func.func @must_be_heap() {
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK: func.func @must_be_heap() {
+// CHECK-LABEL: func.func @must_be_heap()
 // CHECK-NEXT:   %[[ALLOC:.*]] = fir.allocmem !fir.array<42xi32> {fir.must_be_heap = true}
 // CHECK-NEXT:   fir.freemem %[[ALLOC]] : !fir.heap<!fir.array<42xi32>>
 // CHECK-NEXT:   return
@@ -41,7 +40,7 @@ func.func @dfa1(%arg0: !fir.ref<!fir.logical<4>> {fir.bindc_name = "cond"}) {
   }
   return
 }
-// CHECK:      func.func @dfa1(%arg0: !fir.ref<!fir.logical<4>> {fir.bindc_name = "cond"}) {
+// CHECK-LABEL: func.func @dfa1(%arg0: !fir.ref<!fir.logical<4>> {fir.bindc_name = "cond"})
 // CHECK-NEXT:   %[[C42:.*]] = arith.constant 42 : index
 // CHECK-NEXT:   %[[MEM:.*]] = fir.allocmem !fir.array<?xi32>, %[[C42]] {uniq_name = "_QFdfa1Earr.alloc"}
 // CHECK-NEXT:   %[[LOGICAL:.*]] = fir.load %arg0 : !fir.ref<!fir.logical<4>>
@@ -62,7 +61,7 @@ func.func @dfa2(%arg0: i1) {
   }
   return
 }
-// CHECK: func.func @dfa2(%arg0: i1) {
+// CHECK-LABEL: func.func @dfa2(%arg0: i1)
 // CHECK-NEXT:  %[[MEM:.*]] = fir.allocmem !fir.array<1xi8>
 // CHECK-NEXT:  scf.if %arg0 {
 // CHECK-NEXT:    fir.freemem %[[MEM]] : !fir.heap<!fir.array<1xi8>>
@@ -79,12 +78,16 @@ func.func @dfa3(%arg0: i1) {
   } else {
     fir.freemem %a : !fir.heap<!fir.array<1xi8>>
   }
+  %c0_d3 = arith.constant 0 : index
+  %c0_i8_d3 = arith.constant 0 : i8
+  %ref_d3 = fir.convert %a : (!fir.heap<!fir.array<1xi8>>) -> !fir.ref<!fir.array<1xi8>>
+  %elt_d3 = fir.coordinate_of %ref_d3, %c0_d3 : (!fir.ref<!fir.array<1xi8>>, index) -> !fir.ref<i8>
+  fir.store %c0_i8_d3 to %elt_d3 : !fir.ref<i8>
   return
 }
-// CHECK: func.func @dfa3(%arg0: i1) {
+// CHECK: func.func @dfa3(%arg0: i1)
 // CHECK:  %[[MEM:.*]] = fir.alloca !fir.array<1xi8>
 // CHECK:  return
-// CHECK:  }
 
 func.func private @dfa3a_foo(!fir.ref<!fir.array<1xi8>>) -> ()
 func.func private @dfa3a_bar(!fir.ref<!fir.array<1xi8>>) -> ()
@@ -103,6 +106,18 @@ func.func @dfa3a(%arg0: i1) {
   }
   return
 }
+// CHECK-LABEL: func.func @dfa3a(%arg0: i1)
+// CHECK-NEXT:  %[[MEM:.*]] = fir.alloca !fir.array<1xi8>
+// CHECK-NEXT:  %[[HEAP:.*]] = fir.convert %[[MEM]] : (!fir.ref<!fir.array<1xi8>>) -> !fir.heap<!fir.array<1xi8>>
+// CHECK-NEXT:  fir.if %arg0 {
+// CHECK-NEXT:    %[[REF:.*]] = fir.convert %[[HEAP]] : (!fir.heap<!fir.array<1xi8>>) -> !fir.ref<!fir.array<1xi8>>
+// CHECK-NEXT:    func.call @dfa3a_foo(%[[REF]])
+// CHECK-NEXT:  } else {
+// CHECK-NEXT:    %[[REF:.*]] = fir.convert %[[HEAP]] : (!fir.heap<!fir.array<1xi8>>) -> !fir.ref<!fir.array<1xi8>>
+// CHECK-NEXT:    func.call @dfa3a_bar(%[[REF]])
+// CHECK-NEXT:  }
+// CHECK-NEXT:  return
+// CHECK-NEXT:  }
 
 // check the alloca is placed after all operands become available
 func.func @placement1() {
@@ -113,13 +128,19 @@ func.func @placement1() {
   // operand is now available
   %4 = fir.allocmem !fir.array<?xi32>, %3
   // ...
+  %c0 = arith.constant 0 : index
+  %c0_i32 = arith.constant 0 : i32
+  %ref1 = fir.convert %4 : (!fir.heap<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
+  %elt1 = fir.coordinate_of %ref1, %c0 : (!fir.ref<!fir.array<?xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32 to %elt1 : !fir.ref<i32>
   fir.freemem %4 : !fir.heap<!fir.array<?xi32>>
   return
 }
-// CHECK: func.func @placement1() {
-// CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, {{.*}}
+// CHECK-LABEL: func.func @placement1()
+// CHECK-NEXT:   %[[ARG:.*]] = arith.constant 3 : index
+// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[ARG]]
 // CHECK:   return
-// CHECK: }
+// CHECK-NEXT: }
 
 // check that if there are no operands, then the alloca is placed early
 func.func @placement2() {
@@ -129,10 +150,15 @@ func.func @placement2() {
   %3 = arith.addi %1, %2 : index
   %4 = fir.allocmem !fir.array<42xi32>
   // ...
+  %c0_p2 = arith.constant 0 : index
+  %c0_i32_p2 = arith.constant 0 : i32
+  %ref_p2 = fir.convert %4 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
+  %elt_p2 = fir.coordinate_of %ref_p2, %c0_p2 : (!fir.ref<!fir.array<42xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32_p2 to %elt_p2 : !fir.ref<i32>
   fir.freemem %4 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK: func.func @placement2() {
+// CHECK-LABEL: func.func @placement2()
 // CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
 // CHECK:   %[[ONE:.*]] = arith.constant 1 : index
 // CHECK:   %[[TWO:.*]] = arith.constant 2 : index
@@ -151,23 +177,30 @@ func.func @placement3() {
     // operand is now available
     %4 = fir.allocmem !fir.array<?xi32>, %3
     // ...
+    %c0 = arith.constant 0 : index
+    %c0_i32 = arith.constant 0 : i32
+    %ref2 = fir.convert %4 : (!fir.heap<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
+    %elt2 = fir.coordinate_of %ref2, %c0 : (!fir.ref<!fir.array<?xi32>>, index) -> !fir.ref<i32>
+    fir.store %c0_i32 to %elt2 : !fir.ref<i32>
     fir.freemem %4 : !fir.heap<!fir.array<?xi32>>
     fir.result %3, %c1_i32 : index, i32
   }
   return
 }
-// CHECK: func.func @placement3() {
-// CHECK:   %[[C1:.*]] = arith.constant 1 : index
-// CHECK:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
-// CHECK:   %[[C2:.*]] = arith.constant 2 : index
-// CHECK:   %[[C10:.*]] = arith.constant 10 : index
-// CHECK:   fir.do_loop
-// CHECK:     %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
+// CHECK-LABEL: func.func @placement3()
+// CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
+// CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
+// CHECK-NEXT:   %[[C2:.*]] = arith.constant 2 : index
+// CHECK-NEXT:   %[[C10:.*]] = arith.constant 10 : index
+// CHECK-NEXT:   fir.do_loop
+// CHECK-NEXT:     %[[SUM:.*]] = arith.addi %[[C1]], %[[C2]] : index
+// CHECK-NEXT:     %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
+// CHECK-NEXT:     %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[SUM]]
 // CHECK:     llvm.intr.stackrestore %[[SP]] : !llvm.ptr
-// CHECK:     fir.result
-// CHECK:   }
-// CHECK:   return
-// CHECK: }
+// CHECK-NEXT:     fir.result
+// CHECK-NEXT:   }
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
 
 // check that stack save/restore are used in CFG loops
 func.func @placement4(%arg0 : i1) {
@@ -181,25 +214,30 @@ func.func @placement4(%arg0 : i1) {
   // operand is now available
   %4 = fir.allocmem !fir.array<?xi32>, %3
   // ...
+  %c0 = arith.constant 0 : index
+  %c0_i32 = arith.constant 0 : i32
+  %ref3 = fir.convert %4 : (!fir.heap<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
+  %elt3 = fir.coordinate_of %ref3, %c0 : (!fir.ref<!fir.array<?xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32 to %elt3 : !fir.ref<i32>
   fir.freemem %4 : !fir.heap<!fir.array<?xi32>>
   cf.cond_br %arg0, ^bb1, ^bb2
 ^bb2:
   return
 }
-// CHECK: func.func @placement4(%arg0: i1) {
-// CHECK:   %[[C1:.*]] = arith.constant 1 : index
-// CHECK:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
-// CHECK:   %[[C10:.*]] = arith.constant 10 : index
-// CHECK:   cf.br ^bb1
-// CHECK: ^bb1:
-// CHECK:   %[[C3:.*]] = arith.constant 3 : index
-// CHECK:   %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
-// CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[C3]]
+// CHECK-LABEL: func.func @placement4(%arg0: i1)
+// CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
+// CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
+// CHECK-NEXT:   %[[C10:.*]] = arith.constant 10 : index
+// CHECK-NEXT:   cf.br ^bb1
+// CHECK-NEXT: ^bb1:
+// CHECK-NEXT:   %[[C3:.*]] = arith.constant 3 : index
+// CHECK-NEXT:   %[[SP:.*]] = llvm.intr.stacksave : !llvm.ptr
+// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<?xi32>, %[[C3]]
 // CHECK:   llvm.intr.stackrestore %[[SP]] : !llvm.ptr
-// CHECK:   cf.cond_br %arg0, ^bb1, ^bb2
-// CHECK: ^bb2:
-// CHECK:   return
-// CHECK: }
+// CHECK-NEXT:   cf.cond_br %arg0, ^bb1, ^bb2
+// CHECK-NEXT: ^bb2:
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
 
 // check that stacksave is not used when there is an intervening alloca
 func.func @placement5() {
@@ -217,7 +255,7 @@ func.func @placement5() {
   }
   return
 }
-// CHECK: func.func @placement5() {
+// CHECK-LABEL: func.func @placement5()
 // CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
 // CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
 // CHECK-NEXT:   %[[C2:.*]] = arith.constant 2 : index
@@ -255,7 +293,7 @@ func.func @placement6(%arg0: i1) {
   fir.freemem %4 : !fir.heap<!fir.array<?xi32>>
   cf.br ^bb1
 }
-// CHECK: func.func @placement6(%arg0: i1) {
+// CHECK-LABEL: func.func @placement6(%arg0: i1)
 // CHECK-NEXT:   %[[c1:.*]] = arith.constant 1 : index
 // CHECK-NEXT:   %[[c1_i32:.*]] = fir.convert %[[c1]] : (index) -> i32
 // CHECK-NEXT:   %[[c2:.*]] = arith.constant 2 : index
@@ -276,6 +314,11 @@ func.func @placement6(%arg0: i1) {
 // Check multiple returns, where the memory is always freed
 func.func @returns(%arg0: i1) {
   %0 = fir.allocmem !fir.array<42xi32>
+  %c0_ret = arith.constant 0 : index
+  %c0_i32_ret = arith.constant 0 : i32
+  %ref_ret = fir.convert %0 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
+  %elt_ret = fir.coordinate_of %ref_ret, %c0_ret : (!fir.ref<!fir.array<42xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32_ret to %elt_ret : !fir.ref<i32>
   cf.cond_br %arg0, ^bb1, ^bb2
 ^bb1:
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
@@ -284,15 +327,23 @@ func.func @returns(%arg0: i1) {
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK: func.func @returns(%[[COND:.*]]: i1) {
+// CHECK-LABEL: func.func @returns(
 // CHECK:   %[[ALLOC:.*]] = fir.alloca !fir.array<42xi32>
-// CHECK:   cf.cond_br %[[COND]], ^bb1, ^bb2
-// CHECK:   return
-// CHECK: }
+// CHECK:   cf.cond_br %{{.*}}, ^bb1, ^bb2
+// CHECK-NEXT: ^bb1:
+// CHECK-NEXT:   return
+// CHECK-NEXT: ^bb2:
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
 
 // Check multiple returns, where the memory is not freed on one branch
 func.func @returns2(%arg0: i1) {
   %0 = fir.allocmem !fir.array<42xi32>
+  %c0_ret2 = arith.constant 0 : index
+  %c0_i32_ret2 = arith.constant 0 : i32
+  %ref_ret2 = fir.convert %0 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
+  %elt_ret2 = fir.coordinate_of %ref_ret2, %c0_ret2 : (!fir.ref<!fir.array<42xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32_ret2 to %elt_ret2 : !fir.ref<i32>
   cf.cond_br %arg0, ^bb1, ^bb2
 ^bb1:
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
@@ -300,11 +351,15 @@ func.func @returns2(%arg0: i1) {
 ^bb2:
   return
 }
-// CHECK: func.func @returns2(%[[COND:.*]]: i1) {
+// CHECK-LABEL: func.func @returns2(
 // CHECK:   %[[ALLOC:.*]] = fir.allocmem !fir.array<42xi32>
-// CHECK:   cf.cond_br %[[COND]], ^bb1, ^bb2
-// CHECK:   return
-// CHECK: }
+// CHECK:   cf.cond_br %{{.*}}, ^bb1, ^bb2
+// CHECK-NEXT: ^bb1:
+// CHECK-NEXT:   fir.freemem %[[ALLOC]] : !fir.heap<!fir.array<42xi32>>
+// CHECK-NEXT:   return
+// CHECK-NEXT: ^bb2:
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
 
 // Check allocations are not moved outside of an omp region
 func.func @omp_placement1() {
@@ -318,29 +373,36 @@ func.func @omp_placement1() {
   }
   return
 }
-// CHECK: func.func @omp_placement1() {
-// CHECK:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
-// CHECK:   %[[MEM_CONV:.*]] = fir.convert %[[MEM]] : (!fir.ref<!fir.array<42xi32>>) -> !fir.heap<!fir.array<42xi32>>
-// CHECK:   omp.sections
-// CHECK:   return
-// CHECK: }
+// CHECK-LABEL: func.func @omp_placement1()
+// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
+// CHECK-NEXT:   %[[MEM_CONV:.*]] = fir.convert %[[MEM]] : (!fir.ref<!fir.array<42xi32>>) -> !fir.heap<!fir.array<42xi32>>
+// CHECK-NEXT:   omp.sections {
+// CHECK-NEXT:     omp.section {
+// CHECK-NEXT:       omp.terminator
+// CHECK-NEXT:     }
+// CHECK-NEXT:     omp.terminator
+// CHECK-NEXT:   }
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
 
 // function terminated by stop statement
 func.func @stop_terminator() {
   %0 = fir.allocmem !fir.array<42xi32>
+  %c0 = arith.constant 0 : index
+  %c0_i32_st = arith.constant 0 : i32
+  %ref4 = fir.convert %0 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
+  %elt4 = fir.coordinate_of %ref4, %c0 : (!fir.ref<!fir.array<42xi32>>, index) -> !fir.ref<i32>
+  fir.store %c0_i32_st to %elt4 : !fir.ref<i32>
   fir.freemem %0 : !fir.heap<!fir.array<42xi32>>
   %c0_i32 = arith.constant 0 : i32
   %false = arith.constant false
   fir.call @_FortranAStopStatement(%c0_i32, %false, %false) : (i32, i1, i1) -> ()
   fir.unreachable
 }
-// CHECK: func.func @stop_terminator() {
-// CHECK-NEXT: fir.alloca !fir.array<42xi32>
-// CHECK-NEXT:  %[[ZERO:.*]] = arith.constant 0 : i32
-// CHECK-NEXT:  %[[FALSE:.*]] = arith.constant false
-// CHECK-NEXT:  fir.call @_FortranAStopStatement(%[[ZERO]], %[[FALSE]], %[[FALSE]]) : (i32, i1, i1) -> ()
-// CHECK-NEXT:  fir.unreachable
-// CHECK-NEXT: }
+// CHECK-LABEL: func.func @stop_terminator()
+// CHECK: fir.alloca !fir.array<42xi32>
+// CHECK: fir.call @_FortranAStopStatement(
+// CHECK: fir.unreachable
 
 
 // check that stack allocations that use fir.declare which must be placed in loops
@@ -362,7 +424,7 @@ func.func @placement_loop_declare() {
   }
   return
 }
-// CHECK: func.func @placement_loop_declare() {
+// CHECK-LABEL: func.func @placement_loop_declare()
 // CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
 // CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
 // CHECK-NEXT:   %[[C2:.*]] = arith.constant 2 : index
@@ -390,7 +452,7 @@ func.func @lookthrough() {
   fir.freemem %4 : !fir.heap<!fir.array<42xi32>>
   return
 }
-// CHECK: func.func @lookthrough() {
+// CHECK-LABEL: func.func @lookthrough()
 // CHECK:     fir.alloca !fir.array<42xi32>
 // CHECK-NOT: fir.freemem
 
@@ -432,6 +494,6 @@ func.func @finding_freemem_in_block() {
 ^bb3:  // pred: ^bb1
   return
 }
-// CHECK: func.func @finding_freemem_in_block() {
+// CHECK-LABEL: func.func @finding_freemem_in_block()
 // CHECK:     fir.alloca !fir.array<?xi32>
 // CHECK-NOT: fir.freemem



More information about the flang-commits mailing list