Note [Floating Ticks in CorePrep]
It might seem counter-intuitive to float ticks by default, given that we don't actually want to move them if we can help it. On the other hand, nothing gets very far in CorePrep anyway, and we want to preserve the order of let bindings and tick annotations in relation to each other. For example, if we just wrapped let floats when they pass through ticks, we might end up performing the following transformation: src<...> let foo = bar in baz ==> let foo = src<...> bar in src<...> baz Because the let-binding would float through the tick, and then immediately materialize, achieving nothing but decreasing tick accuracy. The only special case is the following scenario: let foo = src<...> (let a = b in bar) in baz ==> let foo = src<...> bar; a = src<...> b in baz Here we would not want the source tick to end up covering "baz" and therefore refrain from pushing ticks outside. Instead, we copy them into the floating binds (here "a") in cpePair. Note that where "b" or "bar" are (value) lambdas we have to push the annotations further inside in order to uphold our rules. All of this is implemented below in @wrapTicks@.
References 0
This Note does not link to any other.
Referenced by 2
- GHC.CoreToStg.Prep call site
- Floating in CorePrep GHC.CoreToStg.Prep