[flang-commits] [flang] [llvm] [Flang][Fir] Set default alignment of array globals to 64 bytes (PR #194969)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Wed Apr 29 15:46:37 PDT 2026


================
@@ -463,6 +463,12 @@ fir::GlobalOp fir::FirOpBuilder::createGlobal(
   }
   auto glob = fir::GlobalOp::create(*this, loc, name, isConst, isTarget, type,
                                     value, linkage, attrs);
+  // Set default alignment for array globals.
+  if (mlir::isa<fir::SequenceType>(type)) {
+    unsigned currentAlign = glob.getAlignment().value_or(0);
+    if (currentAlign < 64)
+      glob.setAlignment(64);
+  }
----------------
tarunprabhu wrote:

This looks like it overrides the alignment on `glob`. Is there a chance that `glob.getAlignment()` returns, say 16. In that case, is it correct to override it?

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


More information about the flang-commits mailing list