An APInt that can fit into a single word stores the bitwidth and the value. In the normal APInt constructor, bits outside the bitwidth are zeroed out. For a zero-width APInt, the only valid value is zero.
DenseMap requires the use of two special keys, an empty key and a tombstone key. APInt has specified that these keys APInt with bitwidth 0 and value either 0 or 1. For a value of 0, this collides with a valid zero-width APInt. Because of this, using a zero-width APInt with a DenseMap will not work.
This change updates the keys to use ~0 and ~1, which are non-valid for zero-width APInt.
Proposed fix for: https://github.com/llvm/llvm-project/issues/58013