Cost centres seem to cause invalid demand analysis results.
With the lateCC pass we now add cost centres in some places where we didn't before and this seems to cause issues with demand analysis/core lint.
We simplify this function (taken from after float out)
-- RHS size: {terms: 5, types: 4, coercions: 8, joins: 0/0}
fail_s9my :: (# #) -> IO ExitCode
[LclId, Arity=2, Str=<L><L>b, Cpr=b]
fail_s9my
= (\ _ [Occ=Dead, OS=OneShot]
(eta_B0 :: ghc-prim:GHC.Prim.State# ghc-prim:GHC.Prim.RealWorld) ->
((GHC.Base.failIO @ExitCode lvl_s9mw)
`cast` (ghc-prim:GHC.Types.N:IO[0] <ExitCode>_R
:: IO ExitCode
~R# (ghc-prim:GHC.Prim.State# ghc-prim:GHC.Prim.RealWorld
-> (# ghc-prim:GHC.Prim.State# ghc-prim:GHC.Prim.RealWorld,
ExitCode #))))
eta_B0)
`cast` (Sym (<(# #)>_R
%<'Many>_N ->_R ghc-prim:GHC.Types.N:IO[0] <ExitCode>_R)
:: ((# #)
-> ghc-prim:GHC.Prim.State# ghc-prim:GHC.Prim.RealWorld
-> (# ghc-prim:GHC.Prim.State# ghc-prim:GHC.Prim.RealWorld,
ExitCode #))
~R# ((# #) -> IO ExitCode))
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
lvl_s9mz :: IO ExitCode
[LclId, Str=b, Cpr=b]
lvl_s9mz = scc<bindIO> scc<bindIO> fail_s9my ghc-prim:GHC.Prim.(##)
into this one (after one iteration of the simplifier)
lvl_s9Jy :: State# RealWorld -> (# State# RealWorld, ExitCode #)
[LclId,
Arity=1,
Str=b,
Cpr=b,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
lvl_s9Jy
= \ (eta_B0 :: State# RealWorld) ->
scc<bindIO>
scc<bindIO>
((failIO @ExitCode (scc<bindIO> scc<bindIO> build @Char lvl_s9mv))
`cast` (N:IO[0] <ExitCode>_R
:: IO ExitCode
~R# (State# RealWorld -> (# State# RealWorld, ExitCode #))))
eta_B0
But the later one results in this core lint error:
*** Core Linted result of Simplifier:
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
idArity 1 exceeds arity imposed by the strictness signature b: lvl_s9Jw
In the RHS of lvl_s9Jw :: State# RealWorld
-> (# State# RealWorld, ExitCode #)
Substitution: [TCvSubst
In scope: InScope {}
Type env: []
Co env: []]
*** Offending Program ***
The core issue seems to be that we infer Str=b
for
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
lvl_s9mz :: IO ExitCode
[LclId, Str=b, Cpr=b]
lvl_s9mz = scc<bindIO> scc<bindIO> fail_s9my ghc-prim:GHC.Prim.(##)
If we expand IO/unwrap the IO newtype this function is of type:
State# RealWorld -> (# State# RealWorld, ExitCode #)
so I don't think this should get a Str of b
as we have to provide the RealWorld argument for it to bottom out.
I assume the cost centre annotations on the RHS somehow interfere with demand analysis in this case.
@sgraf812 Maybe you have an idea?