[flang-commits] [flang] [flang] Emit `fir.global` in the global address space (PR #146653)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Wed Jul 2 02:14:46 PDT 2025


================
@@ -1867,6 +1867,20 @@ fir::factory::deduceOptimalExtents(mlir::ValueRange extents1,
   return extents;
 }
 
+uint64_t fir::factory::getGlobalAddressSpace(mlir::DataLayout *dataLayout) {
+  if (dataLayout)
+    if (mlir::Attribute addrSpace = dataLayout->getGlobalMemorySpace())
+      return mlir::cast<mlir::IntegerAttr>(addrSpace).getUInt();
+  return 0;
----------------
ergawy wrote:

This follow the same pattern as `getAllocaAddressSpace` which I think was made this way to allow for testing modules that do not have data layout attached.

Added @tblah to verify if my understanding is correct or not (since it seems he wrote `getAllocaAddressSpace`).

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


More information about the flang-commits mailing list