Note [Finalising boxity for demand signatures]
The worker/wrapper pass must strictly adhere to the boxity decisions encoded in the demand signature, because that is the information that demand analysis propagates throughout the program. Failing to implement the strategy laid out in the signature can result in reboxing in unexpected places. Hence, we must completely anticipate unboxing decisions during demand analysis and reflect these decisions in demand annotations. That is the job of 'finaliseArgBoxities', which is defined here and called from demand analysis. Here is a list of different Notes it has to take care of: * Note [No lazy, Unboxed demands in demand signature] such as `L!P(L)` in general, but still allow Note [Unboxing evaluated arguments] * Note [No nested Unboxed inside Boxed in demand signature] such as `1P(1!L)` * Note [mkWWstr and unsafeCoerce] NB: Then, the worker/wrapper blindly trusts the boxity info in the demand signature; that is why 'canUnboxArg' does not look at strictness -- it is redundant to do so.
References 4
- No lazy, Unboxed demands in demand signature GHC.Core.Opt.DmdAnal
- No nested Unboxed inside Boxed in demand signature GHC.Core.Opt.DmdAnal
- Unboxing evaluated arguments GHC.Core.Opt.DmdAnal
- mkWWstr and unsafeCoerce GHC.Core.Opt.WorkWrap.Utils
Referenced by 3
- GHC.Core.Opt.DmdAnal call site
- Worker/wrapper for Strictness and Absence GHC.Core.Opt.WorkWrap.Utils
- Boxity analysis GHC.Types.Demand