summaryrefslogtreecommitdiff
path: root/compiler/GHC/Utils/Logger.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2021-07-27 09:11:56 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2021-07-27 17:18:22 +0100
commit559e80d0b11cf3b6f1a6410a730dd23082a9b05c (patch)
tree42fd5011a8d835e2a20c3f3bf6fa3668675cee43 /compiler/GHC/Utils/Logger.hs
parent1ac8d07d2bda8d8e5b521e1762f583d675d0d746 (diff)
downloadhaskell-wip/spj-refactor-Jul21.tar.gz
Inline less logging codewip/spj-refactor-Jul21
When eyeballing calls of GHC.Core.Opt.Simplify.Monad.traceSmpl, I saw that lots of cold-path logging code was getting inlined into the main Simplifier module. So in GHC.Utils.Logger I added a NOINLINE on logDumpFile'. For logging, the "hot" path, up to and including the conditional, should be inlined, but after that we should inline as little as possible, to reduce code size in the caller.
Diffstat (limited to 'compiler/GHC/Utils/Logger.hs')
-rw-r--r--compiler/GHC/Utils/Logger.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler/GHC/Utils/Logger.hs b/compiler/GHC/Utils/Logger.hs
index e497b8c965..bf480b8394 100644
--- a/compiler/GHC/Utils/Logger.hs
+++ b/compiler/GHC/Utils/Logger.hs
@@ -577,11 +577,20 @@ putDumpFileMaybe'
-> SDoc
-> IO ()
putDumpFileMaybe' logger printer flag hdr fmt doc
- = when (logHasDumpFlag logger flag) $ do
- let sty = mkDumpStyle printer
- logDumpFile logger sty flag hdr fmt doc
+ = when (logHasDumpFlag logger flag) $
+ logDumpFile' logger printer flag hdr fmt doc
{-# INLINE putDumpFileMaybe' #-} -- see Note [INLINE conditional tracing utilities]
+
+logDumpFile' :: Logger -> PrintUnqualified -> DumpFlag
+ -> String -> DumpFormat -> SDoc -> IO ()
+{-# NOINLINE logDumpFile' #-}
+-- NOINLINE: Now we are past the conditional, into the "cold" path,
+-- don't inline, to reduce code size at the call site
+-- See Note [INLINE conditional tracing utilities]
+logDumpFile' logger printer flag hdr fmt doc
+ = logDumpFile logger (mkDumpStyle printer) flag hdr fmt doc
+
-- | Ensure that a dump file is created even if it stays empty
touchDumpFile :: Logger -> DumpFlag -> IO ()
touchDumpFile logger flag =