[clang] [lld] [llvm] [mlir] [IR] Introduce `T<address space>` to `DataLayout` to represent flat address space if a target supports it (PR #108786)

Alexander Richardson via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 10:22:03 PDT 2024


================
@@ -245,6 +246,7 @@ class DataLayout {
   unsigned getDefaultGlobalsAddressSpace() const {
     return DefaultGlobalsAddrSpace;
   }
+  unsigned getFlatAddressSpace() const { return FlatAddressSpace; }
----------------
arichardson wrote:

I don't think this is a good API - returning something that looks valid (uint32_t) but might be incorrect at runtime without forcing users to check it.

Storing it as ~0 internally is fine but IMO the API should return `optional` and map ~0 to `std::nullopt`.

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


More information about the cfe-commits mailing list