From ffae57921168365272bf7ce8aaa645917bfdf218 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Tue, 8 Sep 2020 10:05:23 +0200 Subject: Add comments about sm_dflags and simpleOptExpr --- compiler/GHC/Core/Opt/Monad.hs | 13 +++++++++++-- compiler/GHC/Core/SimpleOpt.hs | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/compiler/GHC/Core/Opt/Monad.hs b/compiler/GHC/Core/Opt/Monad.hs index 139b9f0af1..070ea11cc2 100644 --- a/compiler/GHC/Core/Opt/Monad.hs +++ b/compiler/GHC/Core/Opt/Monad.hs @@ -159,14 +159,23 @@ data SimplMode -- See comments in GHC.Core.Opt.Simplify.Monad = SimplMode { sm_names :: [String] -- ^ Name(s) of the phase , sm_phase :: CompilerPhase - , sm_dflags :: DynFlags -- Just for convenient non-monadic - -- access; we don't override these , sm_uf_opts :: !UnfoldingOpts -- ^ Unfolding options , sm_rules :: !Bool -- ^ Whether RULES are enabled , sm_inline :: !Bool -- ^ Whether inlining is enabled , sm_case_case :: !Bool -- ^ Whether case-of-case is enabled , sm_eta_expand :: !Bool -- ^ Whether eta-expansion is enabled , sm_pre_inline :: !Bool -- ^ Whether pre-inlining is enabled + , sm_dflags :: DynFlags + -- Just for convenient non-monadic access; we don't override these. + -- + -- Used for: + -- - target platform (for `exprIsDupable` and `mkDupableAlt`) + -- - Opt_DictsCheap and Opt_PedanticBottoms general flags + -- - rules options (initRuleOpts) + -- - verbose_core2core, dump_inlinings, dump_rule_rewrites/firings + -- - traceAction, dumpAction + -- - inlineCheck + -- - touchDumpFile (generatedDumps, etc.) } instance Outputable SimplMode where diff --git a/compiler/GHC/Core/SimpleOpt.hs b/compiler/GHC/Core/SimpleOpt.hs index d5424a2fc9..8529b13025 100644 --- a/compiler/GHC/Core/SimpleOpt.hs +++ b/compiler/GHC/Core/SimpleOpt.hs @@ -125,6 +125,14 @@ simpleOptExpr :: HasDebugCallStack => SimpleOpts -> CoreExpr -> CoreExpr -- The result is NOT guaranteed occurrence-analysed, because -- in (let x = y in ....) we substitute for x; so y's occ-info -- may change radically +-- +-- Note that simpleOptExpr is a pure function that we want to be able to call +-- from lots of places, including ones that don't have DynFlags (e.g to optimise +-- unfoldings of statically defined Ids via mkCompulsoryUnfolding). It used to +-- fetch its options directly from the DynFlags, however, so some callers had to +-- resort to using unsafeGlobalDynFlags (a global mutable variable containing +-- the DynFlags). It has been modified to take its own SimpleOpts that may be +-- created from DynFlags, but not necessarily. simpleOptExpr opts expr = -- pprTrace "simpleOptExpr" (ppr init_subst $$ ppr expr) -- cgit v1.2.1