[all-commits] [llvm/llvm-project] b19ed2: [DataLayout] Introduce sentinel pointer value
Shilei Tian via All-commits
all-commits at lists.llvm.org
Fri Mar 21 12:19:45 PDT 2025
Branch: refs/heads/users/shiltian/data-layout-sentinel-pointer
Home: https://github.com/llvm/llvm-project
Commit: b19ed2cc2896b9116264681ea45872c89f605c6c
https://github.com/llvm/llvm-project/commit/b19ed2cc2896b9116264681ea45872c89f605c6c
Author: Shilei Tian <i at tianshilei.me>
Date: 2025-03-21 (Fri, 21 Mar 2025)
Changed paths:
M clang/lib/Basic/Targets/AMDGPU.cpp
M clang/test/CodeGen/target-data.c
M clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
M llvm/docs/LangRef.rst
M llvm/include/llvm/IR/DataLayout.h
M llvm/lib/IR/DataLayout.cpp
M llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
M llvm/unittests/IR/DataLayoutTest.cpp
Log Message:
-----------
[DataLayout] Introduce sentinel pointer value
The value of a null pointer is not always `0`. For example, on AMDGPU, the null
pointer in address spaces 3 and 5 is `0xffffffff`. Currently, there is no
target-independent way to get this information, making it difficult and
error-prone to handle null pointers in target-agnostic code.
We do have `ConstantPointerNull`, but it might be a little confusing and
misleading. It represents a pointer with an all-zero value rather than
necessarily a real `nullptr`.
This PR introduces the concept of a *sentinel pointer value* to `DataLayout`,
representing the actual `nullptr` value for a given address space. The changes
include:
- A new interface function:
```
APInt getSentinelPointerValue(unsigned AS)
```
This function returns an `APInt` representing the sentinel pointer value for
the given address space `AS`. An `APInt` is used instead of a literal integer
to support cases where pointers are wider than 64 bits (e.g., AMDGPU’s address
space 8).
- An extension to the data layout string format:
```
p[n]:<size>:<abi>[:<pref>[:<idx>[:<sentinel>]]]
```
The new `<sentinel>` component specifies the sentinel value for the
corresponding pointer. It currently supports two values:
- `0` for an all-zero value
- `f` for a full-bit set value
These two values are the most common representations of `nullptr`. It is
unlikely that any target would define `nullptr` as a random value.
A follow-up patch series will introduce an equivalent of `ConstantPointerNull`
that represents the actual `nullptr`, built on top of this PR.
Commit: a5998da69de31a194925f351cb74c72790956d29
https://github.com/llvm/llvm-project/commit/a5998da69de31a194925f351cb74c72790956d29
Author: Shilei Tian <i at tianshilei.me>
Date: 2025-03-21 (Fri, 21 Mar 2025)
Changed paths:
M llvm/docs/LangRef.rst
M llvm/lib/IR/DataLayout.cpp
M llvm/unittests/IR/DataLayoutTest.cpp
Log Message:
-----------
Replace '0' with 'z' for all-zero value
Commit: 55227d747544a2ccc5c981cff879063f9cebc253
https://github.com/llvm/llvm-project/commit/55227d747544a2ccc5c981cff879063f9cebc253
Author: Shilei Tian <i at tianshilei.me>
Date: 2025-03-21 (Fri, 21 Mar 2025)
Changed paths:
M lld/test/ELF/lto/amdgcn-oses.ll
M lld/test/ELF/lto/amdgcn.ll
Log Message:
-----------
Fix lld test failures
Compare: https://github.com/llvm/llvm-project/compare/015964e72ebc...55227d747544
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list