[clang] [clang][SPIR][SPIRV] Materialize non-generic null pointers via addrspacecast (PR #161773)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 2 23:58:17 PDT 2025
================
@@ -240,6 +243,27 @@ void CommonSPIRTargetCodeGenInfo::setOCLKernelStubCallingConvention(
FT, FT->getExtInfo().withCallingConv(CC_SpirFunction));
}
+// LLVM currently assumes a null pointer has the bit pattern 0, but some GPU
+// targets use a non-zero encoding for null in certain address spaces.
+// Because SPIR(-V) is a virtual target and the bit pattern of a non-generic
+// null is unspecified, materialize non-generic null via an addrspacecast from
+// the generic null.
+// This allows later lowering to substitute the target’s real sentinel value.
+llvm::Constant *
+CommonSPIRTargetCodeGenInfo::getNullPointer(const CodeGen::CodeGenModule &CGM,
----------------
arsenm wrote:
Can you directly copy the AMDGPU implementation, which checks against getTargetNullPointerValue
https://github.com/llvm/llvm-project/pull/161773
More information about the cfe-commits
mailing list