Commit e815d4b1 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Change loop breaker terminology

We used to have "loop breaker" and "non-rule loop breaker", but
the unqualified version in particualr was pretty confusing.  So
now we have "strong loop breaker" and "weak loop breaker";
comments in BasicTypes and OccurAnal.
parent 6e7a74f3
......@@ -47,8 +47,8 @@ module BasicTypes(
TupCon(..), tupleParens,
OccInfo(..), seqOccInfo, zapFragileOcc, isOneOcc,
isDeadOcc, isLoopBreaker, isNonRuleLoopBreaker, isNoOcc,
nonRuleLoopBreaker,
isDeadOcc, isStrongLoopBreaker, isWeakLoopBreaker, isNoOcc,
strongLoopBreaker, weakLoopBreaker,
InsideLam, insideLam, notInsideLam,
OneBranch, oneBranch, notOneBranch,
......@@ -456,24 +456,20 @@ data OccInfo
-- | This identifier breaks a loop of mutually recursive functions. The field
-- marks whether it is only a loop breaker due to a reference in a rule
| IAmALoopBreaker -- Note [LoopBreaker OccInfo]
!RulesOnly -- True <=> This is a weak or rules-only loop breaker
-- See OccurAnal Note [Weak loop breakers]
!RulesOnly
type RulesOnly = Bool
\end{code}
Note [LoopBreaker OccInfo]
~~~~~~~~~~~~~~~~~~~~~~~~~~
An OccInfo of (IAmLoopBreaker False) is used by the occurrence
analyser in two ways:
(a) to mark loop-breakers in a group of recursive
definitions (hence the name)
(b) to mark binders that must not be inlined in this phase
(perhaps it has a NOINLINE pragma)
Things with (IAmLoopBreaker False) do not get an unfolding
pinned on to them, so they are completely opaque.
IAmALoopBreaker True <=> A "weak" or rules-only loop breaker
Do not preInlineUnconditionally
See OccurAnal Note [Weak loop breakers] for (IAmLoopBreaker True).
IAmALoopBreaker False <=> A "strong" loop breaker
Do not inline at all
See OccurAnal Note [Weak loop breakers]
\begin{code}
......@@ -504,16 +500,17 @@ oneBranch, notOneBranch :: OneBranch
oneBranch = True
notOneBranch = False
isLoopBreaker :: OccInfo -> Bool
isLoopBreaker (IAmALoopBreaker _) = True
isLoopBreaker _ = False
strongLoopBreaker, weakLoopBreaker :: OccInfo
strongLoopBreaker = IAmALoopBreaker False
weakLoopBreaker = IAmALoopBreaker True
isNonRuleLoopBreaker :: OccInfo -> Bool
isNonRuleLoopBreaker (IAmALoopBreaker False) = True -- Loop-breaker that breaks a non-rule cycle
isNonRuleLoopBreaker _ = False
isWeakLoopBreaker :: OccInfo -> Bool
isWeakLoopBreaker (IAmALoopBreaker _) = True
isWeakLoopBreaker _ = False
nonRuleLoopBreaker :: OccInfo
nonRuleLoopBreaker = IAmALoopBreaker False
isStrongLoopBreaker :: OccInfo -> Bool
isStrongLoopBreaker (IAmALoopBreaker False) = True -- Loop-breaker that breaks a non-rule cycle
isStrongLoopBreaker _ = False
isDeadOcc :: OccInfo -> Bool
isDeadOcc IAmDead = True
......
......@@ -508,8 +508,8 @@ isStrictId id
idUnfolding :: Id -> Unfolding
-- Do not expose the unfolding of a loop breaker!
idUnfolding id
| isNonRuleLoopBreaker (occInfo info) = NoUnfolding
| otherwise = unfoldingInfo info
| isStrongLoopBreaker (occInfo info) = NoUnfolding
| otherwise = unfoldingInfo info
where
info = idInfo id
......
......@@ -38,7 +38,7 @@ module IdInfo (
-- ** The OccInfo type
OccInfo(..),
isDeadOcc, isLoopBreaker, isNonRuleLoopBreaker,
isDeadOcc, isStrongLoopBreaker, isWeakLoopBreaker,
occInfo, setOccInfo,
InsideLam, OneBranch,
......
......@@ -182,7 +182,7 @@ lintSingleBinding top_lvl_flag rec_flag (binder,rhs)
-- Check whether binder's specialisations contain any out-of-scope variables
; mapM_ (checkBndrIdInScope binder) bndr_vars
; when (isNonRuleLoopBreaker (idOccInfo binder) && isInlinePragma (idInlinePragma binder))
; when (isStrongLoopBreaker (idOccInfo binder) && isInlinePragma (idInlinePragma binder))
(addWarnL (ptext (sLit "INLINE binder is (non-rule) loop breaker:") <+> ppr binder))
-- Only non-rule loop breakers inhibit inlining
......
......@@ -1391,7 +1391,7 @@ tryEtaReduce bndrs body
---------------
fun_arity fun -- See Note [Arity care]
| isLocalId fun && isNonRuleLoopBreaker (idOccInfo fun) = 0
| isLocalId fun && isStrongLoopBreaker (idOccInfo fun) = 0
| otherwise = idArity fun
---------------
......
......@@ -195,7 +195,7 @@ data IfaceInfoItem
= HsArity Arity
| HsStrictness StrictSig
| HsInline InlinePragma
| HsUnfold Bool -- True <=> isNonRuleLoopBreaker is true
| HsUnfold Bool -- True <=> isStrongLoopBreaker is true
IfaceUnfolding -- See Note [Expose recursive functions]
| HsNoCafRefs
......
......@@ -1531,7 +1531,7 @@ toIfaceIdInfo id_info
------------ Unfolding --------------
unfold_hsinfo = toIfUnfolding loop_breaker (unfoldingInfo id_info)
loop_breaker = isNonRuleLoopBreaker (occInfo id_info)
loop_breaker = isStrongLoopBreaker (occInfo id_info)
------------ Inline prag --------------
inline_prag = inlinePragInfo id_info
......
......@@ -40,7 +40,7 @@ import TyCon
import DataCon
import TysWiredIn
import TysPrim ( anyTyConOfKind )
import BasicTypes ( Arity, nonRuleLoopBreaker )
import BasicTypes ( Arity, strongLoopBreaker )
import qualified Var
import VarEnv
import VarSet
......@@ -1055,7 +1055,7 @@ tcIdInfo ignore_prags name ty info
-- The next two are lazy, so they don't transitively suck stuff in
tcPrag info (HsUnfold lb if_unf)
= do { unf <- tcUnfolding name ty info if_unf
; let info1 | lb = info `setOccInfo` nonRuleLoopBreaker
; let info1 | lb = info `setOccInfo` strongLoopBreaker
| otherwise = info
; return (info1 `setUnfoldingInfoLazily` unf) }
\end{code}
......
......@@ -708,7 +708,7 @@ addExternal expose_all id = (new_needed_ids, show_unfold)
idinfo = idInfo id
show_unfold = show_unfolding (unfoldingInfo idinfo)
never_active = isNeverActive (inlinePragmaActivation (inlinePragInfo idinfo))
loop_breaker = isNonRuleLoopBreaker (occInfo idinfo)
loop_breaker = isStrongLoopBreaker (occInfo idinfo)
bottoming_fn = isBottomingSig (strictnessInfo idinfo `orElse` topSig)
-- Stuff to do with the Id's unfolding
......
......@@ -21,7 +21,7 @@ import Type
import Id
import OccName
import DynFlags
import BasicTypes ( isLoopBreaker )
import BasicTypes ( isStrongLoopBreaker )
import Outputable
import Util ( zipLazy )
import MonadUtils
......@@ -273,8 +273,7 @@ vectTopRhs recFs var expr
rhs False Nothing -- Case (3)
= do { let fvs = freeVars expr
; (inline, isScalar, vexpr) <- inBind var $
vectPolyExpr (isLoopBreaker $ idOccInfo var) recFs fvs
-- Maybe isNonRuleLoopBreaker?
vectPolyExpr (isStrongLoopBreaker $ idOccInfo var) recFs fvs
; return (inline, isScalar, vectorised vexpr)
}
......
......@@ -30,7 +30,7 @@ import Var
import VarEnv
import VarSet
import Id
import BasicTypes( isLoopBreaker )
import BasicTypes( isStrongLoopBreaker )
import Literal
import TysWiredIn
import TysPrim
......@@ -153,7 +153,7 @@ vectExpr (_, AnnLet (AnnRec bs) body)
vect_rhs bndr rhs = localV
. inBind bndr
. liftM (\(_,_,z)->z)
$ vectPolyExpr (isLoopBreaker $ idOccInfo bndr) [] rhs
$ vectPolyExpr (isStrongLoopBreaker $ idOccInfo bndr) [] rhs
vectExpr e@(_, AnnLam bndr _)
| isId bndr = liftM (\(_,_,z) ->z) $ vectFnExpr True False [] e
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment