summaryrefslogtreecommitdiff
path: root/compiler/llvmGen/LlvmCodeGen/Base.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-01-03 18:31:08 +0100
committerSylvain Henry <sylvain@haskus.fr>2019-12-18 13:43:37 +0100
commit58655b9da7599135395417a042f53cfa13b2151d (patch)
treecceacdd2c9848e49d5ebc6ba19d209cc823349a2 /compiler/llvmGen/LlvmCodeGen/Base.hs
parenta8f7ecd54821493dc061c55ceebb7e271b17056e (diff)
downloadhaskell-58655b9da7599135395417a042f53cfa13b2151d.tar.gz
Add GHC-API logging hooks
* Add 'dumpAction' hook to DynFlags. It allows GHC API users to catch dumped intermediate codes and information. The format of the dump (Core, Stg, raw text, etc.) is now reported allowing easier automatic handling. * Add 'traceAction' hook to DynFlags. Some dumps go through the trace mechanism (for instance unfoldings that have been considered for inlining). This is problematic because: 1) dumps aren't written into files even with -ddump-to-file on 2) dumps are written on stdout even with GHC API 3) in this specific case, dumping depends on unsafe globally stored DynFlags which is bad for GHC API users We introduce 'traceAction' hook which allows GHC API to catch those traces and to avoid using globally stored DynFlags. * Avoid dumping empty logs via dumpAction/traceAction (but still write empty files to keep the existing behavior)
Diffstat (limited to 'compiler/llvmGen/LlvmCodeGen/Base.hs')
-rw-r--r--compiler/llvmGen/LlvmCodeGen/Base.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/Base.hs b/compiler/llvmGen/LlvmCodeGen/Base.hs
index eaa49fc50e..f43c3dcf75 100644
--- a/compiler/llvmGen/LlvmCodeGen/Base.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Base.hs
@@ -337,10 +337,10 @@ getLlvmPlatform :: LlvmM Platform
getLlvmPlatform = getDynFlag targetPlatform
-- | Dumps the document if the corresponding flag has been set by the user
-dumpIfSetLlvm :: DumpFlag -> String -> Outp.SDoc -> LlvmM ()
-dumpIfSetLlvm flag hdr doc = do
+dumpIfSetLlvm :: DumpFlag -> String -> DumpFormat -> Outp.SDoc -> LlvmM ()
+dumpIfSetLlvm flag hdr fmt doc = do
dflags <- getDynFlags
- liftIO $ dumpIfSet_dyn dflags flag hdr doc
+ liftIO $ dumpIfSet_dyn dflags flag hdr fmt doc
-- | Prints the given contents to the output handle
renderLlvm :: Outp.SDoc -> LlvmM ()
@@ -353,7 +353,7 @@ renderLlvm sdoc = do
(Outp.mkCodeStyle Outp.CStyle) sdoc
-- Dump, if requested
- dumpIfSetLlvm Opt_D_dump_llvm "LLVM Code" sdoc
+ dumpIfSetLlvm Opt_D_dump_llvm "LLVM Code" FormatLLVM sdoc
return ()
-- | Marks a variable as "used"