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/tests/simplCore | |
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/tests/simplCore')
4 files changed, 20 insertions, 35 deletions
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, |