summaryrefslogtreecommitdiff
path: root/compiler/specialise/SpecConstr.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2017-02-02 14:37:24 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-02 22:13:53 -0500
commitbbd3c399939311ec3e308721ab87ca6b9443f358 (patch)
tree1a398f3857502ab42f350008f83b7c67f0d9ff1e /compiler/specialise/SpecConstr.hs
parent6128b2ffbe36ed2779583e05ee9d817eaafc1c9c (diff)
downloadhaskell-bbd3c399939311ec3e308721ab87ca6b9443f358.tar.gz
Ditch static flags
This patch converts the 4 lasting static flags (read from the command line and unsafely stored in immutable global variables) into dynamic flags. Most use cases have been converted into reading them from a DynFlags. In cases for which we don't have easy access to a DynFlags, we read from 'unsafeGlobalDynFlags' that is set at the beginning of each 'runGhc'. It's not perfect (not thread-safe) but it is still better as we can set/unset these 4 flags before each run when using GHC API. Updates haddock submodule. Rebased and finished by: bgamari Test Plan: validate Reviewers: goldfire, erikd, hvr, austin, simonmar, bgamari Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2839 GHC Trac Issues: #8440
Diffstat (limited to 'compiler/specialise/SpecConstr.hs')
-rw-r--r--compiler/specialise/SpecConstr.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs
index 5ee2dec594..f6e10adad4 100644
--- a/compiler/specialise/SpecConstr.hs
+++ b/compiler/specialise/SpecConstr.hs
@@ -41,8 +41,7 @@ import VarEnv
import VarSet
import Name
import BasicTypes
-import DynFlags ( DynFlags(..) )
-import StaticFlags ( opt_PprStyle_Debug )
+import DynFlags ( DynFlags(..), hasPprDebug )
import Maybes ( orElse, catMaybes, isJust, isNothing )
import Demand
import GHC.Serialized ( deserializeWithData )
@@ -1522,8 +1521,10 @@ specialise env bind_calls (RI { ri_fn = fn, ri_lam_bndrs = arg_bndrs
spec_count' = n_pats + spec_count
; case sc_count env of
Just max | not (sc_force env) && spec_count' > max
- -> if (debugIsOn || opt_PprStyle_Debug) -- Suppress this scary message for
- then pprTrace "SpecConstr" msg $ -- ordinary users! Trac #5125
+ -- Suppress this scary message for
+ -- ordinary users! Trac #5125
+ -> if (debugIsOn || hasPprDebug (sc_dflags env))
+ then pprTrace "SpecConstr" msg $
return (nullUsage, spec_info)
else return (nullUsage, spec_info)
where
@@ -1533,8 +1534,10 @@ specialise env bind_calls (RI { ri_fn = fn, ri_lam_bndrs = arg_bndrs
text "but the limit is" <+> int max) ]
, text "Use -fspec-constr-count=n to set the bound"
, extra ]
- extra | not opt_PprStyle_Debug = text "Use -dppr-debug to see specialisations"
- | otherwise = text "Specialisations:" <+> ppr (pats ++ [p | OS p _ _ _ <- specs])
+ extra = sdocWithPprDebug $ \dbg -> if dbg
+ then text "Specialisations:"
+ <+> ppr (pats ++ [p | OS p _ _ _ <- specs])
+ else text "Use -dppr-debug to see specialisations"
_normal_case -> do {