[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:38 PDT 2026


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

Do you think it would be worthwhile to have a default alignment constant declared somewhere and then use that instead of hardcoding the value 64 here? Is this something that we might change in the future? Or, could this be used elsewhere in the compiler?

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


More information about the flang-commits mailing list