[all-commits] [llvm/llvm-project] 13b2ee: [clang][AST] Fix LazyGenerationalUpdatePtr NumLowB...
Jakub Kuderski via All-commits
all-commits at lists.llvm.org
Tue Mar 24 13:59:16 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 13b2ee25aebc937c0f459ca38c2092b882bec9dc
https://github.com/llvm/llvm-project/commit/13b2ee25aebc937c0f459ca38c2092b882bec9dc
Author: Jakub Kuderski <jakub at nod-labs.com>
Date: 2026-03-24 (Tue, 24 Mar 2026)
Changed paths:
M clang/include/clang/AST/ExternalASTSource.h
Log Message:
-----------
[clang][AST] Fix LazyGenerationalUpdatePtr NumLowBitsAvailable on 32-bit (#188318)
The `PointerLikeTypeTraits` for `LazyGenerationalUpdatePtr` claimed
`PointerLikeTypeTraits<T>::NumLowBitsAvailable - 1` spare low bits. This
assumed that the inner `PointerUnion<T, LazyData*>` has `T_bits - 1`
spare bits, which is only true when `alignof(LazyData) >= alignof(*T)`.
On 32-bit systems, `LazyData` (containing pointers and `uint32_t`) has
`alignof = 4`, giving `LazyData*` only 2 low bits. With `T = Decl*` (3
bits due to `alignas(8)`), the inner `PointerUnion` has `min(3,2) - 1 =
1` spare bit, but the PLTT claimed `3 - 1 = 2`.
Historically, the formula was correct when introduced in 053f6c6c9e4d --
at that time `Decl` had no alignment annotation, so `T_bits ==
LazyData*_bits` on all platforms. It became outdated when 771721cb35f3
added `LLVM_ALIGNAS(8)` to `Decl`, raising `Decl*` to 3 bits on 32-bit
while `LazyData*` stayed at 2. The old `PointerIntPair`-based
`PointerUnion::doCast` happened to mask with `minLowBitsAvailable()`
(tolerant of overclaims), so this was never exposed until the
`PunnedPointer` refactoring changed `doCast` to mask with
`To::NumLowBitsAvailable`.
Fixes: https://github.com/llvm/llvm-project/issues/188269
Co-authored-by: Claude Opus 4.6 (1M context) <noreply at anthropic.com>
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