Draft: DmdAnal: Intern `Poly` and `nopDmdType` (#19190)
In #19190 we discovered that a single build of Cabal allocated
-
Poly C_0N
(akatopSubDmd
) 150k times -
DmdType emptyVarEnv [] topDiv
(akanopDmdType
) 320k times
This patch interns all 6 variants of Poly
and nopDmdType
by using
pattern synonyms that wrap a smart constructor.
Why not just use the smart constructor? Because
- That way we can rename the old constructor (I suffixed with an underscore), so that all old use sites trivially refer to the new pattern synonym
- We can be sure that all new use sites intuitively pick the new pattern synonym, simply because they are named the same as before. By constrast, a smart constructor needs continuous diligence and awareness to be called.
Fixes #19190.
Edited by Ben Gamari