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 | |
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')
-rw-r--r-- | testsuite/tests/stranal/should_compile/T10694.stderr | 52 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/CaseBinderCPR.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/DmdAnalGADTs.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr | 16 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/HyperStrUse.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/NewtypeArity.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/StrAnalExample.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T12370.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T17932.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T5075.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T8569.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T8598.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/UnsatFun.stderr | 2 |
14 files changed, 54 insertions, 58 deletions
diff --git a/testsuite/tests/stranal/should_compile/T10694.stderr b/testsuite/tests/stranal/should_compile/T10694.stderr index 66a337ab24..ee700fc6c6 100644 --- a/testsuite/tests/stranal/should_compile/T10694.stderr +++ b/testsuite/tests/stranal/should_compile/T10694.stderr @@ -6,26 +6,26 @@ Result size of Tidy Core = {terms: 74, types: 65, coercions: 0, joins: 0/4} T10694.$wpm [InlPrag=NOINLINE] :: Int -> Int -> (# Int, Int #) [GblId, Arity=2, Str=<L,U(U)><L,U(U)>, Unf=OtherCon []] T10694.$wpm - = \ (w_s1vj :: Int) (w1_s1vk :: Int) -> + = \ (w_s1v1 :: Int) (w1_s1v2 :: Int) -> let { - l_s1uR :: Int + l_s1uz :: Int [LclId] - l_s1uR - = case w_s1vj of { GHC.Types.I# x_aJ9 -> case w1_s1vk of { GHC.Types.I# y_aJc -> GHC.Types.I# (GHC.Prim.+# x_aJ9 y_aJc) } } } in + l_s1uz + = case w_s1v1 of { GHC.Types.I# x_aJ0 -> case w1_s1v2 of { GHC.Types.I# y_aJ3 -> GHC.Types.I# (GHC.Prim.+# x_aJ0 y_aJ3) } } } in let { - l1_s1uS :: Int + l1_s1uA :: Int [LclId] - l1_s1uS - = case w_s1vj of { GHC.Types.I# x_aJh -> case w1_s1vk of { GHC.Types.I# y_aJk -> GHC.Types.I# (GHC.Prim.-# x_aJh y_aJk) } } } in + l1_s1uA + = case w_s1v1 of { GHC.Types.I# x_aJ8 -> case w1_s1v2 of { GHC.Types.I# y_aJb -> GHC.Types.I# (GHC.Prim.-# x_aJ8 y_aJb) } } } in let { - l2_s1uT :: [Int] + l2_s1uB :: [Int] [LclId, Unf=OtherCon []] - l2_s1uT = GHC.Types.: @Int l1_s1uS (GHC.Types.[] @Int) } in + l2_s1uB = GHC.Types.: @Int l1_s1uA (GHC.Types.[] @Int) } in let { - l3_sJv :: [Int] + l3_sJm :: [Int] [LclId, Unf=OtherCon []] - l3_sJv = GHC.Types.: @Int l_s1uR l2_s1uT } in - (# GHC.List.$w!! @Int l3_sJv 0#, GHC.List.$w!! @Int l3_sJv 1# #) + l3_sJm = GHC.Types.: @Int l_s1uz l2_s1uB } in + (# GHC.List.$w!! @Int l3_sJm 0#, GHC.List.$w!! @Int l3_sJm 1# #) -- RHS size: {terms: 10, types: 11, coercions: 0, joins: 0/0} pm [InlPrag=NOUSERINLINE[0]] :: Int -> Int -> (Int, Int) @@ -35,9 +35,9 @@ pm [InlPrag=NOUSERINLINE[0]] :: Int -> Int -> (Int, Int) Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w_s1vj [Occ=Once] :: Int) (w1_s1vk [Occ=Once] :: Int) -> - case T10694.$wpm w_s1vj w1_s1vk of { (# ww1_s1vp [Occ=Once], ww2_s1vq [Occ=Once] #) -> (ww1_s1vp, ww2_s1vq) }}] -pm = \ (w_s1vj :: Int) (w1_s1vk :: Int) -> case T10694.$wpm w_s1vj w1_s1vk of { (# ww1_s1vp, ww2_s1vq #) -> (ww1_s1vp, ww2_s1vq) } + Tmpl= \ (w_s1v1 [Occ=Once] :: Int) (w1_s1v2 [Occ=Once] :: Int) -> + case T10694.$wpm w_s1v1 w1_s1v2 of { (# ww1_s1v7 [Occ=Once], ww2_s1v8 [Occ=Once] #) -> (ww1_s1v7, ww2_s1v8) }}] +pm = \ (w_s1v1 :: Int) (w1_s1v2 :: Int) -> case T10694.$wpm w_s1v1 w1_s1v2 of { (# ww1_s1v7, ww2_s1v8 #) -> (ww1_s1v7, ww2_s1v8) } -- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} m :: Int -> Int -> Int @@ -46,9 +46,9 @@ m :: Int -> Int -> Int Str=<L,U(U)><L,U(U)>, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (x_awt [Occ=Once] :: Int) (y_awu [Occ=Once] :: Int) -> - case pm x_awt y_awu of { (_ [Occ=Dead], mr_aww [Occ=Once]) -> mr_aww }}] -m = \ (x_awt :: Int) (y_awu :: Int) -> case T10694.$wpm x_awt y_awu of { (# ww1_s1vp, ww2_s1vq #) -> ww2_s1vq } + Tmpl= \ (x_awo [Occ=Once] :: Int) (y_awp [Occ=Once] :: Int) -> + case pm x_awo y_awp of { (_ [Occ=Dead], mr_awr [Occ=Once]) -> mr_awr }}] +m = \ (x_awo :: Int) (y_awp :: Int) -> case T10694.$wpm x_awo y_awp of { (# ww1_s1v7, ww2_s1v8 #) -> ww2_s1v8 } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T10694.$trModule4 :: GHC.Prim.Addr# @@ -57,9 +57,7 @@ T10694.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T10694.$trModule3 :: GHC.Types.TrName -[GblId, - Cpr=m1, - Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +[GblId, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] T10694.$trModule3 = GHC.Types.TrNameS T10694.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -69,17 +67,13 @@ T10694.$trModule2 = "T10694"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T10694.$trModule1 :: GHC.Types.TrName -[GblId, - Cpr=m1, - Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +[GblId, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] T10694.$trModule1 = GHC.Types.TrNameS T10694.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -T10694.$trModule :: GHC.Unit.Module -[GblId, - Cpr=m1, - Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] -T10694.$trModule = GHC.Unit.Module T10694.$trModule3 T10694.$trModule1 +T10694.$trModule :: GHC.Types.Module +[GblId, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] +T10694.$trModule = GHC.Types.Module T10694.$trModule3 T10694.$trModule1 diff --git a/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr b/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr index 259b5965e6..c3845dd6de 100644 --- a/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr +++ b/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr @@ -7,7 +7,7 @@ BottomFromInnerLambda.f: <S(S),1*U(U)> ==================== Cpr signatures ==================== -BottomFromInnerLambda.$trModule: m1 +BottomFromInnerLambda.$trModule: BottomFromInnerLambda.expensive: m1 BottomFromInnerLambda.f: diff --git a/testsuite/tests/stranal/sigs/CaseBinderCPR.stderr b/testsuite/tests/stranal/sigs/CaseBinderCPR.stderr index cf95b806ec..54b0a44763 100644 --- a/testsuite/tests/stranal/sigs/CaseBinderCPR.stderr +++ b/testsuite/tests/stranal/sigs/CaseBinderCPR.stderr @@ -6,7 +6,7 @@ CaseBinderCPR.f_list_cmp: <L,C(C1(U(U)))><S,1*U><S,1*U> ==================== Cpr signatures ==================== -CaseBinderCPR.$trModule: m1 +CaseBinderCPR.$trModule: CaseBinderCPR.f_list_cmp: m1 diff --git a/testsuite/tests/stranal/sigs/DmdAnalGADTs.hs b/testsuite/tests/stranal/sigs/DmdAnalGADTs.hs index 0c93cc0743..1a6d68a3b2 100644 --- a/testsuite/tests/stranal/sigs/DmdAnalGADTs.hs +++ b/testsuite/tests/stranal/sigs/DmdAnalGADTs.hs @@ -7,11 +7,13 @@ data D a where A :: D Int B :: D (Int -> Int) +-- Doesn't have the CPR property anymore (#18154), but an expandable unfolding. +-- The point of this test is that f' has the CPR property. hasCPR :: Int hasCPR = 1 hasStrSig :: Int -> Int -hasStrSig x = x +hasStrSig x = x + 1 diverges :: Int diverges = diverges 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)> diff --git a/testsuite/tests/stranal/sigs/HyperStrUse.stderr b/testsuite/tests/stranal/sigs/HyperStrUse.stderr index 812115ec11..1ae91db4d4 100644 --- a/testsuite/tests/stranal/sigs/HyperStrUse.stderr +++ b/testsuite/tests/stranal/sigs/HyperStrUse.stderr @@ -6,7 +6,7 @@ HyperStrUse.f: <S(SL),1*U(1*U(U),A)><S,1*U> ==================== Cpr signatures ==================== -HyperStrUse.$trModule: m1 +HyperStrUse.$trModule: HyperStrUse.f: m1 diff --git a/testsuite/tests/stranal/sigs/NewtypeArity.stderr b/testsuite/tests/stranal/sigs/NewtypeArity.stderr index 5519561d43..55cfe94ac7 100644 --- a/testsuite/tests/stranal/sigs/NewtypeArity.stderr +++ b/testsuite/tests/stranal/sigs/NewtypeArity.stderr @@ -9,9 +9,9 @@ Test.t2: <S,1*U(U)><S,1*U(U)> ==================== Cpr signatures ==================== -Test.$tc'MkT: m1 -Test.$tcT: m1 -Test.$trModule: m1 +Test.$tc'MkT: +Test.$tcT: +Test.$trModule: Test.t: m1 Test.t2: m1 diff --git a/testsuite/tests/stranal/sigs/StrAnalExample.stderr b/testsuite/tests/stranal/sigs/StrAnalExample.stderr index f18fb56998..eb2c5716bc 100644 --- a/testsuite/tests/stranal/sigs/StrAnalExample.stderr +++ b/testsuite/tests/stranal/sigs/StrAnalExample.stderr @@ -6,7 +6,7 @@ StrAnalExample.foo: <S,1*U> ==================== Cpr signatures ==================== -StrAnalExample.$trModule: m1 +StrAnalExample.$trModule: StrAnalExample.foo: diff --git a/testsuite/tests/stranal/sigs/T12370.stderr b/testsuite/tests/stranal/sigs/T12370.stderr index 63fa76d79d..caa780b0d2 100644 --- a/testsuite/tests/stranal/sigs/T12370.stderr +++ b/testsuite/tests/stranal/sigs/T12370.stderr @@ -7,7 +7,7 @@ T12370.foo: <S(SS),1*U(1*U(U),1*U(U))> ==================== Cpr signatures ==================== -T12370.$trModule: m1 +T12370.$trModule: T12370.bar: m1 T12370.foo: m1 diff --git a/testsuite/tests/stranal/sigs/T17932.stderr b/testsuite/tests/stranal/sigs/T17932.stderr index c086c8cd86..7ca56637df 100644 --- a/testsuite/tests/stranal/sigs/T17932.stderr +++ b/testsuite/tests/stranal/sigs/T17932.stderr @@ -10,11 +10,11 @@ T17932.flags: <S(SS),1*U(1*U,1*U)> ==================== Cpr signatures ==================== -T17932.$tc'Options: m1 -T17932.$tc'X: m1 -T17932.$tcOptions: m1 -T17932.$tcX: m1 -T17932.$trModule: m1 +T17932.$tc'Options: +T17932.$tc'X: +T17932.$tcOptions: +T17932.$tcX: +T17932.$trModule: T17932.flags: diff --git a/testsuite/tests/stranal/sigs/T5075.stderr b/testsuite/tests/stranal/sigs/T5075.stderr index 582f62d705..e048ce2fb3 100644 --- a/testsuite/tests/stranal/sigs/T5075.stderr +++ b/testsuite/tests/stranal/sigs/T5075.stderr @@ -6,7 +6,7 @@ T5075.loop: <S(LLC(C(S))LLLLL),U(A,A,C(C1(U)),A,A,A,A,A)><L,U(A,A,C(C1(U)),A,A,A ==================== Cpr signatures ==================== -T5075.$trModule: m1 +T5075.$trModule: T5075.loop: diff --git a/testsuite/tests/stranal/sigs/T8569.stderr b/testsuite/tests/stranal/sigs/T8569.stderr index 122f748775..bfbd22e52e 100644 --- a/testsuite/tests/stranal/sigs/T8569.stderr +++ b/testsuite/tests/stranal/sigs/T8569.stderr @@ -9,10 +9,10 @@ T8569.addUp: <S,1*U><L,U> ==================== Cpr signatures ==================== -T8569.$tc'Rdata: m1 -T8569.$tc'Rint: m1 -T8569.$tcRep: m1 -T8569.$trModule: m1 +T8569.$tc'Rdata: +T8569.$tc'Rint: +T8569.$tcRep: +T8569.$trModule: T8569.addUp: diff --git a/testsuite/tests/stranal/sigs/T8598.stderr b/testsuite/tests/stranal/sigs/T8598.stderr index d6793609d3..8c56089bcd 100644 --- a/testsuite/tests/stranal/sigs/T8598.stderr +++ b/testsuite/tests/stranal/sigs/T8598.stderr @@ -6,7 +6,7 @@ T8598.fun: <S,1*U(U)> ==================== Cpr signatures ==================== -T8598.$trModule: m1 +T8598.$trModule: T8598.fun: m1 diff --git a/testsuite/tests/stranal/sigs/UnsatFun.stderr b/testsuite/tests/stranal/sigs/UnsatFun.stderr index aedf131826..325d25ced7 100644 --- a/testsuite/tests/stranal/sigs/UnsatFun.stderr +++ b/testsuite/tests/stranal/sigs/UnsatFun.stderr @@ -12,7 +12,7 @@ UnsatFun.h3: <C(S),1*C1(U)> ==================== Cpr signatures ==================== -UnsatFun.$trModule: m1 +UnsatFun.$trModule: UnsatFun.f: b UnsatFun.g: UnsatFun.g': |