CprAnal: Don't attach CPR sigs to expandable bindings (#18154)
Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154.
parent
9afd9251
No related branches found
No related tags found
Pipeline #19279 passed with warnings
Stage: lint
Stage: quick-build
Stage: build
Stage: full-build
Stage: cleanup
Stage: packaging
Stage: testing
Showing
- compiler/GHC/Core/Opt/CprAnal.hs 63 additions, 3 deletionscompiler/GHC/Core/Opt/CprAnal.hs
- testsuite/tests/numeric/should_compile/T14170.stdout 0 additions, 3 deletionstestsuite/tests/numeric/should_compile/T14170.stdout
- testsuite/tests/numeric/should_compile/T14465.stdout 0 additions, 3 deletionstestsuite/tests/numeric/should_compile/T14465.stdout
- testsuite/tests/numeric/should_compile/T7116.stdout 0 additions, 3 deletionstestsuite/tests/numeric/should_compile/T7116.stdout
- testsuite/tests/simplCore/should_compile/T13143.stderr 0 additions, 3 deletionstestsuite/tests/simplCore/should_compile/T13143.stderr
- testsuite/tests/simplCore/should_compile/T13543.stderr 1 addition, 1 deletiontestsuite/tests/simplCore/should_compile/T13543.stderr
- testsuite/tests/simplCore/should_compile/T18013.stderr 0 additions, 3 deletionstestsuite/tests/simplCore/should_compile/T18013.stderr
- testsuite/tests/simplCore/should_compile/T3717.stderr 0 additions, 3 deletionstestsuite/tests/simplCore/should_compile/T3717.stderr
- testsuite/tests/simplCore/should_compile/T3772.stdout 0 additions, 3 deletionstestsuite/tests/simplCore/should_compile/T3772.stdout
- testsuite/tests/simplCore/should_compile/T4908.stderr 0 additions, 3 deletionstestsuite/tests/simplCore/should_compile/T4908.stderr
- testsuite/tests/simplCore/should_compile/T4930.stderr 0 additions, 3 deletionstestsuite/tests/simplCore/should_compile/T4930.stderr
- testsuite/tests/simplCore/should_compile/T7360.stderr 0 additions, 11 deletionstestsuite/tests/simplCore/should_compile/T7360.stderr
- testsuite/tests/simplCore/should_compile/noinline01.stderr 3 additions, 3 deletionstestsuite/tests/simplCore/should_compile/noinline01.stderr
- testsuite/tests/simplCore/should_compile/par01.stderr 3 additions, 3 deletionstestsuite/tests/simplCore/should_compile/par01.stderr
- testsuite/tests/simplCore/should_compile/spec-inline.stderr 0 additions, 5 deletionstestsuite/tests/simplCore/should_compile/spec-inline.stderr
- testsuite/tests/stranal/should_compile/T10694.stderr 23 additions, 29 deletionstestsuite/tests/stranal/should_compile/T10694.stderr
- testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr 1 addition, 1 deletiontestsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr
- testsuite/tests/stranal/sigs/CaseBinderCPR.stderr 1 addition, 1 deletiontestsuite/tests/stranal/sigs/CaseBinderCPR.stderr
- testsuite/tests/stranal/sigs/DmdAnalGADTs.hs 3 additions, 1 deletiontestsuite/tests/stranal/sigs/DmdAnalGADTs.hs
- testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr 8 additions, 8 deletionstestsuite/tests/stranal/sigs/DmdAnalGADTs.stderr
Loading
Please register or sign in to comment