diff options
author | Nikita Popov <npopov@redhat.com> | 2025-07-07 12:47:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-07 12:47:41 +0200 |
commit | 7a6435bec59010e4bb2e1e52a9ba840ed152b4ce (patch) | |
tree | 84e594ad24bcde009ec8391551b4b11d5aa9a0fa /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | c19c71b90593dcbb94a9592d7cf75e58c99df6da (diff) | |
download | llvm-7a6435bec59010e4bb2e1e52a9ba840ed152b4ce.zip llvm-7a6435bec59010e4bb2e1e52a9ba840ed152b4ce.tar.gz llvm-7a6435bec59010e4bb2e1e52a9ba840ed152b4ce.tar.bz2 |
[DenseMap] Do not align pointer sentinel values (NFC) (#146595)
DenseMapInfo for pointers currently uses empty/tombstone values that are
aligned (by assuming a very conservative alignment). However, this means
that we have to work with larger immediates.
This patch proposes to use the values -1 and -2 instead, without caring
about pointer alignment. (Non-roundtrip) integer to pointer casts are
implementation-defined in C++, but the general implementer consensus
(including Clang) is that raw pointers do not carry alignment
requirements, only memory accesses do.
We already have lots of places that rely on this using variations on
`reinterpret_cast<T*>(-1)`, so it seems odd to insist on properly
aligned pointers in this one place.
It is necessary to adjust a few other places after this change, which
currently assume that `DenseMapInfo<void *>` returns a highly-aligned
pointer.
This is a small improvement for both compile-time and clang binary size.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
0 files changed, 0 insertions, 0 deletions