[llvm] [WIP] Extend data layout to add sentinel pointer value for address space. (PR #83109)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 01:17:12 PDT 2024
================
@@ -3044,6 +3044,14 @@ as follows:
``n32:64`` for PowerPC 64, or ``n8:16:32:64`` for X86-64. Elements of
this set are considered to support most general arithmetic operations
efficiently.
+``z[n]:<value>``
+ This specifies the default null value for an address space. ``n`` denotes
+ the address space number, and if not specified, it is considered to be
+ for the unlisted address space. For unlisted address space, the default
+ null value is ``0``. ``value`` denotes the default null value for an
+ address space ``n``. To represent negatives values, prefix ``neg`` is
+ added to ``value``. for e.g., ``z0:neg1`` represents for ``0`` address
+ space ``-1`` is the default null value.
----------------
Pierre-vh wrote:
> This needs to define what "null" value means. I think we should possibly avoid using the null terminology, and call it something else. Sentinel pointer? Canonical invalid pointer?
AFAIK, a null pointer in computer science just means a sentinel value for pointer that doesn't point to a valid object. It doesn't mention zero directly for the abstract definition: https://en.wikipedia.org/wiki/Null_pointer
English is my second language so for me it's not confusing, but I think the literary definition is "zero" so there can definitely be confusion
Though, I'm against calling this anything other than `null. Null is the commonly used term, and I'm sure plenty of comments everywhere mention "null" as well. Naming this anything other than null will probably make it confusing.
I'd just add a comment explaining that "null" is the common term, but this should be the understood as an invalid pointer value that may or may not be zero.
https://github.com/llvm/llvm-project/pull/83109
More information about the llvm-commits
mailing list