diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2020-05-05 17:29:01 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-05-13 02:06:29 -0400 |
commit | 86d8ac22608eb8f04ceaff65e76dbeec23b76753 (patch) | |
tree | 66e0c1365014b13f87aefa882bbf7229e34f936a /testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr | |
parent | 90e38b8139c10854280da56664c040120256bacc (diff) | |
download | haskell-86d8ac22608eb8f04ceaff65e76dbeec23b76753.tar.gz |
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.
Diffstat (limited to 'testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr')
-rw-r--r-- | testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr b/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr index a42d492099..6dd5576da4 100644 --- a/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr +++ b/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr @@ -9,21 +9,21 @@ DmdAnalGADTs.f: <S,1*U> DmdAnalGADTs.f': <S,1*U> DmdAnalGADTs.g: <S,1*U> DmdAnalGADTs.hasCPR: -DmdAnalGADTs.hasStrSig: <S,1*U> +DmdAnalGADTs.hasStrSig: <S,1*U(U)> ==================== Cpr signatures ==================== -DmdAnalGADTs.$tc'A: m1 -DmdAnalGADTs.$tc'B: m1 -DmdAnalGADTs.$tcD: m1 -DmdAnalGADTs.$trModule: m1 +DmdAnalGADTs.$tc'A: +DmdAnalGADTs.$tc'B: +DmdAnalGADTs.$tcD: +DmdAnalGADTs.$trModule: DmdAnalGADTs.diverges: b DmdAnalGADTs.f: DmdAnalGADTs.f': m1 DmdAnalGADTs.g: -DmdAnalGADTs.hasCPR: m1 -DmdAnalGADTs.hasStrSig: +DmdAnalGADTs.hasCPR: +DmdAnalGADTs.hasStrSig: m1 @@ -37,6 +37,6 @@ DmdAnalGADTs.f: <S,1*U> DmdAnalGADTs.f': <S,1*U> DmdAnalGADTs.g: <S,1*U> DmdAnalGADTs.hasCPR: -DmdAnalGADTs.hasStrSig: <S,1*U> +DmdAnalGADTs.hasStrSig: <S,1*U(U)> |