Skip to content

When compiling with -fprof-late insert cost centres after unfoldings are created.

Andreas Klebinger requested to merge wip/andreask/late_cc into master

For code like this:

        module A where
        f x = expr

        module B where
        g = ... f ...

We currently simplify f. Then we attach the late cost centre. However after doing so we update the unfolding for f again. Giving us f's unfolding to be f = \x -> {scc f} expr.

This is both good and bad. On one hand it means that even if we inline we properly attribute the cost of expr to f. But it's also bad because it can prevent further optimization of g.

We can avoid this by simply inserting the costcentre for f after unfolding creation. This way the cost centre won't be included in the unfolding.

Fixes #21249 (closed).

Edited by Ben Gamari

Merge request reports