Skip to content

UniqueSet vs UniqSet

While working on !10568 (closed) I discovered that we seem to have a suboptimal situation with regard to sets of uniques.

We have a type UniqSet a which is backed by UniqFM a a which in turn is backed by IntMap a (one of the as is phantom; and after !10568 (closed) it is backed by Word64Map a). So this type is not just a set of uniques, but it is rather a set of Uniquable things.

That is not always what we want. In fact, we have a type that is just a set of uniques. It is called UniqueSet, but it is hidden in GHC.Cmm.Dataflow.Containers. But there are some occurrences of IntMap (now Word64Map) which store uniques, such as in GHC.CmmToAsm.Wasm.Asm.asmTellFunc. Additionally, there are a few places where we have UniqSet Unique, which is inefficient.

I propose we move UniqueSet from GHC.Cmm.Dataflow.Containers to GHC.Types.Unique.Set under a more distinct name like SetOfUniques.

Edited by Jaro Reinders
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information