Simplifier/Worker-wrapper: Replace absent arguments by absent fillers
Consider
{-# LANGUAGE MagicHash #-}
module Lib where
import GHC.Exts
f :: Int# -> Int
f x = 0
{-# OPAQUE f #-}
g :: Int# -> Int
g x = f (x +# 1#)
f
is absent in its parameter, but the arguments at its call sites still need to be computed.
Today we simplify to
g = \ (x_axk :: Int#) -> f (+# x_axk 1#)
I.e. we are doing an addition that is never used, because it occurs in an absent argument.
We should instead replace (+# x_axk 1#)
by a RUBBISH
literal or a suitable absent filler (error "absent"
in the lifted case).
At present, worker/wrapper replaces RHSs of let bindings with an absent filler, but never replaces arguments. We should perhaps change that. (But we should we careful to only replace ok-for-side-effect expressions! Perhaps even just ok-for-spec.)
This could be done either in the Simplifier (which already knows about the demand put on arguments and may well replace absent ones) or in worker/wrapper (which would need to replicate part of the (simple) logic of DmdAnal/Simplifier to track argument demands.).