diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-07-27 09:11:56 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-28 13:19:06 -0400 |
commit | 2567d13b923946a49ae15c51933a2cc348826c9a (patch) | |
tree | b03881fda5c05b54000ed0a67d51fc3cae89e6c9 /compiler/GHC/Utils | |
parent | 05f54bb4f2fd0d8d4e0029ed795bfe1a534ce304 (diff) | |
download | haskell-2567d13b923946a49ae15c51933a2cc348826c9a.tar.gz |
Inline less logging code
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')
-rw-r--r-- | compiler/GHC/Utils/Logger.hs | 15 |
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 = |