[llvm] [ADT] Add and use (for AArch64) `ValueOrSentinel<T, Sentinel>` (PR #158120)

Yanzuo Liu via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 05:53:04 PDT 2025


zwuis wrote:

> That looks like a slightly less general version of this class, so UnsignedOrNone could be implemented as `UnsignedOrNone = ValueOrSentinel<unsigned, -1>`.

Actually could not. Some `UnsignedOrNone` values are stored in bit-fields which are less then 32 bits, so the sentinel is stored as `0` and value `x` is stored as `x + 1` to avoid wrong value when converting bit-fields back to `UnsignedOrNone`.

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


More information about the llvm-commits mailing list