diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-05-04 10:50:04 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-06-27 08:01:39 -0400 |
commit | ac7a7fc88b51f9fb4e84499397e12eb0081ba79e (patch) | |
tree | 075714e3c20f6aa770e8a5cb508112436fe466b5 /testsuite | |
parent | 38378be3506f0d4f597fcd5aa2d9db3124fbf535 (diff) | |
download | haskell-ac7a7fc88b51f9fb4e84499397e12eb0081ba79e.tar.gz |
Don't mark lambda binders as OtherCon
We used to put OtherCon unfoldings on lambda binders of workers
and sometimes also join points/specializations with with the
assumption that since the wrapper would force these arguments
once we execute the RHS they would indeed be in WHNF.
This was wrong for reasons detailed in #21472. So now we purge
evaluated unfoldings from *all* lambda binders.
This fixes #21472, but at the cost of sometimes not using as efficient a
calling convention. It can also change inlining behaviour as some
occurances will no longer look like value arguments when they did
before.
As consequence we also change how we compute CBV information for
arguments slightly. We now *always* determine the CBV convention
for arguments during tidy. Earlier in the pipeline we merely mark
functions as candidates for having their arguments treated as CBV.
As before the process is described in the relevant notes:
Note [CBV Function Ids]
Note [Attaching CBV Marks to ids]
Note [Never put `OtherCon` unfoldigns on lambda binders]
-------------------------
Metric Decrease:
T12425
T13035
T18223
T18223
T18923
MultiLayerModulesTH_OneShot
Metric Increase:
WWRec
-------------------------
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/arityanal/should_compile/Arity11.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/arityanal/should_compile/T18793.stderr | 11 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T13143.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T20103.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T7360.stderr | 27 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/spec-inline.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/stranal/should_compile/T20817.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T16197b.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T16197b.stderr | 20 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T16859.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/all.T | 2 |
11 files changed, 53 insertions, 57 deletions
diff --git a/testsuite/tests/arityanal/should_compile/Arity11.stderr b/testsuite/tests/arityanal/should_compile/Arity11.stderr index a4f2e38b53..7c7451a6d7 100644 --- a/testsuite/tests/arityanal/should_compile/Arity11.stderr +++ b/testsuite/tests/arityanal/should_compile/Arity11.stderr @@ -142,7 +142,4 @@ f11 :: (Integer, Integer) f11 = (F11.f4, F11.f1) ------- Local rules for imported ids -------- -"SPEC fib @Integer @Integer" forall ($dEq :: Eq Integer) ($dNum :: Num Integer) ($dNum1 :: Num Integer). fib @Integer @Integer $dEq $dNum $dNum1 = F11.f11_fib - diff --git a/testsuite/tests/arityanal/should_compile/T18793.stderr b/testsuite/tests/arityanal/should_compile/T18793.stderr index 13ca1c65f5..728108a331 100644 --- a/testsuite/tests/arityanal/should_compile/T18793.stderr +++ b/testsuite/tests/arityanal/should_compile/T18793.stderr @@ -10,12 +10,9 @@ stuff = \ (i :: Int) -> case i of i1 { GHC.Types.I# ipv -> GHC.Types.: @Int i1 ( Rec { -- RHS size: {terms: 23, types: 11, coercions: 0, joins: 0/0} T18793.$wgo1 [InlPrag=[2], Occ=LoopBreaker] :: [Int] -> GHC.Prim.Int# -> GHC.Prim.Int# -[GblId[StrictWorker([!, ~])], Arity=2, Str=<1L><L>, Unf=OtherCon []] +[GblId[StrictWorker([!])], Arity=2, Str=<1L><L>, Unf=OtherCon []] T18793.$wgo1 - = \ (ds - :: [Int] - Unf=OtherCon []) - (ww :: GHC.Prim.Int#) -> + = \ (ds :: [Int]) (ww :: GHC.Prim.Int#) -> case ds of { [] -> ww; : y ys -> @@ -35,8 +32,8 @@ T18793.f_go1 [InlPrag=[2]] :: [Int] -> Int -> Int Str=<1L><1!P(L)>, Cpr=1, 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= \ (ds [Occ=Once1] :: [Int]) (eta [Occ=Once1!] :: Int) -> case eta of { GHC.Types.I# ww [Occ=Once1] -> case T18793.$wgo1 ds ww of ww1 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww1 } }}] -T18793.f_go1 = \ (ds :: [Int]) (eta :: Int) -> case eta of { GHC.Types.I# ww -> case T18793.$wgo1 ds ww of ww1 { __DEFAULT -> GHC.Types.I# ww1 } } + Tmpl= \ (ds [Occ=Once1] :: [Int]) (eta [Occ=Once1!, OS=OneShot] :: Int) -> case eta of { GHC.Types.I# ww [Occ=Once1] -> case T18793.$wgo1 ds ww of ww1 [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww1 } }}] +T18793.f_go1 = \ (ds :: [Int]) (eta [OS=OneShot] :: Int) -> case eta of { GHC.Types.I# ww -> case T18793.$wgo1 ds ww of ww1 { __DEFAULT -> GHC.Types.I# ww1 } } -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T18793.f2 :: Int diff --git a/testsuite/tests/simplCore/should_compile/T13143.stderr b/testsuite/tests/simplCore/should_compile/T13143.stderr index c80ddb569b..16189c6daa 100644 --- a/testsuite/tests/simplCore/should_compile/T13143.stderr +++ b/testsuite/tests/simplCore/should_compile/T13143.stderr @@ -68,18 +68,12 @@ Rec { -- RHS size: {terms: 28, types: 8, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# -[GblId[StrictWorker([!, !, ~])], +[GblId[StrictWorker([!, !])], Arity=3, Str=<1L><1L><L>, Unf=OtherCon []] T13143.$wg - = \ (ds - :: Bool - Unf=OtherCon []) - (ds1 - :: Bool - Unf=OtherCon []) - (ww :: GHC.Prim.Int#) -> + = \ (ds :: Bool) (ds1 :: Bool) (ww :: GHC.Prim.Int#) -> case ds of { False -> case ds1 of { diff --git a/testsuite/tests/simplCore/should_compile/T20103.stderr b/testsuite/tests/simplCore/should_compile/T20103.stderr index 7eea0f5fde..2f246eb985 100644 --- a/testsuite/tests/simplCore/should_compile/T20103.stderr +++ b/testsuite/tests/simplCore/should_compile/T20103.stderr @@ -113,15 +113,9 @@ Rec { -- RHS size: {terms: 44, types: 41, coercions: 21, joins: 0/0} T20103.$wfoo [InlPrag=[2], Occ=LoopBreaker] :: HasCallStack => GHC.Prim.Int# -> GHC.Prim.Int# -[GblId[StrictWorker([!, ~])], - Arity=2, - Str=<SL><1L>, - Unf=OtherCon []] +[GblId[StrictWorker([!])], Arity=2, Str=<SL><1L>, Unf=OtherCon []] T20103.$wfoo - = \ ($dIP - :: HasCallStack - Unf=OtherCon []) - (ww :: GHC.Prim.Int#) -> + = \ ($dIP :: HasCallStack) (ww :: GHC.Prim.Int#) -> case ww of ds { __DEFAULT -> case $dIP diff --git a/testsuite/tests/simplCore/should_compile/T7360.stderr b/testsuite/tests/simplCore/should_compile/T7360.stderr index ce0f5117bb..30efb85c29 100644 --- a/testsuite/tests/simplCore/should_compile/T7360.stderr +++ b/testsuite/tests/simplCore/should_compile/T7360.stderr @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 113, types: 49, coercions: 0, joins: 0/0} + = {terms: 116, types: 50, coercions: 0, joins: 0/0} -- RHS size: {terms: 6, types: 3, coercions: 0, joins: 0/0} T7360.$WFoo3 [InlPrag=INLINE[final] CONLIKE] :: Int %1 -> Foo @@ -20,16 +20,17 @@ T7360.$WFoo3 = \ (conrep [Occ=Once1!] :: Int) -> case conrep of { GHC.Types.I# unbx [Occ=Once1] -> T7360.Foo3 unbx } --- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +-- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} T7360.$wfun1 [InlPrag=NOINLINE] :: Foo -> (# #) -[GblId[StrictWorker([!])], Arity=1, Str=<A>, Unf=OtherCon []] -T7360.$wfun1 = \ _ [Occ=Dead] -> GHC.Prim.(##) +[GblId[StrictWorker([!])], Arity=1, Str=<1A>, Unf=OtherCon []] +T7360.$wfun1 + = \ (x :: Foo) -> case x of { __DEFAULT -> GHC.Prim.(##) } -- RHS size: {terms: 6, types: 2, coercions: 0, joins: 0/0} fun1 [InlPrag=[final]] :: Foo -> () [GblId, Arity=1, - Str=<A>, + Str=<1A>, Cpr=1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -132,8 +133,8 @@ T7360.$tcFoo :: GHC.Types.TyCon WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tcFoo = GHC.Types.TyCon - 1581370841583180512## - 13291578023368289311## + 1581370841583180512##64 + 13291578023368289311##64 T7360.$trModule T7360.$tcFoo1 0# @@ -167,8 +168,8 @@ T7360.$tc'Foo1 :: GHC.Types.TyCon WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo1 = GHC.Types.TyCon - 3986951253261644518## - 2515097940992351150## + 3986951253261644518##64 + 2515097940992351150##64 T7360.$trModule T7360.$tc'Foo5 0# @@ -195,8 +196,8 @@ T7360.$tc'Foo2 :: GHC.Types.TyCon WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo2 = GHC.Types.TyCon - 17325079864060690428## - 2969742457748208427## + 17325079864060690428##64 + 2969742457748208427##64 T7360.$trModule T7360.$tc'Foo7 0# @@ -228,8 +229,8 @@ T7360.$tc'Foo3 :: GHC.Types.TyCon WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T7360.$tc'Foo3 = GHC.Types.TyCon - 3674231676522181654## - 2694749919371021431## + 3674231676522181654##64 + 2694749919371021431##64 T7360.$trModule T7360.$tc'Foo10 0# diff --git a/testsuite/tests/simplCore/should_compile/spec-inline.stderr b/testsuite/tests/simplCore/should_compile/spec-inline.stderr index 7b99cc01ff..e0b2ad4962 100644 --- a/testsuite/tests/simplCore/should_compile/spec-inline.stderr +++ b/testsuite/tests/simplCore/should_compile/spec-inline.stderr @@ -80,11 +80,7 @@ Roman.$wgo [InlPrag=[2]] :: Maybe Int -> Maybe Int -> GHC.Prim.Int# Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [61 30] 249 0}] Roman.$wgo - = \ (u :: Maybe Int - Unf=OtherCon []) - (ds - :: Maybe Int - Unf=OtherCon []) -> + = \ (u :: Maybe Int) (ds :: Maybe Int) -> case ds of { Nothing -> case Roman.foo3 of wild1 { }; Just x -> @@ -113,7 +109,7 @@ Roman.$wgo -- RHS size: {terms: 9, types: 5, coercions: 0, joins: 0/0} Roman.foo_go [InlPrag=[2]] :: Maybe Int -> Maybe Int -> Int -[GblId, +[GblId[StrictWorker([!, !])], Arity=2, Str=<1L><1L>, Cpr=1, diff --git a/testsuite/tests/stranal/should_compile/T20817.stderr b/testsuite/tests/stranal/should_compile/T20817.stderr index ba364234db..c113c3c2d1 100644 --- a/testsuite/tests/stranal/should_compile/T20817.stderr +++ b/testsuite/tests/stranal/should_compile/T20817.stderr @@ -234,10 +234,10 @@ Rec { -- RHS size: {terms: 34, types: 36, coercions: 0, joins: 0/0} $wg [InlPrag=[2], Occ=LoopBreaker, - Dmd=LCL(C1(C1(C1(C1(C1(C1(!L)))))))] + Dmd=LCS(C1(C1(C1(C1(C1(C1(L)))))))] :: forall {a} {b} {c} {d} {e} {t} {t} {t}. Bool -> a -> b -> c -> t -> t -> t -> (# a, b, c, t, t, t #) -[LclId[StrictWorker([!, ~, ~, ~, ~, ~, ~])], +[LclId[StrictWorker([])], Arity=7, Str=<1L><L><L><L><L><L><L>, Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, @@ -252,9 +252,7 @@ $wg (@t) (@t) (@t) - (ds [Dmd=1L] - :: Bool - Unf=OtherCon []) + (ds [Dmd=1L] :: Bool) (ww :: a) (ww :: b) (ww :: c) diff --git a/testsuite/tests/stranal/sigs/T16197b.hs b/testsuite/tests/stranal/sigs/T16197b.hs index 4ce440d3bf..dda6670c64 100644 --- a/testsuite/tests/stranal/sigs/T16197b.hs +++ b/testsuite/tests/stranal/sigs/T16197b.hs @@ -2,6 +2,11 @@ -- Important takeaway: The signature of `f` may not say "strict in the Bool -- field of T", otherwise the Simplifier will drop the `seq` on the `Bool` at -- call sites after unboxing the `T`. +-- +-- Now (with #21497) this has a twist. When we do w/w we insert seqs to make the worker strict in +-- strict fields. This means the simplifier might drop the seq at the call site +-- but we will seq inside the worker so things still work. +-- So instead of checking the strictness sig we now check if there is a seq in the worker. module T16197b where data T = T !Bool diff --git a/testsuite/tests/stranal/sigs/T16197b.stderr b/testsuite/tests/stranal/sigs/T16197b.stderr index d4c250b44a..88988c266b 100644 --- a/testsuite/tests/stranal/sigs/T16197b.stderr +++ b/testsuite/tests/stranal/sigs/T16197b.stderr @@ -1,15 +1,29 @@ ==================== Strictness signatures ==================== -T16197b.f: <1!P(L)> +f: <1!P(L)> ==================== Cpr signatures ==================== -T16197b.f: 1 +f: 1 ==================== Strictness signatures ==================== -T16197b.f: <1!P(L)> +f: <1!P(1L)> + + + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 25, types: 23, coercions: 0, joins: 0/0} + +$WT = \ conrep -> case conrep of conrep { __DEFAULT -> T conrep } + +$wf = \ ww -> case ww of ww1 { __DEFAULT -> (# ww1 #) } + +f = \ ds -> + case ds of { T ww -> case $wf ww of { (# ww1 #) -> Box ww1 } } + diff --git a/testsuite/tests/stranal/sigs/T16859.stderr b/testsuite/tests/stranal/sigs/T16859.stderr index 6dd199c07c..afd96a8000 100644 --- a/testsuite/tests/stranal/sigs/T16859.stderr +++ b/testsuite/tests/stranal/sigs/T16859.stderr @@ -27,10 +27,10 @@ T16859.n_uniq: 1 ==================== Strictness signatures ==================== T16859.bar: <1!A><L> -T16859.baz: <L><1!P(L)><1C1(L)> +T16859.baz: <1L><1!P(L)><1C1(L)> T16859.buz: <1!P(L,L)> -T16859.foo: <L><L> -T16859.mkInternalName: <1!P(L)><L><L> +T16859.foo: <1L><L> +T16859.mkInternalName: <1!P(L)><1L><1L> T16859.n_loc: <1!P(A,A,A,1L)> T16859.n_occ: <1!P(A,1!P(L,L),A,A)> T16859.n_sort: <1!P(1L,A,A,A)> diff --git a/testsuite/tests/stranal/sigs/all.T b/testsuite/tests/stranal/sigs/all.T index 3782fa97a6..3ebfe287ec 100644 --- a/testsuite/tests/stranal/sigs/all.T +++ b/testsuite/tests/stranal/sigs/all.T @@ -23,7 +23,7 @@ test('T13380c', expect_broken('!3014'), compile, ['']) test('T13380f', normal, compile, ['']) test('T18086', normal, compile, ['-package ghc']) test('T18957', normal, compile, ['']) -test('T16197b', normal, compile, ['']) +test('T16197b', [grep_errmsg('\$wf')], compile, ['-ddump-simpl -dsuppress-uniques -dsuppress-all']) test('T19407', normal, compile, ['']) test('T19871', normal, compile, ['']) test('T16859', normal, compile, ['-package ghc']) |