summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-09-08 10:05:23 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-09 11:19:24 -0400
commitffae57921168365272bf7ce8aaa645917bfdf218 (patch)
treecd7ea58267945dbda2dc6f9d5ca592149b969313
parentb3df72a699727b00d5dd8212fcbe46cbbec05f9b (diff)
downloadhaskell-ffae57921168365272bf7ce8aaa645917bfdf218.tar.gz
Add comments about sm_dflags and simpleOptExpr
-rw-r--r--compiler/GHC/Core/Opt/Monad.hs13
-rw-r--r--compiler/GHC/Core/SimpleOpt.hs8
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)