Index: llvm/include/llvm/ADT/APInt.h =================================================================== --- llvm/include/llvm/ADT/APInt.h +++ llvm/include/llvm/ADT/APInt.h @@ -2267,13 +2267,13 @@ template <> struct DenseMapInfo { static inline APInt getEmptyKey() { APInt V(nullptr, 0); - V.U.VAL = 0; + V.U.VAL = ~0ULL; return V; } static inline APInt getTombstoneKey() { APInt V(nullptr, 0); - V.U.VAL = 1; + V.U.VAL = ~1ULL; return V; } Index: llvm/unittests/ADT/APIntTest.cpp =================================================================== --- llvm/unittests/ADT/APIntTest.cpp +++ llvm/unittests/ADT/APIntTest.cpp @@ -8,6 +8,7 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "gtest/gtest.h" @@ -3126,4 +3127,11 @@ EXPECT_EQ(APIntOps::ScaleBitMask(APInt(8, 0xE4), 4, true), APInt(4, 0x08)); } +TEST(APIntTest, DenseMap) { + DenseMap Map; + APInt ZeroWidthInt(0, 0, false); + Map.insert({ZeroWidthInt, 0}); + Map.find(ZeroWidthInt); +} + } // end anonymous namespace