[clang] [lld] [llvm] [WIP][IR][Constants] Change the semantic of `ConstantPointerNull` to represent an actual `nullptr` instead of a zero-value pointer (PR #166667)

Alexander Richardson via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 14 11:42:00 PST 2026


================
@@ -84,6 +84,11 @@ class DataLayout {
     /// for additional metadata (e.g. AMDGPU buffer fat pointers with bounds
     /// and other flags or CHERI capabilities that contain bounds+permissions).
     uint32_t IndexBitWidth;
+    /// The value of the nullptr in this address space. It can be three values:
+    /// all-zeros, all-ones, or std::nullopt. Since we don't have a way to
+    /// represent an arbitrary bit pattern, we use std::nullopt to represent the
+    /// case where the nullptr value is neither 0 nor -1.
+    std::optional<APInt> NullPtrValue;
----------------
arichardson wrote:

The unknown case isn't really modelled well so maybe easiest to drop the std::optional and just return an APInt directly? Zero is already the default for no explicit value. I don't really see a need to model unknown null pointer value in LLVM (or if that would ever make sense).

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


More information about the cfe-commits mailing list