[clang] [Clang][AMDGPU] Get correct nullptr value for AS3 and AS5 (PR #175610)

Shilei Tian via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 12 11:52:37 PST 2026


================
@@ -446,10 +446,18 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
   // value ~0.
   uint64_t getNullPointerValue(LangAS AS) const override {
     // FIXME: Also should handle region.
-    return (AS == LangAS::opencl_local || AS == LangAS::opencl_private ||
-            AS == LangAS::sycl_local || AS == LangAS::sycl_private)
-               ? ~0
-               : 0;
+    // Check language-specific address spaces
+    if (AS == LangAS::opencl_local || AS == LangAS::opencl_private ||
+        AS == LangAS::sycl_local || AS == LangAS::sycl_private)
+      return ~0;
+    // Also check target address spaces that map to local or private
+    if (isTargetAddressSpace(AS)) {
+      unsigned TargetAS = toTargetAddressSpace(AS);
+      if (TargetAS == llvm::AMDGPUAS::LOCAL_ADDRESS ||
+          TargetAS == llvm::AMDGPUAS::PRIVATE_ADDRESS)
+        return ~0;
----------------
shiltian wrote:

Honestly, it might not be a good idea. What return type do you expect to use? An `APInt`? Here it is front end, so we know that those more-than-64-bit pointers will not be used (at least for now) as a real pointer, so we can still assume `uint64_t`, but when it comes to `AMDGPUAddrSpace.h`, it is different.

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


More information about the cfe-commits mailing list