[clang] [clang][CodeGen] Add query for a target's flat address space (PR #95728)

Jessica Clarke via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 17 06:13:24 PDT 2024


================
@@ -1764,6 +1764,13 @@ class TargetInfo : public TransferrableTargetInfo,
     return 0;
   }
 
+  /// \returns Target specific flat ptr address space; a flat ptr is a ptr that
+  /// can be casted to / from all other target address spaces. If the target
+  /// exposes no such address space / does not care, we return 0.
----------------
jrtc27 wrote:

Some targets won't even have a flat address space. But that's fine, because in these specific uses the address space's underlying range/representation/meaning/whatever is completely irrelevant, all that matters is the GlobalObject (GlobalValue?) you get once you strip away an addrspacecasts. So I object to this on several grounds:

1. A flat address space may not exist
2. These uses don't care about the address space beyond being consistent across files
3. The existence of this API invites people to start using it for other things, and relying on properties of it that you've documented as being true which I don't think we want to be guaranteeing

If you really object to the arbitrary address space in use, I would rather see the special arrays be made overloaded/polymorphic instead so that the addrspacecasts can be avoided entirely .

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


More information about the cfe-commits mailing list