summaryrefslogtreecommitdiff
path: root/compiler/profiling
diff options
context:
space:
mode:
authorPeter Wortmann <scpmw@leeds.ac.uk>2014-01-14 18:25:16 +0000
committerAustin Seipp <austin@well-typed.com>2014-12-16 15:02:19 -0600
commit4cdbf80250da2d3ba1c63451e5fbc9b5ca9cbfe9 (patch)
tree0cb8e99ff8202cf6873fd93c22383cdc7036c13f /compiler/profiling
parent07d604fa1dba7caa39cdc4bc3d90844c600adb70 (diff)
downloadhaskell-4cdbf80250da2d3ba1c63451e5fbc9b5ca9cbfe9.tar.gz
Source notes (CorePrep and Stg support)
This is basically just about continuing maintaining source notes after the Core stage. Unfortunately, this is more involved as it might seem, as there are more restrictions on where ticks are allowed to show up. Notes: * We replace the StgTick / StgSCC constructors with a unified StgTick that can carry any tickish. * For handling constructor or lambda applications, we generally float ticks out. * Note that thanks to the NonLam placement, we know that source notes can never appear on lambdas. This means that as long as we are careful to always use mkTick, we will never violate CorePrep invariants. * This is however not automatically true for eta expansion, which needs to somewhat awkwardly strip, then re-tick the expression in question. * Where CorePrep floats out lets, we make sure to wrap them in the same spirit as FloatOut. * Detecting selector thunks becomes a bit more involved, as we can run into ticks at multiple points. (From Phabricator D169)
Diffstat (limited to 'compiler/profiling')
-rw-r--r--compiler/profiling/SCCfinal.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/profiling/SCCfinal.hs b/compiler/profiling/SCCfinal.hs
index 9ad5b5fc3d..dfa3d052a4 100644
--- a/compiler/profiling/SCCfinal.hs
+++ b/compiler/profiling/SCCfinal.hs
@@ -31,6 +31,7 @@ import UniqSupply ( UniqSupply )
import ListSetOps ( removeDups )
import Outputable
import DynFlags
+import CoreSyn ( Tickish(..) )
import FastString
import SrcLoc
import Util
@@ -93,7 +94,8 @@ stgMassageForProfiling dflags mod_name _us stg_binds
do_top_rhs :: Id -> StgRhs -> MassageM StgRhs
do_top_rhs _ (StgRhsClosure _ _ _ _ _ []
- (StgSCC _cc False{-not tick-} _push (StgConApp con args)))
+ (StgTick (ProfNote _cc False{-not tick-} _push)
+ (StgConApp con args)))
| not (isDllConApp dflags mod_name con args)
-- Trivial _scc_ around nothing but static data
-- Eliminate _scc_ ... and turn into StgRhsCon
@@ -146,10 +148,15 @@ stgMassageForProfiling dflags mod_name _us stg_binds
do_expr (StgOpApp con args res_ty)
= return (StgOpApp con args res_ty)
- do_expr (StgSCC cc tick push expr) = do -- Ha, we found a cost centre!
+ do_expr (StgTick note@(ProfNote cc _ _) expr) = do
+ -- Ha, we found a cost centre!
collectCC cc
expr' <- do_expr expr
- return (StgSCC cc tick push expr')
+ return (StgTick note expr')
+
+ do_expr (StgTick ti expr) = do
+ expr' <- do_expr expr
+ return (StgTick ti expr')
do_expr (StgCase expr fv1 fv2 bndr srt alt_type alts) = do
expr' <- do_expr expr
@@ -168,10 +175,6 @@ stgMassageForProfiling dflags mod_name _us stg_binds
(b,e) <- do_let b e
return (StgLetNoEscape lvs1 lvs2 b e)
- do_expr (StgTick m n expr) = do
- expr' <- do_expr expr
- return (StgTick m n expr')
-
do_expr other = pprPanic "SCCfinal.do_expr" (ppr other)
----------------------------------
@@ -201,7 +204,8 @@ stgMassageForProfiling dflags mod_name _us stg_binds
-- We should really attach (PushCC cc CurrentCCS) to the rhs,
-- but need to reinstate PushCC for that.
do_rhs (StgRhsClosure _closure_cc _bi _fv _u _srt []
- (StgSCC cc False{-not tick-} _push (StgConApp con args)))
+ (StgTick (ProfNote cc False{-not tick-} _push)
+ (StgConApp con args)))
= do collectCC cc
return (StgRhsCon currentCCS con args)