Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit ba2825b

Browse files
committed
Revert "[DenseMap] Do not align pointer sentinel values (NFC) (#146595)"
This reverts commit c5c615c. This causes ubsan failures when the sentinel pointers are upcast using static_cast<>, which checks alignment.
1 parent c5c615c commit ba2825b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

NanobindUtils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,11 @@ namespace llvm {
408408
template <>
409409
struct DenseMapInfo<MlirTypeID> {
410410
static inline MlirTypeID getEmptyKey() {
411-
// Shift by 3 to satisfy the TypeID alignment requirement.
412-
void *pointer = reinterpret_cast<void *>(uintptr_t(-1) << 3);
411+
auto *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
413412
return mlirTypeIDCreate(pointer);
414413
}
415414
static inline MlirTypeID getTombstoneKey() {
416-
void *pointer = reinterpret_cast<void *>(uintptr_t(-2) << 3);
415+
auto *pointer = llvm::DenseMapInfo<void *>::getTombstoneKey();
417416
return mlirTypeIDCreate(pointer);
418417
}
419418
static inline unsigned getHashValue(const MlirTypeID &val) {

0 commit comments

Comments
 (0)