[flang-commits] [flang] [llvm] [Flang][OpenMP] Add global address space to globals for target device (PR #119585)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Fri Jan 24 04:34:47 PST 2025


================
@@ -1350,14 +1399,34 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
             ? fir::NameUniquer::getTypeDescriptorAssemblyName(recType.getName())
             : fir::NameUniquer::getTypeDescriptorName(recType.getName());
     mlir::Type llvmPtrTy = ::getLlvmPtrType(mod.getContext());
+
+    // We allow the module to be set to a default layout if it's a regular module
+    // however, we prevent this if it's a GPU module, as the datalayout in these
+    // cases will currently be the union of the GPU Module and the parent builtin
+    // module, with the GPU module overriding the parent where there are duplicates.
+    // However, if we force the default layout onto a GPU module, with no datalayout
+    // it'll result in issues as the infrastructure does not support the union of
+    // two layouts with builtin data layout entries currently (and it doesn't look
+    // like it was intended to).
+    std::optional<mlir::DataLayout> dataLayout =
+        fir::support::getOrSetMLIRDataLayout(
+            mod, /*allowDefaultLayout*/ mlir::isa<mlir::gpu::GPUModuleOp>(mod)
+                     ? false
+                     : true);
----------------
skatrak wrote:

```suggestion
            mod, /*allowDefaultLayout=*/!mlir::isa<mlir::gpu::GPUModuleOp>(mod));
```

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


More information about the flang-commits mailing list