[clang] [lld] [llvm] [WIP][IR][Constants] Change the semantic of `ConstantPointerNull` to represent an actual `nullptr` instead of a zero-value pointer (PR #166667)
Shilei Tian via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 13 20:57:02 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;
----------------
shiltian wrote:
I'm also thinking that, to avoid a large number of test updates, maybe we should treat `std::nullopt` the same as the current behavior, which is a zero value. It might not make sense to update the data layout for all targets.
https://github.com/llvm/llvm-project/pull/166667
More information about the cfe-commits
mailing list