summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-01-22 15:24:08 +0100
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2020-01-31 12:21:10 +0300
commit2a87a565365d1724a83cd0d5c5fc3b696210c4f2 (patch)
tree648ae769b299abab942ebaca5a8ba54da798284e /compiler/main
parentc846618ae0f8601515683a4c7677c20c3272a50f (diff)
downloadhaskell-2a87a565365d1724a83cd0d5c5fc3b696210c4f2.tar.gz
A few optimizations in STG and Cmm parts:
(Guided by the profiler output) - Add a few bang patterns, INLINABLE annotations, and a seqList in a few places in Cmm and STG parts. - Do not add external variables as dependencies in STG dependency analysis (GHC.Stg.DepAnal).
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/DriverPipeline.hs3
-rw-r--r--compiler/main/HscMain.hs21
2 files changed, 22 insertions, 2 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 0781b1a6d8..5db264254c 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1193,7 +1193,8 @@ runPhase (HscOut src_flavour mod_name result) _ dflags = do
hscGenHardCode hsc_env' cgguts mod_location output_fn
final_iface <- liftIO (mkFullIface hsc_env'{hsc_dflags=iface_dflags} partial_iface (Just caf_infos))
- let final_mod_details = updateModDetailsCafInfos caf_infos mod_details
+ let final_mod_details = {-# SCC updateModDetailsCafInfos #-}
+ updateModDetailsCafInfos caf_infos mod_details
setIface final_iface final_mod_details
-- See Note [Writing interface files]
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 391b989915..baa396a1b4 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -1542,6 +1542,24 @@ hscCompileCmmFile hsc_env filename output_filename = runHsc hsc_env $ do
-------------------- Stuff for new code gen ---------------------
+{-
+Note [Forcing of stg_binds]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The two last steps in the STG pipeline are:
+
+* Sorting the bindings in dependency order.
+* Annotating them with free variables.
+
+We want to make sure we do not keep references to unannotated STG bindings
+alive, nor references to bindings which have already been compiled to Cmm.
+
+We explicitly force the bindings to avoid this.
+
+This reduces residency towards the end of the CodeGen phase significantly
+(5-10%).
+-}
+
doCodeGen :: HscEnv -> Module -> [TyCon]
-> CollectedCCs
-> [StgTopBinding]
@@ -1557,7 +1575,8 @@ doCodeGen hsc_env this_mod data_tycons
let stg_binds_w_fvs = annTopBindingsFreeVars stg_binds
let cmm_stream :: Stream IO CmmGroup ()
- cmm_stream = {-# SCC "StgToCmm" #-}
+ -- See Note [Forcing of stg_binds]
+ cmm_stream = stg_binds_w_fvs `seqList` {-# SCC "StgToCmm" #-}
lookupHook stgToCmmHook StgToCmm.codeGen dflags dflags this_mod data_tycons
cost_centre_info stg_binds_w_fvs hpc_info