Skip to content
Commits on Source (9)
  • PHO's avatar
    Don't use non-portable operator "==" in configure.ac · e1aa4052
    PHO authored and Marge Bot's avatar Marge Bot committed
    The test operator "==" is a Bash extension and produces a wrong result
    if /bin/sh is not Bash.
    e1aa4052
  • MaxGabriel's avatar
    Document the units of -ddump-timings · 89f034dd
    MaxGabriel authored and Marge Bot's avatar Marge Bot committed
    Right now, in the output of -ddump-timings to a file, you can't tell what the units are:
    
    ```
    CodeGen [TemplateTestImports]: alloc=22454880 time=14.597
    ```
    
    I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`:
    
    ```
    when (verbosity dflags >= 2 && prtimings == PrintTimings)
      $ liftIO $ logInfo dflags (defaultUserStyle dflags)
          (text "!!!" <+> what <> colon <+> text "finished in"
           <+> doublePrec 2 time
           <+> text "milliseconds"
           <> comma
           <+> text "allocated"
           <+> doublePrec 3 (realToFrac alloc / 1024 / 1024)
           <+> text "megabytes")
    ```
    
    which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB)
    89f034dd
  • Simon Peyton Jones's avatar
    Implement mapTyCo like foldTyCo · beffa147
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    This patch makes mapType use the successful idiom described
    in TyCoRep
       Note [Specialising foldType]
    
    I have not yet changed any functions to use mapType, though there
    may be some suitable candidates.
    
    This patch should be a no-op in terms of functionality but,
    because it inlines the mapper itself, I'm hoping that there may
    be some modest perf improvements.
    
    Metric Decrease:
        T5631
        T5642
        T3064
        T9020
        T14683
        hie002
        haddock.Cabal
        haddock.base
        haddock.compiler
    beffa147
  • Ömer Sinan Ağacan's avatar
    Don't update ModDetails with CafInfos when opts are disabled · 5800ebfe
    Ömer Sinan Ağacan authored and Marge Bot's avatar Marge Bot committed
    This is consistent with the interface file behavior where we omit
    HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0).
    
    ModDetails and ModIface are just different representations of the same
    thing, so they really need to be in sync. This patch does the right
    thing and does not need too much explanation, but here's an example of a
    problem not doing this causes in !2842:
    
        -- MyInteger.hs
        module MyInteger
          ( MyInteger (MyInteger)
          , ToMyInteger (toMyInteger)
          ) where
    
        newtype MyInteger = MyInteger Integer
    
        class ToMyInteger a where
          toMyInteger :: a -> MyInteger
    
        instance ToMyInteger Integer where
          toMyInteger = MyInteger {- . succ -}
    
        -- Main.hs
        module Main
          ( main
          ) where
    
        import MyInteger (MyInteger (MyInteger), toMyInteger)
    
        main :: IO ()
        main = do
          let (MyInteger i) = (id . toMyInteger) (41 :: Integer)
          print i
    
    If I build this with -O0, without this fix, we generate a ModDetails with
    accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that
    it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the
    value:
    
        R3 = MyInteger.$fToMyIntegerInteger_closure + 1;
        R2 = GHC.Base.id_closure;
        R1 = GHC.Base.._closure;
        Sp = Sp - 16;
        call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24;
    
    Now we change the definition by uncommenting the `succ` part and it becomes a thunk:
    
        MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)]
          :: MyInteger.ToMyInteger GHC.Integer.Type.Integer
        [GblId[DFunId(nt)]] =
            {} \u [] $ctoMyInteger_rEA;
    
    and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the
    use site: we can no longer tag it.
    
    But becuase the interface fingerprint does not change (because ModIface does not
    change) we don't rebuild Main and tag the thunk.
    
    (1.2% increase in allocations when building T12545 on armv7 because we
    generate more code without CafInfos)
    
    Metric Increase:
        T12545
    5800ebfe
  • Paavo Parkkinen's avatar
    Add example for Data.Semigroup.diff · 5b632dad
    Paavo Parkkinen authored and Marge Bot's avatar Marge Bot committed
    5b632dad
  • Paavo Parkkinen's avatar
    Clean up · 4d85d68b
    Paavo Parkkinen authored and Marge Bot's avatar Marge Bot committed
    4d85d68b
  • Paavo Parkkinen's avatar
    Make example collapsible · 75168d07
    Paavo Parkkinen authored and Marge Bot's avatar Marge Bot committed
    75168d07
  • Richard Eisenberg's avatar
    Fix #17021 by checking more return kinds · 53ff2cd0
    Richard Eisenberg authored
    All the details are in new Note [Datatype return kinds] in
    TcTyClsDecls.
    
    Test case: typecheck/should_fail/T17021{,b}
               typecheck/should_compile/T17021a
    
    Updates haddock submodule
    53ff2cd0
  • Sylvain Henry's avatar
    Modules: Core operations (#13009) · 093188bf
    Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
    093188bf
......@@ -354,7 +354,7 @@ an unlifted literal, like all the others.
Also, we do not permit case analysis with literal patterns on floating-point
types. See #9238 and Note [Rules for floating-point comparisons] in
PrelRules for the rationale for this restriction.
GHC.Core.Op.ConstantFold for the rationale for this restriction.
-------------------------- GHC.Core INVARIANTS ---------------------------
......@@ -508,7 +508,7 @@ checked by Core Lint.
5. Floating-point values must not be scrutinised against literals.
See #9238 and Note [Rules for floating-point comparisons]
in PrelRules for rationale. Checked in lintCaseExpr;
in GHC.Core.Op.ConstantFold for rationale. Checked in lintCaseExpr;
see the call to isFloatingTy.
6. The 'ty' field of (Case scrut bndr ty alts) is the type of the
......@@ -784,7 +784,7 @@ is crucial for understanding how case-of-case interacts with join points:
_ -> False
The simplifier will pull the case into the join point (see Note [Join points
and case-of-case] in Simplify):
and case-of-case] in GHC.Core.Op.Simplify):
join
j :: Int -> Bool -> Bool -- changed!
......@@ -1810,9 +1810,9 @@ the occurrence info is wrong
-}
-- The Ord is needed for the FiniteMap used in the lookForConstructor
-- in SimplEnv. If you declared that lookForConstructor *ignores*
-- constructor-applications with LitArg args, then you could get
-- rid of this Ord.
-- in GHC.Core.Op.Simplify.Env. If you declared that lookForConstructor
-- *ignores* constructor-applications with LitArg args, then you could get rid
-- of this Ord.
instance Outputable AltCon where
ppr (DataAlt dc) = ppr dc
......
......@@ -1499,7 +1499,7 @@ mkPiCo r v co | isTyVar v = mkHomoForAllCos [v] co
-- We didn't call mkForAllCo here because if v does not appear
-- in co, the argement coercion will be nominal. But here we
-- want it to be r. It is only called in 'mkPiCos', which is
-- only used in SimplUtils, where we are sure for
-- only used in GHC.Core.Op.Simplify.Utils, where we are sure for
-- now (Aug 2018) v won't occur in co.
mkFunCo r (mkReflCo r (varType v)) co
| otherwise = mkFunCo r (mkReflCo r (varType v)) co
......
......@@ -198,6 +198,17 @@ axiom as a whole, and they are computed only when the final axiom is built.
During serialization, the list is converted into a list of the indices
of the branches.
Note [CoAxioms are homogeneous]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All axioms must be *homogeneous*, meaning that the kind of the LHS must
match the kind of the RHS. In practice, this means:
Given a CoAxiom { co_ax_tc = ax_tc },
for every branch CoAxBranch { cab_lhs = lhs, cab_rhs = rhs }:
typeKind (mkTyConApp ax_tc lhs) `eqType` typeKind rhs
This is checked in FamInstEnv.mkCoAxBranch.
-}
-- | A 'CoAxiom' is a \"coercion constructor\", i.e. a named equality axiom.
......@@ -233,6 +244,7 @@ data CoAxBranch
, cab_roles :: [Role] -- See Note [CoAxBranch roles]
, cab_lhs :: [Type] -- Type patterns to match against
, cab_rhs :: Type -- Right-hand side of the equality
-- See Note [CoAxioms are homogeneous]
, cab_incomps :: [CoAxBranch] -- The previous incompatible branches
-- See Note [Storing compatibility]
}
......
......@@ -314,7 +314,7 @@ Nevertheless it is still useful to have data families in the FamInstEnv:
- For finding overlaps and conflicts
- For finding the representation type...see FamInstEnv.topNormaliseType
and its call site in Simplify
and its call site in GHC.Core.Op.Simplify
- In standalone deriving instance Eq (T [Int]) we need to find the
representation type for T [Int]
......@@ -638,13 +638,16 @@ that Note.
mkCoAxBranch :: [TyVar] -- original, possibly stale, tyvars
-> [TyVar] -- Extra eta tyvars
-> [CoVar] -- possibly stale covars
-> TyCon -- family/newtype TyCon (for error-checking only)
-> [Type] -- LHS patterns
-> Type -- RHS
-> [Role]
-> SrcSpan
-> CoAxBranch
mkCoAxBranch tvs eta_tvs cvs lhs rhs roles loc
= CoAxBranch { cab_tvs = tvs'
mkCoAxBranch tvs eta_tvs cvs ax_tc lhs rhs roles loc
= -- See Note [CoAxioms are homogeneous] in Core.Coercion.Axiom
ASSERT( typeKind (mkTyConApp ax_tc lhs) `eqType` typeKind rhs )
CoAxBranch { cab_tvs = tvs'
, cab_eta_tvs = eta_tvs'
, cab_cvs = cvs'
, cab_lhs = tidyTypes env lhs
......@@ -698,7 +701,7 @@ mkSingleCoAxiom role ax_name tvs eta_tvs cvs fam_tc lhs_tys rhs_ty
, co_ax_implicit = False
, co_ax_branches = unbranched (branch { cab_incomps = [] }) }
where
branch = mkCoAxBranch tvs eta_tvs cvs lhs_tys rhs_ty
branch = mkCoAxBranch tvs eta_tvs cvs fam_tc lhs_tys rhs_ty
(map (const Nominal) tvs)
(getSrcSpan ax_name)
......@@ -716,7 +719,7 @@ mkNewTypeCoAxiom name tycon tvs roles rhs_ty
, co_ax_tc = tycon
, co_ax_branches = unbranched (branch { cab_incomps = [] }) }
where
branch = mkCoAxBranch tvs [] [] (mkTyVarTys tvs) rhs_ty
branch = mkCoAxBranch tvs [] [] tycon (mkTyVarTys tvs) rhs_ty
roles (getSrcSpan name)
{-
......
......@@ -29,7 +29,7 @@ import GHC.Core
import GHC.Core.FVs
import GHC.Core.Utils
import GHC.Core.Stats ( coreBindsStats )
import CoreMonad
import GHC.Core.Op.Monad
import Bag
import Literal
import GHC.Core.DataCon
......@@ -167,7 +167,7 @@ In the desugarer, it's very very convenient to be able to say (in effect)
let x::a = True in <body>
That is, use a type let. See Note [Type let] in CoreSyn.
One place it is used is in mkWwArgs; see Note [Join points and beta-redexes]
in WwLib. (Maybe there are other "clients" of this feature; I'm not sure).
in GHC.Core.Op.WorkWrap.Lib. (Maybe there are other "clients" of this feature; I'm not sure).
* Hence when linting <body> we need to remember that a=Int, else we
might reject a correct program. So we carry a type substitution (in
......@@ -639,7 +639,7 @@ lintSingleBinding top_lvl_flag rec_flag (binder,rhs)
-- We used to check that the dmdTypeDepth of a demand signature never
-- exceeds idArity, but that is an unnecessary complication, see
-- Note [idArity varies independently of dmdTypeDepth] in DmdAnal
-- Note [idArity varies independently of dmdTypeDepth] in GHC.Core.Op.DmdAnal
-- Check that the binder's arity is within the bounds imposed by
-- the type and the strictness signature. See Note [exprArity invariant]
......@@ -1146,7 +1146,7 @@ lintCaseExpr scrut var alt_ty alts =
-- Check that the scrutinee is not a floating-point type
-- if there are any literal alternatives
-- See GHC.Core Note [Case expression invariants] item (5)
-- See Note [Rules for floating-point comparisons] in PrelRules
-- See Note [Rules for floating-point comparisons] in GHC.Core.Op.ConstantFold
; let isLitPat (LitAlt _, _ , _) = True
isLitPat _ = False
; checkL (not $ isFloatingTy scrut_ty && any isLitPat alts)
......@@ -1388,7 +1388,8 @@ lintInTy ty
= addLoc (InType ty) $
do { ty' <- applySubstTy ty
; k <- lintType ty'
; lintKind k -- The kind returned by lintType is already
; addLoc (InKind ty' k) $
lintKind k -- The kind returned by lintType is already
-- a LintedKind but we also want to check that
-- k :: *, which lintKind does
; return (ty', k) }
......@@ -2278,6 +2279,7 @@ data LintLocInfo
| ImportedUnfolding SrcLoc -- Some imported unfolding (ToDo: say which)
| TopLevelBindings
| InType Type -- Inside a type
| InKind Type Kind -- Inside a kind
| InCo Coercion -- Inside a coercion
initL :: DynFlags -> LintFlags -> [Var]
......@@ -2533,6 +2535,8 @@ dumpLoc TopLevelBindings
= (noSrcLoc, Outputable.empty)
dumpLoc (InType ty)
= (noSrcLoc, text "In the type" <+> quotes (ppr ty))
dumpLoc (InKind ty ki)
= (noSrcLoc, text "In the kind of" <+> parens (ppr ty <+> dcolon <+> ppr ki))
dumpLoc (InCo co)
= (noSrcLoc, text "In the coercion" <+> quotes (ppr co))
......@@ -2834,7 +2838,7 @@ lintAnnots pname pass guts = do
let binds = flattenBinds $ mg_binds nguts
binds' = flattenBinds $ mg_binds nguts'
(diffs,_) = diffBinds True (mkRnEnv2 emptyInScopeSet) binds binds'
when (not (null diffs)) $ CoreMonad.putMsg $ vcat
when (not (null diffs)) $ GHC.Core.Op.Monad.putMsg $ vcat
[ lint_banner "warning" pname
, text "Core changes with annotations:"
, withPprStyle (defaultDumpStyle dflags) $ nest 2 $ vcat diffs
......
......@@ -193,7 +193,7 @@ mkWildEvBinder pred = mkWildValBinder pred
-- that you expect to use only at a *binding* site. Do not use it at
-- occurrence sites because it has a single, fixed unique, and it's very
-- easy to get into difficulties with shadowing. That's why it is used so little.
-- See Note [WildCard binders] in SimplEnv
-- See Note [WildCard binders] in GHC.Core.Op.Simplify.Env
mkWildValBinder :: Type -> Id
mkWildValBinder ty = mkLocalIdOrCoVar wildCardName ty
-- "OrCoVar" since a coercion can be a scrutinee with -fdefer-type-errors
......@@ -576,7 +576,7 @@ data FloatBind
= FloatLet CoreBind
| FloatCase CoreExpr Id AltCon [Var]
-- case e of y { C ys -> ... }
-- See Note [Floating single-alternative cases] in SetLevels
-- See Note [Floating single-alternative cases] in GHC.Core.Op.SetLevels
instance Outputable FloatBind where
ppr (FloatLet b) = text "LET" <+> ppr b
......@@ -880,7 +880,7 @@ the first. But the stable-unfolding for f looks like
\x. case x of MkT a b -> g ($WMkT b a)
where $WMkT is the wrapper for MkT that evaluates its arguments. We
apply the same w/w split to this unfolding (see Note [Worker-wrapper
for INLINEABLE functions] in WorkWrap) so the template ends up like
for INLINEABLE functions] in GHC.Core.Op.WorkWrap) so the template ends up like
\b. let a = absentError "blah"
x = MkT a b
in case x of MkT a b -> g ($WMkT b a)
......@@ -925,7 +925,7 @@ aBSENT_ERROR_ID
where
absent_ty = mkSpecForAllTys [alphaTyVar] (mkVisFunTy addrPrimTy alphaTy)
-- Not runtime-rep polymorphic. aBSENT_ERROR_ID is only used for
-- lifted-type things; see Note [Absent errors] in WwLib
-- lifted-type things; see Note [Absent errors] in GHC.Core.Op.WorkWrap.Lib
arity_info = vanillaIdInfo `setArityInfo` 1
-- NB: no bottoming strictness info, unlike other error-ids.
-- See Note [aBSENT_ERROR_ID]
......
......@@ -9,7 +9,7 @@
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module CSE (cseProgram, cseOneExpr) where
module GHC.Core.Op.CSE (cseProgram, cseOneExpr) where
#include "HsVersions.h"
......@@ -123,12 +123,12 @@ Notice that
Notice also that in the SUBSTITUTE case we leave behind a binding
x = y
even though we /also/ carry a substitution x -> y. Can we just drop
the binding instead? Well, not at top level! See SimplUtils
Note [Top level and postInlineUnconditionally]; and in any case CSE
applies only to the /bindings/ of the program, and we leave it to the
simplifier to propate effects to the RULES. Finally, it doesn't seem
worth the effort to discard the nested bindings because the simplifier
will do it next.
the binding instead? Well, not at top level! See Note [Top level and
postInlineUnconditionally] in GHC.Core.Op.Simplify.Utils; and in any
case CSE applies only to the /bindings/ of the program, and we leave
it to the simplifier to propate effects to the RULES. Finally, it
doesn't seem worth the effort to discard the nested bindings because
the simplifier will do it next.
Note [CSE for case expressions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -230,8 +230,8 @@ Here 'foo' has a stable unfolding, but its (optimised) RHS is trivial.
the Integer instance of Enum in GHC.Enum.) Suppose moreover that foo's
stable unfolding originates from an INLINE or INLINEABLE pragma on foo.
Then we obviously do NOT want to extend the substitution with (foo->x),
because we promised to inline foo as what the user wrote. See similar
SimplUtils Note [Stable unfoldings and postInlineUnconditionally].
because we promised to inline foo as what the user wrote. See similar Note
[Stable unfoldings and postInlineUnconditionally] in GHC.Core.Op.Simplify.Utils.
Nor do we want to change the reverse mapping. Suppose we have
......@@ -687,7 +687,7 @@ turning K2 into 'x' increases the number of live variables. But
Note [Combine case alternatives]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combineAlts is just a more heavyweight version of the use of
combineIdenticalAlts in SimplUtils.prepareAlts. The basic idea is
combineIdenticalAlts in GHC.Core.Op.Simplify.Utils.prepareAlts. The basic idea is
to transform
DEFAULT -> e1
......@@ -710,7 +710,7 @@ Note [Combine case alts: awkward corner]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We would really like to check isDeadBinder on the binders in the
alternative. But alas, the simplifer zaps occ-info on binders in case
alternatives; see Note [Case alternative occ info] in Simplify.
alternatives; see Note [Case alternative occ info] in GHC.Core.Op.Simplify.
* One alternative (perhaps a good one) would be to do OccAnal
just before CSE. Then perhaps we could get rid of combineIdenticalAlts
......
......@@ -2,7 +2,7 @@
-- Copyright (c) 2014 Joachim Breitner
--
module CallArity
module GHC.Core.Op.CallArity
( callArityAnalProgram
, callArityRHS -- for testing
) where
......
......@@ -16,7 +16,7 @@ ToDo:
DeriveFunctor #-}
{-# OPTIONS_GHC -optc-DNON_POSIX_SOURCE -Wno-incomplete-uni-patterns #-}
module PrelRules
module GHC.Core.Op.ConstantFold
( primOpRules
, builtinRules
, caseRules
......@@ -1117,13 +1117,13 @@ is:
the returned value.
* An application like (dataToTag# (Just x)) is optimised by
dataToTagRule in PrelRules.
dataToTagRule in GHC.Core.Op.ConstantFold.
* A case expression like
case (dataToTag# e) of <alts>
gets transformed t
case e of <transformed alts>
by PrelRules.caseRules; see Note [caseRules for dataToTag]
by GHC.Core.Op.ConstantFold.caseRules; see Note [caseRules for dataToTag]
See #15696 for a long saga.
-}
......@@ -1198,7 +1198,7 @@ Things to note
Implementing seq#. The compiler has magic for SeqOp in
- PrelRules.seqRule: eliminate (seq# <whnf> s)
- GHC.Core.Op.ConstantFold.seqRule: eliminate (seq# <whnf> s)
- GHC.StgToCmm.Expr.cgExpr, and cgCase: special case for seq#
......@@ -1207,7 +1207,7 @@ Implementing seq#. The compiler has magic for SeqOp in
- Simplify.addEvals records evaluated-ness for the result; see
Note [Adding evaluatedness info to pattern-bound variables]
in Simplify
in GHC.Core.Op.Simplify
-}
seqRule :: RuleM CoreExpr
......@@ -2054,7 +2054,7 @@ wordPrimOps dflags = PrimOps
--------------------------------------------------------
-- Constant folding through case-expressions
--
-- cf Scrutinee Constant Folding in simplCore/SimplUtils
-- cf Scrutinee Constant Folding in simplCore/GHC.Core.Op.Simplify.Utils
--------------------------------------------------------
-- | Match the scrutinee of a case and potentially return a new scrutinee and a
......@@ -2215,7 +2215,7 @@ We don't want to get this!
DEFAULT -> e1
DEFAULT -> e2
Instead, we deal with turning one branch into DEFAULT in SimplUtils
Instead, we deal with turning one branch into DEFAULT in GHC.Core.Op.Simplify.Utils
(add_default in mkCase3).
Note [caseRules for dataToTag]
......
......@@ -7,13 +7,13 @@
-- See https://www.microsoft.com/en-us/research/publication/constructed-product-result-analysis-haskell/.
-- CPR analysis should happen after strictness analysis.
-- See Note [Phase ordering].
module CprAnal ( cprAnalProgram ) where
module GHC.Core.Op.CprAnal ( cprAnalProgram ) where
#include "HsVersions.h"
import GhcPrelude
import WwLib ( deepSplitProductType_maybe )
import GHC.Core.Op.WorkWrap.Lib ( deepSplitProductType_maybe )
import GHC.Driver.Session
import Demand
import Cpr
......@@ -107,7 +107,7 @@ cprAnalProgram dflags fam_envs binds = do
let binds_plus_cpr = snd $ mapAccumL cprAnalTopBind env binds
dumpIfSet_dyn dflags Opt_D_dump_cpr_signatures "Cpr signatures" FormatText $
dumpIdInfoOfProgram (ppr . cprInfo) binds_plus_cpr
-- See Note [Stamp out space leaks in demand analysis] in DmdAnal
-- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Op.DmdAnal
seqBinds binds_plus_cpr `seq` return binds_plus_cpr
-- Analyse a (group of) top-level binding(s)
......@@ -251,7 +251,7 @@ cprFix top_lvl env orig_pairs
= loop 1 initial_pairs
where
bot_sig = mkCprSig 0 botCpr
-- See Note [Initialising strictness] in DmdAnal.hs
-- See Note [Initialising strictness] in GHC.Core.Op.DmdAnal
initial_pairs | ae_virgin env = [(setIdCprInfo id bot_sig, rhs) | (id, rhs) <- orig_pairs ]
| otherwise = orig_pairs
......
......@@ -9,14 +9,14 @@
{-# LANGUAGE CPP #-}
module DmdAnal ( dmdAnalProgram ) where
module GHC.Core.Op.DmdAnal ( dmdAnalProgram ) where
#include "HsVersions.h"
import GhcPrelude
import GHC.Driver.Session
import WwLib ( findTypeShape )
import GHC.Core.Op.WorkWrap.Lib ( findTypeShape )
import Demand -- All of it
import GHC.Core
import GHC.Core.Seq ( seqBinds )
......@@ -759,7 +759,7 @@ information, but
* Performing the worker/wrapper split based on this information would be
implicitly eta-expanding `f`, playing fast and loose with divergence and
even being unsound in the presence of newtypes, so we refrain from doing so.
Also see Note [Don't eta expand in w/w] in WorkWrap.
Also see Note [Don't eta expand in w/w] in GHC.Core.Op.WorkWrap.
Since we only compute one signature, we do so for arity 1. Computing multiple
signatures for different arities (i.e., polyvariance) would be entirely
......@@ -1246,8 +1246,9 @@ The once-used information is (currently) only used by the code
generator, though. So:
* We zap the used-once info in the worker-wrapper;
see Note [Zapping Used Once info in WorkWrap] in WorkWrap. If it's
not reliable, it's better not to have it at all.
see Note [Zapping Used Once info in WorkWrap] in
GHC.Core.Op.WorkWrap.
If it's not reliable, it's better not to have it at all.
* Just before TidyCore, we add a pass of the demand analyser,
but WITHOUT subsequent worker/wrapper and simplifier,
......
module Exitify ( exitifyProgram ) where
module GHC.Core.Op.Exitify ( exitifyProgram ) where
{-
Note [Exitification]
......@@ -246,7 +246,7 @@ exitifyRec in_scope pairs
-- We are going to abstract over these variables, so we must
-- zap any IdInfo they have; see #15005
-- cf. SetLevels.abstractVars
-- cf. GHC.Core.Op.SetLevels.abstractVars
zap v | isId v = setIdInfo v vanillaIdInfo
| otherwise = v
......
......@@ -16,7 +16,7 @@ then discover that they aren't needed in the chosen branch.
{-# OPTIONS_GHC -fprof-auto #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module FloatIn ( floatInwards ) where
module GHC.Core.Op.FloatIn ( floatInwards ) where
#include "HsVersions.h"
......@@ -27,7 +27,7 @@ import GHC.Core.Make hiding ( wrapFloats )
import GHC.Driver.Types ( ModGuts(..) )
import GHC.Core.Utils
import GHC.Core.FVs
import CoreMonad ( CoreM )
import GHC.Core.Op.Monad ( CoreM )
import Id ( isOneShotBndr, idType, isJoinId, isJoinId_maybe )
import Var
import GHC.Core.Type
......@@ -91,7 +91,7 @@ The fix is
to let bind the algebraic case scrutinees (done, I think) and
the case alternatives (except the ones with an
unboxed type)(not done, I think). This is best done in the
SetLevels.hs module, which tags things with their level numbers.
GHC.Core.Op.SetLevels.hs module, which tags things with their level numbers.
\item
do the full laziness pass (floating lets outwards).
\item
......
......@@ -8,21 +8,21 @@
{-# LANGUAGE CPP #-}
module FloatOut ( floatOutwards ) where
module GHC.Core.Op.FloatOut ( floatOutwards ) where
import GhcPrelude
import GHC.Core
import GHC.Core.Utils
import GHC.Core.Make
import GHC.Core.Arity ( etaExpand )
import CoreMonad ( FloatOutSwitches(..) )
import GHC.Core.Arity ( etaExpand )
import GHC.Core.Op.Monad ( FloatOutSwitches(..) )
import GHC.Driver.Session
import ErrUtils ( dumpIfSet_dyn, DumpFormat (..) )
import Id ( Id, idArity, idType, isBottomingId,
isJoinId, isJoinId_maybe )
import SetLevels
import GHC.Core.Op.SetLevels
import UniqSupply ( UniqSupply )
import Bag
import Util
......@@ -113,7 +113,7 @@ Note [Join points]
Every occurrence of a join point must be a tail call (see Note [Invariants on
join points] in GHC.Core), so we must be careful with how far we float them. The
mechanism for doing so is the *join ceiling*, detailed in Note [Join ceiling]
in SetLevels. For us, the significance is that a binder might be marked to be
in GHC.Core.Op.SetLevels. For us, the significance is that a binder might be marked to be
dropped at the nearest boundary between tail calls and non-tail calls. For
example:
......@@ -220,7 +220,7 @@ floatBind (NonRec (TB var _) rhs)
= case (floatRhs var rhs) of { (fs, rhs_floats, rhs') ->
-- A tiresome hack:
-- see Note [Bottoming floats: eta expansion] in SetLevels
-- see Note [Bottoming floats: eta expansion] in GHC.Core.Op.SetLevels
let rhs'' | isBottomingId var = etaExpand (idArity var) rhs'
| otherwise = rhs'
......@@ -337,7 +337,7 @@ makes f and x' look mutually recursive when they're not.
The test was shootout/k-nucleotide, as compiled using commit 47d5dd68 on the
wip/join-points branch.
TODO: This can probably be solved somehow in SetLevels. The difference between
TODO: This can probably be solved somehow in GHC.Core.Op.SetLevels. The difference between
"this *is at* level <2,0>" and "this *depends on* level <2,0>" is very
important.)
......@@ -408,7 +408,7 @@ floatExpr lam@(Lam (TB _ lam_spec) _)
bndrs = [b | TB b _ <- bndrs_w_lvls]
bndr_lvl = asJoinCeilLvl (floatSpecLevel lam_spec)
-- All the binders have the same level
-- See SetLevels.lvlLamBndrs
-- See GHC.Core.Op.SetLevels.lvlLamBndrs
-- Use asJoinCeilLvl to make this the join ceiling
in
case (floatBody bndr_lvl body) of { (fs, floats, body') ->
......@@ -597,7 +597,7 @@ lifted to top level.
The trouble is that
(a) we partition these floating bindings *at every binding site*
(b) SetLevels introduces a new bindings site for every float
(b) GHC.Core.Op.SetLevels introduces a new bindings site for every float
So we had better not look at each binding at each binding site!
That is why MajorEnv is represented as a finite map.
......
......@@ -5,7 +5,7 @@
-}
{-# LANGUAGE CPP #-}
module LiberateCase ( liberateCase ) where
module GHC.Core.Op.LiberateCase ( liberateCase ) where
#include "HsVersions.h"
......
{-
(c) The AQUA Project, Glasgow University, 1993-1998
\section[CoreMonad]{The core pipeline monad}
-}
{-# LANGUAGE CPP #-}
......@@ -9,7 +8,7 @@
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module CoreMonad (
module GHC.Core.Op.Monad (
-- * Configuration of the core-to-core passes
CoreToDo(..), runWhen, runMaybe,
SimplMode(..),
......@@ -154,7 +153,7 @@ pprPassDetails (CoreDoSimplify n md) = vcat [ text "Max iterations =" <+> int n
, ppr md ]
pprPassDetails _ = Outputable.empty
data SimplMode -- See comments in SimplMonad
data SimplMode -- See comments in GHC.Core.Op.Simplify.Monad
= SimplMode
{ sm_names :: [String] -- Name(s) of the phase
, sm_phase :: CompilerPhase
......@@ -195,7 +194,7 @@ data FloatOutSwitches = FloatOutSwitches {
-- ^ True <=> float out over-saturated applications
-- based on arity information.
-- See Note [Floating over-saturated applications]
-- in SetLevels
-- in GHC.Core.Op.SetLevels
floatToTopLevelOnly :: Bool -- ^ Allow floating to the top level only.
}
instance Outputable FloatOutSwitches where
......
-- Created this hs-boot file to remove circular dependencies from the use of
-- Plugins. Plugins needs CoreToDo and CoreM types to define core-to-core
-- transformations.
-- However CoreMonad does much more than defining these, and because Plugins are
-- However GHC.Core.Op.Monad does much more than defining these, and because Plugins are
-- activated in various modules, the imports become circular. To solve this I
-- extracted CoreToDo and CoreM into this file.
-- I needed to write the whole definition of these types, otherwise it created
-- a data-newtype conflict.
module CoreMonad ( CoreToDo, CoreM ) where
module GHC.Core.Op.Monad ( CoreToDo, CoreM ) where
import GhcPrelude
......
......@@ -15,7 +15,7 @@ core expression with (hopefully) improved usage information.
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module OccurAnal (
module GHC.Core.Op.OccurAnal (
occurAnalysePgm, occurAnalyseExpr, occurAnalyseExpr_NoBinderSwap
) where
......@@ -302,7 +302,7 @@ But what is the graph? NOT the same graph as was used for Note
'f' that is *always* inlined if it is applicable. We do *not* disable
rules for loop-breakers. It's up to whoever makes the rules to make
sure that the rules themselves always terminate. See Note [Rules for
recursive functions] in Simplify.hs
recursive functions] in GHC.Core.Op.Simplify
Hence, if
f's RHS (or its INLINE template if it has one) mentions g, and
......@@ -647,7 +647,7 @@ Consider this group, which is typical of what SpecConstr builds:
So 'f' and 'fs' are in the same Rec group (since f refers to fs via its RULE).
But watch out! If 'fs' is not chosen as a loop breaker, we may get an infinite loop:
- the RULE is applied in f's RHS (see Note [Self-recursive rules] in Simplify
- the RULE is applied in f's RHS (see Note [Self-recursive rules] in GHC.Core.Op.Simplify
- fs is inlined (say it's small)
- now there's another opportunity to apply the RULE
......@@ -1647,7 +1647,7 @@ So, when analysing the RHS of x3 we notice that x3 will itself
definitely inline the next time round, and so we analyse x3's rhs in
an ordinary context, not rhsCtxt. Hence the "certainly_inline" stuff.
Annoyingly, we have to approximate SimplUtils.preInlineUnconditionally.
Annoyingly, we have to approximate GHC.Core.Op.Simplify.Utils.preInlineUnconditionally.
If (a) the RHS is expandable (see isExpandableApp in occAnalApp), and
(b) certainly_inline says "yes" when preInlineUnconditionally says "no"
then the simplifier iterates indefinitely:
......@@ -1871,7 +1871,7 @@ occAnalApp env (Var fun, args, ticks)
fun_uds = mkOneOcc env fun (if n_val_args > 0 then IsInteresting else NotInteresting) n_args
is_exp = isExpandableApp fun n_val_args
-- See Note [CONLIKE pragma] in BasicTypes
-- The definition of is_exp should match that in Simplify.prepareRhs
-- The definition of is_exp should match that in GHC.Core.Op.Simplify.prepareRhs
one_shots = argsOneShots (idStrictness fun) guaranteed_val_args
guaranteed_val_args = n_val_args + length (takeWhile isOneShotInfo
......
{-
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998
\section{SetLevels}
\section{GHC.Core.Op.SetLevels}
***************************
Overview
......@@ -52,7 +52,7 @@
{-# LANGUAGE CPP, MultiWayIf #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module SetLevels (
module GHC.Core.Op.SetLevels (
setLevels,
Level(..), LevelType(..), tOP_LEVEL, isJoinCeilLvl, asJoinCeilLvl,
......@@ -67,7 +67,7 @@ module SetLevels (
import GhcPrelude
import GHC.Core
import CoreMonad ( FloatOutSwitches(..) )
import GHC.Core.Op.Monad ( FloatOutSwitches(..) )
import GHC.Core.Utils ( exprType, exprIsHNF
, exprOkForSpeculation
, exprIsTopLevelBindable
......@@ -178,7 +178,7 @@ But, check this out:
-- __inline (let x = e in \d. x)
-- things are bad. The inliner doesn't even inline it because it doesn't look
-- like a head-normal form. So it seems a lesser evil to let things float.
-- In SetLevels we do set the context to (Level 0 0) when we get to an InlineMe
-- In GHC.Core.Op.SetLevels we do set the context to (Level 0 0) when we get to an InlineMe
-- which discourages floating out.
So the conclusion is: don't do any floating at all inside an InlineMe.
......@@ -375,7 +375,7 @@ lvlExpr env expr@(_, AnnLam {})
-- a lambda like this (\x -> coerce t (\s -> ...))
-- This used to happen quite a bit in state-transformer programs,
-- but not nearly so much now non-recursive newtypes are transparent.
-- [See SetLevels rev 1.50 for a version with this approach.]
-- [See GHC.Core.Op.SetLevels rev 1.50 for a version with this approach.]
lvlExpr env (_, AnnLet bind body)
= do { (bind', new_env) <- lvlBind env bind
......@@ -434,7 +434,7 @@ lvlApp env orig_expr ((_,AnnVar fn), args)
left n (_, AnnApp f a) rargs
| isValArg (deAnnotate a) = left (n-1) f (a:rargs)
| otherwise = left n f (a:rargs)
left _ _ _ = panic "SetLevels.lvlExpr.left"
left _ _ _ = panic "GHC.Core.Op.SetLevels.lvlExpr.left"
is_val_arg :: CoreExprWithFVs -> Bool
is_val_arg (_, AnnType {}) = False
......@@ -950,8 +950,8 @@ Note [Bottoming floats: eta expansion] c.f Note [Bottoming floats]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tiresomely, though, the simplifier has an invariant that the manifest
arity of the RHS should be the same as the arity; but we can't call
etaExpand during SetLevels because it works over a decorated form of
CoreExpr. So we do the eta expansion later, in FloatOut.
etaExpand during GHC.Core.Op.SetLevels because it works over a decorated form of
CoreExpr. So we do the eta expansion later, in GHC.Core.Op.FloatOut.
Note [Case MFEs]
~~~~~~~~~~~~~~~~
......@@ -1140,7 +1140,7 @@ lvlBind env (AnnRec pairs)
-- This mightBeUnliftedType stuff is the same test as in the non-rec case
-- You might wonder whether we can have a recursive binding for
-- an unlifted value -- but we can if it's a /join binding/ (#16978)
-- (Ultimately I think we should not use SetLevels to
-- (Ultimately I think we should not use GHC.Core.Op.SetLevels to
-- float join bindings at all, but that's another story.)
= -- No float
do { let bind_lvl = incMinorLvl (le_ctxt_lvl env)
......@@ -1399,7 +1399,7 @@ destLevel env fvs fvs_ty is_function is_bot is_join
= tOP_LEVEL
| is_join -- Never float a join point past the join ceiling
-- See Note [Join points] in FloatOut
-- See Note [Join points] in GHC.Core.Op.FloatOut
= if max_fv_id_level `ltLvl` join_ceiling
then join_ceiling
else max_fv_id_level
......
......@@ -7,18 +7,18 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module Simplify ( simplTopBinds, simplExpr, simplRules ) where
module GHC.Core.Op.Simplify ( simplTopBinds, simplExpr, simplRules ) where
#include "HsVersions.h"
import GhcPrelude
import GHC.Driver.Session
import SimplMonad
import GHC.Core.Op.Simplify.Monad
import GHC.Core.Type hiding ( substTy, substTyVar, extendTvSubst, extendCvSubst )
import SimplEnv
import SimplUtils
import OccurAnal ( occurAnalyseExpr )
import GHC.Core.Op.Simplify.Env
import GHC.Core.Op.Simplify.Utils
import GHC.Core.Op.OccurAnal ( occurAnalyseExpr )
import GHC.Core.FamInstEnv ( FamInstEnv )
import Literal ( litIsLifted ) --, mkLitInt ) -- temporalily commented out. See #8326
import Id
......@@ -34,7 +34,7 @@ import GHC.Core.DataCon
( DataCon, dataConWorkId, dataConRepStrictness
, dataConRepArgTys, isUnboxedTupleCon
, StrictnessMark (..) )
import CoreMonad ( Tick(..), SimplMode(..) )
import GHC.Core.Op.Monad ( Tick(..), SimplMode(..) )
import GHC.Core
import Demand ( StrictSig(..), dmdTypeDepth, isStrictDmd
, mkClosedStrictSig, topDmd, botDiv )
......@@ -61,7 +61,7 @@ import PrimOp ( PrimOp (SeqOp) )
{-
The guts of the simplifier is in this module, but the driver loop for
the simplifier is in SimplCore.hs.
the simplifier is in GHC.Core.Op.Simplify.Driver
Note [The big picture]
~~~~~~~~~~~~~~~~~~~~~~
......@@ -300,7 +300,7 @@ simplLazyBind env top_lvl is_rec bndr bndr1 rhs rhs_se
; (body_env, tvs') <- {-#SCC "simplBinders" #-} simplBinders rhs_env tvs
-- See Note [Floating and type abstraction] in SimplUtils
-- See Note [Floating and type abstraction] in GHC.Core.Op.Simplify.Utils
-- Simplify the RHS
; let rhs_cont = mkRhsStop (substTy body_env (exprType body))
......@@ -688,7 +688,7 @@ completeBind env top_lvl mb_cont old_bndr new_bndr new_rhs
occ_info = occInfo old_info
-- Do eta-expansion on the RHS of the binding
-- See Note [Eta-expanding at let bindings] in SimplUtils
-- See Note [Eta-expanding at let bindings] in GHC.Core.Op.Simplify.Utils
; (new_arity, is_bot, final_rhs) <- tryEtaExpandRhs (getMode env)
new_bndr new_rhs
......@@ -1830,7 +1830,7 @@ rebuildCall :: SimplEnv
---------- Bottoming applications --------------
rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args, ai_strs = [] }) cont
-- When we run out of strictness args, it means
-- that the call is definitely bottom; see SimplUtils.mkArgInfo
-- that the call is definitely bottom; see GHC.Core.Op.Simplify.Utils.mkArgInfo
-- Then we want to discard the entire strict continuation. E.g.
-- * case (error "hello") of { ... }
-- * (error "Hello") arg
......@@ -2250,9 +2250,9 @@ Start with a simple situation:
do this for algebraic cases, because we might turn bottom into
non-bottom!
The code in SimplUtils.prepareAlts has the effect of generalise this
idea to look for a case where we're scrutinising a variable, and we
know that only the default case can match. For example:
The code in GHC.Core.Op.Simplify.Utils.prepareAlts has the effect of generalise
this idea to look for a case where we're scrutinising a variable, and we know
that only the default case can match. For example:
case x of
0# -> ...
......@@ -2264,7 +2264,7 @@ Here the inner case is first trimmed to have only one alternative, the
DEFAULT, after which it's an instance of the previous case. This
really only shows up in eliminating error-checking code.
Note that SimplUtils.mkCase combines identical RHSs. So
Note that GHC.Core.Op.Simplify.Utils.mkCase combines identical RHSs. So
case e of ===> case e of DEFAULT -> r
True -> r
......@@ -2762,7 +2762,7 @@ NB: simplLamBndrs preserves this eval info
In addition to handling data constructor fields with !s, addEvals
also records the fact that the result of seq# is always in WHNF.
See Note [seq# magic] in PrelRules. Example (#15226):
See Note [seq# magic] in GHC.Core.Op.ConstantFold. Example (#15226):
case seq# v s of
(# s', v' #) -> E
......@@ -2886,8 +2886,8 @@ it's also good for case-elimintation -- suppose that 'f' was inlined
and did multi-level case analysis, then we'd solve it in one
simplifier sweep instead of two.
Exactly the same issue arises in SpecConstr;
see Note [Add scrutinee to ValueEnv too] in SpecConstr
Exactly the same issue arises in GHC.Core.Op.SpecConstr;
see Note [Add scrutinee to ValueEnv too] in GHC.Core.Op.SpecConstr
HOWEVER, given
case x of y { Just a -> r1; Nothing -> r2 }
......@@ -3104,7 +3104,7 @@ mkDupableCont env (StrictBind { sc_bndr = bndr, sc_bndrs = bndrs
, StrictBind { sc_bndr = bndr', sc_bndrs = []
, sc_body = body2
, sc_env = zapSubstEnv se `setInScopeFromF` floats2
-- See Note [StaticEnv invariant] in SimplUtils
-- See Note [StaticEnv invariant] in GHC.Core.Op.Simplify.Utils
, sc_dup = OkToDup
, sc_cont = mkBoringStop res_ty } ) }
......@@ -3144,7 +3144,7 @@ mkDupableCont env (ApplyToVal { sc_arg = arg, sc_dup = dup
-- Ensure that sc_env includes the free vars of
-- arg'' in its in-scope set, even if makeTrivial
-- has turned arg'' into a fresh variable
-- See Note [StaticEnv invariant] in SimplUtils
-- See Note [StaticEnv invariant] in GHC.Core.Op.Simplify.Utils
, sc_dup = OkToDup, sc_cont = cont' }) }
mkDupableCont env (Select { sc_bndr = case_bndr, sc_alts = alts
......@@ -3185,7 +3185,7 @@ mkDupableCont env (Select { sc_bndr = case_bndr, sc_alts = alts
, sc_bndr = case_bndr'
, sc_alts = alts''
, sc_env = zapSubstEnv se `setInScopeFromF` all_floats
-- See Note [StaticEnv invariant] in SimplUtils
-- See Note [StaticEnv invariant] in GHC.Core.Op.Simplify.Utils
, sc_cont = mkBoringStop (contResultType cont) } ) }
mkDupableAlt :: DynFlags -> OutId
......@@ -3248,7 +3248,7 @@ Note [Fusing case continuations]
It's important to fuse two successive case continuations when the
first has one alternative. That's why we call prepareCaseCont here.
Consider this, which arises from thunk splitting (see Note [Thunk
splitting] in WorkWrap):
splitting] in GHC.Core.Op.WorkWrap):
let
x* = case (case v of {pn -> rn}) of
......@@ -3305,7 +3305,7 @@ So instead we do both: we pass 'c' and 'c#' , and record in c's inlining
Absence analysis may later discard 'c'.
NB: take great care when doing strictness analysis;
see Note [Lambda-bound unfoldings] in DmdAnal.
see Note [Lambda-bound unfoldings] in GHC.Core.Op.DmdAnal.
Also note that we can still end up passing stuff that isn't used. Before
strictness analysis we have
......@@ -3495,7 +3495,7 @@ simplLetUnfolding env top_lvl cont_mb id new_rhs rhs_ty unf
| isStableUnfolding unf
= simplStableUnfolding env top_lvl cont_mb id unf rhs_ty
| isExitJoinId id
= return noUnfolding -- See Note [Do not inline exit join points] in Exitify
= return noUnfolding -- See Note [Do not inline exit join points] in GHC.Core.Op.Exitify
| otherwise
= mkLetUnfolding (seDynFlags env) top_lvl InlineRhs id new_rhs
......@@ -3571,7 +3571,7 @@ simplStableUnfolding env top_lvl mb_cont id unf rhs_ty
is_top_lvl = isTopLevel top_lvl
act = idInlineActivation id
unf_env = updMode (updModeForStableUnfoldings act) env
-- See Note [Simplifying inside stable unfoldings] in SimplUtils
-- See Note [Simplifying inside stable unfoldings] in GHC.Core.Op.Simplify.Utils
{-
Note [Force bottoming field]
......