DmdAnal: Consider not giving record selectors demand signatures
When I compile a huge record like
data Huge
= Huge
{ f1 :: Bool
, f2 :: Bool
, f3 :: Bool
, f4 :: Bool
, f5 :: Bool
, f6 :: Bool
, f7 :: Bool
, f8 :: Bool
, f9 :: Bool
, f10 :: Bool
, f11 :: Bool
, f12 :: Bool }
and run the resulting module through -O -ddump-str-signatures
, I see huge demand signatures cluttering the output
T19871.f1: <1P(1L,A,A,A,A,A,A,A,A,A,A,A)>
T19871.f10: <1P(A,A,A,A,A,A,A,A,A,1L,A,A)>
T19871.f11: <1P(A,A,A,A,A,A,A,A,A,A,1L,A)>
T19871.f12: <1P(A,A,A,A,A,A,A,A,A,A,A,1L)>
T19871.f2: <1P(A,1L,A,A,A,A,A,A,A,A,A,A)>
T19871.f3: <1P(A,A,1L,A,A,A,A,A,A,A,A,A)>
T19871.f4: <1P(A,A,A,1L,A,A,A,A,A,A,A,A)>
T19871.f5: <1P(A,A,A,A,1L,A,A,A,A,A,A,A)>
T19871.f6: <1P(A,A,A,A,A,1L,A,A,A,A,A,A)>
T19871.f7: <1P(A,A,A,A,A,A,1L,A,A,A,A,A)>
T19871.f8: <1P(A,A,A,A,A,A,A,1L,A,A,A,A)>
T19871.f9: <1P(A,A,A,A,A,A,A,A,1L,A,A,A)>
I'm pretty certain these will also end up in interface files. Note that for a record of size N, we'll get demand signatures of size N^2. This is quite unacceptable, for various reasons:
- Interface file bloat
- Compile perf
- record selectors are often inlined
- In the remaining cases, a signature might now make a huge difference. A very simple, conservative one like
<1L>
might suffice. If we really want better information, it might make more sense to come up with a bespoke demand transformer, like we do for dictionary selectors. Heck, we might even simply pretend that the selector was inlined.