X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FsimplCore%2FSimplMonad.lhs;h=afe7289001aced292a521066225d7adf0be89146;hb=3a223cd2811d46295048b3a2dab11403ca291b20;hp=fe43c6d3472ea203ad539ca13ec79fc50e026c70;hpb=ce9687a5f450014c5596b32de8e8a7b99b6389e8;p=ghc-hetmet.git diff --git a/ghc/compiler/simplCore/SimplMonad.lhs b/ghc/compiler/simplCore/SimplMonad.lhs index fe43c6d..afe7289 100644 --- a/ghc/compiler/simplCore/SimplMonad.lhs +++ b/ghc/compiler/simplCore/SimplMonad.lhs @@ -77,7 +77,7 @@ import BasicTypes ( TopLevelFlag, isTopLevel, isLoopBreaker, ) import CmdLineOpts ( SimplifierSwitch(..), SimplifierMode(..), DynFlags, DynFlag(..), dopt, - opt_PprStyle_Debug, opt_HistorySize, opt_SimplNoPreInlining, + opt_PprStyle_Debug, opt_HistorySize, opt_SimplNoPreInlining, opt_RulesOff ) import Unique ( Unique ) import Outputable @@ -682,6 +682,8 @@ settings: SimplGently (a) Simplifying before specialiser/full laziness (b) Simplifiying inside INLINE pragma (c) Simplifying the LHS of a rule + (d) Simplifying a GHCi expression or Template + Haskell splice SimplPhase n Used at all other times @@ -693,6 +695,12 @@ because doing so inhibits floating ==> ...(case x of I# x# -> case fw x# of ...)... and now the redex (f x) isn't floatable any more. +The no-inling thing is also important for Template Haskell. You might be +compiling in one-shot mode with -O2; but when TH compiles a splice before +running it, we don't want to use -O2. Indeed, we don't want to inline +anything, because the byte-code interpreter might get confused about +unboxed tuples and suchlike. + INLINE pragmas ~~~~~~~~~~~~~~ SimplGently is also used as the mode to simplify inside an InlineMe note. @@ -891,22 +899,13 @@ postInlineUnconditionally env bndr occ_info rhs SimplGently -> isAlwaysActive prag SimplPhase n -> isActive n prag prag = idInlinePragma bndr -\end{code} - -blackListInline tells if we must not inline at a call site because the -Id's inline pragma says not to do so. -However, blackListInline is ignored for things with with Compulsory inlinings, -because they don't have bindings, so we must inline them no matter how -gentle we are being. - -\begin{code} activeInline :: SimplEnv -> OutId -> OccInfo -> Bool activeInline env id occ = case getMode env of - SimplGently -> isAlwaysActive prag && isOneOcc occ + SimplGently -> isOneOcc occ && isAlwaysActive prag -- No inlining at all when doing gentle stuff, - -- except for things that occur once + -- except for local things that occur once -- The reason is that too little clean-up happens if you -- don't inline use-once things. Also a bit of inlining is *good* for -- full laziness; it can expose constant sub-expressions. @@ -927,8 +926,15 @@ activeInline env id occ activeRule :: SimplEnv -> Maybe (Activation -> Bool) -- Nothing => No rules at all activeRule env + | opt_RulesOff = Nothing + | otherwise = case getMode env of - SimplGently -> Nothing -- No rules in gentle mode + SimplGently -> Just isAlwaysActive + -- Used to be Nothing (no rules in gentle mode) + -- Main motivation for changing is that I wanted + -- lift String ===> ... + -- to work in Template Haskell when simplifying + -- splices, so we get simpler code for literal strings SimplPhase n -> Just (isActive n) \end{code}