summaryrefslogtreecommitdiff
path: root/compiler/GHC/CmmToLlvm.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-01-07 14:25:15 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-13 21:27:34 -0500
commit8e2f85f6b4662676f0d7addaff9bf2c7d751bb63 (patch)
tree6a5bea5db12d907874cdf26d709d829a3f3216ba /compiler/GHC/CmmToLlvm.hs
parent40983d2331fe34c0af6925db7588d5ac6a19ae36 (diff)
downloadhaskell-8e2f85f6b4662676f0d7addaff9bf2c7d751bb63.tar.gz
Refactor Logger
Before this patch, the only way to override GHC's default logging behavior was to set `log_action`, `dump_action` and `trace_action` fields in DynFlags. This patch introduces a new Logger abstraction and stores it in HscEnv instead. This is part of #17957 (avoid storing state in DynFlags). DynFlags are duplicated and updated per-module (because of OPTIONS_GHC pragma), so we shouldn't store global state in them. This patch also fixes a race in parallel "--make" mode which updated the `generatedDumps` IORef concurrently. Bump haddock submodule The increase in MultilayerModules is tracked in #19293. Metric Increase: MultiLayerModules
Diffstat (limited to 'compiler/GHC/CmmToLlvm.hs')
-rw-r--r--compiler/GHC/CmmToLlvm.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/GHC/CmmToLlvm.hs b/compiler/GHC/CmmToLlvm.hs
index c9b50c731e..3cf7b50ceb 100644
--- a/compiler/GHC/CmmToLlvm.hs
+++ b/compiler/GHC/CmmToLlvm.hs
@@ -35,6 +35,7 @@ import GHC.Utils.Error
import GHC.Data.FastString
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Logger
import GHC.SysTools ( figureLlvmVersion )
import qualified GHC.Data.Stream as Stream
@@ -45,37 +46,37 @@ import System.IO
-- -----------------------------------------------------------------------------
-- | Top-level of the LLVM Code generator
--
-llvmCodeGen :: DynFlags -> Handle
+llvmCodeGen :: Logger -> DynFlags -> Handle
-> Stream.Stream IO RawCmmGroup a
-> IO a
-llvmCodeGen dflags h cmm_stream
- = withTiming dflags (text "LLVM CodeGen") (const ()) $ do
+llvmCodeGen logger dflags h cmm_stream
+ = withTiming logger dflags (text "LLVM CodeGen") (const ()) $ do
bufh <- newBufHandle h
-- Pass header
- showPass dflags "LLVM CodeGen"
+ showPass logger dflags "LLVM CodeGen"
-- get llvm version, cache for later use
- mb_ver <- figureLlvmVersion dflags
+ mb_ver <- figureLlvmVersion logger dflags
-- warn if unsupported
forM_ mb_ver $ \ver -> do
- debugTraceMsg dflags 2
+ debugTraceMsg logger dflags 2
(text "Using LLVM version:" <+> text (llvmVersionStr ver))
let doWarn = wopt Opt_WarnUnsupportedLlvmVersion dflags
- when (not (llvmVersionSupported ver) && doWarn) $ putMsg dflags $
+ when (not (llvmVersionSupported ver) && doWarn) $ putMsg logger dflags $
"You are using an unsupported version of LLVM!" $$
"Currently only " <> text (llvmVersionStr supportedLlvmVersion) <> " is supported." <+>
"System LLVM version: " <> text (llvmVersionStr ver) $$
"We will try though..."
let isS390X = platformArch (targetPlatform dflags) == ArchS390X
let major_ver = head . llvmVersionList $ ver
- when (isS390X && major_ver < 10 && doWarn) $ putMsg dflags $
+ when (isS390X && major_ver < 10 && doWarn) $ putMsg logger dflags $
"Warning: For s390x the GHC calling convention is only supported since LLVM version 10." <+>
"You are using LLVM version: " <> text (llvmVersionStr ver)
-- run code generation
- a <- runLlvm dflags (fromMaybe supportedLlvmVersion mb_ver) bufh $
+ a <- runLlvm logger dflags (fromMaybe supportedLlvmVersion mb_ver) bufh $
llvmCodeGen' dflags (liftStream cmm_stream)
bFlush bufh