From c30ac25f7dfaded58bb2ff85d4bffe662e4af8b1 Mon Sep 17 00:00:00 2001 From: Sebastian Graf Date: Mon, 3 Apr 2023 22:40:04 +0200 Subject: DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208. --- testsuite/tests/deSugar/should_compile/all.T | 2 +- testsuite/tests/simplCore/should_compile/T13143.hs | 10 -- .../tests/simplCore/should_compile/T13143.stderr | 119 -------------- testsuite/tests/simplCore/should_compile/all.T | 4 +- testsuite/tests/stranal/should_compile/T13143.hs | 10 ++ .../tests/stranal/should_compile/T13143.stderr | 123 ++++++++++++++ .../tests/stranal/should_compile/T18894.stderr | 180 ++++++++++++--------- testsuite/tests/stranal/should_compile/all.T | 3 + testsuite/tests/stranal/should_run/T23208.hs | 4 + testsuite/tests/stranal/should_run/T23208.stderr | 3 + testsuite/tests/stranal/should_run/T23208_Lib.hs | 12 ++ testsuite/tests/stranal/should_run/all.T | 1 + 12 files changed, 266 insertions(+), 205 deletions(-) delete mode 100644 testsuite/tests/simplCore/should_compile/T13143.hs delete mode 100644 testsuite/tests/simplCore/should_compile/T13143.stderr create mode 100644 testsuite/tests/stranal/should_compile/T13143.hs create mode 100644 testsuite/tests/stranal/should_compile/T13143.stderr create mode 100644 testsuite/tests/stranal/should_run/T23208.hs create mode 100644 testsuite/tests/stranal/should_run/T23208.stderr create mode 100644 testsuite/tests/stranal/should_run/T23208_Lib.hs (limited to 'testsuite') diff --git a/testsuite/tests/deSugar/should_compile/all.T b/testsuite/tests/deSugar/should_compile/all.T index 43ef2d495e..5d32f43b5f 100644 --- a/testsuite/tests/deSugar/should_compile/all.T +++ b/testsuite/tests/deSugar/should_compile/all.T @@ -110,6 +110,6 @@ test('T14815', [], makefile_test, ['T14815']) test('T13208', [], makefile_test, ['T13208']) test('T16615', normal, compile, ['-ddump-ds -dsuppress-uniques']) test('T18112', [grep_errmsg('cast')], compile, ['-ddump-ds']) -test('T19969', normal, compile, ['-ddump-simpl -dsuppress-uniques']) +test('T19969', [grep_errmsg('LoopBreaker')], compile, ['-ddump-simpl -dsuppress-uniques']) # f should become loopbreaker test('T19883', normal, compile, ['']) test('T22719', normal, compile, ['-ddump-simpl -dsuppress-uniques -dno-typeable-binds']) diff --git a/testsuite/tests/simplCore/should_compile/T13143.hs b/testsuite/tests/simplCore/should_compile/T13143.hs deleted file mode 100644 index c711bdecbe..0000000000 --- a/testsuite/tests/simplCore/should_compile/T13143.hs +++ /dev/null @@ -1,10 +0,0 @@ -module T13143 where - -{-# NOINLINE f #-} -f :: Int -> a -f x = f x - -g :: Bool -> Bool -> Int -> Int -g True True p = f p -g False True p = p + 1 -g b False p = g b True p diff --git a/testsuite/tests/simplCore/should_compile/T13143.stderr b/testsuite/tests/simplCore/should_compile/T13143.stderr deleted file mode 100644 index d614ab1f7a..0000000000 --- a/testsuite/tests/simplCore/should_compile/T13143.stderr +++ /dev/null @@ -1,119 +0,0 @@ - -==================== Tidy Core ==================== -Result size of Tidy Core - = {terms: 71, types: 40, coercions: 0, joins: 0/0} - -Rec { --- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} -T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] - :: forall {a}. (# #) -> a -[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] -T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) -end Rec } - --- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} -f [InlPrag=NOINLINE[final]] :: forall a. Int -> a -[GblId, - Arity=1, - Str=b, - Cpr=b, - Unf=Unf{Src=StableSystem, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True) - Tmpl= \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##)}] -f = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) - --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule4 :: GHC.Prim.Addr# -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 20 0}] -T13143.$trModule4 = "main"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule3 :: GHC.Types.TrName -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 - --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule2 :: GHC.Prim.Addr# -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 30 0}] -T13143.$trModule2 = "T13143"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule1 :: GHC.Types.TrName -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T13143.$trModule1 = GHC.Types.TrNameS T13143.$trModule2 - --- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -T13143.$trModule :: GHC.Types.Module -[GblId, - Unf=Unf{Src=, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=IF_ARGS [] 10 10}] -T13143.$trModule - = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 - --- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} -lvl :: Int -[GblId, Str=b, Cpr=b] -lvl = T13143.$wf @Int GHC.Prim.(##) - -Rec { --- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} -T13143.$wg [InlPrag=[2], Occ=LoopBreaker] - :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# -[GblId[StrictWorker([!, !])], - Arity=3, - Str=<1L><1L>, - Unf=OtherCon []] -T13143.$wg - = \ (ds :: Bool) (ds1 :: Bool) (ww :: GHC.Prim.Int#) -> - case ds of { - False -> - case ds1 of { - False -> T13143.$wg GHC.Types.False GHC.Types.True ww; - True -> GHC.Prim.+# ww 1# - }; - True -> - case ds1 of { - False -> T13143.$wg GHC.Types.True GHC.Types.True ww; - True -> case lvl of wild2 { } - } - } -end Rec } - --- RHS size: {terms: 14, types: 6, coercions: 0, joins: 0/0} -g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int -[GblId, - Arity=3, - Str=<1L><1L><1!P(L)>, - Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, - Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) - Tmpl= \ (ds [Occ=Once1] :: Bool) - (ds1 [Occ=Once1] :: Bool) - (p [Occ=Once1!] :: Int) -> - case p of { GHC.Types.I# ww [Occ=Once1] -> - case T13143.$wg ds ds1 ww of ww1 [Occ=Once1] { __DEFAULT -> - GHC.Types.I# ww1 - } - }}] -g = \ (ds :: Bool) (ds1 :: Bool) (p :: Int) -> - case p of { GHC.Types.I# ww -> - case T13143.$wg ds ds1 ww of ww1 { __DEFAULT -> GHC.Types.I# ww1 } - } - - - diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T index 80381ba45c..90e67d81fe 100644 --- a/testsuite/tests/simplCore/should_compile/all.T +++ b/testsuite/tests/simplCore/should_compile/all.T @@ -228,7 +228,6 @@ test('T13027', normal, compile, ['']) test('T13025', normal, makefile_test, ['T13025']) -test('T13143', only_ways(['optasm']), compile, ['-O -ddump-simpl -dsuppress-uniques -dsuppress-ticks']) test('T13156', normal, makefile_test, ['T13156']) test('T11444', normal, compile, ['']) test('str-rules', @@ -414,7 +413,8 @@ test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) # We expect to see a SPEC rule for $cm test('T19644', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) test('T21391', normal, compile, ['-O -dcore-lint']) -test('T22112', normal, compile, ['-O -dsuppress-uniques -dno-typeable-binds -ddump-simpl']) +# T22112: Simply test that dumping the Core doesn't loop becuse of the unfolding and ignore the dump output +test('T22112', [ grep_errmsg('never matches') ], compile, ['-O -dsuppress-uniques -dno-typeable-binds -fexpose-all-unfoldings -ddump-simpl']) test('T21391a', normal, compile, ['-O -dcore-lint']) # We don't want to see a thunk allocation for the insertBy expression after CorePrep. test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]'), expect_broken(21392) ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) diff --git a/testsuite/tests/stranal/should_compile/T13143.hs b/testsuite/tests/stranal/should_compile/T13143.hs new file mode 100644 index 0000000000..c711bdecbe --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T13143.hs @@ -0,0 +1,10 @@ +module T13143 where + +{-# NOINLINE f #-} +f :: Int -> a +f x = f x + +g :: Bool -> Bool -> Int -> Int +g True True p = f p +g False True p = p + 1 +g b False p = g b True p diff --git a/testsuite/tests/stranal/should_compile/T13143.stderr b/testsuite/tests/stranal/should_compile/T13143.stderr new file mode 100644 index 0000000000..3bb9885a83 --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T13143.stderr @@ -0,0 +1,123 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 71, types: 40, coercions: 0, joins: 0/0} + +Rec { +-- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} +T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] + :: forall {a}. (# #) -> a +[GblId, Arity=1, Str=b{sBp->S}, Cpr=b, Unf=OtherCon []] +T13143.$wf + = \ (@a_sBm) _ [Occ=Dead] -> T13143.$wf @a_sBm GHC.Prim.(##) +end Rec } + +-- RHS size: {terms: 4, types: 3, coercions: 0, joins: 0/0} +f [InlPrag=NOINLINE[final]] :: forall a. Int -> a +[GblId, + Arity=1, + Str=b{sBp->S}, + Cpr=b, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True) + Tmpl= \ (@a_sBm) _ [Occ=Dead] -> T13143.$wf @a_sBm GHC.Prim.(##)}] +f = \ (@a_sBm) _ [Occ=Dead] -> T13143.$wf @a_sBm GHC.Prim.(##) + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T13143.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] +T13143.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T13143.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] +T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T13143.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] +T13143.$trModule2 = "T13143"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T13143.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] +T13143.$trModule1 = GHC.Types.TrNameS T13143.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T13143.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] +T13143.$trModule + = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 + +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +lvl_rBN :: Int +[GblId, Str=b{sBp->S}, Cpr=b] +lvl_rBN = T13143.$wf @Int GHC.Prim.(##) + +Rec { +-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} +T13143.$wg [InlPrag=[2], Occ=LoopBreaker] + :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId[StrictWorker([!, !])], + Arity=3, + Str=<1L><1L>, + Unf=OtherCon []] +T13143.$wg + = \ (ds_sBr :: Bool) (ds1_sBs :: Bool) (ww_sBv :: GHC.Prim.Int#) -> + case ds_sBr of { + False -> + case ds1_sBs of { + False -> T13143.$wg GHC.Types.False GHC.Types.True ww_sBv; + True -> GHC.Prim.+# ww_sBv 1# + }; + True -> + case ds1_sBs of { + False -> T13143.$wg GHC.Types.True GHC.Types.True ww_sBv; + True -> case lvl_rBN of wild2_00 { } + } + } +end Rec } + +-- RHS size: {terms: 14, types: 6, coercions: 0, joins: 0/0} +g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int +[GblId, + Arity=3, + Str=<1L><1L><1!P(L)>, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds_sBr [Occ=Once1] :: Bool) + (ds1_sBs [Occ=Once1] :: Bool) + (p_sBt [Occ=Once1!] :: Int) -> + case p_sBt of { GHC.Types.I# ww_sBv [Occ=Once1] -> + case T13143.$wg ds_sBr ds1_sBs ww_sBv of ww1_sBA [Occ=Once1] + { __DEFAULT -> + GHC.Types.I# ww1_sBA + } + }}] +g = \ (ds_sBr :: Bool) (ds1_sBs :: Bool) (p_sBt :: Int) -> + case p_sBt of { GHC.Types.I# ww_sBv -> + case T13143.$wg ds_sBr ds1_sBs ww_sBv of ww1_sBA { __DEFAULT -> + GHC.Types.I# ww1_sBA + } + } + + + diff --git a/testsuite/tests/stranal/should_compile/T18894.stderr b/testsuite/tests/stranal/should_compile/T18894.stderr index 22c6f3b32d..d5d4ecf1f9 100644 --- a/testsuite/tests/stranal/should_compile/T18894.stderr +++ b/testsuite/tests/stranal/should_compile/T18894.stderr @@ -1,48 +1,54 @@ -==================== Demand analysis ==================== -Result size of Demand analysis +==================== Demand analysis (including Boxity) ==================== +Result size of Demand analysis (including Boxity) = {terms: 189, types: 95, coercions: 0, joins: 0/2} -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] $trModule = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Types.TrName [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] $trModule = "T18894"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Types.TrName [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18894.$trModule :: GHC.Types.Module [LclIdX, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18894.$trModule = GHC.Types.Module $trModule $trModule -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 0# -- RHS size: {terms: 42, types: 15, coercions: 0, joins: 0/1} @@ -51,8 +57,9 @@ g2 [InlPrag=NOINLINE, Dmd=LC(S,C(1,!P(M!P(L),1!P(L))))] [LclId, Arity=2, Str=<1!P(1L)>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 20] 106 20}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [20 20] 106 20}] g2 = \ (m :: Int) (ds [Dmd=1!P(1L)] :: Int) -> case ds of { GHC.Types.I# ds [Dmd=1L] -> @@ -64,8 +71,9 @@ g2 let { c1# :: GHC.Prim.Int# [LclId, - Unf=Unf{Src=, TopLvl=False, Value=False, ConLike=False, - WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 2 0}] + Unf=Unf{Src=, TopLvl=False, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 2 0}] c1# = GHC.Prim.andI# 1# (GHC.Prim.<# wild 0#) } in case GHC.Prim.-# (GHC.Prim.quotInt# (GHC.Prim.-# 2# c1#) wild) c1# of ds2 @@ -81,22 +89,25 @@ g2 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 2# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 2# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 0# -- RHS size: {terms: 36, types: 19, coercions: 0, joins: 0/0} @@ -104,8 +115,9 @@ h2 :: Int -> Int [LclIdX, Arity=1, Str=<1P(SL)>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 162 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [20] 162 10}] h2 = \ (ds [Dmd=1P(SL)] :: Int) -> case ds of wild { GHC.Types.I# ds [Dmd=SL] -> @@ -128,22 +140,25 @@ h2 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 15# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 0# -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} lvl :: (Int, Int) [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = (lvl, lvl) -- RHS size: {terms: 36, types: 10, coercions: 0, joins: 0/1} @@ -151,8 +166,9 @@ g1 [InlPrag=NOINLINE, Dmd=LC(L,!P(L,L))] :: Int -> (Int, Int) [LclId, Arity=1, Str=<1!P(1L)>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 86 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [20] 86 10}] g1 = \ (ds [Dmd=1!P(1L)] :: Int) -> case ds of { GHC.Types.I# ds [Dmd=1L] -> @@ -164,8 +180,9 @@ g1 let { c1# :: GHC.Prim.Int# [LclId, - Unf=Unf{Src=, TopLvl=False, Value=False, ConLike=False, - WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 2 0}] + Unf=Unf{Src=, TopLvl=False, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 2 0}] c1# = GHC.Prim.andI# 1# (GHC.Prim.<# wild 0#) } in case GHC.Prim.-# (GHC.Prim.quotInt# (GHC.Prim.-# 2# c1#) wild) c1# of ds2 @@ -181,15 +198,17 @@ g1 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 0# -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} lvl :: (Int, Int) [LclId, - Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, - WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 30 0}] lvl = g1 (GHC.Types.I# 2#) -- RHS size: {terms: 28, types: 18, coercions: 0, joins: 0/0} @@ -197,8 +216,9 @@ h1 :: Int -> Int [LclIdX, Arity=1, Str=<1!P(SL)>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 111 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [20] 111 10}] h1 = \ (ds [Dmd=1!P(SL)] :: Int) -> case ds of wild [Dmd=M!P(1L)] { GHC.Types.I# ds [Dmd=SL] -> @@ -224,43 +244,49 @@ Result size of Demand analysis -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] $trModule = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Types.TrName [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] $trModule = "T18894"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Types.TrName [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18894.$trModule :: GHC.Types.Module [LclIdX, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T18894.$trModule = GHC.Types.Module $trModule $trModule -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 0# -- RHS size: {terms: 39, types: 17, coercions: 0, joins: 0/1} @@ -269,8 +295,9 @@ $wg2 [InlPrag=NOINLINE, Dmd=LC(S,C(1,!P(M!P(L),1!P(L))))] [LclId[StrictWorker([])], Arity=2, Str=<1L>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 30] 76 20}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [20 30] 76 20}] $wg2 = \ (m :: Int) (ww [Dmd=1L] :: GHC.Prim.Int#) -> case ww of ds [Dmd=ML] { @@ -281,8 +308,9 @@ $wg2 let { c1# :: GHC.Prim.Int# [LclId, - Unf=Unf{Src=, TopLvl=False, Value=False, ConLike=False, - WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 2 0}] + Unf=Unf{Src=, TopLvl=False, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 2 0}] c1# = GHC.Prim.andI# 1# (GHC.Prim.<# wild 0#) } in case GHC.Prim.-# (GHC.Prim.quotInt# (GHC.Prim.-# 2# c1#) wild) c1# of ds2 @@ -297,8 +325,9 @@ $wg2 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} lvl :: Int [LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] lvl = GHC.Types.I# 2# -- RHS size: {terms: 36, types: 23, coercions: 0, joins: 0/0} @@ -306,8 +335,9 @@ h2 :: Int -> Int [LclIdX, Arity=1, Str=<1P(SL)>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 162 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [20] 162 10}] h2 = \ (ds [Dmd=1P(SL)] :: Int) -> case ds of wild { GHC.Types.I# ds [Dmd=SL] -> @@ -333,8 +363,9 @@ $wg1 [InlPrag=NOINLINE, Dmd=LC(L,!P(L,L))] [LclId[StrictWorker([])], Arity=1, Str=<1L>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [30] 56 20}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [30] 56 20}] $wg1 = \ (ww [Dmd=1L] :: GHC.Prim.Int#) -> case ww of ds { @@ -345,8 +376,9 @@ $wg1 let { c1# :: GHC.Prim.Int# [LclId, - Unf=Unf{Src=, TopLvl=False, Value=False, ConLike=False, - WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 2 0}] + Unf=Unf{Src=, TopLvl=False, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 2 0}] c1# = GHC.Prim.andI# 1# (GHC.Prim.<# wild 0#) } in case GHC.Prim.-# (GHC.Prim.quotInt# (GHC.Prim.-# 2# c1#) wild) c1# of ds2 @@ -361,17 +393,19 @@ $wg1 -- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} lvl :: (Int, Int) [LclId, - Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, - WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 50 10}] + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=False, Expandable=False, + Guidance=IF_ARGS [] 50 10}] lvl = case $wg1 2# of { (# ww, ww #) -> (GHC.Types.I# ww, ww) } -- RHS size: {terms: 22, types: 16, coercions: 0, joins: 0/0} -$wh1 [InlPrag=[2], Dmd=LC(S,!P(L))] :: GHC.Prim.Int# -> Int +$wh1 [InlPrag=[2]] :: GHC.Prim.Int# -> Int [LclId[StrictWorker([])], Arity=1, Str=<1L>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [50] 91 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [50] 91 10}] $wh1 = \ (ww [Dmd=1L] :: GHC.Prim.Int#) -> case ww of ds [Dmd=ML] { @@ -388,8 +422,8 @@ h1 [InlPrag=[2]] :: Int -> Int [LclIdX, Arity=1, Str=<1!P(1L)>, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (ds [Occ=Once1!, Dmd=S!P(SL)] :: Int) -> case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> $wh1 ww }}] diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T index 0355def88e..4dbe61a300 100644 --- a/testsuite/tests/stranal/should_compile/all.T +++ b/testsuite/tests/stranal/should_compile/all.T @@ -42,6 +42,9 @@ test('T13031', normal, makefile_test, []) test('T13077', normal, compile, ['']) test('T13077a', normal, compile, ['']) +# T13143: WW for NOINLINE function f +test('T13143', [ grep_errmsg(r'^T13143\.\$wf') ], compile, ['-ddump-simpl']) + # T15627 # Absent bindings of unlifted types should be WW'ed away. # The idea is to check that both $wmutVar and $warray diff --git a/testsuite/tests/stranal/should_run/T23208.hs b/testsuite/tests/stranal/should_run/T23208.hs new file mode 100644 index 0000000000..8125539fc9 --- /dev/null +++ b/testsuite/tests/stranal/should_run/T23208.hs @@ -0,0 +1,4 @@ +import T23208_Lib + +main = print $ g (15 :: Int) + diff --git a/testsuite/tests/stranal/should_run/T23208.stderr b/testsuite/tests/stranal/should_run/T23208.stderr new file mode 100644 index 0000000000..3d71f0be64 --- /dev/null +++ b/testsuite/tests/stranal/should_run/T23208.stderr @@ -0,0 +1,3 @@ +T23208: really important message +CallStack (from HasCallStack): + error, called at T23208_Lib.hs:4:7 in main:T23208_Lib diff --git a/testsuite/tests/stranal/should_run/T23208_Lib.hs b/testsuite/tests/stranal/should_run/T23208_Lib.hs new file mode 100644 index 0000000000..e4952d098d --- /dev/null +++ b/testsuite/tests/stranal/should_run/T23208_Lib.hs @@ -0,0 +1,12 @@ +module T23208_Lib (g) where + +err :: Int -> b +err = error "really important message" + +sg :: Int -> Int +sg n = err n +{-# NOINLINE sg #-} +g :: a -> a +g x = x +{-# NOINLINE g #-} +{-# RULES "g" g @Int = sg #-} diff --git a/testsuite/tests/stranal/should_run/all.T b/testsuite/tests/stranal/should_run/all.T index 9da7863314..42edda5f74 100644 --- a/testsuite/tests/stranal/should_run/all.T +++ b/testsuite/tests/stranal/should_run/all.T @@ -32,3 +32,4 @@ test('T22475', normal, compile_and_run, ['']) test('T22475b', normal, compile_and_run, ['']) # T22549: Do not strictify DFuns, otherwise we will <> test('T22549', normal, compile_and_run, ['-fdicts-strict -fno-specialise']) +test('T23208', exit_code(1), multimod_compile_and_run, ['T23208_Lib', 'T23208']) -- cgit v1.2.1