Collect CCs in CorePrep, including CCs in unfoldings
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Tue, 13 Feb 2018 06:03:57 +0000 (09:03 +0300)
committerÖmer Sinan Ağacan <omeragacan@gmail.com>
Tue, 13 Feb 2018 06:05:18 +0000 (09:05 +0300)
commit5957405808fe89e9b108dc0bc3cf4b56aec37775
tree1b3bea7c22e715fcaf8faf10cae67a23a37e6d94
parentc9a88db3ac4f1c3e97e3492ebe076f2df6463540
Collect CCs in CorePrep, including CCs in unfoldings

This patch includes two changes:

1. Move cost centre collection from `SCCfinal` to `CorePrep`, to be able
   to collect cost centres in unfoldings. `CorePrep` drops unfoldings, so
   that's the latest stage in the compilation pipeline for this.

   After this change `SCCfinal` no longer collects all cost centres, but
   it still generates & collects CAF cost centres + updates cost centre
   stacks of `StgRhsClosure` and `StgRhsCon`s.

   This fixes #5889.

2. Initialize cost centre stack fields of `StgRhs` in `coreToStg`. With
   this we no longer need to update cost centre stack fields in
   `SCCfinal`, so that module is removed.

   Cost centre initialization explained in Note [Cost-centre
   initialization plan].

   Because with -fcaf-all we need to attach a new cost-centre to each
   CAF, `coreTopBindToStg` now returns `CollectedCCs`.

Test Plan: validate

Reviewers: simonpj, bgamari, simonmar

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #5889

Differential Revision: https://phabricator.haskell.org/D4325
compiler/coreSyn/CorePrep.hs
compiler/deSugar/Coverage.hs
compiler/ghc.cabal.in
compiler/main/HscMain.hs
compiler/profiling/CostCentre.hs
compiler/profiling/SCCfinal.hs [deleted file]
compiler/simplStg/SimplStg.hs
compiler/stgSyn/CoreToStg.hs
testsuite/tests/profiling/should_compile/all.T
testsuite/tests/simplCore/should_compile/noinline01.stderr