Note [Renaming uniques deterministically]

GHC/Cmm/UniqueRenamer.hs:35 compiler

As mentioned by Note [Object determinism], a key step in producing
deterministic objects is to rename all existing uniques deterministically.

An important observation is that GHC already produces code in a deterministic
order, both declarations (say, A_closure always comes before B_closure) and the
instructions and data within.

We can leverage this /deterministic order/ to
rename all uniques deterministically, by traversing, specifically, Cmm code
fresh off of StgToCmm and assigning a new unique from a deterministic supply
(an incrementing counter) to every non-external unique in the order they are found.

Since the order is deterministic across runs, so will the renamed uniques.

This Cmm renaming pass is guarded by -fobject-determinism because it means the
compiler must do more work. However, performance profiling has shown the impact
to be small enough that we should consider enabling -fobject-determinism by
default instead eventually.

References 1

Referenced by 3