From git at git.haskell.org Tue Mar 1 17:27:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 1 Mar 2016 17:27:59 +0000 (UTC) Subject: [commit: ghc] master: A bit more tracing in TcHsType.tcTyVar (2d52c3a) Message-ID: <20160301172759.4A4303A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2d52c3ad1b5c1e346dc11e7d9290022475841ab0/ghc >--------------------------------------------------------------- commit 2d52c3ad1b5c1e346dc11e7d9290022475841ab0 Author: Simon Peyton Jones Date: Mon Feb 29 14:17:30 2016 +0000 A bit more tracing in TcHsType.tcTyVar >--------------------------------------------------------------- 2d52c3ad1b5c1e346dc11e7d9290022475841ab0 compiler/typecheck/TcHsType.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index 5b0d9b9..8c22c5c 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -924,10 +924,14 @@ tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon -> TcM (TcType, TcKind) handle_tyfams tc tc_tc | mightBeUnsaturatedTyCon tc_tc - = return (ty, tc_kind) + = do { traceTc "tcTyVar2a" (ppr tc_tc $$ ppr tc_kind) + ; return (ty, tc_kind) } | otherwise - = instantiateTyN 0 ty tc_kind + = do { (tc_ty, kind) <- instantiateTyN 0 ty tc_kind + ; traceTc "tcTyVar2b" (vcat [ ppr tc <+> dcolon <+> ppr tc_kind + , ppr tc_ty $$ ppr kind ]) + ; return (tc_ty, kind) } where ty = mkNakedTyConApp tc [] tc_kind = tyConKind tc_tc From git at git.haskell.org Tue Mar 1 17:28:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 1 Mar 2016 17:28:02 +0000 (UTC) Subject: [commit: ghc] master: Remove unnecessary isTyVar tests in TcType (a0899b2) Message-ID: <20160301172802.0277D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/a0899b2f66a4102a7cf21569889381446ce63833/ghc >--------------------------------------------------------------- commit a0899b2f66a4102a7cf21569889381446ce63833 Author: Simon Peyton Jones Date: Tue Mar 1 17:05:56 2016 +0000 Remove unnecessary isTyVar tests in TcType These extra tests were added by Richard when he had CoVars floating around in places where previously only TyVars had been. But fortunately those days are gone, so these tests are unnecessary, and are slowing GHC down. Let's remove them. >--------------------------------------------------------------- a0899b2f66a4102a7cf21569889381446ce63833 compiler/typecheck/TcType.hs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs index 73a46ae..40821e5 100644 --- a/compiler/typecheck/TcType.hs +++ b/compiler/typecheck/TcType.hs @@ -860,7 +860,6 @@ isTouchableOrFmv ctxt_tclvl tv isTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool isTouchableMetaTyVar ctxt_tclvl tv - | isTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of MetaTv { mtv_tclvl = tv_tclvl } @@ -868,16 +867,13 @@ isTouchableMetaTyVar ctxt_tclvl tv ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl ) tv_tclvl `sameDepthAs` ctxt_tclvl _ -> False - | otherwise = False isFloatedTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool isFloatedTouchableMetaTyVar ctxt_tclvl tv - | isTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of MetaTv { mtv_tclvl = tv_tclvl } -> tv_tclvl `strictlyDeeperThan` ctxt_tclvl _ -> False - | otherwise = False isImmutableTyVar :: TyVar -> Bool isImmutableTyVar tv @@ -892,12 +888,10 @@ isTyConableTyVar tv -- True of a meta-type variable that can be filled in -- with a type constructor application; in particular, -- not a SigTv - | isTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of MetaTv { mtv_info = SigTv } -> False _ -> True - | otherwise = True isFmvTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) @@ -927,20 +921,16 @@ isSkolemTyVar tv _other -> True isOverlappableTyVar tv - | isTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of SkolemTv overlappable -> overlappable _ -> False - | otherwise = False isMetaTyVar tv - | isTyVar tv = ASSERT2( isTcTyVar tv, ppr tv ) case tcTyVarDetails tv of MetaTv {} -> True _ -> False - | otherwise = False -- isAmbiguousTyVar is used only when reporting type errors -- It picks out variables that are unbound, namely meta @@ -948,12 +938,10 @@ isMetaTyVar tv -- RtClosureInspect.zonkRTTIType. These are "ambiguous" in -- the sense that they stand for an as-yet-unknown type isAmbiguousTyVar tv - | isTyVar tv = case tcTyVarDetails tv of MetaTv {} -> True RuntimeUnk {} -> True _ -> False - | otherwise = False isMetaTyVarTy :: TcType -> Bool isMetaTyVarTy (TyVarTy tv) = isMetaTyVar tv From git at git.haskell.org Tue Mar 1 17:28:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 1 Mar 2016 17:28:04 +0000 (UTC) Subject: [commit: ghc] master: Do not check synonym RHS for ambiguity (3c29c77) Message-ID: <20160301172804.AD3993A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3c29c770be7a8c7268dcb8d8624853428aa42071/ghc >--------------------------------------------------------------- commit 3c29c770be7a8c7268dcb8d8624853428aa42071 Author: Simon Peyton Jones Date: Mon Feb 29 14:12:28 2016 +0000 Do not check synonym RHS for ambiguity With this patch we no longer check the RHS of a type synonym declaration for ambiguity. It only affects type synonyms with foralls on the RHS (which are rare in the first place), and it's arguably over-aggressive to check them for ambiguity. See TcValidity Note [When we don't check for ambiguity] This fixes the ASSERT failures in th T3100 typecheck/should_compile T3692 typecheck/should_fail T3592 >--------------------------------------------------------------- 3c29c770be7a8c7268dcb8d8624853428aa42071 compiler/typecheck/TcValidity.hs | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs index 784cfa0..99a9be3 100644 --- a/compiler/typecheck/TcValidity.hs +++ b/compiler/typecheck/TcValidity.hs @@ -216,13 +216,10 @@ checkAmbiguity ctxt ty wantAmbiguityCheck :: UserTypeCtxt -> Bool wantAmbiguityCheck ctxt - = case ctxt of - GhciCtxt -> False -- Allow ambiguous types in GHCi's :kind command - -- E.g. type family T a :: * -- T :: forall k. k -> * - -- Then :k T should work in GHCi, not complain that - -- (T k) is ambiguous! - _ -> True - + = case ctxt of -- See Note [When we don't check for ambiguity] + GhciCtxt -> False + TySynCtxt {} -> False + _ -> True checkUserTypeError :: Type -> TcM () -- Check to see if the type signature mentions "TypeError blah" @@ -247,7 +244,26 @@ checkUserTypeError = check ; failWithTcM (env1, pprUserTypeErrorTy tidy_msg) } -{- +{- Note [When we don't check for ambiguity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In a few places we do not want to check a user-specified type for ambiguity + +* GhciCtxt: Allow ambiguous types in GHCi's :kind command + E.g. type family T a :: * -- T :: forall k. k -> * + Then :k T should work in GHCi, not complain that + (T k) is ambiguous! + +* TySynCtxt: type T a b = C a b => blah + It may be that when we /use/ T, we'll give an 'a' or 'b' that somehow + cure the ambiguity. So we defer the ambiguity check to the use site. + + There is also an implementation reason (Trac #11608). In the RHS of + a type synonym we don't (currently) instantiate 'a' and 'b' with + TcTyVars before calling checkValidType, so we get asertion failures + from doing an ambiguity check on a type with TyVars in it. Fixing this + would not be hard, but let's wait till there's a reason. + + ************************************************************************ * * Checking validity of a user-defined type @@ -472,13 +488,12 @@ check_type env ctxt rank ty where (tvs, theta, tau) = tcSplitSigmaTy ty tau_kind = typeKind tau + (env', _) = tidyTyCoVarBndrs env tvs phi_kind | null theta = tau_kind | otherwise = liftedTypeKind -- If there are any constraints, the kind is *. (#11405) - (env', _) = tidyTyCoVarBndrs env tvs - check_type _ _ _ (TyVarTy _) = return () check_type env ctxt rank (ForAllTy (Anon arg_ty) res_ty) From git at git.haskell.org Tue Mar 1 17:28:07 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 1 Mar 2016 17:28:07 +0000 (UTC) Subject: [commit: ghc] master: Comments only (243e2ab) Message-ID: <20160301172807.622223A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/243e2abb3d50b73ede06f5302e51ba804a9321ec/ghc >--------------------------------------------------------------- commit 243e2abb3d50b73ede06f5302e51ba804a9321ec Author: Simon Peyton Jones Date: Mon Feb 29 14:16:18 2016 +0000 Comments only >--------------------------------------------------------------- 243e2abb3d50b73ede06f5302e51ba804a9321ec compiler/typecheck/TcCanonical.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/TcCanonical.hs b/compiler/typecheck/TcCanonical.hs index 2da3153..a5fd412 100644 --- a/compiler/typecheck/TcCanonical.hs +++ b/compiler/typecheck/TcCanonical.hs @@ -866,12 +866,13 @@ can_eq_app ev NomEq s1 t1 s2 t2 ----------------------- -- | Break apart an equality over a casted type +-- looking like (ty1 |> co1) ~ ty2 (modulo a swap-flag) canEqCast :: Bool -- are both types flat? -> CtEvidence -> EqRel -> SwapFlag - -> TcType -> Coercion -- LHS (res. RHS), the casted type - -> TcType -> TcType -- RHS (res. LHS), both normal and pretty + -> TcType -> Coercion -- LHS (res. RHS), ty1 |> co1 + -> TcType -> TcType -- RHS (res. LHS), ty2 both normal and pretty -> TcS (StopOrContinue Ct) canEqCast flat ev eq_rel swapped ty1 co1 ty2 ps_ty2 = do { traceTcS "Decomposing cast" (vcat [ ppr ev From git at git.haskell.org Tue Mar 1 17:28:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 1 Mar 2016 17:28:10 +0000 (UTC) Subject: [commit: ghc] master: Don't complain about unused Rule binders (57b4c55) Message-ID: <20160301172810.166B03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/57b4c5524fcbf02f61dfc8d9395906dc7f50f048/ghc >--------------------------------------------------------------- commit 57b4c5524fcbf02f61dfc8d9395906dc7f50f048 Author: Simon Peyton Jones Date: Tue Mar 1 17:07:26 2016 +0000 Don't complain about unused Rule binders This fixes Trac #11643. It's a corner case, now documented in Note [Linting rules] in CoreLint >--------------------------------------------------------------- 57b4c5524fcbf02f61dfc8d9395906dc7f50f048 compiler/coreSyn/CoreLint.hs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index 90e68e8..99625c9 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -1175,7 +1175,10 @@ lintCoreRule fun_ty (Rule { ru_name = name, ru_bndrs = bndrs ; ensureEqTys lhs_ty rhs_ty $ (rule_doc <+> vcat [ text "lhs type:" <+> ppr lhs_ty , text "rhs type:" <+> ppr rhs_ty ]) - ; let bad_bndrs = filterOut (`elemVarSet` exprsFreeVars args) bndrs + ; let bad_bndrs = filterOut (`elemVarSet` exprsFreeVars args) $ + filter (`elemVarSet` exprFreeVars rhs) $ + bndrs + ; checkL (null bad_bndrs) (rule_doc <+> text "unbound" <+> ppr bad_bndrs) -- See Note [Linting rules] @@ -1186,9 +1189,9 @@ lintCoreRule fun_ty (Rule { ru_name = name, ru_bndrs = bndrs {- Note [Linting rules] ~~~~~~~~~~~~~~~~~~~~~~~ It's very bad if simplifying a rule means that one of the template -variables (ru_bndrs) becomes not-mentioned in the template argumments -(ru_args). How can that happen? Well, in Trac #10602, SpecConstr -stupidly constructed a rule like +variables (ru_bndrs) that /is/ mentioned on the RHS becomes +not-mentioned in the LHS (ru_args). How can that happen? Well, in +Trac #10602, SpecConstr stupidly constructed a rule like forall x,c1,c2. f (x |> c1 |> c2) = .... @@ -1198,6 +1201,16 @@ Trac #10602, it collapsed to the identity and was removed altogether.) We don't have a great story for what to do here, but at least this check will nail it. + +NB (Trac #11643): it's possible that a variable listed in the +binders becomes not-mentioned on both LHS and RHS. Here's a silly +example: + RULE forall x y. f (g x y) = g (x+1 (y-1) +And suppose worker/wrapper decides that 'x' is Absent. Then +we'll end up with + RULE forall x y. f ($gw y) = $gw (x+1) +This seems sufficiently obscure that there isn't enough payoff to +try to trim the forall'd binder list. -} {- From git at git.haskell.org Tue Mar 1 20:50:42 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 1 Mar 2016 20:50:42 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Update submodule to Cabal-1.24 branch (b0f5a2a) Message-ID: <20160301205042.3DD543A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/b0f5a2ae378a6b2496bdd28bc416349c9cf56385/ghc >--------------------------------------------------------------- commit b0f5a2ae378a6b2496bdd28bc416349c9cf56385 Author: Herbert Valerio Riedel Date: Tue Mar 1 21:51:05 2016 +0100 Update submodule to Cabal-1.24 branch ghc-8.0 now is officially tracking the 1.24 branch NB: `cabal submodule update --remote libraries/Cabal` will do the right thing now >--------------------------------------------------------------- b0f5a2ae378a6b2496bdd28bc416349c9cf56385 .gitmodules | 1 + libraries/Cabal | 2 +- utils/check-api-annotations/check-api-annotations.cabal | 2 +- utils/ghc-cabal/ghc-cabal.cabal | 2 +- utils/ghctags/Main.hs | 2 +- utils/ghctags/ghctags.cabal | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index 29ca854..1b846b3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,6 +10,7 @@ path = libraries/Cabal url = ../packages/Cabal.git ignore = untracked + branch = 1.24 [submodule "libraries/containers"] path = libraries/containers url = ../packages/containers.git diff --git a/libraries/Cabal b/libraries/Cabal index 7aab356..df45e05 160000 --- a/libraries/Cabal +++ b/libraries/Cabal @@ -1 +1 @@ -Subproject commit 7aab3566e721c30ff5847a21051d5b5047176dc7 +Subproject commit df45e05eb249cd422afe1b406a3ed8eb0043bcb4 diff --git a/utils/check-api-annotations/check-api-annotations.cabal b/utils/check-api-annotations/check-api-annotations.cabal index ade5fe4..89ed803 100644 --- a/utils/check-api-annotations/check-api-annotations.cabal +++ b/utils/check-api-annotations/check-api-annotations.cabal @@ -24,6 +24,6 @@ Executable check-api-annotations Build-Depends: base >= 4 && < 5, containers, - Cabal >= 1.22 && <1.24, + Cabal == 1.24.*, directory, ghc diff --git a/utils/ghc-cabal/ghc-cabal.cabal b/utils/ghc-cabal/ghc-cabal.cabal index d6048a3..78a0f22 100644 --- a/utils/ghc-cabal/ghc-cabal.cabal +++ b/utils/ghc-cabal/ghc-cabal.cabal @@ -21,7 +21,7 @@ Executable ghc-cabal Build-Depends: base >= 3 && < 5, bytestring >= 0.10 && < 0.11, - Cabal >= 1.22 && < 1.24, + Cabal == 1.24.*, directory >= 1.1 && < 1.3, filepath >= 1.2 && < 1.5 diff --git a/utils/ghctags/Main.hs b/utils/ghctags/Main.hs index ccdd327..0eff514 100644 --- a/utils/ghctags/Main.hs +++ b/utils/ghctags/Main.hs @@ -188,7 +188,7 @@ flagsFromCabal distPref = do let bi = libBuildInfo lib odir = buildDir lbi opts = componentGhcOptions V.normal lbi bi clbi odir - in return $ renderGhcOptions (compiler lbi) opts + in return $ renderGhcOptions (compiler lbi) (hostPlatform lbi) opts _ -> error "no library" ---------------------------------------------------------------- diff --git a/utils/ghctags/ghctags.cabal b/utils/ghctags/ghctags.cabal index d73c7fa..62eedb8 100644 --- a/utils/ghctags/ghctags.cabal +++ b/utils/ghctags/ghctags.cabal @@ -18,6 +18,6 @@ Executable ghctags Build-Depends: base >= 4 && < 5, containers, - Cabal >= 1.22 && <1.24, + Cabal == 1.24.*, ghc From git at git.haskell.org Wed Mar 2 15:22:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 2 Mar 2016 15:22:54 +0000 (UTC) Subject: [commit: ghc] master: Fix an outright bug in expandTypeSynonyms (286dc02) Message-ID: <20160302152254.0FB803A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/286dc021ef515d02453cd5e31774b852d3a1310f/ghc >--------------------------------------------------------------- commit 286dc021ef515d02453cd5e31774b852d3a1310f Author: Simon Peyton Jones Date: Wed Mar 2 15:12:12 2016 +0000 Fix an outright bug in expandTypeSynonyms The bug was in this code: go subst (TyConApp tc tys) | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys = let subst' = unionTCvSubst subst (mkTvSubstPrs tenv) in go subst' (mkAppTys rhs tys') This is wrong in two ways. * It is wrong to apply the expanded substitution to tys', * The unionTCvSubst is utterly wrong; after all, rhs is completely separate, and the union makes a non-idempotent substitution. It was the non-idempotency that gave the Lint failure in Trac #11665, when there was a type synonym whose RHS mentioned another type synonym, something like type T a b = a -> b type S x y = T y x It only affects SpecConstr because that's about the only place where expandTypeSyonym is called. I tried to trigger the failure with a simple test case, but failed, so I have not added a regression test. Fortunately the solution is very simple and solid. FWIW, the culprit was 674654, "Add kind equalities to GHC". >--------------------------------------------------------------- 286dc021ef515d02453cd5e31774b852d3a1310f compiler/types/Type.hs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 78c20a9..b71bba3 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -327,14 +327,26 @@ expandTypeSynonyms :: Type -> Type -- 'expandTypeSynonyms' only expands out type synonyms mentioned in the type, -- not in the kinds of any TyCon or TyVar mentioned in the type. expandTypeSynonyms ty - = go (mkEmptyTCvSubst (mkTyCoInScopeSet [ty] [])) ty + = go (mkEmptyTCvSubst in_scope) ty where + in_scope = mkInScopeSet (tyCoVarsOfType ty) + go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys - = let subst' = unionTCvSubst subst (mkTvSubstPrs tenv) in - go subst' (mkAppTys rhs tys') + | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + = let subst' = mkTvSubst in_scope (mkVarEnv tenv) + -- Make a fresh substitution; rhs has nothing to + -- do with anything that has happened so far + -- NB: if you make changes here, be sure to build an + -- /idempotent/ substitution, even in the nested case + -- type T a b = a -> b + -- type S x y = T y x + -- (Trac #11665) + in mkAppTys (go subst' rhs) tys' | otherwise - = TyConApp tc (map (go subst) tys) + = TyConApp tc expanded_tys + where + expanded_tys = (map (go subst) tys) + go _ (LitTy l) = LitTy l go subst (TyVarTy tv) = substTyVar subst tv go subst (AppTy t1 t2) = mkAppTy (go subst t1) (go subst t2) From git at git.haskell.org Wed Mar 2 15:22:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 2 Mar 2016 15:22:56 +0000 (UTC) Subject: [commit: ghc] master: Use tyConArity rather than (length tvs) (aea1e5d) Message-ID: <20160302152256.CE8D33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/aea1e5dbfd841edf546e789df496e77389d26f65/ghc >--------------------------------------------------------------- commit aea1e5dbfd841edf546e789df496e77389d26f65 Author: Simon Peyton Jones Date: Wed Mar 2 15:22:46 2016 +0000 Use tyConArity rather than (length tvs) A bit more efficient >--------------------------------------------------------------- aea1e5dbfd841edf546e789df496e77389d26f65 compiler/types/TyCon.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs index 5d01732..3c0a945 100644 --- a/compiler/types/TyCon.hs +++ b/compiler/types/TyCon.hs @@ -1798,10 +1798,9 @@ expandSynTyCon_maybe -- ^ Expand a type synonym application, if any expandSynTyCon_maybe tc tys - | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs } <- tc - , let n_tvs = length tvs - = case n_tvs `compare` length tys of - LT -> Just (tvs `zip` tys, rhs, drop n_tvs tys) + | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc + = case arity `compare` length tys of + LT -> Just (tvs `zip` tys, rhs, drop arity tys) EQ -> Just (tvs `zip` tys, rhs, []) GT -> Nothing | otherwise From git at git.haskell.org Thu Mar 3 10:09:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 3 Mar 2016 10:09:32 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: testsuite: Bump haddock.base allocations (ff3f7d0) Message-ID: <20160303100932.8B5C73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/ff3f7d003d4860a36a8f2b1198a74422fa138e7c/ghc >--------------------------------------------------------------- commit ff3f7d003d4860a36a8f2b1198a74422fa138e7c Author: Ben Gamari Date: Wed Mar 2 23:06:04 2016 +0100 testsuite: Bump haddock.base allocations >--------------------------------------------------------------- ff3f7d003d4860a36a8f2b1198a74422fa138e7c testsuite/tests/perf/haddock/all.T | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/perf/haddock/all.T b/testsuite/tests/perf/haddock/all.T index 5a99333..e2787d6 100644 --- a/testsuite/tests/perf/haddock/all.T +++ b/testsuite/tests/perf/haddock/all.T @@ -5,7 +5,7 @@ test('haddock.base', [unless(in_tree_compiler(), skip), req_haddock ,stats_num_field('bytes allocated', - [(wordsize(64), 27812188000, 5) + [(wordsize(64), 31112113880, 5) # 2012-08-14: 5920822352 (amd64/Linux) # 2012-09-20: 5829972376 (amd64/Linux) # 2012-10-08: 5902601224 (amd64/Linux) @@ -28,6 +28,7 @@ test('haddock.base', # 2015-12-11: 11119767632 (amd64/Linux) - TypeInType (see #11196) # 2015-12-17: 26282821104 (x86_64/Linux) - Update Haddock to master # 2015-12-17: 27812188000 (x86_64/Linux) - Move Data.Functor.* into base + # 2015-03-02: 31112113880 (x86_64/Linux) - More creep ,(platform('i386-unknown-mingw32'), 4434804940, 5) # 2013-02-10: 3358693084 (x86/Windows) From git at git.haskell.org Thu Mar 3 10:09:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 3 Mar 2016 10:09:35 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix an outright bug in expandTypeSynonyms (3fc2336) Message-ID: <20160303100935.524F83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/3fc233641d69c0f12fd2b782ccddf22bf2a652c0/ghc >--------------------------------------------------------------- commit 3fc233641d69c0f12fd2b782ccddf22bf2a652c0 Author: Simon Peyton Jones Date: Wed Mar 2 15:12:12 2016 +0000 Fix an outright bug in expandTypeSynonyms The bug was in this code: go subst (TyConApp tc tys) | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys = let subst' = unionTCvSubst subst (mkTvSubstPrs tenv) in go subst' (mkAppTys rhs tys') This is wrong in two ways. * It is wrong to apply the expanded substitution to tys', * The unionTCvSubst is utterly wrong; after all, rhs is completely separate, and the union makes a non-idempotent substitution. It was the non-idempotency that gave the Lint failure in Trac #11665, when there was a type synonym whose RHS mentioned another type synonym, something like type T a b = a -> b type S x y = T y x It only affects SpecConstr because that's about the only place where expandTypeSyonym is called. I tried to trigger the failure with a simple test case, but failed, so I have not added a regression test. Fortunately the solution is very simple and solid. FWIW, the culprit was 674654, "Add kind equalities to GHC". (cherry picked from commit 286dc021ef515d02453cd5e31774b852d3a1310f) >--------------------------------------------------------------- 3fc233641d69c0f12fd2b782ccddf22bf2a652c0 compiler/types/Type.hs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 07b20c6..ef24be3 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -328,14 +328,26 @@ expandTypeSynonyms :: Type -> Type -- 'expandTypeSynonyms' only expands out type synonyms mentioned in the type, -- not in the kinds of any TyCon or TyVar mentioned in the type. expandTypeSynonyms ty - = go (mkEmptyTCvSubst (mkTyCoInScopeSet [ty] [])) ty + = go (mkEmptyTCvSubst in_scope) ty where + in_scope = mkInScopeSet (tyCoVarsOfType ty) + go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys - = let subst' = unionTCvSubst subst (mkTvSubstPrs tenv) in - go subst' (mkAppTys rhs tys') + | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + = let subst' = mkTvSubst in_scope (mkVarEnv tenv) + -- Make a fresh substitution; rhs has nothing to + -- do with anything that has happened so far + -- NB: if you make changes here, be sure to build an + -- /idempotent/ substitution, even in the nested case + -- type T a b = a -> b + -- type S x y = T y x + -- (Trac #11665) + in mkAppTys (go subst' rhs) tys' | otherwise - = TyConApp tc (map (go subst) tys) + = TyConApp tc expanded_tys + where + expanded_tys = (map (go subst) tys) + go _ (LitTy l) = LitTy l go subst (TyVarTy tv) = substTyVar subst tv go subst (AppTy t1 t2) = mkAppTy (go subst t1) (go subst t2) From git at git.haskell.org Thu Mar 3 10:09:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 3 Mar 2016 10:09:38 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Define mkTvSubst, and use it (dedff08) Message-ID: <20160303100938.2A5713A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/dedff088136aab9a992e648d0444b34768b5d561/ghc >--------------------------------------------------------------- commit dedff088136aab9a992e648d0444b34768b5d561 Author: Simon Peyton Jones Date: Mon Feb 8 17:36:52 2016 +0000 Define mkTvSubst, and use it mkTvSubst :: InScopeSet -> TvSubstEnv -> TCvSubst produces a TCvSubst with an empty CvSubstEnv (cherry picked from commit fac0efc3f7a583a3b5b903b5c78e4f8455e95e17) >--------------------------------------------------------------- dedff088136aab9a992e648d0444b34768b5d561 compiler/typecheck/TcDeriv.hs | 4 +--- compiler/typecheck/TcGenDeriv.hs | 6 ++---- compiler/typecheck/TcInstDcls.hs | 4 +--- compiler/typecheck/TcType.hs | 2 +- compiler/types/FamInstEnv.hs | 3 +-- compiler/types/TyCoRep.hs | 16 +++++++++++----- compiler/types/Unify.hs | 18 ++++++++---------- 7 files changed, 25 insertions(+), 28 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc dedff088136aab9a992e648d0444b34768b5d561 From git at git.haskell.org Sat Mar 5 20:15:15 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:15 +0000 (UTC) Subject: [commit: ghc] master: Add Monoid instance for FastString (91a6a9c) Message-ID: <20160305201515.CCDBB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/91a6a9cb94172a4c2235e6b2f9001df982bed4cc/ghc >--------------------------------------------------------------- commit 91a6a9cb94172a4c2235e6b2f9001df982bed4cc Author: Ben Gamari Date: Fri Mar 4 22:48:50 2016 +0100 Add Monoid instance for FastString >--------------------------------------------------------------- 91a6a9cb94172a4c2235e6b2f9001df982bed4cc compiler/utils/FastString.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs index ea95d84..27bb510 100644 --- a/compiler/utils/FastString.hs +++ b/compiler/utils/FastString.hs @@ -192,6 +192,10 @@ instance Ord FastString where | otherwise = y compare a b = cmpFS a b +instance Monoid FastString where + mempty = nilFS + mappend = appendFS + instance Show FastString where show fs = show (unpackFS fs) From git at git.haskell.org Sat Mar 5 20:15:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:18 +0000 (UTC) Subject: [commit: ghc] master: SimplEnv: Add Haddock headings to export list (15517f3) Message-ID: <20160305201518.7E5813A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/15517f3c4444e5bf5cb3da1bf909c2d418eaf741/ghc >--------------------------------------------------------------- commit 15517f3c4444e5bf5cb3da1bf909c2d418eaf741 Author: Ben Gamari Date: Fri Mar 4 23:15:34 2016 +0100 SimplEnv: Add Haddock headings to export list >--------------------------------------------------------------- 15517f3c4444e5bf5cb3da1bf909c2d418eaf741 compiler/simplCore/SimplEnv.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/simplCore/SimplEnv.hs b/compiler/simplCore/SimplEnv.hs index 53fe9f4..da82943 100644 --- a/compiler/simplCore/SimplEnv.hs +++ b/compiler/simplCore/SimplEnv.hs @@ -7,14 +7,15 @@ {-# LANGUAGE CPP #-} module SimplEnv ( + -- * Basic types InId, InBind, InExpr, InAlt, InArg, InType, InBndr, InVar, OutId, OutTyVar, OutBind, OutExpr, OutAlt, OutArg, OutType, OutBndr, OutVar, InCoercion, OutCoercion, - -- The simplifier mode + -- * The simplifier mode setMode, getMode, updMode, - -- Environments + -- * Environments SimplEnv(..), StaticEnv, pprSimplEnv, -- Temp not abstract mkSimplEnv, extendIdSubst, SimplEnv.extendTvSubst, SimplEnv.extendCvSubst, @@ -22,14 +23,16 @@ module SimplEnv ( getInScope, setInScope, setInScopeSet, modifyInScope, addNewInScopeIds, getSimplRules, + -- * Substitution results SimplSR(..), mkContEx, substId, lookupRecBndr, refineFromInScope, + -- * Simplifying 'Id' binders simplNonRecBndr, simplRecBndrs, simplBinder, simplBinders, substTy, substTyVar, getTCvSubst, substCo, substCoVar, - -- Floats + -- * Floats Floats, emptyFloats, isEmptyFloats, addNonRec, addFloats, extendFloats, wrapFloats, setFloats, zapFloats, addRecFloats, mapFloats, doFloatFromRhs, getFloatBinds @@ -38,7 +41,7 @@ module SimplEnv ( #include "HsVersions.h" import SimplMonad -import CoreMonad ( SimplifierMode(..) ) +import CoreMonad ( SimplifierMode(..) ) import CoreSyn import CoreUtils import Var @@ -139,6 +142,7 @@ pprSimplEnv env type SimplIdSubst = IdEnv SimplSR -- IdId |--> OutExpr -- See Note [Extending the Subst] in CoreSubst +-- | A substitution result. data SimplSR = DoneEx OutExpr -- Completed term | DoneId OutId -- Completed term variable From git at git.haskell.org Sat Mar 5 20:15:21 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:21 +0000 (UTC) Subject: [commit: ghc] master: users-guide: Mention #11558 in release notes (1f3d953) Message-ID: <20160305201521.3C7C53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1f3d953e97f3c107f76d992bd087ed91f72d24e1/ghc >--------------------------------------------------------------- commit 1f3d953e97f3c107f76d992bd087ed91f72d24e1 Author: Ben Gamari Date: Sat Mar 5 16:26:33 2016 +0100 users-guide: Mention #11558 in release notes >--------------------------------------------------------------- 1f3d953e97f3c107f76d992bd087ed91f72d24e1 docs/users_guide/8.0.1-notes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst index 17c15ac..b9d7472 100644 --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -10,8 +10,8 @@ performance improvements over the 7.10 branch. .. warning:: Only Cabal versions 1.24 and newer will function properly with this release. - Consequently it will likely be necessary to recompile ``cabal-install`` - before installing new packages. + (see :ghc-ticket:`11558`). Consequently it will likely be necessary to + recompile ``cabal-install`` before installing new packages. The reason for this is a change in how packages are identified in GHC 8.0. While previous versions of Cabal identified packages to GHC with a From git at git.haskell.org Sat Mar 5 20:15:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:23 +0000 (UTC) Subject: [commit: ghc] master: rts/timer: use timerfd_* on Linux instead of alarm signals (120b9cd) Message-ID: <20160305201523.E94433A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/120b9cdb31878ecee442c0a4bb9532a9d30c0c64/ghc >--------------------------------------------------------------- commit 120b9cdb31878ecee442c0a4bb9532a9d30c0c64 Author: Sylvain HENRY Date: Sat Mar 5 20:00:06 2016 +0100 rts/timer: use timerfd_* on Linux instead of alarm signals Reviewers: erikd, simonmar, austin, bgamari Reviewed By: simonmar, bgamari Subscribers: hvr, thomie Differential Revision: https://phabricator.haskell.org/D1947 GHC Trac Issues: #10840 >--------------------------------------------------------------- 120b9cdb31878ecee442c0a4bb9532a9d30c0c64 configure.ac | 2 +- rts/posix/Itimer.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 81 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index cc162e7..adc22dd 100644 --- a/configure.ac +++ b/configure.ac @@ -766,7 +766,7 @@ dnl off_t, because it will affect the result of that test. AC_SYS_LARGEFILE dnl ** check for specific header (.h) files that we are interested in -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h]) +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h]) dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708 AC_CHECK_HEADERS([sys/cpuset.h], [], [], diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index 57c7741..f6c00a6 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -53,6 +53,31 @@ #define USE_PTHREAD_FOR_ITIMER #endif +/* + * On Linux in the threaded RTS we can use timerfd_* (introduced in Linux + * 2.6.25) and a thread instead of alarm signals. It avoids the risk of + * interrupting syscalls (see #10840) and the risk of being accidentally + * modified in user code using signals. + */ +#if defined(linux_HOST_OS) && defined(THREADED_RTS) && HAVE_SYS_TIMERFD_H +#include +#include +#define USE_PTHREAD_FOR_ITIMER +#define USE_TIMERFD_FOR_ITIMER 1 +#undef USE_TIMER_CREATE +#else +#define USE_TIMERFD_FOR_ITIMER 0 +#endif + +/* + * TFD_CLOEXEC has been added in Linux 2.6.26. + * If it is not available, we use fcntl(F_SETFD). + */ +#ifndef TFD_CLOEXEC +#define TFD_CLOEXEC 0 +#endif + + #if defined(USE_PTHREAD_FOR_ITIMER) #include #include @@ -150,15 +175,50 @@ static void install_vtalrm_handler(TickProc handle_tick) #endif #if defined(USE_PTHREAD_FOR_ITIMER) -static volatile int itimer_enabled; +enum ItimerState {STOPPED, RUNNING, STOPPING, EXITED}; +static volatile enum ItimerState itimer_state = STOPPED; static void *itimer_thread_func(void *_handle_tick) { TickProc handle_tick = _handle_tick; + uint64_t nticks; + int timerfd = -1; + +#if USE_TIMERFD_FOR_ITIMER + struct itimerspec it; + it.it_value.tv_sec = TimeToSeconds(itimer_interval); + it.it_value.tv_nsec = TimeToNS(itimer_interval) % 1000000000; + it.it_interval = it.it_value; + + timerfd = timerfd_create(CLOCK_MONOTONIC,TFD_CLOEXEC); + if (timerfd == -1) { + sysErrorBelch("timerfd_create"); + stg_exit(EXIT_FAILURE); + } + if (!TFD_CLOEXEC) { + fcntl(timerfd, F_SETFD, FD_CLOEXEC); + } + timerfd_settime(timerfd,0,&it,NULL); +#endif + while (1) { - usleep(TimeToUS(itimer_interval)); - switch (itimer_enabled) { - case 1: handle_tick(0); break; - case 2: itimer_enabled = 0; + if (USE_TIMERFD_FOR_ITIMER) { + read(timerfd, &nticks, sizeof(nticks)); + } else { + usleep(TimeToUS(itimer_interval)); + } + switch (itimer_state) { + case RUNNING: + handle_tick(0); + break; + case STOPPED: + break; + case STOPPING: + itimer_state = STOPPED; + break; + case EXITED: + if (USE_TIMERFD_FOR_ITIMER) + close(timerfd); + return NULL; } } return NULL; @@ -172,7 +232,13 @@ initTicker (Time interval, TickProc handle_tick) #if defined(USE_PTHREAD_FOR_ITIMER) pthread_t tid; - pthread_create(&tid, NULL, itimer_thread_func, (void*)handle_tick); + int r = pthread_create(&tid, NULL, itimer_thread_func, (void*)handle_tick); + if (!r) { + pthread_detach(tid); +#if HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(tid, "ghc_ticker"); +#endif + } #elif defined(USE_TIMER_CREATE) { struct sigevent ev; @@ -198,7 +264,7 @@ void startTicker(void) { #if defined(USE_PTHREAD_FOR_ITIMER) - itimer_enabled = 1; + itimer_state = RUNNING; #elif defined(USE_TIMER_CREATE) { struct itimerspec it; @@ -232,10 +298,11 @@ void stopTicker(void) { #if defined(USE_PTHREAD_FOR_ITIMER) - if (itimer_enabled == 1) { - itimer_enabled = 2; + if (itimer_state == RUNNING) { + itimer_state = STOPPING; /* Wait for the thread to confirm it won't generate another tick. */ - while (itimer_enabled != 0) + write_barrier(); + while (itimer_state != STOPPED) sched_yield(); } #elif defined(USE_TIMER_CREATE) @@ -266,7 +333,9 @@ stopTicker(void) void exitTicker (rtsBool wait STG_UNUSED) { -#if defined(USE_TIMER_CREATE) +#if defined(USE_PTHREAD_FOR_ITIMER) + itimer_state = EXITED; +#elif defined(USE_TIMER_CREATE) // Before deleting the timer set the signal to ignore to avoid the // possibility of the signal being delivered after the timer is deleted. signal(ITIMER_SIGNAL, SIG_IGN); From git at git.haskell.org Sat Mar 5 20:15:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:27 +0000 (UTC) Subject: [commit: ghc] master: GHCi: Fix load/reload space leaks (#4029) (6ca9b15) Message-ID: <20160305201527.90A893A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/6ca9b15f77e58931953edb7c872b803cb261fce9/ghc >--------------------------------------------------------------- commit 6ca9b15f77e58931953edb7c872b803cb261fce9 Author: Jason Eisenberg Date: Sat Mar 5 20:00:38 2016 +0100 GHCi: Fix load/reload space leaks (#4029) This patch addresses GHCi load/reload space leaks which could be fixed without adversely affecting performance. Test Plan: make test "TEST=T4029" Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D1950 GHC Trac Issues: #4029 >--------------------------------------------------------------- 6ca9b15f77e58931953edb7c872b803cb261fce9 compiler/main/GhcMake.hs | 19 +- compiler/main/InteractiveEval.hs | 4 +- compiler/main/Packages.hs | 12 +- ghc/GHCi/UI.hs | 6 +- testsuite/tests/perf/space_leaks/T4029.script | 335 +++++++++++++++++++++++ testsuite/tests/perf/space_leaks/T4029a.hs | 3 + testsuite/tests/perf/space_leaks/T4029b.hs | 23 ++ testsuite/tests/perf/space_leaks/all.T | 11 + testsuite/tests/rename/should_fail/T11071.stderr | 8 +- 9 files changed, 402 insertions(+), 19 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 6ca9b15f77e58931953edb7c872b803cb261fce9 From git at git.haskell.org Sat Mar 5 20:15:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:30 +0000 (UTC) Subject: [commit: ghc] master: Fix printing of an `IfacePatSyn` (3801262) Message-ID: <20160305201530.CF1993A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3801262e89957a0fceeec0c5683045cf327aac64/ghc >--------------------------------------------------------------- commit 3801262e89957a0fceeec0c5683045cf327aac64 Author: Rik Steenkamp Date: Sat Mar 5 20:01:06 2016 +0100 Fix printing of an `IfacePatSyn` Now the existentially quantified type variables are printed at the correct location when printing a pattern synonym type from an `IfacePatSyn`. The function `pprIfaceContextMaybe` has been removed as it is no longer needed. Fixes #11524. Reviewers: austin, goldfire, thomie, bgamari, mpickering Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1958 GHC Trac Issues: #11524 >--------------------------------------------------------------- 3801262e89957a0fceeec0c5683045cf327aac64 compiler/hsSyn/HsBinds.hs | 12 ------- compiler/iface/IfaceSyn.hs | 24 +++++++------ compiler/iface/IfaceType.hs | 15 ++++---- testsuite/tests/ghci/scripts/T11524a.script | 55 +++++++++++++++++++++++++++++ testsuite/tests/ghci/scripts/T11524a.stdout | 49 +++++++++++++++++++++++++ testsuite/tests/ghci/scripts/all.T | 1 + 6 files changed, 125 insertions(+), 31 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 3801262e89957a0fceeec0c5683045cf327aac64 From git at git.haskell.org Sat Mar 5 20:15:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:33 +0000 (UTC) Subject: [commit: ghc] master: Using unsafe foreign import for rtsSupportsBoundThreads (part of #9696) (1d6177b) Message-ID: <20160305201533.8FC1F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1d6177b133f3a6ac28cc8a679807563cfca3c56a/ghc >--------------------------------------------------------------- commit 1d6177b133f3a6ac28cc8a679807563cfca3c56a Author: Marcin Mrotek Date: Sat Mar 5 20:02:18 2016 +0100 Using unsafe foreign import for rtsSupportsBoundThreads (part of #9696) A safe import is unnecessary considering rtsSupportsBoundThreads simply returns a constant. This commit doesn't fix the main issue of ticket #9696 that "readRawBufferPtr and writeRawBufferPtr allocate memory". Reviewers: bgamari, austin, hvr Reviewed By: hvr Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1964 GHC Trac Issues: #9696 >--------------------------------------------------------------- 1d6177b133f3a6ac28cc8a679807563cfca3c56a libraries/base/Control/Concurrent.hs | 2 +- libraries/base/GHC/ConsoleHandler.hs | 2 +- libraries/base/GHC/IO/FD.hs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs index e047662..535b2f0 100644 --- a/libraries/base/Control/Concurrent.hs +++ b/libraries/base/Control/Concurrent.hs @@ -253,7 +253,7 @@ waiting for the results in the main thread. -- If @rtsSupportsBoundThreads@ is 'False', 'isCurrentThreadBound' -- will always return 'False' and both 'forkOS' and 'runInBoundThread' will -- fail. -foreign import ccall rtsSupportsBoundThreads :: Bool +foreign import ccall unsafe rtsSupportsBoundThreads :: Bool {- | diff --git a/libraries/base/GHC/ConsoleHandler.hs b/libraries/base/GHC/ConsoleHandler.hs index 6d1e36f..8579c22 100644 --- a/libraries/base/GHC/ConsoleHandler.hs +++ b/libraries/base/GHC/ConsoleHandler.hs @@ -137,7 +137,7 @@ installHandler handler no_handler = errorWithoutStackTrace "win32ConsoleHandler" -foreign import ccall "rtsSupportsBoundThreads" threaded :: Bool +foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool foreign import ccall unsafe "RtsExternal.h rts_InstallConsoleEvent" rts_installHandler :: CInt -> Ptr (StablePtr (CInt -> IO ())) -> IO CInt diff --git a/libraries/base/GHC/IO/FD.hs b/libraries/base/GHC/IO/FD.hs index eb7b80b..fb8a1d5 100644 --- a/libraries/base/GHC/IO/FD.hs +++ b/libraries/base/GHC/IO/FD.hs @@ -638,7 +638,7 @@ foreign import WINDOWS_CCONV safe "send" #endif -foreign import ccall "rtsSupportsBoundThreads" threaded :: Bool +foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool -- ----------------------------------------------------------------------------- -- utils From git at git.haskell.org Sat Mar 5 20:15:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 5 Mar 2016 20:15:36 +0000 (UTC) Subject: [commit: ghc] master: Drop module qualifier from punned record fields (#11662) (bd681bc) Message-ID: <20160305201536.DEDD23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/bd681bceba535d0e67e8182964dc167877e4756d/ghc >--------------------------------------------------------------- commit bd681bceba535d0e67e8182964dc167877e4756d Author: Adam Gundry Date: Sat Mar 5 20:02:32 2016 +0100 Drop module qualifier from punned record fields (#11662) A record pattern match, construction or update like `Rec { Mod.f }` should expand to `Rec { Mod.f = f }` rather than `Rec { Mod.f = Mod.f }`. Test Plan: New test rename/should_compile/T11662 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: hesselink, thomie Differential Revision: https://phabricator.haskell.org/D1965 GHC Trac Issues: #11662 >--------------------------------------------------------------- bd681bceba535d0e67e8182964dc167877e4756d compiler/rename/RnPat.hs | 8 ++++++-- testsuite/tests/rename/should_compile/T11662.hs | 14 ++++++++++++++ testsuite/tests/rename/should_compile/T11662_A.hs | 3 +++ testsuite/tests/rename/should_compile/all.T | 4 ++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/compiler/rename/RnPat.hs b/compiler/rename/RnPat.hs index eab3090..98ca38b 100644 --- a/compiler/rename/RnPat.hs +++ b/compiler/rename/RnPat.hs @@ -561,7 +561,9 @@ rnHsRecFields ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot }) = do { sel <- setSrcSpan loc $ lookupRecFieldOcc parent doc lbl ; arg' <- if pun then do { checkErr pun_ok (badPun (L loc lbl)) - ; return (L loc (mk_arg loc lbl)) } + -- Discard any module qualifier (#11662) + ; let arg_rdr = mkRdrUnqual (rdrNameOcc lbl) + ; return (L loc (mk_arg loc arg_rdr)) } else return arg ; return (L l (HsRecField { hsRecFieldLbl = L loc (FieldOcc (L ll lbl) sel) @@ -689,7 +691,9 @@ rnHsRecUpdFields flds else fmap Left $ lookupGlobalOccRn lbl ; arg' <- if pun then do { checkErr pun_ok (badPun (L loc lbl)) - ; return (L loc (HsVar (L loc lbl))) } + -- Discard any module qualifier (#11662) + ; let arg_rdr = mkRdrUnqual (rdrNameOcc lbl) + ; return (L loc (HsVar (L loc arg_rdr))) } else return arg ; (arg'', fvs) <- rnLExpr arg' diff --git a/testsuite/tests/rename/should_compile/T11662.hs b/testsuite/tests/rename/should_compile/T11662.hs new file mode 100644 index 0000000..e9afda0 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T11662.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE NamedFieldPuns #-} +module T11662 where + +import T11662_A (Rec (Rec)) +import qualified T11662_A + +g :: Rec -> Integer +g (Rec { T11662_A.f }) = f + +h :: Integer -> Rec -> Rec +h f r = r { T11662_A.f } + +k :: Integer -> Rec +k f = Rec { T11662_A.f } diff --git a/testsuite/tests/rename/should_compile/T11662_A.hs b/testsuite/tests/rename/should_compile/T11662_A.hs new file mode 100644 index 0000000..1d4f625 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T11662_A.hs @@ -0,0 +1,3 @@ +module T11662_A where + +data Rec = Rec { f :: Integer } diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T index 65f92e2..ede9f19 100644 --- a/testsuite/tests/rename/should_compile/all.T +++ b/testsuite/tests/rename/should_compile/all.T @@ -233,3 +233,7 @@ test('T11164', test('T11167', normal, compile, ['']) test('T11167_ambig', normal, compile, ['']) test('T10625', normal, compile, ['']) +test('T11662', + [extra_clean(['T11662_A.hi', 'T11662_A.o'])], + multimod_compile, + ['T11662', '-v0']) From git at git.haskell.org Sun Mar 6 09:53:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 6 Mar 2016 09:53:33 +0000 (UTC) Subject: [commit: ghc] master: Fix minimum alignment for StgClosure (Trac #11395) (ade1a46) Message-ID: <20160306095333.9C5143A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/ade1a461ab4ba3e6de3c4afe9fe9766b7b4e51b3/ghc >--------------------------------------------------------------- commit ade1a461ab4ba3e6de3c4afe9fe9766b7b4e51b3 Author: Sergei Trofimovich Date: Sun Mar 6 09:55:12 2016 +0000 Fix minimum alignment for StgClosure (Trac #11395) The bug is observed on m68k-linux target as crash in RTS: -- a.hs: main = print 43 $ inplace/bin/ghc-stage1 --make -debug a.hs $ ./a Program terminated with signal SIGSEGV, Segmentation fault. #0 0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858) at includes/rts/storage/ClosureMacros.h:248 (gdb) bt #0 0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858) at includes/rts/storage/ClosureMacros.h:248 #1 0x80463b46 in LOOKS_LIKE_INFO_PTR (p=32858) at includes/rts/storage/ClosureMacros.h:253 #2 0x80463b6c in LOOKS_LIKE_CLOSURE_PTR ( p=0x805aac6e ) at includes/rts/storage/ClosureMacros.h:258 #3 0x80463e4c in initStorage () at rts/sm/Storage.c:121 #4 0x8043ffb4 in hs_init_ghc (...) at rts/RtsStartup.c:181 #5 0x80455982 in hs_main (...) at rts/RtsMain.c:51 #6 0x80003c1c in main () GHC assumes last 2 pointer bits are tags on 32-bit targets. But here 'stg_dummy_ret_closure' address violates the assumption: LOOKS_LIKE_CLOSURE_PTR (p=0x805aac6e ) I've added compiler hint for static StgClosure objects to align closures at least by their natural alignment (what GHC assumes). See Note [StgWord alignment]. Signed-off-by: Sergei Trofimovich Test Plan: ran basic test on m68k qemu, it got past ASSERTs Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1974 GHC Trac Issues: #11395 >--------------------------------------------------------------- ade1a461ab4ba3e6de3c4afe9fe9766b7b4e51b3 compiler/cmm/PprC.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs index e679d55..c269530 100644 --- a/compiler/cmm/PprC.hs +++ b/compiler/cmm/PprC.hs @@ -148,10 +148,34 @@ pprWordArray :: CLabel -> [CmmStatic] -> SDoc pprWordArray lbl ds = sdocWithDynFlags $ \dflags -> hcat [ pprLocalness lbl, text "StgWord" - , space, ppr lbl, text "[] = {" ] + , space, ppr lbl, text "[]" + -- See Note [StgWord alignment] + , pprAlignment (wordWidth dflags) + , text "= {" ] $$ nest 8 (commafy (pprStatics dflags ds)) $$ text "};" +pprAlignment :: Width -> SDoc +pprAlignment words = + text "__attribute__((aligned(" <> int (widthInBytes words) <> text ")))" + +-- Note [StgWord alignment] +-- C codegen builds static closures as StgWord C arrays (pprWordArray). +-- Their real C type is 'StgClosure'. Macros like UNTAG_CLOSURE assume +-- pointers to 'StgClosure' are aligned at pointer size boundary: +-- 4 byte boundary on 32 systems +-- and 8 bytes on 64-bit systems +-- see TAG_MASK and TAG_BITS definition and usage. +-- +-- It's a reasonable assumption also known as natural alignment. +-- Although some architectures have different alignment rules. +-- One of known exceptions is m68k (Trac #11395, comment:16) where: +-- __alignof__(StgWord) == 2, sizeof(StgWord) == 4 +-- +-- Thus we explicitly increase alignment by using +-- __attribute__((aligned(4))) +-- declaration. + -- -- has to be static, if it isn't globally visible -- From git at git.haskell.org Mon Mar 7 21:52:48 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 21:52:48 +0000 (UTC) Subject: [commit: packages/hpc] master: Revert "Testsuite: hpc_fork is failing for some ways" (0741f65) Message-ID: <20160307215248.384393A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/hpc On branch : master Link : http://git.haskell.org/packages/hpc.git/commitdiff/0741f656fdadc14960f55e1970080d4699371055 >--------------------------------------------------------------- commit 0741f656fdadc14960f55e1970080d4699371055 Author: Ben Gamari Date: Mon Mar 7 14:50:18 2016 +0100 Revert "Testsuite: hpc_fork is failing for some ways" This reverts commit 17c3771e42e64ecda8970e8d6bea5c7e7fe1a4d6. As noted in GHC #11643, this is now fixed. >--------------------------------------------------------------- 0741f656fdadc14960f55e1970080d4699371055 tests/fork/test.T | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/fork/test.T b/tests/fork/test.T index 5b27e62..cd8b963 100644 --- a/tests/fork/test.T +++ b/tests/fork/test.T @@ -2,12 +2,6 @@ setTestOpts([omit_ways(['ghci','threaded2']), when(fast(), skip)]) hpc_prefix = "perl ../hpcrun.pl --clear --exeext={exeext} --hpc={hpc}" -failing_ways_for_11645 = \ - [w for w in prof_ways if w not in threaded_ways and w in opt_ways] - -# Skip on Windows, no forkProcess. -test('hpc_fork', - [when(opsys('mingw32'), skip), cmd_prefix(hpc_prefix), - expect_broken_for(11645, failing_ways_for_11645)], - compile_and_run, ['-fhpc']) +test('hpc_fork', [ when(opsys('mingw32'), skip), # no forkProcess on Windows + cmd_prefix(hpc_prefix) ], compile_and_run, ['-fhpc']) From git at git.haskell.org Mon Mar 7 21:54:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 21:54:22 +0000 (UTC) Subject: [commit: ghc] master: GhcMake: Clang/ASSERT fix (5e2605e) Message-ID: <20160307215422.D0F3F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/5e2605e4e740d46014eaf3eb2b2b2e05a43bb8b2/ghc >--------------------------------------------------------------- commit 5e2605e4e740d46014eaf3eb2b2b2e05a43bb8b2 Author: Erik de Castro Lopo Date: Mon Mar 7 14:32:07 2016 +0100 GhcMake: Clang/ASSERT fix Test Plan: Build with clang Reviewers: thomie, rwbarton, austin, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1977 >--------------------------------------------------------------- 5e2605e4e740d46014eaf3eb2b2b2e05a43bb8b2 compiler/main/GhcMake.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs index 6232119..3655c0b 100644 --- a/compiler/main/GhcMake.hs +++ b/compiler/main/GhcMake.hs @@ -367,10 +367,12 @@ load how_much = do liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1 -- there should be no Nothings where linkables should be, now - ASSERT( isNoLink (ghcLink dflags) + let just_linkables = + isNoLink (ghcLink dflags) || all (isJust.hm_linkable) (filter ((== HsSrcFile).mi_hsc_src.hm_iface) - (eltsUFM hpt4))) do + (eltsUFM hpt4)) + ASSERT( just_linkables ) do -- Link everything together linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4 From git at git.haskell.org Mon Mar 7 21:54:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 21:54:25 +0000 (UTC) Subject: [commit: ghc] master: Revert "Mark tests for #11643, #11644, #11645 and #9406 expect_broken" (13a801a) Message-ID: <20160307215425.899EE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/13a801af10289e0931532f7df4a6814b058389f3/ghc >--------------------------------------------------------------- commit 13a801af10289e0931532f7df4a6814b058389f3 Author: Ben Gamari Date: Mon Mar 7 14:49:38 2016 +0100 Revert "Mark tests for #11643, #11644, #11645 and #9406 expect_broken" This reverts commit 90fa8cf2bf1677545c3f4a8bc967b1674822e90a. As noted in #11643, these should be fixed. Updates hpc submodule. >--------------------------------------------------------------- 13a801af10289e0931532f7df4a6814b058389f3 libraries/hpc | 2 +- testsuite/tests/indexed-types/should_compile/all.T | 12 +++++++----- testsuite/tests/rts/all.T | 4 +--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/hpc b/libraries/hpc index 17c3771..0741f65 160000 --- a/libraries/hpc +++ b/libraries/hpc @@ -1 +1 @@ -Subproject commit 17c3771e42e64ecda8970e8d6bea5c7e7fe1a4d6 +Subproject commit 0741f656fdadc14960f55e1970080d4699371055 diff --git a/testsuite/tests/indexed-types/should_compile/all.T b/testsuite/tests/indexed-types/should_compile/all.T index b7223cc..bee76d2 100644 --- a/testsuite/tests/indexed-types/should_compile/all.T +++ b/testsuite/tests/indexed-types/should_compile/all.T @@ -1,3 +1,6 @@ +# Keep optimised tests, so we test coercion optimisation +setTestOpts(omit_ways(['optasm', 'optllvm', 'hpc'])) + test('Simple1', normal, compile, ['']) test('Simple2', normal, compile, ['']) test('Simple3', normal, compile, ['']) @@ -78,13 +81,13 @@ test('Class3', normal, compile, ['']) test('Refl', normal, compile, ['']) test('Refl2', normal, compile, ['']) -test('Rules1', [expect_broken_for(11643, opt_ways)], compile, ['']) +test('Rules1', normal, compile, ['']) test('Numerals', normal, compile, ['']) test('ColInference', normal, compile, ['']) test('ColInference2', normal, compile, ['']) -test('ColInference3', [expect_broken_for(11643, opt_ways)], compile, ['']) +test('ColInference3', normal, compile, ['']) test('ColInference4', normal, compile, ['']) test('ColInference5', normal, compile, ['']) test('ColInference6', normal, compile, ['']) @@ -128,7 +131,7 @@ test('T3208b', normal, compile_fail, ['']) test('T3418', normal, compile, ['']) test('T3423', normal, compile, ['']) test('T2850', normal, compile, ['']) -test('T3220', [expect_broken_for(11644, opt_ways)], compile, ['']) +test('T3220', normal, compile, ['']) test('T3590', normal, compile, ['']) test('CoTest3', normal, compile, ['']) test('Roman1', normal, compile, ['']) @@ -206,8 +209,7 @@ test('T7489', normal, compile, ['']) test('T7585', normal, compile, ['']) test('T7282', normal, compile, ['']) test('T7804', normal, compile, ['']) -test('T7837', expect_broken_for(9406, prof_ways), compile, - ['-O -ddump-rule-firings']) +test('T7837', normal, compile, ['-O -ddump-rule-firings']) test('T4185', normal, compile, ['']) # Caused infinite loop in the compiler diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index b81e0e8..60513ca 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -255,9 +255,7 @@ test('T9045', [ omit_ways(['ghci']), extra_run_opts('10000 +RTS -A8k -RTS') ], c # I couldn't reproduce 9078 with the -threaded runtime, but could easily # with the non-threaded one. -# Skip the prof_ways, because we don't build the 'debug_p' rts way by default. -test('T9078', [omit_ways(threaded_ways + prof_ways)], compile_and_run, - ['-with-rtsopts="-DS" -debug']) +test('T9078', [ omit_ways(threaded_ways) ], compile_and_run, ['-with-rtsopts="-DS" -debug']) test('T10017', [ when(opsys('mingw32'), skip) , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, ['']) From git at git.haskell.org Mon Mar 7 22:17:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 22:17:30 +0000 (UTC) Subject: [commit: ghc] master: Reduce fragmentation from m32_allocator (82e36ed) Message-ID: <20160307221730.B3F0D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/82e36edcbd831e9b7c05e1c2cb918ad5de56cd3a/ghc >--------------------------------------------------------------- commit 82e36edcbd831e9b7c05e1c2cb918ad5de56cd3a Author: Bartosz Nitka Date: Sun Mar 6 13:18:12 2016 -0800 Reduce fragmentation from m32_allocator This patch brings in two improvements: a) m32_allocator will now reuse the pages that are no longer used by anyone else. b) m32_allocator will preallocate the "filling" area, so that the pages it allocates end up as a big chunk instead of being allocated on demand in random places, fragmenting the precious lower 2G address space. Test Plan: testsuite - 3 tests failing with substTy asserts Reviewers: ezyang, austin, bgamari, erikd, hsyl20, simonmar Reviewed By: hsyl20, simonmar Subscribers: hvr, thomie Differential Revision: https://phabricator.haskell.org/D1976 >--------------------------------------------------------------- 82e36edcbd831e9b7c05e1c2cb918ad5de56cd3a rts/Linker.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/rts/Linker.c b/rts/Linker.c index c7c61cf..be48484 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -281,6 +281,7 @@ struct m32_alloc_t { }; #define M32_MAX_PAGES 32 +#define M32_REFCOUNT_BYTES 8 /** * Allocator @@ -1460,6 +1461,16 @@ static void munmapForLinker (void * addr, size_t size) */ static void m32_allocator_init(m32_allocator m32) { memset(m32, 0, sizeof(struct m32_allocator_t)); + // Preallocate the initial M32_MAX_PAGES to ensure that they don't + // fragment the memory. + unsigned int pgsz = (unsigned int)getPageSize(); + char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0); + int i; + for (i=0; ipages[i].base_addr = bigchunk + i*pgsz; + *((uintptr_t*)m32->pages[i].base_addr) = 1; + m32->pages[i].current_size = M32_REFCOUNT_BYTES; + } } /** @@ -1493,7 +1504,7 @@ static void m32_allocator_flush(m32_allocator m32) { // Return true if the object has its own dedicated set of pages #define m32_is_large_object(size,alignment) \ - (size >= getPageSize() - ROUND_UP(8,alignment)) + (size >= getPageSize() - ROUND_UP(M32_REFCOUNT_BYTES,alignment)) // Return true if the object has its own dedicated set of pages #define m32_is_large_object_addr(addr) \ @@ -1544,6 +1555,14 @@ m32_alloc(m32_allocator m32, unsigned int size, empty = empty == -1 ? i : empty; continue; } + // If the page is referenced only by the allocator, we can reuse it. + // If we don't then we'll be left with a bunch of pages that have a + // few bytes left to allocate and we don't get to use or free them + // until we use up all the "filling" pages. This will unnecessarily + // allocate new pages and fragment the address space. + if (*((uintptr_t*)(m32->pages[i].base_addr)) == 1) { + m32->pages[i].current_size = M32_REFCOUNT_BYTES; + } // page can contain the buffer? unsigned int alsize = ROUND_UP(m32->pages[i].current_size, alignment); if (size <= pgsz - alsize) { @@ -1575,12 +1594,13 @@ m32_alloc(m32_allocator m32, unsigned int size, return NULL; } m32->pages[empty].base_addr = addr; - // Add 8 bytes for the counter + padding - m32->pages[empty].current_size = size+ROUND_UP(8,alignment); + // Add M32_REFCOUNT_BYTES bytes for the counter + padding + m32->pages[empty].current_size = + size+ROUND_UP(M32_REFCOUNT_BYTES,alignment); // Initialize the counter: // 1 for the allocator + 1 for the returned allocated memory *((uintptr_t*)addr) = 2; - return (char*)addr + ROUND_UP(8,alignment); + return (char*)addr + ROUND_UP(M32_REFCOUNT_BYTES,alignment); } } From git at git.haskell.org Mon Mar 7 22:46:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 22:46:01 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users-guide: Mention #11558 in release notes (af7a35f) Message-ID: <20160307224601.E68383A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/af7a35f912988cc2e45569905e06e4db7f4319d5/ghc >--------------------------------------------------------------- commit af7a35f912988cc2e45569905e06e4db7f4319d5 Author: Ben Gamari Date: Sat Mar 5 16:26:33 2016 +0100 users-guide: Mention #11558 in release notes (cherry picked from commit 1f3d953e97f3c107f76d992bd087ed91f72d24e1) >--------------------------------------------------------------- af7a35f912988cc2e45569905e06e4db7f4319d5 docs/users_guide/8.0.1-notes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst index c240f29..df12e8a 100644 --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -10,8 +10,8 @@ performance improvements over the 7.10 branch. .. warning:: Only Cabal versions 1.24 and newer will function properly with this release. - Consequently it will likely be necessary to recompile ``cabal-install`` - before installing new packages. + (see :ghc-ticket:`11558`). Consequently it will likely be necessary to + recompile ``cabal-install`` before installing new packages. The reason for this is a change in how packages are identified in GHC 8.0. While previous versions of Cabal identified packages to GHC with a From git at git.haskell.org Mon Mar 7 22:46:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 22:46:05 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: GHCi: Fix load/reload space leaks (#4029) (6ae616f) Message-ID: <20160307224605.81C643A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6ae616f5be1db6da8bc0c5e36736a76cfea46844/ghc >--------------------------------------------------------------- commit 6ae616f5be1db6da8bc0c5e36736a76cfea46844 Author: Jason Eisenberg Date: Sat Mar 5 20:00:38 2016 +0100 GHCi: Fix load/reload space leaks (#4029) This patch addresses GHCi load/reload space leaks which could be fixed without adversely affecting performance. Test Plan: make test "TEST=T4029" Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D1950 GHC Trac Issues: #4029 (cherry picked from commit 6ca9b15f77e58931953edb7c872b803cb261fce9) >--------------------------------------------------------------- 6ae616f5be1db6da8bc0c5e36736a76cfea46844 compiler/main/GhcMake.hs | 19 +- compiler/main/InteractiveEval.hs | 4 +- compiler/main/Packages.hs | 12 +- ghc/GHCi/UI.hs | 6 +- testsuite/tests/perf/space_leaks/T4029.script | 335 +++++++++++++++++++++++ testsuite/tests/perf/space_leaks/T4029a.hs | 3 + testsuite/tests/perf/space_leaks/T4029b.hs | 23 ++ testsuite/tests/perf/space_leaks/all.T | 11 + testsuite/tests/rename/should_fail/T11071.stderr | 8 +- 9 files changed, 402 insertions(+), 19 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 6ae616f5be1db6da8bc0c5e36736a76cfea46844 From git at git.haskell.org Mon Mar 7 22:46:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 22:46:08 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix printing of an `IfacePatSyn` (37310ef) Message-ID: <20160307224608.BC2063A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/37310efa53e5c341d2b525c4f3a62696fb64caab/ghc >--------------------------------------------------------------- commit 37310efa53e5c341d2b525c4f3a62696fb64caab Author: Rik Steenkamp Date: Sat Mar 5 20:01:06 2016 +0100 Fix printing of an `IfacePatSyn` Now the existentially quantified type variables are printed at the correct location when printing a pattern synonym type from an `IfacePatSyn`. The function `pprIfaceContextMaybe` has been removed as it is no longer needed. Fixes #11524. Reviewers: austin, goldfire, thomie, bgamari, mpickering Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1958 GHC Trac Issues: #11524 (cherry picked from commit 3801262e89957a0fceeec0c5683045cf327aac64) >--------------------------------------------------------------- 37310efa53e5c341d2b525c4f3a62696fb64caab compiler/hsSyn/HsBinds.hs | 12 ------- compiler/iface/IfaceSyn.hs | 24 +++++++------ compiler/iface/IfaceType.hs | 15 ++++---- testsuite/tests/ghci/scripts/T11524a.script | 55 +++++++++++++++++++++++++++++ testsuite/tests/ghci/scripts/T11524a.stdout | 49 +++++++++++++++++++++++++ testsuite/tests/ghci/scripts/all.T | 1 + 6 files changed, 125 insertions(+), 31 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 37310efa53e5c341d2b525c4f3a62696fb64caab From git at git.haskell.org Mon Mar 7 22:46:12 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 7 Mar 2016 22:46:12 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Drop module qualifier from punned record fields (#11662) (40d08b6) Message-ID: <20160307224612.334F13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/40d08b6286468ba1418cd19ed8d37c1650711049/ghc >--------------------------------------------------------------- commit 40d08b6286468ba1418cd19ed8d37c1650711049 Author: Adam Gundry Date: Sat Mar 5 20:02:32 2016 +0100 Drop module qualifier from punned record fields (#11662) A record pattern match, construction or update like `Rec { Mod.f }` should expand to `Rec { Mod.f = f }` rather than `Rec { Mod.f = Mod.f }`. Test Plan: New test rename/should_compile/T11662 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: hesselink, thomie Differential Revision: https://phabricator.haskell.org/D1965 GHC Trac Issues: #11662 (cherry picked from commit bd681bceba535d0e67e8182964dc167877e4756d) >--------------------------------------------------------------- 40d08b6286468ba1418cd19ed8d37c1650711049 compiler/rename/RnPat.hs | 8 ++++++-- testsuite/tests/rename/should_compile/T11662.hs | 14 ++++++++++++++ testsuite/tests/rename/should_compile/T11662_A.hs | 3 +++ testsuite/tests/rename/should_compile/all.T | 4 ++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/compiler/rename/RnPat.hs b/compiler/rename/RnPat.hs index 460954d..51ddea9 100644 --- a/compiler/rename/RnPat.hs +++ b/compiler/rename/RnPat.hs @@ -562,7 +562,9 @@ rnHsRecFields ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot }) = do { sel <- setSrcSpan loc $ lookupRecFieldOcc parent doc lbl ; arg' <- if pun then do { checkErr pun_ok (badPun (L loc lbl)) - ; return (L loc (mk_arg loc lbl)) } + -- Discard any module qualifier (#11662) + ; let arg_rdr = mkRdrUnqual (rdrNameOcc lbl) + ; return (L loc (mk_arg loc arg_rdr)) } else return arg ; return (L l (HsRecField { hsRecFieldLbl = L loc (FieldOcc (L ll lbl) sel) @@ -690,7 +692,9 @@ rnHsRecUpdFields flds else fmap Left $ lookupGlobalOccRn lbl ; arg' <- if pun then do { checkErr pun_ok (badPun (L loc lbl)) - ; return (L loc (HsVar (L loc lbl))) } + -- Discard any module qualifier (#11662) + ; let arg_rdr = mkRdrUnqual (rdrNameOcc lbl) + ; return (L loc (HsVar (L loc arg_rdr))) } else return arg ; (arg'', fvs) <- rnLExpr arg' diff --git a/testsuite/tests/rename/should_compile/T11662.hs b/testsuite/tests/rename/should_compile/T11662.hs new file mode 100644 index 0000000..e9afda0 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T11662.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE NamedFieldPuns #-} +module T11662 where + +import T11662_A (Rec (Rec)) +import qualified T11662_A + +g :: Rec -> Integer +g (Rec { T11662_A.f }) = f + +h :: Integer -> Rec -> Rec +h f r = r { T11662_A.f } + +k :: Integer -> Rec +k f = Rec { T11662_A.f } diff --git a/testsuite/tests/rename/should_compile/T11662_A.hs b/testsuite/tests/rename/should_compile/T11662_A.hs new file mode 100644 index 0000000..1d4f625 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T11662_A.hs @@ -0,0 +1,3 @@ +module T11662_A where + +data Rec = Rec { f :: Integer } diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T index 8c120cd..31495af 100644 --- a/testsuite/tests/rename/should_compile/all.T +++ b/testsuite/tests/rename/should_compile/all.T @@ -232,3 +232,7 @@ test('T11164', multimod_compile, ['T11164', '-v0']) test('T11167', normal, compile, ['']) test('T11167_ambig', normal, compile, ['']) +test('T11662', + [extra_clean(['T11662_A.hi', 'T11662_A.o'])], + multimod_compile, + ['T11662', '-v0']) From git at git.haskell.org Tue Mar 8 08:12:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 08:12:59 +0000 (UTC) Subject: [commit: ghc] master: Split external symbol prototypes (EF_) (Trac #11395) (90e1e16) Message-ID: <20160308081259.AA6F13A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/90e1e160b783644c2d3cc0a05e3a804cea549cf9/ghc >--------------------------------------------------------------- commit 90e1e160b783644c2d3cc0a05e3a804cea549cf9 Author: Sergei Trofimovich Date: Tue Mar 8 08:14:08 2016 +0000 Split external symbol prototypes (EF_) (Trac #11395) Before the patch both Cmm and C symbols were declared with 'EF_' macro: #define EF_(f) extern StgFunPtr f() but for Cmm symbols we know exact prototypes. The patch splits there prototypes in to: #define EFF_(f) void f() /* See Note [External function prototypes] */ #define EF_(f) StgFunPtr f(void) Cmm functions are 'EF_' (External Functions), C functions are 'EFF_' (External Foreign Functions). While at it changed external C function prototype to return 'void' to workaround ghc bug on m68k. Described in detail in Trac #11395. This makes simple tests work on m68k-linux target! Thanks to Michael Karcher for awesome analysis happening in Trac #11395. Signed-off-by: Sergei Trofimovich Test Plan: ran "hello world" on m68k successfully Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1975 GHC Trac Issues: #11395 >--------------------------------------------------------------- 90e1e160b783644c2d3cc0a05e3a804cea549cf9 compiler/cmm/CLabel.hs | 8 +++++++- compiler/cmm/PprC.hs | 5 +++-- includes/Stg.h | 20 +++++++++++++++++--- includes/stg/MiscClosures.h | 15 +++++++++++++-- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs index 9304d66..15c5ff3 100644 --- a/compiler/cmm/CLabel.hs +++ b/compiler/cmm/CLabel.hs @@ -88,8 +88,9 @@ module CLabel ( mkForeignLabel, addLabelSize, - foreignLabelStdcallInfo, + foreignLabelStdcallInfo, + isForeignLabel, mkCCLabel, mkCCSLabel, DynamicLinkerLabelInfo(..), @@ -492,6 +493,11 @@ addLabelSize (ForeignLabel str _ src fod) sz addLabelSize label _ = label +-- | Whether label is a non-haskell label (defined in C code) +isForeignLabel :: CLabel -> Bool +isForeignLabel (ForeignLabel _ _ _ _) = True +isForeignLabel _lbl = False + -- | Get the label size field from a ForeignLabel foreignLabelStdcallInfo :: CLabel -> Maybe Int foreignLabelStdcallInfo (ForeignLabel _ info _ _) = info diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs index c269530..673ac2d 100644 --- a/compiler/cmm/PprC.hs +++ b/compiler/cmm/PprC.hs @@ -264,7 +264,7 @@ pprStmt stmt = -- We also need to cast mem primops to prevent conflicts with GCC -- builtins (see bug #5967). | Just _align <- machOpMemcpyishAlign op - = (text ";EF_(" <> fn <> char ')' <> semi) $$ + = (text ";EFF_(" <> fn <> char ')' <> semi) $$ pprForeignCall fn cconv hresults hargs | otherwise = pprCall fn cconv hresults hargs @@ -1005,7 +1005,8 @@ pprExternDecl _in_srt lbl hcat [ visibility, label_type lbl, lparen, ppr lbl, text ");" ] where - label_type lbl | isCFunctionLabel lbl = text "F_" + label_type lbl | isForeignLabel lbl && isCFunctionLabel lbl = text "FF_" + | isCFunctionLabel lbl = text "F_" | otherwise = text "I_" visibility diff --git a/includes/Stg.h b/includes/Stg.h index 899e685..a8ab5ca 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -222,11 +222,21 @@ typedef StgFunPtr F_; #define II_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) #define IF_(f) static StgFunPtr GNUC3_ATTRIBUTE(used) f(void) #define FN_(f) StgFunPtr f(void) -#define EF_(f) extern StgFunPtr f() /* See Note [External function prototypes] */ +#define EF_(f) StgFunPtr f(void) /* External Cmm functions */ +#define EFF_(f) void f() /* See Note [External function prototypes] */ -/* Note [External function prototypes] See Trac #8965 +/* Note [External function prototypes] See Trac #8965, #11395 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The external-function macro EF_(F) used to be defined as +In generated C code we need to distinct between two types +of external symbols: +1. Cmm functions declared by 'EF_' macro (External Functions) +2. C functions declared by 'EFF_' macro (External Foreign Functions) + +Cmm functions are simple as they are internal to GHC. + +C functions are trickier: + +The external-function macro EFF_(F) used to be defined as extern StgFunPtr f(void) i.e a function of zero arguments. On most platforms this doesn't matter very much: calls to these functions put the parameters in the @@ -249,6 +259,10 @@ unspecified argument list rather than a void argument list. This is no worse for platforms that don't care either way, and allows a successful bootstrap of GHC 7.8 on little-endian Linux ppc64 (which uses the ELFv2 ABI). + +Another case is m68k ABI where 'void*' return type is returned by 'a0' +register while 'long' return type is returned by 'd0'. Thus we trick +external prototype return neither of these types to workaround #11395. */ diff --git a/includes/stg/MiscClosures.h b/includes/stg/MiscClosures.h index 5f5e0d6..3fd4128 100644 --- a/includes/stg/MiscClosures.h +++ b/includes/stg/MiscClosures.h @@ -490,8 +490,19 @@ extern StgWord RTS_VAR(CCS_LIST); /* registered CCS list */ extern StgWord CCS_SYSTEM[]; extern unsigned int RTS_VAR(CC_ID); /* global ids */ extern unsigned int RTS_VAR(CCS_ID); -RTS_FUN_DECL(enterFunCCS); -RTS_FUN_DECL(pushCostCentre); + +// Calls to these rts functions are generated directly +// by codegen (see compiler/codeGen/StgCmmProf.hs) +// and don't require (don't emit) forward declarations. +// +// In unregisterised mode (when building via .hc files) +// the calls are ordinary C calls. Functions must be in +// scope and must match prototype assumed by +// 'compiler/codeGen/StgCmmProf.hs' +// as opposed to real prototype declared in +// 'includes/rts/prof/CCS.h' +void enterFunCCS (void *reg, void *ccsfn); +void * pushCostCentre (void *ccs, void *cc); // Capability.c extern unsigned int n_capabilities; From git at git.haskell.org Tue Mar 8 11:49:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 11:49:20 +0000 (UTC) Subject: [commit: ghc] master: template-haskell: Drop use of Rank2Types/PolymorphicComponents (1a9734a) Message-ID: <20160308114920.292FC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1a9734a69260e69943c00755952edd7185dcc484/ghc >--------------------------------------------------------------- commit 1a9734a69260e69943c00755952edd7185dcc484 Author: Herbert Valerio Riedel Date: Tue Mar 8 12:42:32 2016 +0100 template-haskell: Drop use of Rank2Types/PolymorphicComponents As per #6032, `Rank2Types` and `PolymorphicComponents` have been deprecated in favour of `RankNTypes`. also update `other-extensions` in template-haskell.cabal flag to reflect reality. >--------------------------------------------------------------- 1a9734a69260e69943c00755952edd7185dcc484 libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 5 ++--- libraries/template-haskell/template-haskell.cabal | 10 ++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index a3284c5..86242aa 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -1,8 +1,7 @@ -{-# LANGUAGE CPP, DeriveDataTypeable, PolymorphicComponents, +{-# LANGUAGE CPP, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, DefaultSignatures, - ScopedTypeVariables, Rank2Types #-} + RankNTypes, RoleAnnotations, ScopedTypeVariables #-} -{-# LANGUAGE RoleAnnotations #-} {-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} #if MIN_VERSION_base(4,8,0) diff --git a/libraries/template-haskell/template-haskell.cabal b/libraries/template-haskell/template-haskell.cabal index b96e122..7241708 100644 --- a/libraries/template-haskell/template-haskell.cabal +++ b/libraries/template-haskell/template-haskell.cabal @@ -26,13 +26,15 @@ source-repository head Library default-language: Haskell2010 other-extensions: + BangPatterns + CPP + DefaultSignatures DeriveDataTypeable + DeriveGeneric FlexibleInstances - MagicHash - PolymorphicComponents RankNTypes + RoleAnnotations ScopedTypeVariables - UnboxedTuples exposed-modules: Language.Haskell.TH @@ -47,7 +49,7 @@ Library Language.Haskell.TH.Lib.Map build-depends: - base >= 4.6 && < 4.10, + base >= 4.8 && < 4.10, ghc-boot == 8.1, pretty == 1.1.* From git at git.haskell.org Tue Mar 8 11:49:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 11:49:22 +0000 (UTC) Subject: [commit: ghc] master: template-haskell: remove redundant CPP use (941b8f5) Message-ID: <20160308114922.D6FD13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/941b8f5fa1ffbf404fde1f59a7866b937efd173a/ghc >--------------------------------------------------------------- commit 941b8f5fa1ffbf404fde1f59a7866b937efd173a Author: Herbert Valerio Riedel Date: Tue Mar 8 12:46:49 2016 +0100 template-haskell: remove redundant CPP use GHC 8.1's template-haskell package requires base>=4.8 anyway, so we can assume Numeric.Natural to be available unconditionally. >--------------------------------------------------------------- 941b8f5fa1ffbf404fde1f59a7866b937efd173a libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index 86242aa..f26f37e 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -4,10 +4,6 @@ {-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} -#if MIN_VERSION_base(4,8,0) -#define HAS_NATURAL -#endif - ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Syntax @@ -40,10 +36,7 @@ import Data.Ratio import GHC.Generics ( Generic ) import GHC.Lexeme ( startsVarSym, startsVarId ) import Language.Haskell.TH.LanguageExtensions - -#ifdef HAS_NATURAL import Numeric.Natural -#endif ----------------------------------------------------- -- @@ -570,10 +563,8 @@ instance Lift Word32 where instance Lift Word64 where lift x = return (LitE (IntegerL (fromIntegral x))) -#ifdef HAS_NATURAL instance Lift Natural where lift x = return (LitE (IntegerL (fromIntegral x))) -#endif instance Integral a => Lift (Ratio a) where lift x = return (LitE (RationalL (toRational x))) From git at git.haskell.org Tue Mar 8 12:25:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 12:25:26 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: template-haskell: Drop use of Rank2Types/PolymorphicComponents (125f68a) Message-ID: <20160308122526.9704C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/125f68a9093f82abb4ab085747d4271bcd95076c/ghc >--------------------------------------------------------------- commit 125f68a9093f82abb4ab085747d4271bcd95076c Author: Herbert Valerio Riedel Date: Tue Mar 8 12:42:32 2016 +0100 template-haskell: Drop use of Rank2Types/PolymorphicComponents As per #6032, `Rank2Types` and `PolymorphicComponents` have been deprecated in favour of `RankNTypes`. also update `other-extensions` in template-haskell.cabal flag to reflect reality. (cherry picked from commit 1a9734a69260e69943c00755952edd7185dcc484) >--------------------------------------------------------------- 125f68a9093f82abb4ab085747d4271bcd95076c libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 5 ++--- libraries/template-haskell/template-haskell.cabal | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index d2c3649..d2ed425 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -1,8 +1,7 @@ -{-# LANGUAGE CPP, DeriveDataTypeable, PolymorphicComponents, +{-# LANGUAGE CPP, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, DefaultSignatures, - ScopedTypeVariables, Rank2Types #-} + RankNTypes, RoleAnnotations, ScopedTypeVariables #-} -{-# LANGUAGE RoleAnnotations #-} {-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} #if MIN_VERSION_base(4,8,0) diff --git a/libraries/template-haskell/template-haskell.cabal b/libraries/template-haskell/template-haskell.cabal index cbdf5f2..efd5e66 100644 --- a/libraries/template-haskell/template-haskell.cabal +++ b/libraries/template-haskell/template-haskell.cabal @@ -26,13 +26,15 @@ source-repository head Library default-language: Haskell2010 other-extensions: + BangPatterns + CPP + DefaultSignatures DeriveDataTypeable + DeriveGeneric FlexibleInstances - MagicHash - PolymorphicComponents RankNTypes + RoleAnnotations ScopedTypeVariables - UnboxedTuples exposed-modules: Language.Haskell.TH @@ -47,8 +49,8 @@ Library Language.Haskell.TH.Lib.Map build-depends: - base >= 4.6 && < 4.10, - ghc-boot >= 7.11 && < 8.1, + base >= 4.7 && < 4.10, + ghc-boot == 8.0.*, pretty == 1.1.* -- We need to set the unit ID to template-haskell (without a From git at git.haskell.org Tue Mar 8 16:28:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:28:22 +0000 (UTC) Subject: [commit: ghc] master: template-haskell: define `MonadFail Q` instance (1c76e16) Message-ID: <20160308162822.2C29A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1c76e1686bd4291556ae9357151f256c805b4b5d/ghc >--------------------------------------------------------------- commit 1c76e1686bd4291556ae9357151f256c805b4b5d Author: Herbert Valerio Riedel Date: Tue Mar 8 17:26:00 2016 +0100 template-haskell: define `MonadFail Q` instance When `MonadFail`is available, this patch makes `MonadFail` a superclass of `Quasi`, and `Q` an instance of `MonadFail`. NB: Since f16ddcee0c64a92ab911a7841a8cf64e3ac671fd, we need to be able to compile `template-haskell` with stage0 compilers that don't provide a `MonadFail` class yet. Once we reach GHC 8.3 development we can drop the CPP conditionals again. Addresses #11661 Reviewed By: bgamari, goldfire Differential Revision: https://phabricator.haskell.org/D1982 >--------------------------------------------------------------- 1c76e1686bd4291556ae9357151f256c805b4b5d libraries/ghci/GHCi/TH.hs | 4 ++++ .../template-haskell/Language/Haskell/TH/Syntax.hs | 19 +++++++++++++++++++ libraries/template-haskell/changelog.md | 2 ++ testsuite/tests/stranal/should_compile/T9208.hs | 8 ++++++++ 4 files changed, 33 insertions(+) diff --git a/libraries/ghci/GHCi/TH.hs b/libraries/ghci/GHCi/TH.hs index 00601ba..1525221 100644 --- a/libraries/ghci/GHCi/TH.hs +++ b/libraries/ghci/GHCi/TH.hs @@ -12,6 +12,7 @@ import GHCi.RemoteTypes import GHC.Serialized import Control.Exception +import qualified Control.Monad.Fail as Fail import Data.Binary import Data.Binary.Put import Data.ByteString (ByteString) @@ -60,6 +61,9 @@ instance Monad GHCiQ where do (m', s') <- runGHCiQ m s (a, s'') <- runGHCiQ (f m') s' return (a, s'') + fail = Fail.fail + +instance Fail.MonadFail GHCiQ where fail err = GHCiQ $ \s -> throwIO (GHCiQException s err) getState :: GHCiQ QState diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index f26f37e..ce3c908 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -4,6 +4,10 @@ {-# OPTIONS_GHC -fno-warn-inline-rule-shadowing #-} +#if MIN_VERSION_base(4,9,0) +# define HAS_MONADFAIL 1 +#endif + ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Syntax @@ -38,13 +42,21 @@ import GHC.Lexeme ( startsVarSym, startsVarId ) import Language.Haskell.TH.LanguageExtensions import Numeric.Natural +#if HAS_MONADFAIL +import qualified Control.Monad.Fail as Fail +#endif + ----------------------------------------------------- -- -- The Quasi class -- ----------------------------------------------------- +#if HAS_MONADFAIL +class Fail.MonadFail m => Quasi m where +#else class Monad m => Quasi m where +#endif qNewName :: String -> m Name -- ^ Fresh names @@ -162,7 +174,14 @@ runQ (Q m) = m instance Monad Q where Q m >>= k = Q (m >>= \x -> unQ (k x)) (>>) = (*>) +#if !HAS_MONADFAIL fail s = report True s >> Q (fail "Q monad failure") +#else + fail = Fail.fail + +instance Fail.MonadFail Q where + fail s = report True s >> Q (Fail.fail "Q monad failure") +#endif instance Functor Q where fmap f (Q x) = Q (fmap f x) diff --git a/libraries/template-haskell/changelog.md b/libraries/template-haskell/changelog.md index 1c0919a..c313c62 100644 --- a/libraries/template-haskell/changelog.md +++ b/libraries/template-haskell/changelog.md @@ -43,6 +43,8 @@ fixity if there is an explicit fixity declaration for that `Name`, and `Nothing` otherwise (#10704 and #11345) + * Add `MonadFail Q` instance for GHC 8.0 and later (#11661) + * TODO: document API changes and important bugfixes diff --git a/testsuite/tests/stranal/should_compile/T9208.hs b/testsuite/tests/stranal/should_compile/T9208.hs index f587da7..bf98fba 100644 --- a/testsuite/tests/stranal/should_compile/T9208.hs +++ b/testsuite/tests/stranal/should_compile/T9208.hs @@ -22,6 +22,9 @@ module Eval ( import Control.Applicative import Control.Monad +#if __GLASGOW_HASKELL__ >= 800 +import Control.Monad.Fail (MonadFail(fail)) +#endif import Data.Binary import Data.Binary.Get @@ -73,6 +76,11 @@ instance Monad GHCJSQ where return (a, s'') return = pure +#if __GLASGOW_HASKELL__ >= 800 +instance MonadFail GHCJSQ where + fail = undefined +#endif + instance TH.Quasi GHCJSQ where qRunIO m = GHCJSQ $ \s -> fmap (,s) m -- | the Template Haskell server From git at git.haskell.org Tue Mar 8 16:32:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:32:38 +0000 (UTC) Subject: [commit: ghc] wip/rae: Move and expand (slightly) TypeApplications docs (589ad97) Message-ID: <20160308163238.D9A523A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/589ad978552f2845f9056880a4ce62fb239a06a4/ghc >--------------------------------------------------------------- commit 589ad978552f2845f9056880a4ce62fb239a06a4 Author: Richard Eisenberg Date: Sun Feb 21 20:51:27 2016 -0500 Move and expand (slightly) TypeApplications docs >--------------------------------------------------------------- 589ad978552f2845f9056880a4ce62fb239a06a4 docs/users_guide/glasgow_exts.rst | 143 ++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 66 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 725f2ba..88ac8d4 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1749,72 +1749,6 @@ data constructor in an import or export list with the keyword ``pattern``, to allow the import or export of a data constructor without its parent type constructor (see :ref:`patsyn-impexp`). -.. _visible-type-application: - -Visible type application -~~~~~~~~~~~~~~~~~~~~~~~~ - -.. ghc-flag:: -XTypeApplications - - :implies: :ghc-flag:`-XAllowAmbiguousTypes` - :since: 8.0.1 - - Allow the use of type application syntax. - -The :ghc-flag:`-XTypeApplications` extension allows you to use -*visible type application* in expressions. Here is an -example: ``show (read @Int "5")``. The ``@Int`` -is the visible type application; it specifies the value of the type variable -in ``read``'s type. - -A visible type application is preceded with an ``@`` -sign. (To disambiguate the syntax, the ``@`` must be -preceded with a non-identifier letter, usually a space. For example, -``read at Int 5`` would not parse.) It can be used whenever -the full polymorphic type of the function is known. If the function -is an identifier (the common case), its type is considered known only when -the identifier has been given a type signature. If the identifier does -not have a type signature, visible type application cannot be used. - -Here are the details: - -- If an identifier's type signature does not include an - explicit ``forall``, the type variable arguments appear - in the left-to-right order in which the variables appear in the type. - So, ``foo :: Monad m => a b -> m (a c)`` - will have its type variables - ordered as ``m, a, b, c``. - -- If any of the variables depend on other variables (that is, if some - of the variables are *kind* variables), the variables are reordered - so that kind variables come before type variables, preserving the - left-to-right order as much as possible. That is, GHC performs a - stable topological sort on the variables. - - For example: if we have ``bar :: Proxy (a :: (j, k)) -> b``, then - the variables are ordered ``j``, ``k``, ``a``, ``b``. - -- Class methods' type arguments include the class type - variables, followed by any variables an individual method is polymorphic - in. So, ``class Monad m where return :: a -> m a`` means - that ``return``'s type arguments are ``m, a``. - -- With the :ghc-flag:`-XRankNTypes` extension - (:ref:`universal-quantification`), it is possible to declare - type arguments somewhere other than the beginning of a type. For example, - we can have ``pair :: forall a. a -> forall b. b -> (a, b)`` - and then say ``pair @Bool True @Char`` which would have - type ``Char -> (Bool, Char)``. - -- Partial type signatures (:ref:`partial-type-signatures`) - work nicely with visible type - application. If you want to specify only the second type argument to - ``wurble``, then you can say ``wurble @_ @Int``. - The first argument is a wildcard, just like in a partial type signature. - However, if used in a visible type application, it is *not* - necessary to specify :ghc-flag:`-XPartialTypeSignatures` and your - code will not generate a warning informing you of the omitted type. - .. _syntax-stolen: Summary of stolen syntax @@ -8280,6 +8214,83 @@ and :ghc-flag:`-XGADTs`. You can switch it off again with :ghc-flag:`-XNoMonoLocalBinds <-XMonoLocalBinds>` but type inference becomes less predicatable if you do so. (Read the papers!) +.. _visible-type-application: + +Visible type application +======================== + +.. ghc-flag:: -XTypeApplications + + :implies: :ghc-flag:`-XAllowAmbiguousTypes` + :since: 8.0.1 + + Allow the use of type application syntax. + +The :ghc-flag:`-XTypeApplications` extension allows you to use +*visible type application* in expressions. Here is an +example: ``show (read @Int "5")``. The ``@Int`` +is the visible type application; it specifies the value of the type variable +in ``read``'s type. + +A visible type application is preceded with an ``@`` +sign. (To disambiguate the syntax, the ``@`` must be +preceded with a non-identifier letter, usually a space. For example, +``read at Int 5`` would not parse.) It can be used whenever +the full polymorphic type of the function is known. If the function +is an identifier (the common case), its type is considered known only when +the identifier has been given a type signature. If the identifier does +not have a type signature, visible type application cannot be used. + +Here are the details: + +- If an identifier's type signature does not include an + explicit ``forall``, the type variable arguments appear + in the left-to-right order in which the variables appear in the type. + So, ``foo :: Monad m => a b -> m (a c)`` + will have its type variables + ordered as ``m, a, b, c``. + +- If any of the variables depend on other variables (that is, if some + of the variables are *kind* variables), the variables are reordered + so that kind variables come before type variables, preserving the + left-to-right order as much as possible. That is, GHC performs a + stable topological sort on the variables. + + For example: if we have ``bar :: Proxy (a :: (j, k)) -> b``, then + the variables are ordered ``j``, ``k``, ``a``, ``b``. + +- Visible type application is available to instantiate only user-specified + type variables. This means that in ``data Proxy a = Proxy``, the unmentioned + kind variable used in ``a``'s kind is *not* available for visible type + application. + +- Class methods' type arguments include the class type + variables, followed by any variables an individual method is polymorphic + in. So, ``class Monad m where return :: a -> m a`` means + that ``return``'s type arguments are ``m, a``. + +- With the :ghc-flag:`-XRankNTypes` extension + (:ref:`universal-quantification`), it is possible to declare + type arguments somewhere other than the beginning of a type. For example, + we can have ``pair :: forall a. a -> forall b. b -> (a, b)`` + and then say ``pair @Bool True @Char`` which would have + type ``Char -> (Bool, Char)``. + +- Partial type signatures (:ref:`partial-type-signatures`) + work nicely with visible type + application. If you want to specify only the second type argument to + ``wurble``, then you can say ``wurble @_ @Int``. + The first argument is a wildcard, just like in a partial type signature. + However, if used in a visible type application, it is *not* + necessary to specify :ghc-flag:`-XPartialTypeSignatures` and your + code will not generate a warning informing you of the omitted type. + +- When printing types with :ghc-flag:`-fprint-explicit-foralls` enabled, + type variables not available for visible type application are printed + in braces. Thus, if you write ``myLength = length`` without a type + signature, ``myLength``'s inferred type will be + ``forall {f} {a}. Foldable f => f a -> Int``. + .. _implicit-parameters: Implicit parameters From git at git.haskell.org Tue Mar 8 16:32:42 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:32:42 +0000 (UTC) Subject: [commit: ghc] wip/rae: Fix #11407. (aece78a) Message-ID: <20160308163242.50FA73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/aece78a4cee28df557c3c69d7be76b77d3f1aa26/ghc >--------------------------------------------------------------- commit aece78a4cee28df557c3c69d7be76b77d3f1aa26 Author: Richard Eisenberg Date: Mon Feb 22 12:54:56 2016 -0500 Fix #11407. This removes the `defer_me` check that was in checkTauTvUpdate and uses only a type family check instead. The old defer_me check repeated work done by fast_check in occurCheckExpand. There is also some error message improvement, necessitated by the terrible error message that the test case produced, even when it didn't consume all of memory. test case: dependent/should_fail/T11407 >--------------------------------------------------------------- aece78a4cee28df557c3c69d7be76b77d3f1aa26 compiler/typecheck/TcErrors.hs | 15 +++++++- compiler/typecheck/TcUnify.hs | 45 +++++----------------- compiler/types/TyCoRep.hs | 25 ++++++------ compiler/types/Type.hs | 9 ++++- compiler/types/Type.hs-boot | 5 +++ testsuite/tests/dependent/should_fail/T11407.hs | 10 +++++ .../tests/dependent/should_fail/T11407.stderr | 9 +++++ testsuite/tests/dependent/should_fail/all.T | 1 + 8 files changed, 71 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc aece78a4cee28df557c3c69d7be76b77d3f1aa26 From git at git.haskell.org Tue Mar 8 16:32:45 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:32:45 +0000 (UTC) Subject: [commit: ghc] wip/rae: Fix #11334. (208f43d) Message-ID: <20160308163245.D31F13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/208f43d58d7c5c0d4142407e4367353080f9f94b/ghc >--------------------------------------------------------------- commit 208f43d58d7c5c0d4142407e4367353080f9f94b Author: Richard Eisenberg Date: Mon Feb 22 21:47:32 2016 -0500 Fix #11334. Now we fail when trying to default non-*-kinded kind variables with -XNoPolyKinds. test case: dependent/should_fail/T11334 >--------------------------------------------------------------- 208f43d58d7c5c0d4142407e4367353080f9f94b compiler/typecheck/TcMType.hs | 36 ++++++++++++++++++++-- compiler/types/TyCoRep.hs | 4 ++- testsuite/tests/dependent/should_fail/T11334.hs | 8 +++++ .../tests/dependent/should_fail/T11334.stderr | 24 +++++++++++++++ testsuite/tests/dependent/should_fail/all.T | 1 + 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index e8c120d..b905f53 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -84,6 +84,7 @@ module TcMType ( import TyCoRep import TcType import Type +import Kind import Coercion import Class import Var @@ -936,15 +937,23 @@ zonkQuantifiedTyVarOrType tv else Left `liftM` skolemiseUnboundMetaTyVar tv vanillaSkolemTv _other -> pprPanic "zonkQuantifiedTyVar" (ppr tv) -- FlatSkol, RuntimeUnk --- | Take an (unconstrained) meta tyvar and default it. Works only for --- kind vars (of type *) and RuntimeRep vars (of type RuntimeRep). +-- | Take an (unconstrained) meta tyvar and default it. Works only on +-- vars of type RuntimeRep and of type *. For other kinds, it issues +-- an error. See Note [Defaulting with -XNoPolyKinds] defaultKindVar :: TcTyVar -> TcM Kind defaultKindVar kv | ASSERT( isMetaTyVar kv ) isRuntimeRepVar kv = writeMetaTyVar kv ptrRepLiftedTy >> return ptrRepLiftedTy - | otherwise + | isStarKind (tyVarKind kv) = writeMetaTyVar kv liftedTypeKind >> return liftedTypeKind + | otherwise + = do { addErr (vcat [ text "Cannot default kind variable" <+> quotes (ppr kv') + , text "of kind:" <+> ppr (tyVarKind kv') + , text "Perhaps enable PolyKinds or add a kind signature" ]) + ; return (mkTyVarTy kv) } + where + (_, kv') = tidyOpenTyCoVar emptyTidyEnv kv skolemiseUnboundMetaTyVar :: TcTyVar -> TcTyVarDetails -> TcM TyVar -- We have a Meta tyvar with a ref-cell inside it @@ -970,6 +979,27 @@ skolemiseUnboundMetaTyVar tv details ; return final_tv } {- +Note [Defaulting with -XNoPolyKinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + + data Compose f g a = Mk (f (g a)) + +We infer + + Compose :: forall k1 k2. (k2 -> *) -> (k1 -> k2) -> k1 -> * + Mk :: forall k1 k2 (f :: k2 -> *) (g :: k1 -> k2) (a :: k1). + f (g a) -> Compose k1 k2 f g a + +Now, in another module, we have -XNoPolyKinds -XDataKinds in effect. +What does 'Mk mean? Pre GHC-8.0 with -XNoPolyKinds, +we just defaulted all kind variables to *. But that's no good here, +because the kind variables in 'Mk aren't of kind *, so defaulting to * +is ill-kinded. + +After some debate on #11334, we decided to issue an error in this case. +The code is in defaultKindVar. + Note [What is a meta variable?] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A "meta type-variable", also know as a "unification variable" is a placeholder diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index 3798f69..c0a68d6 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -2882,7 +2882,9 @@ tidyOpenTyCoVar :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) tidyOpenTyCoVar env@(_, subst) tyvar = case lookupVarEnv subst tyvar of Just tyvar' -> (env, tyvar') -- Already substituted - Nothing -> tidyTyCoVarBndr env tyvar -- Treat it as a binder + Nothing -> + let env' = tidyFreeTyCoVars env (tyCoVarsOfType (tyVarKind tyvar)) in + tidyTyCoVarBndr env' tyvar -- Treat it as a binder --------------- tidyTyVarOcc :: TidyEnv -> TyVar -> TyVar diff --git a/testsuite/tests/dependent/should_fail/T11334.hs b/testsuite/tests/dependent/should_fail/T11334.hs new file mode 100644 index 0000000..1f9970f --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T11334.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE DataKinds, NoPolyKinds #-} + +module T11334 where + +import Data.Functor.Compose +import Data.Proxy + +p = Proxy :: Proxy 'Compose diff --git a/testsuite/tests/dependent/should_fail/T11334.stderr b/testsuite/tests/dependent/should_fail/T11334.stderr new file mode 100644 index 0000000..f7c87a3 --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T11334.stderr @@ -0,0 +1,24 @@ + +T11334.hs:8:14: error: + ? Cannot default kind variable ?f0? + of kind: k0 -> * + Perhaps enable PolyKinds or add a kind signature + ? In an expression type signature: Proxy Compose + In the expression: Proxy :: Proxy Compose + In an equation for ?p?: p = Proxy :: Proxy Compose + +T11334.hs:8:14: error: + ? Cannot default kind variable ?g0? + of kind: k10 -> k0 + Perhaps enable PolyKinds or add a kind signature + ? In an expression type signature: Proxy Compose + In the expression: Proxy :: Proxy Compose + In an equation for ?p?: p = Proxy :: Proxy Compose + +T11334.hs:8:14: error: + ? Cannot default kind variable ?a0? + of kind: k10 + Perhaps enable PolyKinds or add a kind signature + ? In an expression type signature: Proxy Compose + In the expression: Proxy :: Proxy Compose + In an equation for ?p?: p = Proxy :: Proxy Compose diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index 08f6cf6..63f08d2 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -9,3 +9,4 @@ test('SelfDep', normal, compile_fail, ['']) test('BadTelescope4', normal, compile_fail, ['']) test('RenamingStar', normal, compile_fail, ['']) test('T11407', normal, compile_fail, ['']) +test('T11334', normal, compile_fail, ['']) From git at git.haskell.org Tue Mar 8 16:32:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:32:49 +0000 (UTC) Subject: [commit: ghc] wip/rae: Fix #11401. (8a659dc) Message-ID: <20160308163249.132C33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/8a659dcf04ce6dcad37eeb6eafafc10ceb14849b/ghc >--------------------------------------------------------------- commit 8a659dcf04ce6dcad37eeb6eafafc10ceb14849b Author: Richard Eisenberg Date: Mon Feb 22 22:15:44 2016 -0500 Fix #11401. This commit teaches shortCutReduction about Derived constraints. >--------------------------------------------------------------- 8a659dcf04ce6dcad37eeb6eafafc10ceb14849b compiler/typecheck/TcInteract.hs | 40 +++++++++------------- testsuite/tests/typecheck/should_compile/T11401.hs | 33 ++++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs index 90f7243..a0654d2 100644 --- a/compiler/typecheck/TcInteract.hs +++ b/compiler/typecheck/TcInteract.hs @@ -1527,47 +1527,39 @@ shortCutReduction :: CtEvidence -> TcTyVar -> TcCoercion -> TyCon -> [TcType] -> TcS (StopOrContinue Ct) -- See Note [Top-level reductions for type functions] shortCutReduction old_ev fsk ax_co fam_tc tc_args - | isGiven old_ev - = ASSERT( ctEvEqRel old_ev == NomEq ) + = ASSERT( ctEvEqRel old_ev == NomEq) do { (xis, cos) <- flattenManyNom old_ev tc_args -- ax_co :: F args ~ G tc_args -- cos :: xis ~ tc_args -- old_ev :: F args ~ fsk -- G cos ; sym ax_co ; old_ev :: G xis ~ fsk - ; new_ev <- newGivenEvVar deeper_loc + ; new_ev <- case ctEvFlavour old_ev of + Given -> newGivenEvVar deeper_loc ( mkPrimEqPred (mkTyConApp fam_tc xis) (mkTyVarTy fsk) , EvCoercion (mkTcTyConAppCo Nominal fam_tc cos `mkTcTransCo` mkTcSymCo ax_co `mkTcTransCo` ctEvCoercion old_ev) ) - ; let new_ct = CFunEqCan { cc_ev = new_ev, cc_fun = fam_tc, cc_tyargs = xis, cc_fsk = fsk } - ; updWorkListTcS (extendWorkListFunEq new_ct) - ; stopWith old_ev "Fun/Top (given, shortcut)" } + Derived -> newDerivedNC deeper_loc $ + mkPrimEqPred (mkTyConApp fam_tc xis) + (mkTyVarTy fsk) - | otherwise - = ASSERT( not (isDerived old_ev) ) -- Caller ensures this - ASSERT( ctEvEqRel old_ev == NomEq ) - do { (xis, cos) <- flattenManyNom old_ev tc_args - -- ax_co :: F args ~ G tc_args - -- cos :: xis ~ tc_args - -- G cos ; sym ax_co ; old_ev :: G xis ~ fsk - -- new_ev :: G xis ~ fsk - -- old_ev :: F args ~ fsk := ax_co ; sym (G cos) ; new_ev - - ; (new_ev, new_co) <- newWantedEq deeper_loc Nominal - (mkTyConApp fam_tc xis) (mkTyVarTy fsk) - ; setWantedEq (ctev_dest old_ev) - (ax_co `mkTcTransCo` mkTcSymCo (mkTcTyConAppCo Nominal fam_tc cos) - `mkTcTransCo` new_co) + Wanted -> + do { (new_ev, new_co) <- newWantedEq deeper_loc Nominal + (mkTyConApp fam_tc xis) (mkTyVarTy fsk) + ; setWantedEq (ctev_dest old_ev) $ + ax_co `mkTcTransCo` mkTcSymCo (mkTcTyConAppCo Nominal + fam_tc cos) + `mkTcTransCo` new_co + ; return new_ev } ; let new_ct = CFunEqCan { cc_ev = new_ev, cc_fun = fam_tc , cc_tyargs = xis, cc_fsk = fsk } ; updWorkListTcS (extendWorkListFunEq new_ct) - ; stopWith old_ev "Fun/Top (wanted, shortcut)" } + ; stopWith old_ev "Fun/Top (shortcut)" } where - loc = ctEvLoc old_ev - deeper_loc = bumpCtLocDepth loc + deeper_loc = bumpCtLocDepth (ctEvLoc old_ev) dischargeFmv :: CtEvidence -> TcTyVar -> TcCoercion -> TcType -> TcS () -- (dischargeFmv x fmv co ty) diff --git a/testsuite/tests/typecheck/should_compile/T11401.hs b/testsuite/tests/typecheck/should_compile/T11401.hs new file mode 100644 index 0000000..5235aaf --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11401.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE FlexibleInstances #-} +module T11401 where + +newtype Value a = Value a +newtype CodeGen r a = CodeGen a + +bind :: CodeGen r a -> (a -> CodeGen r b) -> CodeGen r b +bind (CodeGen a) k = k a + +class + (f ~ CalledFunction g, r ~ CallerResult g, g ~ CallerFunction f r) => + CallArgs f g r where + type CalledFunction g :: * + type CallerResult g :: * + type CallerFunction f r :: * + call :: f -> g + +instance CallArgs (IO a) (CodeGen r (Value a)) r where + type CalledFunction (CodeGen r (Value a)) = IO a + type CallerResult (CodeGen r (Value a)) = r + type CallerFunction (IO a) r = CodeGen r (Value a) + call = undefined + +instance CallArgs b b' r => CallArgs (a -> b) (Value a -> b') r where + type CalledFunction (Value a -> b') = a -> CalledFunction b' + type CallerResult (Value a -> b') = CallerResult b' + type CallerFunction (a -> b) r = Value a -> CallerFunction b r + call = undefined + +test :: IO a -> (a -> IO ()) -> CodeGen () (Value ()) +test start stop = bind (call start) (call stop) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 4310be4..19ed440 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -506,3 +506,4 @@ test('T11458', normal, compile, ['']) test('T11524', normal, compile, ['']) test('T11552', normal, compile, ['']) test('T11246', normal, compile, ['']) +test('T11401', normal, compile, ['']) From git at git.haskell.org Tue Mar 8 16:32:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:32:51 +0000 (UTC) Subject: [commit: ghc] wip/rae: Expand Note [Non-trivial definitional equality] (b82a936) Message-ID: <20160308163251.BED943A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/b82a93681b6a58a5ee5e5923e472806954ce453d/ghc >--------------------------------------------------------------- commit b82a93681b6a58a5ee5e5923e472806954ce453d Author: Richard Eisenberg Date: Wed Feb 24 14:41:37 2016 -0500 Expand Note [Non-trivial definitional equality] This adapts the text from D1944. >--------------------------------------------------------------- b82a93681b6a58a5ee5e5923e472806954ce453d compiler/types/TyCoRep.hs | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index c0a68d6..67262d6 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -354,6 +354,58 @@ two types have the same kind. This allows us to be a little sloppier in keeping track of coercions, which is a good thing. It also means that eqType does not depend on eqCoercion, which is also a good thing. +Why is this sensible? That is, why is something different than ?-equivalence +appropriate for the implementation of eqType? + +Anything smaller than ~ and homogeneous is an appropriate definition for +equality. The type safety of FC depends only on ~. Let's say ? : ? ~ ?. Any +expression of type ? can be transmuted to one of type ? at any point by +casting. The same is true of types of type ?. So in some sense, ? and ? are +interchangeable. + +But let's be more precise. If we examine the typing rules of FC (say, those in +http://www.cis.upenn.edu/~eir/papers/2015/equalities/equalities-extended.pdf) +there are several places where the same metavariable is used in two different +premises to a rule. (For example, see Ty_App.) There is an implicit equality +check here. What definition of equality should we use? By convention, we use +?-equivalence. Take any rule with one (or more) of these implicit equality +checks. Then there is an admissible rule that uses ~ instead of the implicit +check, adding in casts as appropriate. + +The only problem here is that ~ is heterogeneous. To make the kinds work out +in the admissible rule that uses ~, it is necessary to homogenize the +coercions. That is, if we have ? : (? : ?1) ~ (? : ?2), then we don't use ?; +we use ? |> kind ?, which is homogeneous. + +The effect of this all is that eqType, the implementation of the implicit +equality check, can use any homogeneous relation that is smaller than ~, as +those rules must also be admissible. + +What would go wrong if we insisted on the casts matching? See the beginning of +Section 8 in the unpublished paper above. Theoretically, nothing at all goes +wrong. But in practical terms, getting the coercions right proved to be +nightmarish. And types would explode: during kind-checking, we often produce +reflexive kind coercions. When we try to cast by these, mkCastTy just discards +them. But if we used an eqType that distinguished between Int and Int |> <*>, +then we couldn't discard -- the output of kind-checking would be enormous, +and we would need enormous casts with lots of CoherenceCo's to straighten +them out. + +Would anything go wrong if eqType respected type families? No, not at all. But +that makes eqType rather hard to implement. + +Thus, the guideline for eqType is that it should be the largest +easy-to-implement relation that is still smaller than ~ and homogeneous. The +precise choice of relation is somewhat incidental, as long as the smart +constructors and destructors in Type respect whatever relation is chosen. + +Another helpful principle with eqType is this: + + ** If (t1 eqType t2) then I can replace t1 by t2 anywhere. ** + +This principle also tells us that eqType must relate only types with the +same kinds. + Note [VisibilityFlag] ~~~~~~~~~~~~~~~~~~~~~ All named binders are equipped with a visibility flag, which says From git at git.haskell.org Tue Mar 8 16:32:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:32:54 +0000 (UTC) Subject: [commit: ghc] wip/rae: Refactor visible type application. (0e0b112) Message-ID: <20160308163254.EA7B13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/0e0b1120486dc08050aabdf6c31cfef1d56cd425/ghc >--------------------------------------------------------------- commit 0e0b1120486dc08050aabdf6c31cfef1d56cd425 Author: Richard Eisenberg Date: Tue Feb 23 09:51:50 2016 -0500 Refactor visible type application. This replaces the old HsType and HsTypeOut constructors with HsAppType and HsAppTypeOut, leading to some simplification. (This refactoring addresses #11329.) This also fixes #11456, which stumbled over HsType (which is not an expression). test case: ghci/scripts/T11456 >--------------------------------------------------------------- 0e0b1120486dc08050aabdf6c31cfef1d56cd425 compiler/deSugar/Coverage.hs | 23 ++--- compiler/deSugar/DsExpr.hs | 15 +-- compiler/deSugar/DsMeta.hs | 4 +- compiler/hsSyn/HsExpr.hs | 63 ++++++----- compiler/hsSyn/HsUtils.hs | 26 ++--- compiler/parser/Parser.y | 11 +- compiler/rename/RnExpr.hs | 10 +- compiler/rename/RnSource.hs | 1 + compiler/typecheck/TcExpr.hs | 115 +++++++++++---------- compiler/typecheck/TcHsSyn.hs | 8 +- compiler/typecheck/TcRnTypes.hs | 4 +- testsuite/tests/ghci/scripts/T11456.hs | 5 + testsuite/tests/ghci/scripts/T11456.script | 2 + testsuite/tests/ghci/scripts/all.T | 1 + testsuite/tests/typecheck/should_fail/T9605.stderr | 20 ++-- .../tests/typecheck/should_fail/VtaFail.stderr | 2 +- 16 files changed, 166 insertions(+), 144 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 0e0b1120486dc08050aabdf6c31cfef1d56cd425 From git at git.haskell.org Tue Mar 8 16:32:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:32:57 +0000 (UTC) Subject: [commit: ghc] wip/rae: Remove vestigial isTyVar checks. (f553f81) Message-ID: <20160308163257.992D03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/f553f81c382a3891e5934362cd6d33604efc9ef2/ghc >--------------------------------------------------------------- commit f553f81c382a3891e5934362cd6d33604efc9ef2 Author: Richard Eisenberg Date: Fri Feb 26 08:38:35 2016 -0500 Remove vestigial isTyVar checks. >--------------------------------------------------------------- f553f81c382a3891e5934362cd6d33604efc9ef2 compiler/typecheck/TcType.hs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs index 972cbae..c5e1943 100644 --- a/compiler/typecheck/TcType.hs +++ b/compiler/typecheck/TcType.hs @@ -849,22 +849,18 @@ isTouchableOrFmv ctxt_tclvl tv isTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool isTouchableMetaTyVar ctxt_tclvl tv - | isTyVar tv = case tcTyVarDetails tv of MetaTv { mtv_tclvl = tv_tclvl } -> ASSERT2( checkTcLevelInvariant ctxt_tclvl tv_tclvl, ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl ) tv_tclvl `sameDepthAs` ctxt_tclvl _ -> False - | otherwise = False isFloatedTouchableMetaTyVar :: TcLevel -> TcTyVar -> Bool isFloatedTouchableMetaTyVar ctxt_tclvl tv - | isTyVar tv = case tcTyVarDetails tv of MetaTv { mtv_tclvl = tv_tclvl } -> tv_tclvl `strictlyDeeperThan` ctxt_tclvl _ -> False - | otherwise = False isImmutableTyVar :: TyVar -> Bool isImmutableTyVar tv @@ -879,11 +875,9 @@ isTyConableTyVar tv -- True of a meta-type variable that can be filled in -- with a type constructor application; in particular, -- not a SigTv - | isTyVar tv = case tcTyVarDetails tv of MetaTv { mtv_info = SigTv } -> False _ -> True - | otherwise = True isFmvTyVar tv = case tcTyVarDetails tv of @@ -909,18 +903,14 @@ isSkolemTyVar tv _other -> True isOverlappableTyVar tv - | isTyVar tv = case tcTyVarDetails tv of SkolemTv overlappable -> overlappable _ -> False - | otherwise = False isMetaTyVar tv - | isTyVar tv = case tcTyVarDetails tv of MetaTv {} -> True _ -> False - | otherwise = False -- isAmbiguousTyVar is used only when reporting type errors -- It picks out variables that are unbound, namely meta @@ -928,12 +918,10 @@ isMetaTyVar tv -- RtClosureInspect.zonkRTTIType. These are "ambiguous" in -- the sense that they stand for an as-yet-unknown type isAmbiguousTyVar tv - | isTyVar tv = case tcTyVarDetails tv of MetaTv {} -> True RuntimeUnk {} -> True _ -> False - | otherwise = False isMetaTyVarTy :: TcType -> Bool isMetaTyVarTy (TyVarTy tv) = isMetaTyVar tv From git at git.haskell.org Tue Mar 8 16:33:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:33:00 +0000 (UTC) Subject: [commit: ghc] wip/rae: Cache coercionKind, fixing #11598. (1ac0607) Message-ID: <20160308163300.5E9243A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/1ac06072fa1b6d87f90e10d1f7692b5315eb31bf/ghc >--------------------------------------------------------------- commit 1ac06072fa1b6d87f90e10d1f7692b5315eb31bf Author: Richard Eisenberg Date: Wed Feb 24 23:28:07 2016 -0500 Cache coercionKind, fixing #11598. This commit creates a new datatype, CoercionRep, that stores the details of a coercion. The Coercion datatype now stores its kind, role, and free variables, so looking up these details is very quick. In the cases that we never need these details, I believe that laziness will prevent us from calculating them. >--------------------------------------------------------------- 1ac06072fa1b6d87f90e10d1f7692b5315eb31bf compiler/coreSyn/CoreFVs.hs | 56 +- compiler/coreSyn/CoreLint.hs | 209 +++--- compiler/iface/IfaceSyn.hs | 4 +- compiler/iface/IfaceType.hs | 127 ++-- compiler/iface/TcIface.hs | 60 +- compiler/prelude/TysWiredIn.hs-boot | 2 + compiler/simplCore/Simplify.hs | 1 + compiler/specialise/Rules.hs | 57 +- compiler/typecheck/FamInst.hs | 2 +- compiler/typecheck/TcEvidence.hs | 6 +- compiler/typecheck/TcHsSyn.hs | 18 +- compiler/typecheck/TcMType.hs | 42 +- compiler/typecheck/TcSMonad.hs | 4 +- compiler/typecheck/TcTyClsDecls.hs | 2 +- compiler/typecheck/TcType.hs | 129 ++-- compiler/typecheck/TcValidity.hs | 26 +- compiler/types/Coercion.hs | 1214 +++++++++++++++++++---------------- compiler/types/Coercion.hs-boot | 36 +- compiler/types/FamInstEnv.hs | 144 ++--- compiler/types/OptCoercion.hs | 654 +++++++++++++++---- compiler/types/TyCoRep.hs | 706 ++++++++++++++------ compiler/types/TyCoRep.hs-boot | 1 + compiler/types/Type.hs | 228 +++---- compiler/types/Type.hs-boot | 10 +- compiler/types/Unify.hs | 223 +------ compiler/utils/FV.hs | 12 + compiler/utils/Pair.hs | 4 +- 27 files changed, 2319 insertions(+), 1658 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 1ac06072fa1b6d87f90e10d1f7692b5315eb31bf From git at git.haskell.org Tue Mar 8 16:33:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 16:33:02 +0000 (UTC) Subject: [commit: ghc] wip/rae's head updated: Cache coercionKind, fixing #11598. (1ac0607) Message-ID: <20160308163302.B55C73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/rae' now includes: 67d2226 Derive Eq and Ord instance for SrcLoc and RealSrcLoc a82956d Remove superfluous code when deriving Foldable/Traversable 525b54c users-guide: Fix typos 0c420cb Comments only (#11513) 27842ec Fix thinko that crept into D1908 01449eb Fix desugaring of bang-pattern let-bindings b529255 (Another) minor refactoring of substitutions 4d031cf Improve piResultTys and friends a008ead Take type-function arity into account 206a8bf Unwire Typeable representation types 0b68cbe Bump haddock submodule 8b073f6 A few more typos in non-code 2f733b3 Delete support for deprecated "-- # ..."-style haddock options d738e66 Modifier letter in middle of identifier is ok c6007fe Pass -haddock to tests in should_compile_*flag*_nohaddock a8653c8 Docs: no space in `-i?dir1?:?dir2?` [skip ci] 6cec905 Refactoring only: use ExprLStmt 3259bf6 Fix a bug in ApplicativeDo (#11612) 2340485 Fix a double-free bug in -fexternal-interpreter 80d35be Use a better test for profiling 1ef7add Add test (only) to assure that #11535 is fixed 9634e24 unexport MAKEFLAGS when running tests (#11569) 0b00add Add test for #6132: hash bang + CPP 6e691ca Testsuite: pass '-s --no-print-directory' to MAKE f451039 Build system: fix sed expression (#11537) bb9cd45 Fix GHC.Stats documentation markup (#11619) ed11909 Docs: -keep-llvm-file(s)/-ddump-llvm imply -fllvm d3cf2a9 Add missing files 31c312e Testsuite: delete Windows line endings [skip ci] (#11631) 8626ac9 Testsuite: delete Windows line endings [skip ci] (#11631) 754a2f2 Testsuite: delete Windows line endings [skip ci] (#11631) 6074c10 Testsuite: delete Windows line endings [skip ci] (#11631) d5e8b39 Testsuite: delete Windows line endings [skip ci] (#11631) 978c3ea Testsuite: accept output without Windows line endings (#11631) 42f06f6 Testsuite: accept output without Windows line endings (#11631) 28620ba Testsuite: delete Windows line endings [skip ci] (#11631) 6d0aa9f Testsuite: delete Windows line endings [skip ci] (#11631) 73e4095 Testsuite: cleanup profiling/should_run/all.T (#11521) 176be87 Filter out -prof callstacks from test output (#11521) 661aa07 Testsuite: failing profiling tests (#10037) 2aee419 Allow combining characters in identifiers (#7650) a3e0e93 Testsuite: MAKEFLAGS is magic, do not unexport it 32a9a7f Extend `-Wunrecognised-warning-flag` to cover `-f(no-)warn-*` ce36115 Follow-up to 32a9a7f514bdd33ff72a673ade d8c64e8 Address #11471 by putting RuntimeRep in kinds. 589ad97 Move and expand (slightly) TypeApplications docs aece78a Fix #11407. 208f43d Fix #11334. 8a659dc Fix #11401. 0e0b112 Refactor visible type application. b82a936 Expand Note [Non-trivial definitional equality] f553f81 Remove vestigial isTyVar checks. 1ac0607 Cache coercionKind, fixing #11598. From git at git.haskell.org Tue Mar 8 17:19:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 17:19:18 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: template-haskell: define `MonadFail Q` instance (35b747f) Message-ID: <20160308171918.250C13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/35b747fcde36bdc96e533bd1c3f02d81845453c2/ghc >--------------------------------------------------------------- commit 35b747fcde36bdc96e533bd1c3f02d81845453c2 Author: Herbert Valerio Riedel Date: Tue Mar 8 17:26:00 2016 +0100 template-haskell: define `MonadFail Q` instance When `MonadFail`is available, this patch makes `MonadFail` a superclass of `Quasi`, and `Q` an instance of `MonadFail`. NB: Since f16ddcee0c64a92ab911a7841a8cf64e3ac671fd, we need to be able to compile `template-haskell` with stage0 compilers that don't provide a `MonadFail` class yet. Once we reach GHC 8.3 development we can drop the CPP conditionals again. Addresses #11661 (cherry picked from commit 1c76e1686bd4291556ae9357151f256c805b4b5d) >--------------------------------------------------------------- 35b747fcde36bdc96e533bd1c3f02d81845453c2 libraries/ghci/GHCi/TH.hs | 6 +++++- .../template-haskell/Language/Haskell/TH/Syntax.hs | 21 +++++++++++++++++++++ libraries/template-haskell/changelog.md | 2 ++ testsuite/tests/stranal/should_compile/T9208.hs | 8 ++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/libraries/ghci/GHCi/TH.hs b/libraries/ghci/GHCi/TH.hs index 34d6fad6..f4f4725 100644 --- a/libraries/ghci/GHCi/TH.hs +++ b/libraries/ghci/GHCi/TH.hs @@ -12,6 +12,7 @@ import GHCi.RemoteTypes import GHC.Serialized import Control.Exception +import qualified Control.Monad.Fail as Fail import Data.Binary import Data.Binary.Put import Data.ByteString (ByteString) @@ -60,7 +61,10 @@ instance Monad GHCiQ where do (m', s') <- runGHCiQ m s (a, s'') <- runGHCiQ (f m') s' return (a, s'') - return = pure + + fail = Fail.fail + +instance Fail.MonadFail GHCiQ where fail err = GHCiQ $ \s -> throwIO (GHCiQException s err) getState :: GHCiQ QState diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index d2ed425..e363adc 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -8,6 +8,10 @@ #define HAS_NATURAL #endif +#if MIN_VERSION_base(4,9,0) +# define HAS_MONADFAIL 1 +#endif + ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Syntax @@ -48,13 +52,21 @@ import Language.Haskell.TH.LanguageExtensions import Numeric.Natural #endif +#if HAS_MONADFAIL +import qualified Control.Monad.Fail as Fail +#endif + ----------------------------------------------------- -- -- The Quasi class -- ----------------------------------------------------- +#if HAS_MONADFAIL +class Fail.MonadFail m => Quasi m where +#else class (Applicative m, Monad m) => Quasi m where +#endif qNewName :: String -> m Name -- ^ Fresh names @@ -172,8 +184,17 @@ runQ (Q m) = m instance Monad Q where Q m >>= k = Q (m >>= \x -> unQ (k x)) (>>) = (*>) + return = pure + +#if !HAS_MONADFAIL fail s = report True s >> Q (fail "Q monad failure") +#else + fail = Fail.fail + +instance Fail.MonadFail Q where + fail s = report True s >> Q (Fail.fail "Q monad failure") +#endif instance Functor Q where fmap f (Q x) = Q (fmap f x) diff --git a/libraries/template-haskell/changelog.md b/libraries/template-haskell/changelog.md index 1c0919a..c313c62 100644 --- a/libraries/template-haskell/changelog.md +++ b/libraries/template-haskell/changelog.md @@ -43,6 +43,8 @@ fixity if there is an explicit fixity declaration for that `Name`, and `Nothing` otherwise (#10704 and #11345) + * Add `MonadFail Q` instance for GHC 8.0 and later (#11661) + * TODO: document API changes and important bugfixes diff --git a/testsuite/tests/stranal/should_compile/T9208.hs b/testsuite/tests/stranal/should_compile/T9208.hs index f587da7..bf98fba 100644 --- a/testsuite/tests/stranal/should_compile/T9208.hs +++ b/testsuite/tests/stranal/should_compile/T9208.hs @@ -22,6 +22,9 @@ module Eval ( import Control.Applicative import Control.Monad +#if __GLASGOW_HASKELL__ >= 800 +import Control.Monad.Fail (MonadFail(fail)) +#endif import Data.Binary import Data.Binary.Get @@ -73,6 +76,11 @@ instance Monad GHCJSQ where return (a, s'') return = pure +#if __GLASGOW_HASKELL__ >= 800 +instance MonadFail GHCJSQ where + fail = undefined +#endif + instance TH.Quasi GHCJSQ where qRunIO m = GHCJSQ $ \s -> fmap (,s) m -- | the Template Haskell server From git at git.haskell.org Tue Mar 8 17:19:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 8 Mar 2016 17:19:20 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Update submodule to latest Cabal-1.24 snapshot (62f3dc1) Message-ID: <20160308171920.D12783A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/62f3dc1a8ae78638f298875735b09e8684e521fb/ghc >--------------------------------------------------------------- commit 62f3dc1a8ae78638f298875735b09e8684e521fb Author: Herbert Valerio Riedel Date: Tue Mar 8 18:20:39 2016 +0100 Update submodule to latest Cabal-1.24 snapshot >--------------------------------------------------------------- 62f3dc1a8ae78638f298875735b09e8684e521fb libraries/Cabal | 2 +- testsuite/tests/perf/haddock/all.T | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/Cabal b/libraries/Cabal index df45e05..5d0c56e 160000 --- a/libraries/Cabal +++ b/libraries/Cabal @@ -1 +1 @@ -Subproject commit df45e05eb249cd422afe1b406a3ed8eb0043bcb4 +Subproject commit 5d0c56ec49e07516c26a62c1a261e890752bc16b diff --git a/testsuite/tests/perf/haddock/all.T b/testsuite/tests/perf/haddock/all.T index e2787d6..4818c20 100644 --- a/testsuite/tests/perf/haddock/all.T +++ b/testsuite/tests/perf/haddock/all.T @@ -51,7 +51,7 @@ test('haddock.base', test('haddock.Cabal', [unless(in_tree_compiler(), skip), req_haddock ,stats_num_field('bytes allocated', - [(wordsize(64), 10519532424, 5) + [(wordsize(64), 11123698216, 5) # 2012-08-14: 3255435248 (amd64/Linux) # 2012-08-29: 3324606664 (amd64/Linux, new codegen) # 2012-10-08: 3373401360 (amd64/Linux) @@ -75,6 +75,7 @@ test('haddock.Cabal', # 2015-12-11: 8114833312 (amd64/Linux) - TypeInType (See #11196) # 2015-12-17: 9982130512 (amd64/Linux) - Update Haddock to master # 2015-12-22: 10519532424 (amd64/Linux) - Lots of new Semigroup instances in Cabal + # 2015-03-08: 11123698216 (amd64/Linux) - Cabal update ,(platform('i386-unknown-mingw32'), 3293415576, 5) # 2012-10-30: 1733638168 (x86/Windows) From git at git.haskell.org Wed Mar 9 05:08:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 9 Mar 2016 05:08:05 +0000 (UTC) Subject: [commit: ghc] wip/rae: More work on caching coercions. (e058c6e) Message-ID: <20160309050805.E4FD43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/e058c6e27a92691582fdafc5b3725896a90bf686/ghc >--------------------------------------------------------------- commit e058c6e27a92691582fdafc5b3725896a90bf686 Author: Richard Eisenberg Date: Wed Mar 9 00:09:47 2016 -0500 More work on caching coercions. >--------------------------------------------------------------- e058c6e27a92691582fdafc5b3725896a90bf686 compiler/coreSyn/CoreLint.hs | 19 +- compiler/coreSyn/CoreUtils.hs | 1 - compiler/iface/IfaceSyn.hs | 70 +++-- compiler/iface/IfaceType.hs | 161 ++++++---- compiler/iface/TcIface.hs | 66 ++-- compiler/typecheck/TcCanonical.hs | 8 +- compiler/typecheck/TcMType.hs | 2 +- compiler/typecheck/TcType.hs | 72 +---- compiler/types/Coercion.hs | 348 +++++++++++---------- compiler/types/FamInstEnv.hs | 25 +- compiler/types/OptCoercion.hs | 61 ++-- compiler/types/TyCoRep.hs | 151 ++++++--- compiler/types/Type.hs | 28 +- .../tests/indexed-types/should_fail/T5439.stderr | 16 +- 14 files changed, 563 insertions(+), 465 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e058c6e27a92691582fdafc5b3725896a90bf686 From git at git.haskell.org Wed Mar 9 13:14:11 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 9 Mar 2016 13:14:11 +0000 (UTC) Subject: [commit: ghc] master: Fix the implementation of lazyId (4c3a0a4) Message-ID: <20160309131411.11CFC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/4c3a0a4a7b999251cbbee00befbfe32b86e556e2/ghc >--------------------------------------------------------------- commit 4c3a0a4a7b999251cbbee00befbfe32b86e556e2 Author: Simon Peyton Jones Date: Tue Mar 8 15:27:54 2016 +0000 Fix the implementation of lazyId 'lazy' was doing part of its job, but not all! In particular, an application f (lazy e) where f is strict, was still being compiled using call-by-value in CorePrep. This defeated the purpose of defining catch as catch a b = catch# (lazy a) b See Trac #11555, and Neil Mitchell's test case in comment:14 This patch makes 'lazy' behave properly. I updated Note [lazyId magic] in MkId, but all the action is in CorePrep. I can't say I really like this, but it does the job. >--------------------------------------------------------------- 4c3a0a4a7b999251cbbee00befbfe32b86e556e2 compiler/basicTypes/MkId.hs | 57 +++++++++++++++++++++++++++++++------------- compiler/coreSyn/CorePrep.hs | 48 +++++++++++++++++++++---------------- 2 files changed, 68 insertions(+), 37 deletions(-) diff --git a/compiler/basicTypes/MkId.hs b/compiler/basicTypes/MkId.hs index 8ee5013..92d6b5e 100644 --- a/compiler/basicTypes/MkId.hs +++ b/compiler/basicTypes/MkId.hs @@ -1324,23 +1324,46 @@ may fire. Note [lazyId magic] ~~~~~~~~~~~~~~~~~~~ - lazy :: forall a?. a? -> a? (i.e. works for unboxed types too) - -Used to lazify pseq: pseq a b = a `seq` lazy b - -Also, no strictness: by being a built-in Id, all the info about lazyId comes from here, -not from GHC.Base.hi. This is important, because the strictness -analyser will spot it as strict! - -Also no unfolding in lazyId: it gets "inlined" by a HACK in CorePrep. -It's very important to do this inlining *after* unfoldings are exposed -in the interface file. Otherwise, the unfolding for (say) pseq in the -interface file will not mention 'lazy', so if we inline 'pseq' we'll totally -miss the very thing that 'lazy' was there for in the first place. -See Trac #3259 for a real world example. - -lazyId is defined in GHC.Base, so we don't *have* to inline it. If it -appears un-applied, we'll end up just calling it. +lazy :: forall a?. a? -> a? (i.e. works for unboxed types too) + +'lazy' is used to make sure that a sub-expression, and its free variables, +are truly used call-by-need, with no code motion. Key examples: + +* pseq: pseq a b = a `seq` lazy b + We want to make sure that the free vars of 'b' are not evaluated + before 'a', even though the expression is plainly strict in 'b'. + +* catch: catch a b = catch# (lazy a) b + Again, it's clear that 'a' will be evaluated strictly (and indeed + applied to a state token) but we want to make sure that any exceptions + arising from the evaluation of 'a' are caught by the catch (see + Trac #11555). + +Implementing 'lazy' is a bit tricky: + +* It must not have a strictness signature: by being a built-in Id, + all the info about lazyId comes from here, not from GHC.Base.hi. + This is important, because the strictness analyser will spot it as + strict! + +* It must not have an unfolding: it gets "inlined" by a HACK in + CorePrep. It's very important to do this inlining *after* unfoldings + are exposed in the interface file. Otherwise, the unfolding for + (say) pseq in the interface file will not mention 'lazy', so if we + inline 'pseq' we'll totally miss the very thing that 'lazy' was + there for in the first place. See Trac #3259 for a real world + example. + +* Suppose CorePrep sees (catch# (lazy e) b). At all costs we must + avoid using call by value here: + case e of r -> catch# r b + Avoiding that is the whole point of 'lazy'. So in CorePrep (which + generate the 'case' expression for a call-by-value call) we must + spot the 'lazy' on the arg (in CorePrep.cpeApp), and build a 'let' + instead. + +* lazyId is defined in GHC.Base, so we don't *have* to inline it. If it + appears un-applied, we'll end up just calling it. Note [runRW magic] ~~~~~~~~~~~~~~~~~~ diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs index 3f9f4c8..e6acc2b 100644 --- a/compiler/coreSyn/CorePrep.hs +++ b/compiler/coreSyn/CorePrep.hs @@ -657,14 +657,14 @@ rhsToBody expr = return (emptyFloats, expr) cpeApp :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeRhs) -- May return a CpeRhs because of saturating primops cpeApp env expr - = do { (app, (head,depth), _, floats, ss) <- collect_args expr 0 + = do { (app, head, _, floats, ss) <- collect_args expr 0 ; MASSERT(null ss) -- make sure we used all the strictness info -- Now deal with the function ; case head of - Var fn_id -> do { sat_app <- maybeSaturate fn_id app depth - ; return (floats, sat_app) } - _other -> return (floats, app) } + Just (fn_id, depth) -> do { sat_app <- maybeSaturate fn_id app depth + ; return (floats, sat_app) } + _other -> return (floats, app) } where -- Deconstruct and rebuild the application, floating any non-atomic @@ -675,13 +675,13 @@ cpeApp env expr collect_args :: CoreExpr - -> Int -- Current app depth - -> UniqSM (CpeApp, -- The rebuilt expression - (CoreExpr,Int), -- The head of the application, - -- and no. of args it was applied to - Type, -- Type of the whole expr - Floats, -- Any floats we pulled out - [Demand]) -- Remaining argument demands + -> Int -- Current app depth + -> UniqSM (CpeApp, -- The rebuilt expression + Maybe (Id, Int), -- The head of the application, + -- and no. of args it was applied to + Type, -- Type of the whole expr + Floats, -- Any floats we pulled out + [Demand]) -- Remaining argument demands collect_args (App fun arg@(Type arg_ty)) depth = do { (fun',hd,fun_ty,floats,ss) <- collect_args fun depth @@ -693,12 +693,13 @@ cpeApp env expr collect_args (App fun arg) depth = do { (fun',hd,fun_ty,floats,ss) <- collect_args fun (depth+1) - ; let - (ss1, ss_rest) = case ss of - (ss1:ss_rest) -> (ss1, ss_rest) - [] -> (topDmd, []) - (arg_ty, res_ty) = expectJust "cpeBody:collect_args" $ - splitFunTy_maybe fun_ty + ; let (ss1, ss_rest) -- See Note [lazyId magic] in MkId + = case (ss, isLazyExpr arg) of + (_ : ss_rest, True) -> (topDmd, ss_rest) + (ss1 : ss_rest, False) -> (ss1, ss_rest) + ([], _) -> (topDmd, []) + (arg_ty, res_ty) = expectJust "cpeBody:collect_args" $ + splitFunTy_maybe fun_ty ; (fs, arg') <- cpeArg env ss1 arg arg_ty ; return (App fun' arg', hd, res_ty, fs `appendFloats` floats, ss_rest) } @@ -706,7 +707,7 @@ cpeApp env expr collect_args (Var v) depth = do { v1 <- fiddleCCall v ; let v2 = lookupCorePrepEnv env v1 - ; return (Var v2, (Var v2, depth), idType v2, emptyFloats, stricts) } + ; return (Var v2, Just (v2, depth), idType v2, emptyFloats, stricts) } where stricts = case idStrictness v of StrictSig (DmdType _ demands _) @@ -732,14 +733,21 @@ cpeApp env expr ; return (fun',hd,fun_ty,addFloat floats (FloatTick tickish),ss) } -- N-variable fun, better let-bind it - collect_args fun depth + collect_args fun _ = do { (fun_floats, fun') <- cpeArg env evalDmd fun ty -- The evalDmd says that it's sure to be evaluated, -- so we'll end up case-binding it - ; return (fun', (fun', depth), ty, fun_floats, []) } + ; return (fun', Nothing, ty, fun_floats, []) } where ty = exprType fun +isLazyExpr :: CoreExpr -> Bool +-- See Note [lazyId magic] in MkId +isLazyExpr (Cast e _) = isLazyExpr e +isLazyExpr (Tick _ e) = isLazyExpr e +isLazyExpr (Var f `App` _ `App` _) = f `hasKey` lazyIdKey +isLazyExpr _ = False + -- --------------------------------------------------------------------------- -- CpeArg: produces a result satisfying CpeArg -- --------------------------------------------------------------------------- From git at git.haskell.org Wed Mar 9 13:14:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 9 Mar 2016 13:14:13 +0000 (UTC) Subject: [commit: ghc] master: Refactoring around TcPatSyn.tcPatToExpr (5a494d8) Message-ID: <20160309131413.B81743A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/5a494d8ec688e42601262913172f24cee7a36c9b/ghc >--------------------------------------------------------------- commit 5a494d8ec688e42601262913172f24cee7a36c9b Author: Simon Peyton Jones Date: Wed Mar 9 13:14:09 2016 +0000 Refactoring around TcPatSyn.tcPatToExpr Just comments, a bit of refactoring, and a better error-reporting infrastructure >--------------------------------------------------------------- 5a494d8ec688e42601262913172f24cee7a36c9b compiler/typecheck/TcPatSyn.hs | 173 +++++++++++++---------- testsuite/tests/patsyn/should_fail/unidir.stderr | 7 +- 2 files changed, 106 insertions(+), 74 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 5a494d8ec688e42601262913172f24cee7a36c9b From git at git.haskell.org Thu Mar 10 10:18:42 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 10 Mar 2016 10:18:42 +0000 (UTC) Subject: [commit: ghc] master: Update Cabal submodule to latest HEAD snapshot (374f919) Message-ID: <20160310101842.DECD43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/374f9199e33b62a4d8ae49e4efbd7d9ad17fce58/ghc >--------------------------------------------------------------- commit 374f9199e33b62a4d8ae49e4efbd7d9ad17fce58 Author: Herbert Valerio Riedel Date: Tue Mar 8 10:58:49 2016 +0100 Update Cabal submodule to latest HEAD snapshot >--------------------------------------------------------------- 374f9199e33b62a4d8ae49e4efbd7d9ad17fce58 libraries/Cabal | 2 +- utils/check-api-annotations/check-api-annotations.cabal | 2 +- utils/ghc-cabal/ghc-cabal.cabal | 2 +- utils/ghctags/Main.hs | 2 +- utils/ghctags/ghctags.cabal | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/Cabal b/libraries/Cabal index ecdf65a..9accafe 160000 --- a/libraries/Cabal +++ b/libraries/Cabal @@ -1 +1 @@ -Subproject commit ecdf65a3c1e01b798e9d073258a6d1c8ff63a6d8 +Subproject commit 9accafebff3743fc499fa6d565d55ba25326db28 diff --git a/utils/check-api-annotations/check-api-annotations.cabal b/utils/check-api-annotations/check-api-annotations.cabal index ade5fe4..da68dba 100644 --- a/utils/check-api-annotations/check-api-annotations.cabal +++ b/utils/check-api-annotations/check-api-annotations.cabal @@ -24,6 +24,6 @@ Executable check-api-annotations Build-Depends: base >= 4 && < 5, containers, - Cabal >= 1.22 && <1.24, + Cabal >= 1.25 && <1.27, directory, ghc diff --git a/utils/ghc-cabal/ghc-cabal.cabal b/utils/ghc-cabal/ghc-cabal.cabal index d6048a3..1f328d8 100644 --- a/utils/ghc-cabal/ghc-cabal.cabal +++ b/utils/ghc-cabal/ghc-cabal.cabal @@ -21,7 +21,7 @@ Executable ghc-cabal Build-Depends: base >= 3 && < 5, bytestring >= 0.10 && < 0.11, - Cabal >= 1.22 && < 1.24, + Cabal >= 1.25 && < 1.27, directory >= 1.1 && < 1.3, filepath >= 1.2 && < 1.5 diff --git a/utils/ghctags/Main.hs b/utils/ghctags/Main.hs index ccdd327..0eff514 100644 --- a/utils/ghctags/Main.hs +++ b/utils/ghctags/Main.hs @@ -188,7 +188,7 @@ flagsFromCabal distPref = do let bi = libBuildInfo lib odir = buildDir lbi opts = componentGhcOptions V.normal lbi bi clbi odir - in return $ renderGhcOptions (compiler lbi) opts + in return $ renderGhcOptions (compiler lbi) (hostPlatform lbi) opts _ -> error "no library" ---------------------------------------------------------------- diff --git a/utils/ghctags/ghctags.cabal b/utils/ghctags/ghctags.cabal index d73c7fa..b871f8c 100644 --- a/utils/ghctags/ghctags.cabal +++ b/utils/ghctags/ghctags.cabal @@ -18,6 +18,6 @@ Executable ghctags Build-Depends: base >= 4 && < 5, containers, - Cabal >= 1.22 && <1.24, + Cabal >= 1.25 && <1.27, ghc From git at git.haskell.org Thu Mar 10 14:04:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 10 Mar 2016 14:04:44 +0000 (UTC) Subject: [commit: ghc] wip/rae: Fix testsuite failures, etc. (65fc411) Message-ID: <20160310140444.A20623A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/65fc411406fc1e2b3f6c63abd2371490b10243b3/ghc >--------------------------------------------------------------- commit 65fc411406fc1e2b3f6c63abd2371490b10243b3 Author: Richard Eisenberg Date: Thu Mar 10 09:06:22 2016 -0500 Fix testsuite failures, etc. >--------------------------------------------------------------- 65fc411406fc1e2b3f6c63abd2371490b10243b3 compiler/coreSyn/CoreLint.hs | 10 ++++--- compiler/simplCore/SimplCore.hs | 1 + compiler/typecheck/TcErrors.hs | 2 +- compiler/typecheck/TcFlatten.hs | 19 ++++++++----- compiler/typecheck/TcHsType.hs | 4 ++- compiler/typecheck/TcType.hs | 9 ++++--- compiler/typecheck/TcUnify.hs | 26 +++++++++++++----- compiler/types/Coercion.hs | 14 +++++++++- compiler/types/OptCoercion.hs | 4 +-- compiler/types/TyCoRep.hs | 10 +++---- compiler/types/Type.hs | 7 +++-- .../tests/dependent/should_fail/T11407.stderr | 1 - testsuite/tests/pmcheck/should_compile/T11195.hs | 31 +++++++++++++++------- testsuite/tests/polykinds/T9222.stderr | 2 +- .../tests/roles/should_compile/Roles13.stderr | 7 ++--- .../tests/simplCore/should_compile/T4201.stdout | 2 +- testsuite/tests/typecheck/should_fail/tcfail068.hs | 0 17 files changed, 101 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 65fc411406fc1e2b3f6c63abd2371490b10243b3 From git at git.haskell.org Thu Mar 10 21:51:48 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 10 Mar 2016 21:51:48 +0000 (UTC) Subject: [commit: ghc] master: fix Float/Double unreg cross-compilation (c42cdb7) Message-ID: <20160310215148.C6ABE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c42cdb7f6dcfd519d9607ac9fa53f049b2922fb8/ghc >--------------------------------------------------------------- commit c42cdb7f6dcfd519d9607ac9fa53f049b2922fb8 Author: Sergei Trofimovich Date: Thu Mar 10 21:53:16 2016 +0000 fix Float/Double unreg cross-compilation Looking at more failures on m68k (Trac #11395) I've noticed the arith001 and arith012 test failures. (--host=x86_64-linux --target=m68k-linux). The following example was enough to reproduce a problem: v :: Float v = 43 main = print v m68k binaries printed '0.0' instead of '43.0'. The bug here is how we encode Floats and Double as Words with the same binary representation. Floats: Before the patch we just coerced Float to Int. That breaks when we cross-compile from 64-bit LE to 32-bit BE. The patch fixes conversion by accounting for padding. when we extend 32-bit value to 64-bit value (LE and BE do it slightly differently). Doubles: Before the patch Doubles were coerced to a pair of Ints (not correct as x86_64 can hold Double in one Int) and then trucated this pair of Ints to pair of Word32. The patch fixes conversion by always decomposing in Word32 and accounting for host endianness (newly introduced hostBE) and target endianness (wORDS_BIGENDIAN). I've tested this patch on Double and Float conversion on --host=x86_64-linux --target=m68k-linux crosscompiler. It fixes 10 tests related to printing Floats and Doubles. Thanks to Bertram Felgenhauer who poined out this probem. Signed-off-by: Sergei Trofimovich Test Plan: checked some examples manually, fixed 10 tests in test suite Reviewers: int-e, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1990 GHC Trac Issues: #11395 >--------------------------------------------------------------- c42cdb7f6dcfd519d9607ac9fa53f049b2922fb8 compiler/cmm/PprC.hs | 79 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs index 673ac2d..4bb256a 100644 --- a/compiler/cmm/PprC.hs +++ b/compiler/cmm/PprC.hs @@ -504,7 +504,7 @@ pprLit1 other = pprLit other pprStatics :: DynFlags -> [CmmStatic] -> [SDoc] pprStatics _ [] = [] pprStatics dflags (CmmStaticLit (CmmFloat f W32) : rest) - -- floats are padded to a word, see #1852 + -- floats are padded to a word by padLitToWord, see #1852 | wORD_SIZE dflags == 8, CmmStaticLit (CmmInt 0 W32) : rest' <- rest = pprLit1 (floatToWord dflags f) : pprStatics dflags rest' | wORD_SIZE dflags == 4 @@ -516,6 +516,7 @@ pprStatics dflags (CmmStaticLit (CmmFloat f W32) : rest) ppr' _other = text "bad static!" pprStatics dflags (CmmStaticLit (CmmFloat f W64) : rest) = map pprLit1 (doubleToWords dflags f) ++ pprStatics dflags rest + pprStatics dflags (CmmStaticLit (CmmInt i W64) : rest) | wordWidth dflags == W32 = if wORDS_BIGENDIAN dflags @@ -1176,54 +1177,72 @@ pprStringInCStyle s = doubleQuotes (text (concatMap charToC s)) -- Initialising static objects with floating-point numbers. We can't -- just emit the floating point number, because C will cast it to an int -- by rounding it. We want the actual bit-representation of the float. +-- +-- Consider a concrete C example: +-- double d = 2.5e-10; +-- float f = 2.5e-10f; +-- +-- int * i2 = &d; printf ("i2: %08X %08X\n", i2[0], i2[1]); +-- long long * l = &d; printf (" l: %016llX\n", l[0]); +-- int * i = &f; printf (" i: %08X\n", i[0]); +-- Result on 64-bit LE (x86_64): +-- i2: E826D695 3DF12E0B +-- l: 3DF12E0BE826D695 +-- i: 2F89705F +-- Result on 32-bit BE (m68k): +-- i2: 3DF12E0B E826D695 +-- l: 3DF12E0BE826D695 +-- i: 2F89705F +-- +-- The trick here is to notice that binary representation does not +-- change much: only Word32 values get swapped on LE hosts / targets. -- This is a hack to turn the floating point numbers into ints that we -- can safely initialise to static locations. -big_doubles :: DynFlags -> Bool -big_doubles dflags - | widthInBytes W64 == 2 * wORD_SIZE dflags = True - | widthInBytes W64 == wORD_SIZE dflags = False - | otherwise = panic "big_doubles" - -castFloatToIntArray :: STUArray s Int Float -> ST s (STUArray s Int Int) -castFloatToIntArray = U.castSTUArray +castFloatToWord32Array :: STUArray s Int Float -> ST s (STUArray s Int Word32) +castFloatToWord32Array = U.castSTUArray -castDoubleToIntArray :: STUArray s Int Double -> ST s (STUArray s Int Int) -castDoubleToIntArray = U.castSTUArray +castDoubleToWord64Array :: STUArray s Int Double -> ST s (STUArray s Int Word64) +castDoubleToWord64Array = U.castSTUArray --- floats are always 1 word floatToWord :: DynFlags -> Rational -> CmmLit floatToWord dflags r = runST (do arr <- newArray_ ((0::Int),0) writeArray arr 0 (fromRational r) - arr' <- castFloatToIntArray arr - i <- readArray arr' 0 - return (CmmInt (toInteger i) (wordWidth dflags)) + arr' <- castFloatToWord32Array arr + w32 <- readArray arr' 0 + return (CmmInt (toInteger w32 `shiftL` wo) (wordWidth dflags)) ) + where wo | wordWidth dflags == W64 + , wORDS_BIGENDIAN dflags = 32 + | otherwise = 0 doubleToWords :: DynFlags -> Rational -> [CmmLit] doubleToWords dflags r - | big_doubles dflags -- doubles are 2 words = runST (do arr <- newArray_ ((0::Int),1) writeArray arr 0 (fromRational r) - arr' <- castDoubleToIntArray arr - i1 <- readArray arr' 0 - i2 <- readArray arr' 1 - return [ CmmInt (toInteger i1) (wordWidth dflags) - , CmmInt (toInteger i2) (wordWidth dflags) - ] - ) - | otherwise -- doubles are 1 word - = runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 (fromRational r) - arr' <- castDoubleToIntArray arr - i <- readArray arr' 0 - return [ CmmInt (toInteger i) (wordWidth dflags) ] + arr' <- castDoubleToWord64Array arr + w64 <- readArray arr' 0 + return (pprWord64 w64) ) + where targetWidth = wordWidth dflags + targetBE = wORDS_BIGENDIAN dflags + pprWord64 w64 + | targetWidth == W64 = + [ CmmInt (toInteger w64) targetWidth ] + | targetWidth == W32 = + [ CmmInt (toInteger targetW1) targetWidth + , CmmInt (toInteger targetW2) targetWidth + ] + | otherwise = panic "doubleToWords.pprWord64" + where (targetW1, targetW2) + | targetBE = (wHi, wLo) + | otherwise = (wLo, wHi) + wHi = w64 `shiftR` 32 + wLo = w64 .&. 0xFFFFffff -- --------------------------------------------------------------------------- -- Utils From git at git.haskell.org Fri Mar 11 12:26:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:26:56 +0000 (UTC) Subject: [commit: ghc] master: Fix #11624, cannot declare hs-boot if already one in scope. (fc16690) Message-ID: <20160311122656.847923A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/fc16690a536b74e7af72e963599471474e3df603/ghc >--------------------------------------------------------------- commit fc16690a536b74e7af72e963599471474e3df603 Author: Edward Z. Yang Date: Fri Mar 11 10:37:26 2016 +0100 Fix #11624, cannot declare hs-boot if already one in scope. I'm not sure if this fix is the "right way" to do it, but it solves the proximal problem, which is that lookupBindGroupOcc was picking out the wrong renaming for hs-boot signatures, which then lead to an interface file error. Signed-off-by: Edward Z. Yang Test Plan: validate Reviewers: simonpj, hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1963 GHC Trac Issues: #11624 >--------------------------------------------------------------- fc16690a536b74e7af72e963599471474e3df603 compiler/rename/RnBinds.hs | 22 +++++++--------------- compiler/rename/RnEnv.hs | 4 ++-- compiler/rename/RnSource.hs | 8 +++++++- testsuite/tests/driver/sigof02/all.T | 8 ++++---- testsuite/tests/driver/sigof02/sigof02dmt.stderr | 15 ++++++++------- testsuite/tests/driver/sigof02/sigof02dt.stderr | 15 ++++++++------- testsuite/tests/rename/should_compile/T11624.hs | 4 ++++ .../tests/rename/should_compile/T11624.hs-boot | 3 +++ .../tests/rename/should_compile/T11624.stderr | 3 +++ testsuite/tests/rename/should_compile/T11624a.hs | 4 ++++ testsuite/tests/rename/should_compile/all.T | 1 + 11 files changed, 51 insertions(+), 36 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc fc16690a536b74e7af72e963599471474e3df603 From git at git.haskell.org Fri Mar 11 12:26:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:26:59 +0000 (UTC) Subject: [commit: ghc] master: Add regression test for #11555 (c937f42) Message-ID: <20160311122659.8C49F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c937f424e4acd61d1c558e8fe9b47e7d580fdbd8/ghc >--------------------------------------------------------------- commit c937f424e4acd61d1c558e8fe9b47e7d580fdbd8 Author: Ben Gamari Date: Fri Mar 11 11:20:43 2016 +0100 Add regression test for #11555 >--------------------------------------------------------------- c937f424e4acd61d1c558e8fe9b47e7d580fdbd8 testsuite/tests/stranal/should_run/T11555a.hs | 38 +++++++++++++++++++++++ testsuite/tests/stranal/should_run/T11555a.stdout | 2 ++ testsuite/tests/stranal/should_run/all.T | 1 + 3 files changed, 41 insertions(+) diff --git a/testsuite/tests/stranal/should_run/T11555a.hs b/testsuite/tests/stranal/should_run/T11555a.hs new file mode 100644 index 0000000..29f2a49 --- /dev/null +++ b/testsuite/tests/stranal/should_run/T11555a.hs @@ -0,0 +1,38 @@ +module Main(main) where + +import Control.Monad +import Control.Exception +import Control.Monad.Trans.Cont +import GHC.Exts + + +type RAW a = ContT () IO a + +-- See https://ghc.haskell.org/trac/ghc/ticket/11555 +catchSafe1, catchSafe2 :: IO a -> (SomeException -> IO a) -> IO a +catchSafe1 a b = lazy a `catch` b +catchSafe2 a b = join (evaluate a) `catch` b + +-- | Run and then call a continuation. +runRAW1, runRAW2 :: RAW a -> (Either SomeException a -> IO ()) -> IO () +runRAW1 m k = m `runContT` (k . Right) `catchSafe1` \e -> k $ Left e +runRAW2 m k = m `runContT` (k . Right) `catchSafe2` \e -> k $ Left e + +{-# NOINLINE run1 #-} +run1 :: RAW ()-> IO () +run1 rs = do + runRAW1 rs $ \x -> case x of + Left e -> putStrLn "CAUGHT" + Right x -> return x + +{-# NOINLINE run2 #-} +run2 :: RAW ()-> IO () +run2 rs = do + runRAW2 rs $ \x -> case x of + Left e -> putStrLn "CAUGHT" + Right x -> return x + +main :: IO () +main = do + run1 $ error "MISSED" + run2 $ error "MISSED" diff --git a/testsuite/tests/stranal/should_run/T11555a.stdout b/testsuite/tests/stranal/should_run/T11555a.stdout new file mode 100644 index 0000000..16ff8b4 --- /dev/null +++ b/testsuite/tests/stranal/should_run/T11555a.stdout @@ -0,0 +1,2 @@ +CAUGHT +CAUGHT diff --git a/testsuite/tests/stranal/should_run/all.T b/testsuite/tests/stranal/should_run/all.T index efd1afa..a4b550e 100644 --- a/testsuite/tests/stranal/should_run/all.T +++ b/testsuite/tests/stranal/should_run/all.T @@ -11,3 +11,4 @@ test('T9254', normal, compile_and_run, ['']) test('T10148', normal, compile_and_run, ['']) test('T10218', normal, compile_and_run, ['']) test('T11076', normal, multimod_compile_and_run, ['T11076.hs', 'T11076_prim.cmm']) +test('T11555a', normal, compile_and_run, ['']) From git at git.haskell.org Fri Mar 11 12:27:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:02 +0000 (UTC) Subject: [commit: ghc] master: Use catchException in a few more places (a1c4230) Message-ID: <20160311122702.3F5D93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/a1c4230e15cbf897b97903c8a1199a1cc91efd26/ghc >--------------------------------------------------------------- commit a1c4230e15cbf897b97903c8a1199a1cc91efd26 Author: Ben Gamari Date: Fri Mar 11 10:43:52 2016 +0100 Use catchException in a few more places These are cases in the standard library that may benefit from the strictness signature of catchException and where we know that the action won't bottom. Test Plan: Validate, carefully consider changed callsites Reviewers: austin, hvr Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1972 >--------------------------------------------------------------- a1c4230e15cbf897b97903c8a1199a1cc91efd26 libraries/base/Control/Concurrent.hs | 6 +++--- libraries/base/GHC/IO/Handle/Text.hs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs index 535b2f0..9b328b6 100644 --- a/libraries/base/Control/Concurrent.hs +++ b/libraries/base/Control/Concurrent.hs @@ -109,7 +109,7 @@ import Control.Exception.Base as Exception import GHC.Conc hiding (threadWaitRead, threadWaitWrite, threadWaitReadSTM, threadWaitWriteSTM) -import GHC.IO ( unsafeUnmask ) +import GHC.IO ( unsafeUnmask, catchException ) import GHC.IORef ( newIORef, readIORef, writeIORef ) import GHC.Base @@ -308,7 +308,7 @@ forkOS action0 MaskedInterruptible -> action0 MaskedUninterruptible -> uninterruptibleMask_ action0 - action_plus = Exception.catch action1 childHandler + action_plus = catchException action1 childHandler entry <- newStablePtr (myThreadId >>= putMVar mv >> action_plus) err <- forkOS_createThread entry @@ -381,7 +381,7 @@ runInUnboundThread action = do mv <- newEmptyMVar mask $ \restore -> do tid <- forkIO $ Exception.try (restore action) >>= putMVar mv - let wait = takeMVar mv `Exception.catch` \(e :: SomeException) -> + let wait = takeMVar mv `catchException` \(e :: SomeException) -> Exception.throwTo tid e >> wait wait >>= unsafeResult else action diff --git a/libraries/base/GHC/IO/Handle/Text.hs b/libraries/base/GHC/IO/Handle/Text.hs index 65832c7..4a5e4cf 100644 --- a/libraries/base/GHC/IO/Handle/Text.hs +++ b/libraries/base/GHC/IO/Handle/Text.hs @@ -246,7 +246,7 @@ hGetLineBufferedLoop handle_ at Handle__{..} maybeFillReadBuffer :: Handle__ -> CharBuffer -> IO (Maybe CharBuffer) maybeFillReadBuffer handle_ buf - = Exception.catch + = catchException (do buf' <- getSomeCharacters handle_ buf return (Just buf') ) From git at git.haskell.org Fri Mar 11 12:27:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:05 +0000 (UTC) Subject: [commit: ghc] master: Make `catch` lazy in the action (30ee910) Message-ID: <20160311122705.66F403A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/30ee9102db2f16894912e19b9d16156824611bbb/ghc >--------------------------------------------------------------- commit 30ee9102db2f16894912e19b9d16156824611bbb Author: Ben Gamari Date: Fri Mar 11 10:38:10 2016 +0100 Make `catch` lazy in the action Previously ```lang=haskell catch (error "uh oh") (\(_ :: SomeException) -> print "it failed") ``` would unexpectedly fail with "uh oh" instead of the handler being run due to the strictness of `catch` in its first argument. See #11555 for details. Test Plan: Validate Reviewers: austin, hvr, simonpj Reviewed By: simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1973 GHC Trac Issues: #11555 >--------------------------------------------------------------- 30ee9102db2f16894912e19b9d16156824611bbb libraries/base/Control/Exception/Base.hs | 2 +- libraries/base/GHC/IO.hs | 39 ++++++++++++++++++++++++++++++++ libraries/base/tests/.gitignore | 1 + libraries/base/tests/T11555.hs | 9 ++++++++ libraries/base/tests/T11555.stdout | 1 + libraries/base/tests/all.T | 1 + 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs index 351771b..5b3d47c 100644 --- a/libraries/base/Control/Exception/Base.hs +++ b/libraries/base/Control/Exception/Base.hs @@ -147,7 +147,7 @@ catch :: Exception e => IO a -- ^ The computation to run -> (e -> IO a) -- ^ Handler to invoke if an exception is raised -> IO a -catch = catchException +catch act = catchException (lazy act) -- | The function 'catchJust' is like 'catch', but it takes an extra -- argument which is an /exception predicate/, a function which diff --git a/libraries/base/GHC/IO.hs b/libraries/base/GHC/IO.hs index 186f6c6..52a333a 100644 --- a/libraries/base/GHC/IO.hs +++ b/libraries/base/GHC/IO.hs @@ -126,12 +126,22 @@ Now catch# has type have to work around that in the definition of catchException below). -} +-- | Catch an exception in the 'IO' monad. +-- +-- Note that this function is /strict/ in the action. That is, +-- @catchException undefined b == _|_ at . See #exceptions_and_strictness# +-- for details. catchException :: Exception e => IO a -> (e -> IO a) -> IO a catchException (IO io) handler = IO $ catch# io handler' where handler' e = case fromException e of Just e' -> unIO (handler e') Nothing -> raiseIO# e +-- | Catch any 'Exception' type in the 'IO' monad. +-- +-- Note that this function is /strict/ in the action. That is, +-- @catchException undefined b == _|_ at . See #exceptions_and_strictness# for +-- details. catchAny :: IO a -> (forall e . Exception e => e -> IO a) -> IO a catchAny (IO io) handler = IO $ catch# io handler' where handler' (SomeException e) = unIO (handler e) @@ -373,3 +383,32 @@ a `finally` sequel = -- use @'return' '$!' x at . evaluate :: a -> IO a evaluate a = IO $ \s -> seq# a s -- NB. see #2273, #5129 + +{- $exceptions_and_strictness + +Laziness can interact with @catch at -like operations in non-obvious ways (see, +e.g. GHC Trac #11555). For instance, consider these subtly-different examples, + +> test1 = Control.Exception.catch (error "uh oh") (\(_ :: SomeException) -> putStrLn "it failed") +> +> test2 = GHC.IO.catchException (error "uh oh") (\(_ :: SomeException) -> putStrLn "it failed") + +While the first case is always guaranteed to print "it failed", the behavior of + at test2@ may vary with optimization level. + +The unspecified behavior of @test2@ is due to the fact that GHC may assume that +'catchException' (and the 'catch#' primitive operation which it is built upon) +is strict in its first argument. This assumption allows the compiler to better +optimize @catchException@ calls at the expense of deterministic behavior when +the action may be bottom. + +Namely, the assumed strictness means that exceptions thrown while evaluating the +action-to-be-executed may not be caught; only exceptions thrown during execution +of the action will be handled by the exception handler. + +Since this strictness is a small optimization and may lead to surprising +results, all of the @catch@ and @handle@ variants offered by "Control.Exception" +are lazy in their first argument. If you are certain that that the action to be +executed won't bottom in performance-sensitive code, you might consider using +'GHC.IO.catchException' or 'GHC.IO.catchAny' for a small speed-up. +-} diff --git a/libraries/base/tests/.gitignore b/libraries/base/tests/.gitignore index a430bd7..32b9d10 100644 --- a/libraries/base/tests/.gitignore +++ b/libraries/base/tests/.gitignore @@ -273,3 +273,4 @@ /weak001 /T9395 /T9532 +/T11555 diff --git a/libraries/base/tests/T11555.hs b/libraries/base/tests/T11555.hs new file mode 100644 index 0000000..ce5b961 --- /dev/null +++ b/libraries/base/tests/T11555.hs @@ -0,0 +1,9 @@ +import Control.Exception + +-- Ensure that catch catches exceptions thrown during the evaluation of the +-- action-to-be-executed. This should output "it failed". +main :: IO () +main = catch (error "uh oh") handler + +handler :: SomeException -> IO () +handler _ = putStrLn "it failed" diff --git a/libraries/base/tests/T11555.stdout b/libraries/base/tests/T11555.stdout new file mode 100644 index 0000000..2f1c27e --- /dev/null +++ b/libraries/base/tests/T11555.stdout @@ -0,0 +1 @@ +it failed diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T index 06ef3bb..574aba6 100644 --- a/libraries/base/tests/all.T +++ b/libraries/base/tests/all.T @@ -212,3 +212,4 @@ test('T9848', ['-O']) test('T10149', normal, compile_and_run, ['']) test('T11334', normal, compile_and_run, ['']) +test('T11555', normal, compile_and_run, ['']) \ No newline at end of file From git at git.haskell.org Fri Mar 11 12:27:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:08 +0000 (UTC) Subject: [commit: ghc] master: Document Quasi-quotes/list comprehension ambiguity (767ff7c) Message-ID: <20160311122708.1666B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/767ff7cab7fc2d27b66cdd25d551ccf9e9e7c51d/ghc >--------------------------------------------------------------- commit 767ff7cab7fc2d27b66cdd25d551ccf9e9e7c51d Author: Ben Gamari Date: Fri Mar 11 10:38:42 2016 +0100 Document Quasi-quotes/list comprehension ambiguity Test Plan: read it Reviewers: austin, goldfire Reviewed By: goldfire Subscribers: hvr, thomie Differential Revision: https://phabricator.haskell.org/D1981 GHC Trac Issues: #11679 >--------------------------------------------------------------- 767ff7cab7fc2d27b66cdd25d551ccf9e9e7c51d docs/users_guide/glasgow_exts.rst | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 454c73e..dd714ec 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1873,7 +1873,15 @@ The following syntax is stolen: Stolen by: :ghc-flag:`-XImplicitParams` -``[|``, ``[e|``, ``[p|``, ``[d|``, ``[t|``, ``$(``, ``$$(``, ``[||``, ``[e||``, ``$varid``, ``$$varid`` +``[|``, ``[e|``, ``[p|``, ``[d|``, ``[t|``, ``[||``, ``[e||`` + .. index:: + single: Quasi-quotes + + Stolen by: :ghc-flag:`-XQuasiQuotes`. Moreover, this introduces an ambiguity + with list comprehension syntax. See + :ref:`quasi-quotes-list-comprehension-ambiguity` for details. + +``$(``, ``$$(``, ``$varid``, ``$$varid`` .. index:: single: Template Haskell @@ -9985,6 +9993,24 @@ Here are the salient features quasi-quotes do not cause a declaration group break. See :ref:`th-syntax` for more information. +.. _quasi-quotes-list-comprehension-ambiguity: + +.. warning:: + + .. index:: + single: quasi-quotes; ambiguity with list comprehensions + single: list comprehensions; ambiguity with quasi-quotes + + :ghc-flag:`-XQuasiQuotes` introduces an unfortunate ambiguity with list + comprehension syntax. Consider the following, :: + + let x = [v| v <- [0..10]] + + Without :ghc-flag:`-XQuasiQuotes` this is parsed as a list comprehension. + With :ghc-flag:`-XQuasiQuotes` this is parsed as a quasi-quote; however, + this parse will fail due to the lack of a closing ``|]``. See + :ghc-ticket:`11679`. + The example below shows quasi-quotation in action. The quoter ``expr`` is bound to a value of type ``QuasiQuoter`` defined in module ``Expr``. The example makes use of an antiquoted variable ``n``, indicated by the From git at git.haskell.org Fri Mar 11 12:27:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:10 +0000 (UTC) Subject: [commit: ghc] master: Include version in AC_PACKAGE_TARNAME (a74a384) Message-ID: <20160311122710.B76C23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/a74a3846c84ad55de3deeed8b2401a2ed514b2e1/ghc >--------------------------------------------------------------- commit a74a3846c84ad55de3deeed8b2401a2ed514b2e1 Author: Ben Gamari Date: Fri Mar 11 10:39:20 2016 +0100 Include version in AC_PACKAGE_TARNAME `AC_PACKAGE_TARNAME` is used by autoconf to generate the default value of docdir, which we now set to include a version number (see #11354). This fixed #11659. Test Plan: `./configure --help`, validate Reviewers: austin, thomie, hvr, erikd Reviewed By: hvr, erikd Subscribers: erikd Differential Revision: https://phabricator.haskell.org/D1983 GHC Trac Issues: #11659 >--------------------------------------------------------------- a74a3846c84ad55de3deeed8b2401a2ed514b2e1 configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index adc22dd..dbc19de 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.1], [glasgow-haskell-bugs at haskell.org], [ghc]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.1], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Set this to YES for a released version, otherwise NO : ${RELEASE=NO} From git at git.haskell.org Fri Mar 11 12:27:14 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:14 +0000 (UTC) Subject: [commit: ghc] master: add regression test for #11145. (f3def76) Message-ID: <20160311122714.1487E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/f3def7643d390db54d18b8c3d385c490fba58a41/ghc >--------------------------------------------------------------- commit f3def7643d390db54d18b8c3d385c490fba58a41 Author: Dominik Bollmann Date: Fri Mar 11 10:38:28 2016 +0100 add regression test for #11145. The original TH failure observed by the ticket, namely that Template Haskell quotes of data instance GADTs are broken, is not observable anymore in HEAD. I therefore just added the corresponding regression test. Test Plan: ./validate Reviewers: goldfire, austin, thomie, jstolarek, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1978 GHC Trac Issues: #11145 >--------------------------------------------------------------- f3def7643d390db54d18b8c3d385c490fba58a41 testsuite/tests/th/T11145.hs | 9 +++++++++ testsuite/tests/th/T11145.stderr | 8 ++++++++ testsuite/tests/th/all.T | 1 + 3 files changed, 18 insertions(+) diff --git a/testsuite/tests/th/T11145.hs b/testsuite/tests/th/T11145.hs new file mode 100644 index 0000000..f3968e9 --- /dev/null +++ b/testsuite/tests/th/T11145.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TemplateHaskell #-} +module T11145 where + +data family Fuggle x y + +[d| data instance Fuggle Int (Maybe (a,b)) where + MkFuggle :: Fuggle Int (Maybe Bool) |] diff --git a/testsuite/tests/th/T11145.stderr b/testsuite/tests/th/T11145.stderr new file mode 100644 index 0000000..98e518c --- /dev/null +++ b/testsuite/tests/th/T11145.stderr @@ -0,0 +1,8 @@ + +T11145.hs:8:1: error: + ? Data constructor ?MkFuggle? returns type ?Fuggle + Int (Maybe Bool)? + instead of an instance of its parent type ?Fuggle + Int (Maybe (a_a4MU, b_a4MV))? + ? In the definition of data constructor ?MkFuggle? + In the data instance declaration for ?Fuggle? diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index c39136b..7e9f25d 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -396,3 +396,4 @@ test('TH_finalizer', normal, compile, ['-v0']) test('T10603', normal, compile, ['-ddump-splices -dsuppress-uniques']) test('T11452', normal, compile_fail, ['-v0']) test('T9022', normal, compile_and_run, ['-v0']) +test('T11145', normal, compile_fail, ['-v0']) \ No newline at end of file From git at git.haskell.org Fri Mar 11 12:27:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:16 +0000 (UTC) Subject: [commit: ghc] master: Add Note [Running splices in the Renamer] (d48220e) Message-ID: <20160311122716.CF40C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/d48220eb7b2029ab90ea8185ac82b6bed51009ad/ghc >--------------------------------------------------------------- commit d48220eb7b2029ab90ea8185ac82b6bed51009ad Author: Owen Stephens Date: Fri Mar 11 10:39:55 2016 +0100 Add Note [Running splices in the Renamer] Reviewers: austin, goldfire, bgamari Reviewed By: goldfire, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1985 >--------------------------------------------------------------- d48220eb7b2029ab90ea8185ac82b6bed51009ad compiler/rename/RnSplice.hs | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/compiler/rename/RnSplice.hs b/compiler/rename/RnSplice.hs index 9279be1..b23621d 100644 --- a/compiler/rename/RnSplice.hs +++ b/compiler/rename/RnSplice.hs @@ -402,12 +402,54 @@ rnSpliceExpr splice ; return (HsSpliceE rn_splice, lcl_names `plusFV` gbl_names) } - | otherwise -- Run it here + | otherwise -- Run it here, see Note [Running splices in the Renamer] = do { traceRn (text "rnSpliceExpr: untyped expression splice") ; rn_expr <- runRnSplice UntypedExpSplice runMetaE ppr rn_splice ; (lexpr3, fvs) <- checkNoErrs (rnLExpr rn_expr) ; return (HsPar lexpr3, fvs) } +{- Note [Running splices in the Renamer] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Splices used to be run in the typechecker, which led to (Trac #4364). Since the +renamer must decide which expressions depend on which others, and it cannot +reliably do this for arbitrary splices, we used to conservatively say that +splices depend on all other expressions in scope. Unfortunately, this led to +the problem of cyclic type declarations seen in (Trac #4364). Instead, by +running splices in the renamer, we side-step the problem of determining +dependencies: by the time the dependency analysis happens, any splices have +already been run, and expression dependencies can be determined as usual. + +However, see (Trac #9813), for an example where we would like to run splices +*after* performing dependency analysis (that is, after renaming). It would be +desirable to typecheck "non-splicy" expressions (those expressions that do not +contain splices directly or via dependence on an expression that does) before +"splicy" expressions, such that types/expressions within the same declaration +group would be available to `reify` calls, for example consider the following: + +> module M where +> data D = C +> f = 1 +> g = $(mapM reify ['f, 'D, ''C] ...) + +Compilation of this example fails since D/C/f are not in the type environment +and thus cannot be reified as they have not been typechecked by the time the +splice is renamed and thus run. + +These requirements are at odds: we do not want to run splices in the renamer as +we wish to first determine dependencies and typecheck certain expressions, +making them available to reify, but cannot accurately determine dependencies +without running splices in the renamer! + +Indeed, the conclusion of (Trac #9813) was that it is not worth the complexity +to try and + a) implement and maintain the code for renaming/typechecking non-splicy + expressions before splicy expressions, + b) explain to TH users which expressions are/not available to reify at any + given point. + +-} + ---------------------- rnSpliceType :: HsSplice RdrName -> PostTc Name Kind -> RnM (HsType Name, FreeVars) From git at git.haskell.org Fri Mar 11 12:27:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:19 +0000 (UTC) Subject: [commit: ghc] master: Fix readme link to FixingBugs wiki page (90b8af0) Message-ID: <20160311122719.829543A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/90b8af05660dc2b36c62a07ff86703cbb9e04766/ghc >--------------------------------------------------------------- commit 90b8af05660dc2b36c62a07ff86703cbb9e04766 Author: Chris Martin Date: Fri Mar 11 10:40:06 2016 +0100 Fix readme link to FixingBugs wiki page Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1988 >--------------------------------------------------------------- 90b8af05660dc2b36c62a07ff86703cbb9e04766 README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 227657f..2cecbdc 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ There are two ways to get a source tree: repository from Github] [7]. **DO NOT submit pull request directly to the github repo.** - *See the GHC team's working conventions re [how to contribute a patch to GHC](http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs "ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBug").* + *See the GHC team's working conventions re [how to contribute a patch to GHC](http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs).* Building & Installing From git at git.haskell.org Fri Mar 11 12:27:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:22 +0000 (UTC) Subject: [commit: ghc] master: Make integer-gmp operations more strict (f8056fc) Message-ID: <20160311122722.32F8F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/f8056fca87e83fd37d3f2441f5cb0335e12e3aef/ghc >--------------------------------------------------------------- commit f8056fca87e83fd37d3f2441f5cb0335e12e3aef Author: Herbert Valerio Riedel Date: Fri Mar 11 10:39:30 2016 +0100 Make integer-gmp operations more strict Reviewers: austin, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1984 GHC Trac Issues: #10691 >--------------------------------------------------------------- f8056fca87e83fd37d3f2441f5cb0335e12e3aef libraries/integer-gmp/src/GHC/Integer/Type.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/integer-gmp/src/GHC/Integer/Type.hs b/libraries/integer-gmp/src/GHC/Integer/Type.hs index 3e563dc..9ed17fc 100644 --- a/libraries/integer-gmp/src/GHC/Integer/Type.hs +++ b/libraries/integer-gmp/src/GHC/Integer/Type.hs @@ -426,7 +426,7 @@ minusInteger x y = inline plusInteger x (inline negateInteger y) -- | Multiply two 'Integer's timesInteger :: Integer -> Integer -> Integer -timesInteger _ (S# 0#) = S# 0# +timesInteger !_ (S# 0#) = S# 0# timesInteger (S# 0#) _ = S# 0# timesInteger x (S# 1#) = x timesInteger (S# 1#) y = y @@ -515,7 +515,7 @@ bitInteger i# -- | Test if /n/-th bit is set. testBitInteger :: Integer -> Int# -> Bool -testBitInteger _ n# | isTrue# (n# <# 0#) = False +testBitInteger !_ n# | isTrue# (n# <# 0#) = False testBitInteger (S# i#) n# | isTrue# (n# <# GMP_LIMB_BITS#) = isTrue# (((uncheckedIShiftL# 1# n#) `andI#` i#) /=# 0#) @@ -614,7 +614,7 @@ xorInteger x y {- S# -} = xorInteger x (unsafePromote y) -- | Bitwise AND operation andInteger :: Integer -> Integer -> Integer -- short-cuts -andInteger (S# 0#) _ = S# 0# +andInteger (S# 0#) !_ = S# 0# andInteger _ (S# 0#) = S# 0# andInteger (S# -1#) y = y andInteger x (S# -1#) = x @@ -646,7 +646,7 @@ unsafePromote x = x quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) quotRemInteger n (S# 1#) = (# n, S# 0# #) quotRemInteger n (S# -1#) = let !q = negateInteger n in (# q, (S# 0#) #) -quotRemInteger _ (S# 0#) = (# S# (quotInt# 0# 0#),S# (remInt# 0# 0#) #) +quotRemInteger !_ (S# 0#) = (# S# (quotInt# 0# 0#),S# (remInt# 0# 0#) #) quotRemInteger (S# 0#) _ = (# S# 0#, S# 0# #) quotRemInteger (S# n#) (S# d#) = case quotRemInt# n# d# of (# q#, r# #) -> (# S# q#, S# r# #) @@ -679,7 +679,7 @@ quotRemInteger n@(S# n#) (Jp# d) -- need to account for (S# minBound) quotInteger :: Integer -> Integer -> Integer quotInteger n (S# 1#) = n quotInteger n (S# -1#) = negateInteger n -quotInteger _ (S# 0#) = S# (quotInt# 0# 0#) +quotInteger !_ (S# 0#) = S# (quotInt# 0# 0#) quotInteger (S# 0#) _ = S# 0# quotInteger (S# n#) (S# d#) = S# (quotInt# n# d#) quotInteger (Jp# n) (S# d#) @@ -699,7 +699,7 @@ quotInteger n d = case inline quotRemInteger n d of (# q, _ #) -> q {-# CONSTANT_FOLDED quotInteger #-} remInteger :: Integer -> Integer -> Integer -remInteger _ (S# 1#) = S# 0# +remInteger !_ (S# 1#) = S# 0# remInteger _ (S# -1#) = S# 0# remInteger _ (S# 0#) = S# (remInt# 0# 0#) remInteger (S# 0#) _ = S# 0# @@ -763,7 +763,7 @@ gcdInteger (Jp# a) (S# b#) -- | Compute least common multiple. lcmInteger :: Integer -> Integer -> Integer -lcmInteger (S# 0#) _ = S# 0# +lcmInteger (S# 0#) !_ = S# 0# lcmInteger (S# 1#) b = absInteger b lcmInteger (S# -1#) b = absInteger b lcmInteger _ (S# 0#) = S# 0# @@ -998,7 +998,7 @@ sqrBigNat x sqrBigNat x = timesBigNat x x -- TODO: mpn_sqr timesBigNatWord :: BigNat -> GmpLimb# -> BigNat -timesBigNatWord _ 0## = zeroBigNat +timesBigNatWord !_ 0## = zeroBigNat timesBigNatWord x 1## = x timesBigNatWord x@(BN# x#) y# | isTrue# (nx# ==# 1#) = @@ -1231,7 +1231,7 @@ remBigNat n@(BN# nba#) d@(BN# dba#) -- | Note: Result of div/0 undefined quotRemBigNatWord :: BigNat -> GmpLimb# -> (# BigNat, GmpLimb# #) -quotRemBigNatWord _ 0## = (# nullBigNat, 0## #) +quotRemBigNatWord !_ 0## = (# nullBigNat, 0## #) quotRemBigNatWord n 1## = (# n, 0## #) quotRemBigNatWord n@(BN# nba#) d# = case compareBigNatWord n d# of LT -> (# zeroBigNat, bigNatToWord n #) From git at git.haskell.org Fri Mar 11 12:27:24 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:24 +0000 (UTC) Subject: [commit: ghc] master: Add doc to (<$>) explaining its relationship to ($) (06b70ff) Message-ID: <20160311122724.D81C03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/06b70ffc7b17bd34ea771b8be11574c4002db6c8/ghc >--------------------------------------------------------------- commit 06b70ffc7b17bd34ea771b8be11574c4002db6c8 Author: Chris Martin Date: Fri Mar 11 10:40:16 2016 +0100 Add doc to (<$>) explaining its relationship to ($) Reviewers: bgamari, hvr, austin Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1989 >--------------------------------------------------------------- 06b70ffc7b17bd34ea771b8be11574c4002db6c8 libraries/base/Data/Functor.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libraries/base/Data/Functor.hs b/libraries/base/Data/Functor.hs index 72ee965..8eba29e 100644 --- a/libraries/base/Data/Functor.hs +++ b/libraries/base/Data/Functor.hs @@ -33,6 +33,15 @@ infixl 4 <$> -- | An infix synonym for 'fmap'. -- +-- The name of this operator is an allusion to '$'. +-- Note the similarities between their types: +-- +-- > ($) :: (a -> b) -> a -> b +-- > (<$>) :: Functor f => (a -> b) -> f a -> f b +-- +-- Whereas '$' is function application, '<$>' is function +-- application lifted over a 'Functor'. +-- -- ==== __Examples__ -- -- Convert from a @'Maybe' 'Int'@ to a @'Maybe' 'String'@ using 'show': From git at git.haskell.org Fri Mar 11 12:27:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:27 +0000 (UTC) Subject: [commit: ghc] master: rtx/posix/Itimer.c: Handle return value of `read` (8626d76) Message-ID: <20160311122727.8FCA53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/8626d76a723c2514bab91afb82e6b8b94fed2a2b/ghc >--------------------------------------------------------------- commit 8626d76a723c2514bab91afb82e6b8b94fed2a2b Author: Erik de Castro Lopo Date: Fri Mar 11 10:40:50 2016 +0100 rtx/posix/Itimer.c: Handle return value of `read` On Ubuntu libc's `read` function is marked with attribute `warn_unused_result` which was causing build failures on Harbourmaster. Test Plan: validate on Harbourmaster Reviewers: austin, hvr, bgamari Reviewed By: hvr, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1993 GHC Trac Issues: #11697 >--------------------------------------------------------------- 8626d76a723c2514bab91afb82e6b8b94fed2a2b rts/posix/Itimer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index f6c00a6..b833295 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -202,7 +202,8 @@ static void *itimer_thread_func(void *_handle_tick) while (1) { if (USE_TIMERFD_FOR_ITIMER) { - read(timerfd, &nticks, sizeof(nticks)); + if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) + sysErrorBelch("Itimer: read(timer_fd) failed"); } else { usleep(TimeToUS(itimer_interval)); } From git at git.haskell.org Fri Mar 11 12:27:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:30 +0000 (UTC) Subject: [commit: ghc] master: Add MonadUnique instance for LlvmM (6a2992d) Message-ID: <20160311122730.513163A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/6a2992dc4b6582bd95b0cef1a674a99ca8299403/ghc >--------------------------------------------------------------- commit 6a2992dc4b6582bd95b0cef1a674a99ca8299403 Author: Ben Gamari Date: Fri Mar 11 10:41:05 2016 +0100 Add MonadUnique instance for LlvmM Reviewers: erikd, austin Reviewed By: erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1994 >--------------------------------------------------------------- 6a2992dc4b6582bd95b0cef1a674a99ca8299403 compiler/llvmGen/LlvmCodeGen/Base.hs | 21 ++++++++++++++------- compiler/llvmGen/LlvmCodeGen/CodeGen.hs | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/compiler/llvmGen/LlvmCodeGen/Base.hs b/compiler/llvmGen/LlvmCodeGen/Base.hs index 3a60891..3e2b795 100644 --- a/compiler/llvmGen/LlvmCodeGen/Base.hs +++ b/compiler/llvmGen/LlvmCodeGen/Base.hs @@ -18,7 +18,7 @@ module LlvmCodeGen.Base ( runLlvm, liftStream, withClearVars, varLookup, varInsert, markStackReg, checkStackReg, funLookup, funInsert, getLlvmVer, getDynFlags, getDynFlag, getLlvmPlatform, - dumpIfSetLlvm, renderLlvm, runUs, markUsedVar, getUsedVars, + dumpIfSetLlvm, renderLlvm, markUsedVar, getUsedVars, ghcInternalFunctions, getMetaUniqueId, @@ -224,6 +224,19 @@ instance Monad LlvmM where instance HasDynFlags LlvmM where getDynFlags = LlvmM $ \env -> return (envDynFlags env, env) +instance MonadUnique LlvmM where + getUniqueSupplyM = do + us <- getEnv envUniq + let (us1, us2) = splitUniqSupply us + modifyEnv (\s -> s { envUniq = us2 }) + return us1 + + getUniqueM = do + us <- getEnv envUniq + let (u,us') = takeUniqFromSupply us + modifyEnv (\s -> s { envUniq = us' }) + return u + -- | Lifting of IO actions. Not exported, as we want to encapsulate IO. liftIO :: IO a -> LlvmM a liftIO m = LlvmM $ \env -> do x <- m @@ -323,12 +336,6 @@ renderLlvm sdoc = do dumpIfSetLlvm Opt_D_dump_llvm "LLVM Code" sdoc return () --- | Run a @UniqSM@ action with our unique supply -runUs :: UniqSM a -> LlvmM a -runUs m = LlvmM $ \env -> do - let (x, us') = initUs (envUniq env) m - return (x, env { envUniq = us' }) - -- | Marks a variable as "used" markUsedVar :: LlvmVar -> LlvmM () markUsedVar v = modifyEnv $ \env -> env { envUsedVars = v : envUsedVars env } diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs index 4bc6248..fa47d6a 100644 --- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs @@ -144,7 +144,7 @@ getInstrinct2 fname fty@(LMFunction funSig) = do return [] Nothing -> do funInsert fname fty - un <- runUs getUniqueM + un <- getUniqueM let lbl = mkAsmTempLabel un return [CmmData (Section Data lbl) [([],[fty])]] @@ -1783,7 +1783,7 @@ getHsFunc' name fty -- | Create a new local var mkLocalVar :: LlvmType -> LlvmM LlvmVar mkLocalVar ty = do - un <- runUs getUniqueM + un <- getUniqueM return $ LMLocalVar un ty From git at git.haskell.org Fri Mar 11 12:27:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:32 +0000 (UTC) Subject: [commit: ghc] master: Add ghc-flag directory for -XPatternGuards (e764ede) Message-ID: <20160311122732.F28873A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e764ede35f5c5b2c41e1670c6a9b831e0a70cd17/ghc >--------------------------------------------------------------- commit e764ede35f5c5b2c41e1670c6a9b831e0a70cd17 Author: Ben Gamari Date: Fri Mar 11 10:41:30 2016 +0100 Add ghc-flag directory for -XPatternGuards Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1987 >--------------------------------------------------------------- e764ede35f5c5b2c41e1670c6a9b831e0a70cd17 docs/users_guide/glasgow_exts.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index dd714ec..f46a6d6 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -385,11 +385,15 @@ instance, the binary integer literal ``0b11001001`` will be desugared into Pattern guards -------------- -Pattern guards (Glasgow extension) The discussion that follows is an -abbreviated version of Simon Peyton Jones's original -`proposal `__. -(Note that the proposal was written before pattern guards were -implemented, so refers to them as unimplemented.) +.. ghc-flag:: -XPatternGuards + + Enable pattern matches in guards. + +The discussion that follows is an abbreviated version of Simon Peyton Jones's +original `proposal +`__. (Note that the +proposal was written before pattern guards were implemented, so refers to them +as unimplemented.) Suppose we have an abstract data type of finite maps, with a lookup operation: :: From git at git.haskell.org Fri Mar 11 12:27:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:35 +0000 (UTC) Subject: [commit: ghc] master: Handle unset HOME environment variable more gracefully (2908ae8) Message-ID: <20160311122735.AB14E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2908ae8dbe8fd69f8c3ac3dab199026dfc250445/ghc >--------------------------------------------------------------- commit 2908ae8dbe8fd69f8c3ac3dab199026dfc250445 Author: Ben Gamari Date: Fri Mar 11 10:44:03 2016 +0100 Handle unset HOME environment variable more gracefully Test Plan: * Validate * try `env -i ghc` * try `env -i runghc HelloWorld.hs` Reviewers: austin Subscribers: thomie, ezyang Differential Revision: https://phabricator.haskell.org/D1971 GHC Trac Issues: #11678 >--------------------------------------------------------------- 2908ae8dbe8fd69f8c3ac3dab199026dfc250445 compiler/main/DynFlags.hs | 9 +++++---- compiler/main/Packages.hs | 6 +++--- compiler/utils/Maybes.hs | 10 +++++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index ce51d3e..2e8af7d 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1046,9 +1046,10 @@ opt_i dflags = sOpt_i (settings dflags) -- | The directory for this version of ghc in the user's app directory -- (typically something like @~/.ghc/x86_64-linux-7.6.3@) -- -versionedAppDir :: DynFlags -> IO FilePath +versionedAppDir :: DynFlags -> MaybeT IO FilePath versionedAppDir dflags = do - appdir <- getAppUserDataDirectory (programName dflags) + -- Make sure we handle the case the HOME isn't set (see #11678) + appdir <- tryMaybeT $ getAppUserDataDirectory (programName dflags) return $ appdir versionedFilePath dflags -- | A filepath like @x86_64-linux-7.6.3@ with the platform string to use when @@ -4334,7 +4335,7 @@ interpretPackageEnv dflags = do namedEnvPath :: String -> MaybeT IO FilePath namedEnvPath name = do - appdir <- liftMaybeT $ versionedAppDir dflags + appdir <- versionedAppDir dflags return $ appdir "environments" name probeEnvName :: String -> MaybeT IO FilePath @@ -4394,7 +4395,7 @@ interpretPackageEnv dflags = do findLocalEnvFile :: MaybeT IO FilePath findLocalEnvFile = do curdir <- liftMaybeT getCurrentDirectory - homedir <- liftMaybeT getHomeDirectory + homedir <- tryMaybeT getHomeDirectory let probe dir | isDrive dir || dir == homedir = mzero probe dir = do diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs index decd7a1..2655c45 100644 --- a/compiler/main/Packages.hs +++ b/compiler/main/Packages.hs @@ -384,11 +384,11 @@ resolvePackageConfig dflags GlobalPkgConf = return $ Just (systemPackageConfig d -- NB: This logic is reimplemented in Cabal, so if you change it, -- make sure you update Cabal. (Or, better yet, dump it in the -- compiler info so Cabal can use the info.) -resolvePackageConfig dflags UserPkgConf = handleIO (\_ -> return Nothing) $ do +resolvePackageConfig dflags UserPkgConf = runMaybeT $ do dir <- versionedAppDir dflags let pkgconf = dir "package.conf.d" - exist <- doesDirectoryExist pkgconf - return $ if exist then Just pkgconf else Nothing + exist <- tryMaybeT $ doesDirectoryExist pkgconf + if exist then return pkgconf else mzero resolvePackageConfig _ (PkgConfFile name) = return $ Just name readPackageConfig :: DynFlags -> FilePath -> IO (FilePath, [PackageConfig]) diff --git a/compiler/utils/Maybes.hs b/compiler/utils/Maybes.hs index 83dc9b6..a736e3d 100644 --- a/compiler/utils/Maybes.hs +++ b/compiler/utils/Maybes.hs @@ -14,11 +14,13 @@ module Maybes ( whenIsJust, expectJust, - MaybeT(..), liftMaybeT + -- * MaybeT + MaybeT(..), liftMaybeT, tryMaybeT ) where import Control.Monad import Control.Monad.Trans.Maybe +import Control.Exception (catch, SomeException(..)) import Data.Maybe infixr 4 `orElse` @@ -65,6 +67,12 @@ orElse = flip fromMaybe liftMaybeT :: Monad m => m a -> MaybeT m a liftMaybeT act = MaybeT $ Just `liftM` act +-- | Try performing an 'IO' action, failing on error. +tryMaybeT :: IO a -> MaybeT IO a +tryMaybeT action = MaybeT $ catch (Just `fmap` action) handler + where + handler (SomeException _) = return Nothing + {- ************************************************************************ * * From git at git.haskell.org Fri Mar 11 12:27:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:38 +0000 (UTC) Subject: [commit: ghc] master: Move getOccFS to Name (3ea11eb) Message-ID: <20160311122738.57F2D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3ea11eb1c367a15e5b7dac83d31937ac7d44b3b2/ghc >--------------------------------------------------------------- commit 3ea11eb1c367a15e5b7dac83d31937ac7d44b3b2 Author: Ben Gamari Date: Fri Mar 11 11:42:01 2016 +0100 Move getOccFS to Name >--------------------------------------------------------------- 3ea11eb1c367a15e5b7dac83d31937ac7d44b3b2 compiler/basicTypes/Name.hs | 4 +++- compiler/iface/MkIface.hs | 17 +++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler/basicTypes/Name.hs b/compiler/basicTypes/Name.hs index 74eec8a..eb820d4 100644 --- a/compiler/basicTypes/Name.hs +++ b/compiler/basicTypes/Name.hs @@ -68,7 +68,7 @@ module Name ( -- * Class 'NamedThing' and overloaded friends NamedThing(..), - getSrcLoc, getSrcSpan, getOccString, + getSrcLoc, getSrcSpan, getOccString, getOccFS, pprInfixName, pprPrefixName, pprModulePrefix, nameStableString, @@ -633,10 +633,12 @@ class NamedThing a where getSrcLoc :: NamedThing a => a -> SrcLoc getSrcSpan :: NamedThing a => a -> SrcSpan getOccString :: NamedThing a => a -> String +getOccFS :: NamedThing a => a -> FastString getSrcLoc = nameSrcLoc . getName getSrcSpan = nameSrcSpan . getName getOccString = occNameString . getOccName +getOccFS = occNameFS . getOccName pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc -- See Outputable.pprPrefixVar, pprInfixVar; diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 4bd5c36..6970b08 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -1427,7 +1427,7 @@ tyConToIfaceDecl env tycon if_binders = zipIfaceBinders tc_tyvars (tyConBinders tycon) if_res_kind = tidyToIfaceType tc_env1 (tyConResKind tycon) if_syn_type ty = tidyToIfaceType tc_env1 ty - if_res_var = getFS `fmap` tyConFamilyResVar_maybe tycon + if_res_var = getOccFS `fmap` tyConFamilyResVar_maybe tycon -- use these when you don't have tyConTyVars (degenerate_binders, degenerate_res_kind) @@ -1528,7 +1528,7 @@ classToIfaceDecl env clas ifFDs = map toIfaceFD clas_fds, ifATs = map toIfaceAT clas_ats, ifSigs = map toIfaceClassOp op_stuff, - ifMinDef = fmap getFS (classMinimalDef clas), + ifMinDef = fmap getOccFS (classMinimalDef clas), ifRec = boolToRecFlag (isRecursiveTyCon tycon) }) where (clas_tyvars, clas_fds, sc_theta, _, clas_ats, op_stuff) @@ -1562,8 +1562,8 @@ classToIfaceDecl env clas toDmSpec (_, VanillaDM) = VanillaDM toDmSpec (_, GenericDM dm_ty) = GenericDM (tidyToIfaceType env1 dm_ty) - toIfaceFD (tvs1, tvs2) = (map (getFS . tidyTyVar env1) tvs1, - map (getFS . tidyTyVar env1) tvs2) + toIfaceFD (tvs1, tvs2) = (map (getOccFS . tidyTyVar env1) tvs1, + map (getOccFS . tidyTyVar env1) tvs2) -------------------------- tidyToIfaceType :: TidyEnv -> Type -> IfaceType @@ -1590,9 +1590,6 @@ tidyTyVar :: TidyEnv -> TyVar -> TyVar tidyTyVar (_, subst) tv = lookupVarEnv subst tv `orElse` tv -- TcType.tidyTyVarOcc messes around with FlatSkols -getFS :: NamedThing a => a -> FastString -getFS x = occNameFS (getOccName x) - -------------------------- instanceToIfaceInst :: ClsInst -> IfaceClsInst instanceToIfaceInst (ClsInst { is_dfun = dfun_id, is_flag = oflag @@ -1768,7 +1765,7 @@ toIfaceExpr (Lam x b) = IfaceLam (toIfaceBndr x, toIfaceOneShot x) (toIfac toIfaceExpr (App f a) = toIfaceApp f [a] toIfaceExpr (Case s x ty as) | null as = IfaceECase (toIfaceExpr s) (toIfaceType ty) - | otherwise = IfaceCase (toIfaceExpr s) (getFS x) (map toIfaceAlt as) + | otherwise = IfaceCase (toIfaceExpr s) (getOccFS x) (map toIfaceAlt as) toIfaceExpr (Let b e) = IfaceLet (toIfaceBind b) (toIfaceExpr e) toIfaceExpr (Cast e co) = IfaceCast (toIfaceExpr e) (toIfaceCoercion co) toIfaceExpr (Tick t e) @@ -1799,7 +1796,7 @@ toIfaceBind (Rec prs) = IfaceRec [(toIfaceLetBndr b, toIfaceExpr r) | (b,r) < --------------------- toIfaceAlt :: (AltCon, [Var], CoreExpr) -> (IfaceConAlt, [FastString], IfaceExpr) -toIfaceAlt (c,bs,r) = (toIfaceCon c, map getFS bs, toIfaceExpr r) +toIfaceAlt (c,bs,r) = (toIfaceCon c, map getOccFS bs, toIfaceExpr r) --------------------- toIfaceCon :: AltCon -> IfaceConAlt @@ -1835,5 +1832,5 @@ toIfaceVar v | Just fcall <- isFCallId_maybe v = IfaceFCall fcall (toIfaceType (idType v)) -- Foreign calls have special syntax | isExternalName name = IfaceExt name - | otherwise = IfaceLcl (getFS name) + | otherwise = IfaceLcl (getOccFS name) where name = idName v From git at git.haskell.org Fri Mar 11 12:27:41 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 12:27:41 +0000 (UTC) Subject: [commit: ghc] master: Bump allocations for T6048 (7ba817c) Message-ID: <20160311122741.03C893A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/7ba817c217d3c5c4dd9550b0cf0f4314b54895a3/ghc >--------------------------------------------------------------- commit 7ba817c217d3c5c4dd9550b0cf0f4314b54895a3 Author: Ben Gamari Date: Fri Mar 11 13:23:30 2016 +0100 Bump allocations for T6048 This occassionally fails with allocations a few tenths of a percent above threshold. Sadly there isn't a clear cause; it's likely just the result of gradual creep, further underscoring the need for more regular performance characterization. >--------------------------------------------------------------- 7ba817c217d3c5c4dd9550b0cf0f4314b54895a3 testsuite/tests/perf/compiler/all.T | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index 61ac9b2..e7e467c 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -587,7 +587,7 @@ test('T6048', # 2014-09-03: 56315812 (x86 Windows, w/w for INLINEAVBLE) # 2014-12-01: 49987836 (x86 Windows) - (wordsize(64), 95946688, 12)]) + (wordsize(64), 108225624, 12)]) # 18/09/2012 97247032 amd64/Linux # 16/01/2014 108578664 amd64/Linux (unknown, likely foldl-via-foldr) # 18/01/2014 95960720 amd64/Linux Call Arity improvements @@ -597,6 +597,7 @@ test('T6048', # 29/08/2014 108354472 amd64/Linux w/w for INLINABLE things # 14/09/2014 88186056 amd64/Linux BPP part1 change (more NoImplicitPreludes in base) # 08/01/2014 95946688 amd64/Linux Mostly 4c834fd. Occasional spikes to 103822120! + # 11/03/2016 108225624 amd64/Linux unknown reason sadly; likely gradual creep. ], compile,['']) From git at git.haskell.org Fri Mar 11 13:26:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 13:26:47 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Do not check synonym RHS for ambiguity (43163e3) Message-ID: <20160311132647.B451F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/43163e3bd5bcd7c92fc692b365be750a7b766026/ghc >--------------------------------------------------------------- commit 43163e3bd5bcd7c92fc692b365be750a7b766026 Author: Simon Peyton Jones Date: Mon Feb 29 14:12:28 2016 +0000 Do not check synonym RHS for ambiguity With this patch we no longer check the RHS of a type synonym declaration for ambiguity. It only affects type synonyms with foralls on the RHS (which are rare in the first place), and it's arguably over-aggressive to check them for ambiguity. See TcValidity Note [When we don't check for ambiguity] This fixes the ASSERT failures in th T3100 typecheck/should_compile T3692 typecheck/should_fail T3592 (cherry picked from commit 3c29c770be7a8c7268dcb8d8624853428aa42071) >--------------------------------------------------------------- 43163e3bd5bcd7c92fc692b365be750a7b766026 compiler/typecheck/TcValidity.hs | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs index d436f95..6b8b347 100644 --- a/compiler/typecheck/TcValidity.hs +++ b/compiler/typecheck/TcValidity.hs @@ -217,13 +217,10 @@ checkAmbiguity ctxt ty wantAmbiguityCheck :: UserTypeCtxt -> Bool wantAmbiguityCheck ctxt - = case ctxt of - GhciCtxt -> False -- Allow ambiguous types in GHCi's :kind command - -- E.g. type family T a :: * -- T :: forall k. k -> * - -- Then :k T should work in GHCi, not complain that - -- (T k) is ambiguous! - _ -> True - + = case ctxt of -- See Note [When we don't check for ambiguity] + GhciCtxt -> False + TySynCtxt {} -> False + _ -> True checkUserTypeError :: Type -> TcM () -- Check to see if the type signature mentions "TypeError blah" @@ -248,7 +245,26 @@ checkUserTypeError = check ; failWithTcM (env1, pprUserTypeErrorTy tidy_msg) } -{- +{- Note [When we don't check for ambiguity] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In a few places we do not want to check a user-specified type for ambiguity + +* GhciCtxt: Allow ambiguous types in GHCi's :kind command + E.g. type family T a :: * -- T :: forall k. k -> * + Then :k T should work in GHCi, not complain that + (T k) is ambiguous! + +* TySynCtxt: type T a b = C a b => blah + It may be that when we /use/ T, we'll give an 'a' or 'b' that somehow + cure the ambiguity. So we defer the ambiguity check to the use site. + + There is also an implementation reason (Trac #11608). In the RHS of + a type synonym we don't (currently) instantiate 'a' and 'b' with + TcTyVars before calling checkValidType, so we get asertion failures + from doing an ambiguity check on a type with TyVars in it. Fixing this + would not be hard, but let's wait till there's a reason. + + ************************************************************************ * * Checking validity of a user-defined type @@ -460,13 +476,12 @@ check_type env ctxt rank ty where (tvs, theta, tau) = tcSplitSigmaTy ty tau_kind = typeKind tau + (env', _) = tidyTyCoVarBndrs env tvs phi_kind | null theta = tau_kind | otherwise = liftedTypeKind -- If there are any constraints, the kind is *. (#11405) - (env', _) = tidyTyCoVarBndrs env tvs - check_type _ _ _ (TyVarTy _) = return () check_type env ctxt rank (ForAllTy (Anon arg_ty) res_ty) From git at git.haskell.org Fri Mar 11 13:26:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 13:26:50 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Document Quasi-quotes/list comprehension ambiguity (57cfb47) Message-ID: <20160311132650.73FB53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/57cfb4740424f4ab49f772a241fc38bf18d9d19c/ghc >--------------------------------------------------------------- commit 57cfb4740424f4ab49f772a241fc38bf18d9d19c Author: Ben Gamari Date: Fri Mar 11 10:38:42 2016 +0100 Document Quasi-quotes/list comprehension ambiguity Test Plan: read it Reviewers: austin, goldfire Reviewed By: goldfire Subscribers: hvr, thomie Differential Revision: https://phabricator.haskell.org/D1981 GHC Trac Issues: #11679 (cherry picked from commit 767ff7cab7fc2d27b66cdd25d551ccf9e9e7c51d) >--------------------------------------------------------------- 57cfb4740424f4ab49f772a241fc38bf18d9d19c docs/users_guide/glasgow_exts.rst | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 829d140..faf9172 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1873,7 +1873,15 @@ The following syntax is stolen: Stolen by: :ghc-flag:`-XImplicitParams` -``[|``, ``[e|``, ``[p|``, ``[d|``, ``[t|``, ``$(``, ``$$(``, ``[||``, ``[e||``, ``$varid``, ``$$varid`` +``[|``, ``[e|``, ``[p|``, ``[d|``, ``[t|``, ``[||``, ``[e||`` + .. index:: + single: Quasi-quotes + + Stolen by: :ghc-flag:`-XQuasiQuotes`. Moreover, this introduces an ambiguity + with list comprehension syntax. See + :ref:`quasi-quotes-list-comprehension-ambiguity` for details. + +``$(``, ``$$(``, ``$varid``, ``$$varid`` .. index:: single: Template Haskell @@ -9985,6 +9993,24 @@ Here are the salient features quasi-quotes do not cause a declaration group break. See :ref:`th-syntax` for more information. +.. _quasi-quotes-list-comprehension-ambiguity: + +.. warning:: + + .. index:: + single: quasi-quotes; ambiguity with list comprehensions + single: list comprehensions; ambiguity with quasi-quotes + + :ghc-flag:`-XQuasiQuotes` introduces an unfortunate ambiguity with list + comprehension syntax. Consider the following, :: + + let x = [v| v <- [0..10]] + + Without :ghc-flag:`-XQuasiQuotes` this is parsed as a list comprehension. + With :ghc-flag:`-XQuasiQuotes` this is parsed as a quasi-quote; however, + this parse will fail due to the lack of a closing ``|]``. See + :ghc-ticket:`11679`. + The example below shows quasi-quotation in action. The quoter ``expr`` is bound to a value of type ``QuasiQuoter`` defined in module ``Expr``. The example makes use of an antiquoted variable ``n``, indicated by the From git at git.haskell.org Fri Mar 11 13:26:53 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 13:26:53 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Include version in AC_PACKAGE_TARNAME (cabe462) Message-ID: <20160311132653.29C193A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/cabe4620ca7eeddfcf8b2ee624eac6be029e2276/ghc >--------------------------------------------------------------- commit cabe4620ca7eeddfcf8b2ee624eac6be029e2276 Author: Ben Gamari Date: Fri Mar 11 10:39:20 2016 +0100 Include version in AC_PACKAGE_TARNAME `AC_PACKAGE_TARNAME` is used by autoconf to generate the default value of docdir, which we now set to include a version number (see #11354). This fixed #11659. Test Plan: `./configure --help`, validate Reviewers: austin, thomie, hvr, erikd Reviewed By: hvr, erikd Subscribers: erikd Differential Revision: https://phabricator.haskell.org/D1983 GHC Trac Issues: #11659 (cherry picked from commit a74a3846c84ad55de3deeed8b2401a2ed514b2e1) >--------------------------------------------------------------- cabe4620ca7eeddfcf8b2ee624eac6be029e2276 configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ab0f34b..31b6147 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.0.0], [glasgow-haskell-bugs at haskell.org], [ghc]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.0.0], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Set this to YES for a released version, otherwise NO : ${RELEASE=NO} From git at git.haskell.org Fri Mar 11 13:26:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 13:26:55 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add ghc-flag directory for -XPatternGuards (74bb198) Message-ID: <20160311132655.E1CEA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/74bb1989a7686b3439715b8536dc9705a2484744/ghc >--------------------------------------------------------------- commit 74bb1989a7686b3439715b8536dc9705a2484744 Author: Ben Gamari Date: Fri Mar 11 10:41:30 2016 +0100 Add ghc-flag directory for -XPatternGuards Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1987 (cherry picked from commit e764ede35f5c5b2c41e1670c6a9b831e0a70cd17) >--------------------------------------------------------------- 74bb1989a7686b3439715b8536dc9705a2484744 docs/users_guide/glasgow_exts.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index faf9172..9518c9f 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -385,11 +385,15 @@ instance, the binary integer literal ``0b11001001`` will be desugared into Pattern guards -------------- -Pattern guards (Glasgow extension) The discussion that follows is an -abbreviated version of Simon Peyton Jones's original -`proposal `__. -(Note that the proposal was written before pattern guards were -implemented, so refers to them as unimplemented.) +.. ghc-flag:: -XPatternGuards + + Enable pattern matches in guards. + +The discussion that follows is an abbreviated version of Simon Peyton Jones's +original `proposal +`__. (Note that the +proposal was written before pattern guards were implemented, so refers to them +as unimplemented.) Suppose we have an abstract data type of finite maps, with a lookup operation: :: From git at git.haskell.org Fri Mar 11 13:26:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 13:26:58 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Handle unset HOME environment variable more gracefully (6e524eb) Message-ID: <20160311132658.965713A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6e524ebaf299043990048356b01c045f2d6dc0d5/ghc >--------------------------------------------------------------- commit 6e524ebaf299043990048356b01c045f2d6dc0d5 Author: Ben Gamari Date: Fri Mar 11 10:44:03 2016 +0100 Handle unset HOME environment variable more gracefully Test Plan: * Validate * try `env -i ghc` * try `env -i runghc HelloWorld.hs` Reviewers: austin Subscribers: thomie, ezyang Differential Revision: https://phabricator.haskell.org/D1971 GHC Trac Issues: #11678 (cherry picked from commit 2908ae8dbe8fd69f8c3ac3dab199026dfc250445) >--------------------------------------------------------------- 6e524ebaf299043990048356b01c045f2d6dc0d5 compiler/main/DynFlags.hs | 9 +++++---- compiler/main/Packages.hs | 6 +++--- compiler/utils/Maybes.hs | 10 +++++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 0a54834..fa1141e 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1047,9 +1047,10 @@ opt_i dflags = sOpt_i (settings dflags) -- | The directory for this version of ghc in the user's app directory -- (typically something like @~/.ghc/x86_64-linux-7.6.3@) -- -versionedAppDir :: DynFlags -> IO FilePath +versionedAppDir :: DynFlags -> MaybeT IO FilePath versionedAppDir dflags = do - appdir <- getAppUserDataDirectory (programName dflags) + -- Make sure we handle the case the HOME isn't set (see #11678) + appdir <- tryMaybeT $ getAppUserDataDirectory (programName dflags) return $ appdir versionedFilePath dflags -- | A filepath like @x86_64-linux-7.6.3@ with the platform string to use when @@ -4314,7 +4315,7 @@ interpretPackageEnv dflags = do namedEnvPath :: String -> MaybeT IO FilePath namedEnvPath name = do - appdir <- liftMaybeT $ versionedAppDir dflags + appdir <- versionedAppDir dflags return $ appdir "environments" name probeEnvName :: String -> MaybeT IO FilePath @@ -4374,7 +4375,7 @@ interpretPackageEnv dflags = do findLocalEnvFile :: MaybeT IO FilePath findLocalEnvFile = do curdir <- liftMaybeT getCurrentDirectory - homedir <- liftMaybeT getHomeDirectory + homedir <- tryMaybeT getHomeDirectory let probe dir | isDrive dir || dir == homedir = mzero probe dir = do diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs index 2b3ee59..2f4bdf7 100644 --- a/compiler/main/Packages.hs +++ b/compiler/main/Packages.hs @@ -387,11 +387,11 @@ resolvePackageConfig dflags GlobalPkgConf = return $ Just (systemPackageConfig d -- NB: This logic is reimplemented in Cabal, so if you change it, -- make sure you update Cabal. (Or, better yet, dump it in the -- compiler info so Cabal can use the info.) -resolvePackageConfig dflags UserPkgConf = handleIO (\_ -> return Nothing) $ do +resolvePackageConfig dflags UserPkgConf = runMaybeT $ do dir <- versionedAppDir dflags let pkgconf = dir "package.conf.d" - exist <- doesDirectoryExist pkgconf - return $ if exist then Just pkgconf else Nothing + exist <- tryMaybeT $ doesDirectoryExist pkgconf + if exist then return pkgconf else mzero resolvePackageConfig _ (PkgConfFile name) = return $ Just name readPackageConfig :: DynFlags -> FilePath -> IO (FilePath, [PackageConfig]) diff --git a/compiler/utils/Maybes.hs b/compiler/utils/Maybes.hs index ac51070..f42de8b 100644 --- a/compiler/utils/Maybes.hs +++ b/compiler/utils/Maybes.hs @@ -14,12 +14,14 @@ module Maybes ( whenIsJust, expectJust, - MaybeT(..), liftMaybeT + -- * MaybeT + MaybeT(..), liftMaybeT, tryMaybeT ) where import Control.Applicative as A import Control.Monad import Control.Monad.Trans.Maybe +import Control.Exception (catch, SomeException(..)) import Data.Maybe infixr 4 `orElse` @@ -66,6 +68,12 @@ orElse = flip fromMaybe liftMaybeT :: Monad m => m a -> MaybeT m a liftMaybeT act = MaybeT $ Just `liftM` act +-- | Try performing an 'IO' action, failing on error. +tryMaybeT :: IO a -> MaybeT IO a +tryMaybeT action = MaybeT $ catch (Just `fmap` action) handler + where + handler (SomeException _) = return Nothing + {- ************************************************************************ * * From git at git.haskell.org Fri Mar 11 13:27:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 13:27:01 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Bump allocations for T6048 (15acd42) Message-ID: <20160311132701.469D93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/15acd4227106ed912c8d6ebc476263f70cd4510c/ghc >--------------------------------------------------------------- commit 15acd4227106ed912c8d6ebc476263f70cd4510c Author: Ben Gamari Date: Fri Mar 11 13:23:30 2016 +0100 Bump allocations for T6048 This occassionally fails with allocations a few tenths of a percent above threshold. Sadly there isn't a clear cause; it's likely just the result of gradual creep, further underscoring the need for more regular performance characterization. (cherry picked from commit 7ba817c217d3c5c4dd9550b0cf0f4314b54895a3) >--------------------------------------------------------------- 15acd4227106ed912c8d6ebc476263f70cd4510c testsuite/tests/perf/compiler/all.T | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index 25ebac5..9df08d8 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -587,7 +587,7 @@ test('T6048', # 2014-09-03: 56315812 (x86 Windows, w/w for INLINEAVBLE) # 2014-12-01: 49987836 (x86 Windows) - (wordsize(64), 95946688, 12)]) + (wordsize(64), 108225624, 12)]) # 18/09/2012 97247032 amd64/Linux # 16/01/2014 108578664 amd64/Linux (unknown, likely foldl-via-foldr) # 18/01/2014 95960720 amd64/Linux Call Arity improvements @@ -597,6 +597,7 @@ test('T6048', # 29/08/2014 108354472 amd64/Linux w/w for INLINABLE things # 14/09/2014 88186056 amd64/Linux BPP part1 change (more NoImplicitPreludes in base) # 08/01/2014 95946688 amd64/Linux Mostly 4c834fd. Occasional spikes to 103822120! + # 11/03/2016 108225624 amd64/Linux unknown reason sadly; likely gradual creep. ], compile,['']) From git at git.haskell.org Fri Mar 11 14:21:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:22 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Make integer-gmp operations more strict (8e8b6df) Message-ID: <20160311142122.91E7E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/8e8b6df2e56389a1ed13d4198b1d2f3347706aaa/ghc >--------------------------------------------------------------- commit 8e8b6df2e56389a1ed13d4198b1d2f3347706aaa Author: Herbert Valerio Riedel Date: Fri Mar 11 10:39:30 2016 +0100 Make integer-gmp operations more strict Reviewers: austin, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1984 GHC Trac Issues: #10691 (cherry picked from commit f8056fca87e83fd37d3f2441f5cb0335e12e3aef) >--------------------------------------------------------------- 8e8b6df2e56389a1ed13d4198b1d2f3347706aaa libraries/integer-gmp/src/GHC/Integer/Type.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/integer-gmp/src/GHC/Integer/Type.hs b/libraries/integer-gmp/src/GHC/Integer/Type.hs index 3e563dc..9ed17fc 100644 --- a/libraries/integer-gmp/src/GHC/Integer/Type.hs +++ b/libraries/integer-gmp/src/GHC/Integer/Type.hs @@ -426,7 +426,7 @@ minusInteger x y = inline plusInteger x (inline negateInteger y) -- | Multiply two 'Integer's timesInteger :: Integer -> Integer -> Integer -timesInteger _ (S# 0#) = S# 0# +timesInteger !_ (S# 0#) = S# 0# timesInteger (S# 0#) _ = S# 0# timesInteger x (S# 1#) = x timesInteger (S# 1#) y = y @@ -515,7 +515,7 @@ bitInteger i# -- | Test if /n/-th bit is set. testBitInteger :: Integer -> Int# -> Bool -testBitInteger _ n# | isTrue# (n# <# 0#) = False +testBitInteger !_ n# | isTrue# (n# <# 0#) = False testBitInteger (S# i#) n# | isTrue# (n# <# GMP_LIMB_BITS#) = isTrue# (((uncheckedIShiftL# 1# n#) `andI#` i#) /=# 0#) @@ -614,7 +614,7 @@ xorInteger x y {- S# -} = xorInteger x (unsafePromote y) -- | Bitwise AND operation andInteger :: Integer -> Integer -> Integer -- short-cuts -andInteger (S# 0#) _ = S# 0# +andInteger (S# 0#) !_ = S# 0# andInteger _ (S# 0#) = S# 0# andInteger (S# -1#) y = y andInteger x (S# -1#) = x @@ -646,7 +646,7 @@ unsafePromote x = x quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) quotRemInteger n (S# 1#) = (# n, S# 0# #) quotRemInteger n (S# -1#) = let !q = negateInteger n in (# q, (S# 0#) #) -quotRemInteger _ (S# 0#) = (# S# (quotInt# 0# 0#),S# (remInt# 0# 0#) #) +quotRemInteger !_ (S# 0#) = (# S# (quotInt# 0# 0#),S# (remInt# 0# 0#) #) quotRemInteger (S# 0#) _ = (# S# 0#, S# 0# #) quotRemInteger (S# n#) (S# d#) = case quotRemInt# n# d# of (# q#, r# #) -> (# S# q#, S# r# #) @@ -679,7 +679,7 @@ quotRemInteger n@(S# n#) (Jp# d) -- need to account for (S# minBound) quotInteger :: Integer -> Integer -> Integer quotInteger n (S# 1#) = n quotInteger n (S# -1#) = negateInteger n -quotInteger _ (S# 0#) = S# (quotInt# 0# 0#) +quotInteger !_ (S# 0#) = S# (quotInt# 0# 0#) quotInteger (S# 0#) _ = S# 0# quotInteger (S# n#) (S# d#) = S# (quotInt# n# d#) quotInteger (Jp# n) (S# d#) @@ -699,7 +699,7 @@ quotInteger n d = case inline quotRemInteger n d of (# q, _ #) -> q {-# CONSTANT_FOLDED quotInteger #-} remInteger :: Integer -> Integer -> Integer -remInteger _ (S# 1#) = S# 0# +remInteger !_ (S# 1#) = S# 0# remInteger _ (S# -1#) = S# 0# remInteger _ (S# 0#) = S# (remInt# 0# 0#) remInteger (S# 0#) _ = S# 0# @@ -763,7 +763,7 @@ gcdInteger (Jp# a) (S# b#) -- | Compute least common multiple. lcmInteger :: Integer -> Integer -> Integer -lcmInteger (S# 0#) _ = S# 0# +lcmInteger (S# 0#) !_ = S# 0# lcmInteger (S# 1#) b = absInteger b lcmInteger (S# -1#) b = absInteger b lcmInteger _ (S# 0#) = S# 0# @@ -998,7 +998,7 @@ sqrBigNat x sqrBigNat x = timesBigNat x x -- TODO: mpn_sqr timesBigNatWord :: BigNat -> GmpLimb# -> BigNat -timesBigNatWord _ 0## = zeroBigNat +timesBigNatWord !_ 0## = zeroBigNat timesBigNatWord x 1## = x timesBigNatWord x@(BN# x#) y# | isTrue# (nx# ==# 1#) = @@ -1231,7 +1231,7 @@ remBigNat n@(BN# nba#) d@(BN# dba#) -- | Note: Result of div/0 undefined quotRemBigNatWord :: BigNat -> GmpLimb# -> (# BigNat, GmpLimb# #) -quotRemBigNatWord _ 0## = (# nullBigNat, 0## #) +quotRemBigNatWord !_ 0## = (# nullBigNat, 0## #) quotRemBigNatWord n 1## = (# n, 0## #) quotRemBigNatWord n@(BN# nba#) d# = case compareBigNatWord n d# of LT -> (# zeroBigNat, bigNatToWord n #) From git at git.haskell.org Fri Mar 11 14:21:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:27 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: rtx/posix/Itimer.c: Handle return value of `read` (fd3e581) Message-ID: <20160311142127.E8EF23A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/fd3e581b7c9142247601774afc98e49f63b8af45/ghc >--------------------------------------------------------------- commit fd3e581b7c9142247601774afc98e49f63b8af45 Author: Erik de Castro Lopo Date: Fri Mar 11 10:40:50 2016 +0100 rtx/posix/Itimer.c: Handle return value of `read` On Ubuntu libc's `read` function is marked with attribute `warn_unused_result` which was causing build failures on Harbourmaster. Test Plan: validate on Harbourmaster Reviewers: austin, hvr, bgamari Reviewed By: hvr, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1993 GHC Trac Issues: #11697 (cherry picked from commit 8626d76a723c2514bab91afb82e6b8b94fed2a2b) >--------------------------------------------------------------- fd3e581b7c9142247601774afc98e49f63b8af45 rts/posix/Itimer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index f6c00a6..b833295 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -202,7 +202,8 @@ static void *itimer_thread_func(void *_handle_tick) while (1) { if (USE_TIMERFD_FOR_ITIMER) { - read(timerfd, &nticks, sizeof(nticks)); + if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) + sysErrorBelch("Itimer: read(timer_fd) failed"); } else { usleep(TimeToUS(itimer_interval)); } From git at git.haskell.org Fri Mar 11 14:21:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:25 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: rts/timer: use timerfd_* on Linux instead of alarm signals (bbdc52f) Message-ID: <20160311142125.3BC903A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/bbdc52f3a6e6a28e209fb8f65699121d4ef3a4e3/ghc >--------------------------------------------------------------- commit bbdc52f3a6e6a28e209fb8f65699121d4ef3a4e3 Author: Sylvain HENRY Date: Sat Mar 5 20:00:06 2016 +0100 rts/timer: use timerfd_* on Linux instead of alarm signals Reviewers: erikd, simonmar, austin, bgamari Reviewed By: simonmar, bgamari Subscribers: hvr, thomie Differential Revision: https://phabricator.haskell.org/D1947 GHC Trac Issues: #10840 (cherry picked from commit 120b9cdb31878ecee442c0a4bb9532a9d30c0c64) >--------------------------------------------------------------- bbdc52f3a6e6a28e209fb8f65699121d4ef3a4e3 configure.ac | 2 +- rts/posix/Itimer.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 81 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 31b6147..7b3e2de 100644 --- a/configure.ac +++ b/configure.ac @@ -778,7 +778,7 @@ dnl off_t, because it will affect the result of that test. AC_SYS_LARGEFILE dnl ** check for specific header (.h) files that we are interested in -AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h]) +AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h sched.h]) dnl sys/cpuset.h needs sys/param.h to be included first on FreeBSD 9.1; #7708 AC_CHECK_HEADERS([sys/cpuset.h], [], [], diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index 57c7741..f6c00a6 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -53,6 +53,31 @@ #define USE_PTHREAD_FOR_ITIMER #endif +/* + * On Linux in the threaded RTS we can use timerfd_* (introduced in Linux + * 2.6.25) and a thread instead of alarm signals. It avoids the risk of + * interrupting syscalls (see #10840) and the risk of being accidentally + * modified in user code using signals. + */ +#if defined(linux_HOST_OS) && defined(THREADED_RTS) && HAVE_SYS_TIMERFD_H +#include +#include +#define USE_PTHREAD_FOR_ITIMER +#define USE_TIMERFD_FOR_ITIMER 1 +#undef USE_TIMER_CREATE +#else +#define USE_TIMERFD_FOR_ITIMER 0 +#endif + +/* + * TFD_CLOEXEC has been added in Linux 2.6.26. + * If it is not available, we use fcntl(F_SETFD). + */ +#ifndef TFD_CLOEXEC +#define TFD_CLOEXEC 0 +#endif + + #if defined(USE_PTHREAD_FOR_ITIMER) #include #include @@ -150,15 +175,50 @@ static void install_vtalrm_handler(TickProc handle_tick) #endif #if defined(USE_PTHREAD_FOR_ITIMER) -static volatile int itimer_enabled; +enum ItimerState {STOPPED, RUNNING, STOPPING, EXITED}; +static volatile enum ItimerState itimer_state = STOPPED; static void *itimer_thread_func(void *_handle_tick) { TickProc handle_tick = _handle_tick; + uint64_t nticks; + int timerfd = -1; + +#if USE_TIMERFD_FOR_ITIMER + struct itimerspec it; + it.it_value.tv_sec = TimeToSeconds(itimer_interval); + it.it_value.tv_nsec = TimeToNS(itimer_interval) % 1000000000; + it.it_interval = it.it_value; + + timerfd = timerfd_create(CLOCK_MONOTONIC,TFD_CLOEXEC); + if (timerfd == -1) { + sysErrorBelch("timerfd_create"); + stg_exit(EXIT_FAILURE); + } + if (!TFD_CLOEXEC) { + fcntl(timerfd, F_SETFD, FD_CLOEXEC); + } + timerfd_settime(timerfd,0,&it,NULL); +#endif + while (1) { - usleep(TimeToUS(itimer_interval)); - switch (itimer_enabled) { - case 1: handle_tick(0); break; - case 2: itimer_enabled = 0; + if (USE_TIMERFD_FOR_ITIMER) { + read(timerfd, &nticks, sizeof(nticks)); + } else { + usleep(TimeToUS(itimer_interval)); + } + switch (itimer_state) { + case RUNNING: + handle_tick(0); + break; + case STOPPED: + break; + case STOPPING: + itimer_state = STOPPED; + break; + case EXITED: + if (USE_TIMERFD_FOR_ITIMER) + close(timerfd); + return NULL; } } return NULL; @@ -172,7 +232,13 @@ initTicker (Time interval, TickProc handle_tick) #if defined(USE_PTHREAD_FOR_ITIMER) pthread_t tid; - pthread_create(&tid, NULL, itimer_thread_func, (void*)handle_tick); + int r = pthread_create(&tid, NULL, itimer_thread_func, (void*)handle_tick); + if (!r) { + pthread_detach(tid); +#if HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(tid, "ghc_ticker"); +#endif + } #elif defined(USE_TIMER_CREATE) { struct sigevent ev; @@ -198,7 +264,7 @@ void startTicker(void) { #if defined(USE_PTHREAD_FOR_ITIMER) - itimer_enabled = 1; + itimer_state = RUNNING; #elif defined(USE_TIMER_CREATE) { struct itimerspec it; @@ -232,10 +298,11 @@ void stopTicker(void) { #if defined(USE_PTHREAD_FOR_ITIMER) - if (itimer_enabled == 1) { - itimer_enabled = 2; + if (itimer_state == RUNNING) { + itimer_state = STOPPING; /* Wait for the thread to confirm it won't generate another tick. */ - while (itimer_enabled != 0) + write_barrier(); + while (itimer_state != STOPPED) sched_yield(); } #elif defined(USE_TIMER_CREATE) @@ -266,7 +333,9 @@ stopTicker(void) void exitTicker (rtsBool wait STG_UNUSED) { -#if defined(USE_TIMER_CREATE) +#if defined(USE_PTHREAD_FOR_ITIMER) + itimer_state = EXITED; +#elif defined(USE_TIMER_CREATE) // Before deleting the timer set the signal to ignore to avoid the // possibility of the signal being delivered after the timer is deleted. signal(ITIMER_SIGNAL, SIG_IGN); From git at git.haskell.org Fri Mar 11 14:21:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:30 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix the implementation of lazyId (051765f) Message-ID: <20160311142130.A2CAB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/051765f18f44253cfb6db2a04117293122c3bae3/ghc >--------------------------------------------------------------- commit 051765f18f44253cfb6db2a04117293122c3bae3 Author: Simon Peyton Jones Date: Tue Mar 8 15:27:54 2016 +0000 Fix the implementation of lazyId 'lazy' was doing part of its job, but not all! In particular, an application f (lazy e) where f is strict, was still being compiled using call-by-value in CorePrep. This defeated the purpose of defining catch as catch a b = catch# (lazy a) b See Trac #11555, and Neil Mitchell's test case in comment:14 This patch makes 'lazy' behave properly. I updated Note [lazyId magic] in MkId, but all the action is in CorePrep. I can't say I really like this, but it does the job. (cherry picked from commit 4c3a0a4a7b999251cbbee00befbfe32b86e556e2) >--------------------------------------------------------------- 051765f18f44253cfb6db2a04117293122c3bae3 compiler/basicTypes/MkId.hs | 57 +++++++++++++++++++++++++++++++------------- compiler/coreSyn/CorePrep.hs | 48 +++++++++++++++++++++---------------- 2 files changed, 68 insertions(+), 37 deletions(-) diff --git a/compiler/basicTypes/MkId.hs b/compiler/basicTypes/MkId.hs index ef80d38..cc0064e 100644 --- a/compiler/basicTypes/MkId.hs +++ b/compiler/basicTypes/MkId.hs @@ -1323,23 +1323,46 @@ may fire. Note [lazyId magic] ~~~~~~~~~~~~~~~~~~~ - lazy :: forall a?. a? -> a? (i.e. works for unboxed types too) - -Used to lazify pseq: pseq a b = a `seq` lazy b - -Also, no strictness: by being a built-in Id, all the info about lazyId comes from here, -not from GHC.Base.hi. This is important, because the strictness -analyser will spot it as strict! - -Also no unfolding in lazyId: it gets "inlined" by a HACK in CorePrep. -It's very important to do this inlining *after* unfoldings are exposed -in the interface file. Otherwise, the unfolding for (say) pseq in the -interface file will not mention 'lazy', so if we inline 'pseq' we'll totally -miss the very thing that 'lazy' was there for in the first place. -See Trac #3259 for a real world example. - -lazyId is defined in GHC.Base, so we don't *have* to inline it. If it -appears un-applied, we'll end up just calling it. +lazy :: forall a?. a? -> a? (i.e. works for unboxed types too) + +'lazy' is used to make sure that a sub-expression, and its free variables, +are truly used call-by-need, with no code motion. Key examples: + +* pseq: pseq a b = a `seq` lazy b + We want to make sure that the free vars of 'b' are not evaluated + before 'a', even though the expression is plainly strict in 'b'. + +* catch: catch a b = catch# (lazy a) b + Again, it's clear that 'a' will be evaluated strictly (and indeed + applied to a state token) but we want to make sure that any exceptions + arising from the evaluation of 'a' are caught by the catch (see + Trac #11555). + +Implementing 'lazy' is a bit tricky: + +* It must not have a strictness signature: by being a built-in Id, + all the info about lazyId comes from here, not from GHC.Base.hi. + This is important, because the strictness analyser will spot it as + strict! + +* It must not have an unfolding: it gets "inlined" by a HACK in + CorePrep. It's very important to do this inlining *after* unfoldings + are exposed in the interface file. Otherwise, the unfolding for + (say) pseq in the interface file will not mention 'lazy', so if we + inline 'pseq' we'll totally miss the very thing that 'lazy' was + there for in the first place. See Trac #3259 for a real world + example. + +* Suppose CorePrep sees (catch# (lazy e) b). At all costs we must + avoid using call by value here: + case e of r -> catch# r b + Avoiding that is the whole point of 'lazy'. So in CorePrep (which + generate the 'case' expression for a call-by-value call) we must + spot the 'lazy' on the arg (in CorePrep.cpeApp), and build a 'let' + instead. + +* lazyId is defined in GHC.Base, so we don't *have* to inline it. If it + appears un-applied, we'll end up just calling it. Note [runRW magic] ~~~~~~~~~~~~~~~~~~ diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs index ef2c2b1..34a0a98 100644 --- a/compiler/coreSyn/CorePrep.hs +++ b/compiler/coreSyn/CorePrep.hs @@ -661,14 +661,14 @@ rhsToBody expr = return (emptyFloats, expr) cpeApp :: CorePrepEnv -> CoreExpr -> UniqSM (Floats, CpeRhs) -- May return a CpeRhs because of saturating primops cpeApp env expr - = do { (app, (head,depth), _, floats, ss) <- collect_args expr 0 + = do { (app, head, _, floats, ss) <- collect_args expr 0 ; MASSERT(null ss) -- make sure we used all the strictness info -- Now deal with the function ; case head of - Var fn_id -> do { sat_app <- maybeSaturate fn_id app depth - ; return (floats, sat_app) } - _other -> return (floats, app) } + Just (fn_id, depth) -> do { sat_app <- maybeSaturate fn_id app depth + ; return (floats, sat_app) } + _other -> return (floats, app) } where -- Deconstruct and rebuild the application, floating any non-atomic @@ -679,13 +679,13 @@ cpeApp env expr collect_args :: CoreExpr - -> Int -- Current app depth - -> UniqSM (CpeApp, -- The rebuilt expression - (CoreExpr,Int), -- The head of the application, - -- and no. of args it was applied to - Type, -- Type of the whole expr - Floats, -- Any floats we pulled out - [Demand]) -- Remaining argument demands + -> Int -- Current app depth + -> UniqSM (CpeApp, -- The rebuilt expression + Maybe (Id, Int), -- The head of the application, + -- and no. of args it was applied to + Type, -- Type of the whole expr + Floats, -- Any floats we pulled out + [Demand]) -- Remaining argument demands collect_args (App fun arg@(Type arg_ty)) depth = do { (fun',hd,fun_ty,floats,ss) <- collect_args fun depth @@ -697,12 +697,13 @@ cpeApp env expr collect_args (App fun arg) depth = do { (fun',hd,fun_ty,floats,ss) <- collect_args fun (depth+1) - ; let - (ss1, ss_rest) = case ss of - (ss1:ss_rest) -> (ss1, ss_rest) - [] -> (topDmd, []) - (arg_ty, res_ty) = expectJust "cpeBody:collect_args" $ - splitFunTy_maybe fun_ty + ; let (ss1, ss_rest) -- See Note [lazyId magic] in MkId + = case (ss, isLazyExpr arg) of + (_ : ss_rest, True) -> (topDmd, ss_rest) + (ss1 : ss_rest, False) -> (ss1, ss_rest) + ([], _) -> (topDmd, []) + (arg_ty, res_ty) = expectJust "cpeBody:collect_args" $ + splitFunTy_maybe fun_ty ; (fs, arg') <- cpeArg env ss1 arg arg_ty ; return (App fun' arg', hd, res_ty, fs `appendFloats` floats, ss_rest) } @@ -710,7 +711,7 @@ cpeApp env expr collect_args (Var v) depth = do { v1 <- fiddleCCall v ; let v2 = lookupCorePrepEnv env v1 - ; return (Var v2, (Var v2, depth), idType v2, emptyFloats, stricts) } + ; return (Var v2, Just (v2, depth), idType v2, emptyFloats, stricts) } where stricts = case idStrictness v of StrictSig (DmdType _ demands _) @@ -736,14 +737,21 @@ cpeApp env expr ; return (fun',hd,fun_ty,addFloat floats (FloatTick tickish),ss) } -- N-variable fun, better let-bind it - collect_args fun depth + collect_args fun _ = do { (fun_floats, fun') <- cpeArg env evalDmd fun ty -- The evalDmd says that it's sure to be evaluated, -- so we'll end up case-binding it - ; return (fun', (fun', depth), ty, fun_floats, []) } + ; return (fun', Nothing, ty, fun_floats, []) } where ty = exprType fun +isLazyExpr :: CoreExpr -> Bool +-- See Note [lazyId magic] in MkId +isLazyExpr (Cast e _) = isLazyExpr e +isLazyExpr (Tick _ e) = isLazyExpr e +isLazyExpr (Var f `App` _ `App` _) = f `hasKey` lazyIdKey +isLazyExpr _ = False + -- --------------------------------------------------------------------------- -- CpeArg: produces a result satisfying CpeArg -- --------------------------------------------------------------------------- From git at git.haskell.org Fri Mar 11 14:21:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:33 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Make `catch` lazy in the action (2e0ef45) Message-ID: <20160311142133.CFFF73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/2e0ef457d085255f2fff117713f896972105d288/ghc >--------------------------------------------------------------- commit 2e0ef457d085255f2fff117713f896972105d288 Author: Ben Gamari Date: Fri Mar 11 10:38:10 2016 +0100 Make `catch` lazy in the action Previously ```lang=haskell catch (error "uh oh") (\(_ :: SomeException) -> print "it failed") ``` would unexpectedly fail with "uh oh" instead of the handler being run due to the strictness of `catch` in its first argument. See #11555 for details. Test Plan: Validate Reviewers: austin, hvr, simonpj Reviewed By: simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1973 GHC Trac Issues: #11555 (cherry picked from commit 30ee9102db2f16894912e19b9d16156824611bbb) >--------------------------------------------------------------- 2e0ef457d085255f2fff117713f896972105d288 libraries/base/Control/Exception/Base.hs | 2 +- libraries/base/GHC/IO.hs | 39 ++++++++++++++++++++++++++++++++ libraries/base/tests/.gitignore | 1 + libraries/base/tests/T11555.hs | 9 ++++++++ libraries/base/tests/T11555.stdout | 1 + libraries/base/tests/all.T | 1 + 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs index 351771b..5b3d47c 100644 --- a/libraries/base/Control/Exception/Base.hs +++ b/libraries/base/Control/Exception/Base.hs @@ -147,7 +147,7 @@ catch :: Exception e => IO a -- ^ The computation to run -> (e -> IO a) -- ^ Handler to invoke if an exception is raised -> IO a -catch = catchException +catch act = catchException (lazy act) -- | The function 'catchJust' is like 'catch', but it takes an extra -- argument which is an /exception predicate/, a function which diff --git a/libraries/base/GHC/IO.hs b/libraries/base/GHC/IO.hs index 186f6c6..52a333a 100644 --- a/libraries/base/GHC/IO.hs +++ b/libraries/base/GHC/IO.hs @@ -126,12 +126,22 @@ Now catch# has type have to work around that in the definition of catchException below). -} +-- | Catch an exception in the 'IO' monad. +-- +-- Note that this function is /strict/ in the action. That is, +-- @catchException undefined b == _|_ at . See #exceptions_and_strictness# +-- for details. catchException :: Exception e => IO a -> (e -> IO a) -> IO a catchException (IO io) handler = IO $ catch# io handler' where handler' e = case fromException e of Just e' -> unIO (handler e') Nothing -> raiseIO# e +-- | Catch any 'Exception' type in the 'IO' monad. +-- +-- Note that this function is /strict/ in the action. That is, +-- @catchException undefined b == _|_ at . See #exceptions_and_strictness# for +-- details. catchAny :: IO a -> (forall e . Exception e => e -> IO a) -> IO a catchAny (IO io) handler = IO $ catch# io handler' where handler' (SomeException e) = unIO (handler e) @@ -373,3 +383,32 @@ a `finally` sequel = -- use @'return' '$!' x at . evaluate :: a -> IO a evaluate a = IO $ \s -> seq# a s -- NB. see #2273, #5129 + +{- $exceptions_and_strictness + +Laziness can interact with @catch at -like operations in non-obvious ways (see, +e.g. GHC Trac #11555). For instance, consider these subtly-different examples, + +> test1 = Control.Exception.catch (error "uh oh") (\(_ :: SomeException) -> putStrLn "it failed") +> +> test2 = GHC.IO.catchException (error "uh oh") (\(_ :: SomeException) -> putStrLn "it failed") + +While the first case is always guaranteed to print "it failed", the behavior of + at test2@ may vary with optimization level. + +The unspecified behavior of @test2@ is due to the fact that GHC may assume that +'catchException' (and the 'catch#' primitive operation which it is built upon) +is strict in its first argument. This assumption allows the compiler to better +optimize @catchException@ calls at the expense of deterministic behavior when +the action may be bottom. + +Namely, the assumed strictness means that exceptions thrown while evaluating the +action-to-be-executed may not be caught; only exceptions thrown during execution +of the action will be handled by the exception handler. + +Since this strictness is a small optimization and may lead to surprising +results, all of the @catch@ and @handle@ variants offered by "Control.Exception" +are lazy in their first argument. If you are certain that that the action to be +executed won't bottom in performance-sensitive code, you might consider using +'GHC.IO.catchException' or 'GHC.IO.catchAny' for a small speed-up. +-} diff --git a/libraries/base/tests/.gitignore b/libraries/base/tests/.gitignore index a430bd7..32b9d10 100644 --- a/libraries/base/tests/.gitignore +++ b/libraries/base/tests/.gitignore @@ -273,3 +273,4 @@ /weak001 /T9395 /T9532 +/T11555 diff --git a/libraries/base/tests/T11555.hs b/libraries/base/tests/T11555.hs new file mode 100644 index 0000000..ce5b961 --- /dev/null +++ b/libraries/base/tests/T11555.hs @@ -0,0 +1,9 @@ +import Control.Exception + +-- Ensure that catch catches exceptions thrown during the evaluation of the +-- action-to-be-executed. This should output "it failed". +main :: IO () +main = catch (error "uh oh") handler + +handler :: SomeException -> IO () +handler _ = putStrLn "it failed" diff --git a/libraries/base/tests/T11555.stdout b/libraries/base/tests/T11555.stdout new file mode 100644 index 0000000..2f1c27e --- /dev/null +++ b/libraries/base/tests/T11555.stdout @@ -0,0 +1 @@ +it failed diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T index 06ef3bb..574aba6 100644 --- a/libraries/base/tests/all.T +++ b/libraries/base/tests/all.T @@ -212,3 +212,4 @@ test('T9848', ['-O']) test('T10149', normal, compile_and_run, ['']) test('T11334', normal, compile_and_run, ['']) +test('T11555', normal, compile_and_run, ['']) \ No newline at end of file From git at git.haskell.org Fri Mar 11 14:21:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:36 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add regression test for #11555 (a90c51f) Message-ID: <20160311142136.D86703A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/a90c51f155ff598dfc9cedf198db05560100864c/ghc >--------------------------------------------------------------- commit a90c51f155ff598dfc9cedf198db05560100864c Author: Ben Gamari Date: Fri Mar 11 11:20:43 2016 +0100 Add regression test for #11555 (cherry picked from commit c937f424e4acd61d1c558e8fe9b47e7d580fdbd8) >--------------------------------------------------------------- a90c51f155ff598dfc9cedf198db05560100864c testsuite/tests/stranal/should_run/T11555a.hs | 38 +++++++++++++++++++++++ testsuite/tests/stranal/should_run/T11555a.stdout | 2 ++ testsuite/tests/stranal/should_run/all.T | 1 + 3 files changed, 41 insertions(+) diff --git a/testsuite/tests/stranal/should_run/T11555a.hs b/testsuite/tests/stranal/should_run/T11555a.hs new file mode 100644 index 0000000..29f2a49 --- /dev/null +++ b/testsuite/tests/stranal/should_run/T11555a.hs @@ -0,0 +1,38 @@ +module Main(main) where + +import Control.Monad +import Control.Exception +import Control.Monad.Trans.Cont +import GHC.Exts + + +type RAW a = ContT () IO a + +-- See https://ghc.haskell.org/trac/ghc/ticket/11555 +catchSafe1, catchSafe2 :: IO a -> (SomeException -> IO a) -> IO a +catchSafe1 a b = lazy a `catch` b +catchSafe2 a b = join (evaluate a) `catch` b + +-- | Run and then call a continuation. +runRAW1, runRAW2 :: RAW a -> (Either SomeException a -> IO ()) -> IO () +runRAW1 m k = m `runContT` (k . Right) `catchSafe1` \e -> k $ Left e +runRAW2 m k = m `runContT` (k . Right) `catchSafe2` \e -> k $ Left e + +{-# NOINLINE run1 #-} +run1 :: RAW ()-> IO () +run1 rs = do + runRAW1 rs $ \x -> case x of + Left e -> putStrLn "CAUGHT" + Right x -> return x + +{-# NOINLINE run2 #-} +run2 :: RAW ()-> IO () +run2 rs = do + runRAW2 rs $ \x -> case x of + Left e -> putStrLn "CAUGHT" + Right x -> return x + +main :: IO () +main = do + run1 $ error "MISSED" + run2 $ error "MISSED" diff --git a/testsuite/tests/stranal/should_run/T11555a.stdout b/testsuite/tests/stranal/should_run/T11555a.stdout new file mode 100644 index 0000000..16ff8b4 --- /dev/null +++ b/testsuite/tests/stranal/should_run/T11555a.stdout @@ -0,0 +1,2 @@ +CAUGHT +CAUGHT diff --git a/testsuite/tests/stranal/should_run/all.T b/testsuite/tests/stranal/should_run/all.T index efd1afa..a4b550e 100644 --- a/testsuite/tests/stranal/should_run/all.T +++ b/testsuite/tests/stranal/should_run/all.T @@ -11,3 +11,4 @@ test('T9254', normal, compile_and_run, ['']) test('T10148', normal, compile_and_run, ['']) test('T10218', normal, compile_and_run, ['']) test('T11076', normal, multimod_compile_and_run, ['T11076.hs', 'T11076_prim.cmm']) +test('T11555a', normal, compile_and_run, ['']) From git at git.haskell.org Fri Mar 11 14:21:39 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:39 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Use catchException in a few more places (caef285) Message-ID: <20160311142139.8F8313A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/caef2856a0a52e68bb49d8cabf26c8a63c35fdfe/ghc >--------------------------------------------------------------- commit caef2856a0a52e68bb49d8cabf26c8a63c35fdfe Author: Ben Gamari Date: Fri Mar 11 10:43:52 2016 +0100 Use catchException in a few more places These are cases in the standard library that may benefit from the strictness signature of catchException and where we know that the action won't bottom. Test Plan: Validate, carefully consider changed callsites Reviewers: austin, hvr Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1972 (cherry picked from commit a1c4230e15cbf897b97903c8a1199a1cc91efd26) >--------------------------------------------------------------- caef2856a0a52e68bb49d8cabf26c8a63c35fdfe libraries/base/Control/Concurrent.hs | 6 +++--- libraries/base/GHC/IO/Handle/Text.hs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs index e047662..376870a 100644 --- a/libraries/base/Control/Concurrent.hs +++ b/libraries/base/Control/Concurrent.hs @@ -109,7 +109,7 @@ import Control.Exception.Base as Exception import GHC.Conc hiding (threadWaitRead, threadWaitWrite, threadWaitReadSTM, threadWaitWriteSTM) -import GHC.IO ( unsafeUnmask ) +import GHC.IO ( unsafeUnmask, catchException ) import GHC.IORef ( newIORef, readIORef, writeIORef ) import GHC.Base @@ -308,7 +308,7 @@ forkOS action0 MaskedInterruptible -> action0 MaskedUninterruptible -> uninterruptibleMask_ action0 - action_plus = Exception.catch action1 childHandler + action_plus = catchException action1 childHandler entry <- newStablePtr (myThreadId >>= putMVar mv >> action_plus) err <- forkOS_createThread entry @@ -381,7 +381,7 @@ runInUnboundThread action = do mv <- newEmptyMVar mask $ \restore -> do tid <- forkIO $ Exception.try (restore action) >>= putMVar mv - let wait = takeMVar mv `Exception.catch` \(e :: SomeException) -> + let wait = takeMVar mv `catchException` \(e :: SomeException) -> Exception.throwTo tid e >> wait wait >>= unsafeResult else action diff --git a/libraries/base/GHC/IO/Handle/Text.hs b/libraries/base/GHC/IO/Handle/Text.hs index 65832c7..4a5e4cf 100644 --- a/libraries/base/GHC/IO/Handle/Text.hs +++ b/libraries/base/GHC/IO/Handle/Text.hs @@ -246,7 +246,7 @@ hGetLineBufferedLoop handle_ at Handle__{..} maybeFillReadBuffer :: Handle__ -> CharBuffer -> IO (Maybe CharBuffer) maybeFillReadBuffer handle_ buf - = Exception.catch + = catchException (do buf' <- getSomeCharacters handle_ buf return (Just buf') ) From git at git.haskell.org Fri Mar 11 14:21:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:43 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11624, cannot declare hs-boot if already one in scope. (88a86f1) Message-ID: <20160311142143.2D5943A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/88a86f126f0fb2439b832927d51fd6d6445135b7/ghc >--------------------------------------------------------------- commit 88a86f126f0fb2439b832927d51fd6d6445135b7 Author: Edward Z. Yang Date: Fri Mar 11 10:37:26 2016 +0100 Fix #11624, cannot declare hs-boot if already one in scope. I'm not sure if this fix is the "right way" to do it, but it solves the proximal problem, which is that lookupBindGroupOcc was picking out the wrong renaming for hs-boot signatures, which then lead to an interface file error. Signed-off-by: Edward Z. Yang Test Plan: validate Reviewers: simonpj, hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1963 GHC Trac Issues: #11624 (cherry picked from commit fc16690a536b74e7af72e963599471474e3df603) >--------------------------------------------------------------- 88a86f126f0fb2439b832927d51fd6d6445135b7 compiler/rename/RnBinds.hs | 22 +++++++--------------- compiler/rename/RnEnv.hs | 4 ++-- compiler/rename/RnSource.hs | 8 +++++++- testsuite/tests/driver/sigof02/all.T | 8 ++++---- testsuite/tests/driver/sigof02/sigof02dmt.stderr | 15 ++++++++------- testsuite/tests/driver/sigof02/sigof02dt.stderr | 15 ++++++++------- testsuite/tests/rename/should_compile/T11624.hs | 4 ++++ .../tests/rename/should_compile/T11624.hs-boot | 3 +++ .../tests/rename/should_compile/T11624.stderr | 3 +++ testsuite/tests/rename/should_compile/T11624a.hs | 4 ++++ testsuite/tests/rename/should_compile/all.T | 1 + 11 files changed, 51 insertions(+), 36 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 88a86f126f0fb2439b832927d51fd6d6445135b7 From git at git.haskell.org Fri Mar 11 14:21:45 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 14:21:45 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Unconditionally handle TH known key names. (745bdd8) Message-ID: <20160311142145.D66A63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/745bdd88f9e4f9c85d46e84c58d6799bf71725b7/ghc >--------------------------------------------------------------- commit 745bdd88f9e4f9c85d46e84c58d6799bf71725b7 Author: Edward Z. Yang Date: Thu Feb 25 21:47:30 2016 +0100 Unconditionally handle TH known key names. Previously, we didn't add Template Haskell key names to the list of known uniques when building a stage 1 compiler. But with f16ddcee0c64a92ab911a7841a8cf64e3ac671fd we may refer to TH names even in stage 1, and this was causing uniques to not be setup properly. Signed-off-by: Edward Z. Yang Test Plan: validate and run stage1 test suite Reviewers: osa1, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1520 GHC Trac Issues: #10382 (cherry picked from commit bbfff2298d7ea7d0f4e590f8137f43a651e8f61d) >--------------------------------------------------------------- 745bdd88f9e4f9c85d46e84c58d6799bf71725b7 compiler/main/HscMain.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs index b069345..c34b6fd 100644 --- a/compiler/main/HscMain.hs +++ b/compiler/main/HscMain.hs @@ -98,12 +98,12 @@ import Type ( Type ) import {- Kind parts of -} Type ( Kind ) import CoreLint ( lintInteractiveExpr ) import VarEnv ( emptyTidyEnv ) -import THNames ( templateHaskellNames ) import Panic import ConLike import Control.Concurrent #endif +import THNames ( templateHaskellNames ) import Module import Packages import RdrName @@ -216,9 +216,7 @@ allKnownKeyNames -- where templateHaskellNames are defined = all_names where all_names = knownKeyNames -#ifdef GHCI ++ templateHaskellNames -#endif namesEnv = foldl (\m n -> extendNameEnv_Acc (:) singleton m n n) emptyUFM all_names From git at git.haskell.org Fri Mar 11 15:15:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 15:15:13 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: GhcMake: Clang/ASSERT fix (7d5bdea) Message-ID: <20160311151513.5AC993A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/7d5bdeac73d8ad593dbdeba4ee21d28a76bd18e7/ghc >--------------------------------------------------------------- commit 7d5bdeac73d8ad593dbdeba4ee21d28a76bd18e7 Author: Erik de Castro Lopo Date: Mon Mar 7 14:32:07 2016 +0100 GhcMake: Clang/ASSERT fix Test Plan: Build with clang Reviewers: thomie, rwbarton, austin, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1977 (cherry picked from commit 5e2605e4e740d46014eaf3eb2b2b2e05a43bb8b2) >--------------------------------------------------------------- 7d5bdeac73d8ad593dbdeba4ee21d28a76bd18e7 compiler/main/GhcMake.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs index 6232119..3655c0b 100644 --- a/compiler/main/GhcMake.hs +++ b/compiler/main/GhcMake.hs @@ -367,10 +367,12 @@ load how_much = do liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1 -- there should be no Nothings where linkables should be, now - ASSERT( isNoLink (ghcLink dflags) + let just_linkables = + isNoLink (ghcLink dflags) || all (isJust.hm_linkable) (filter ((== HsSrcFile).mi_hsc_src.hm_iface) - (eltsUFM hpt4))) do + (eltsUFM hpt4)) + ASSERT( just_linkables ) do -- Link everything together linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4 From git at git.haskell.org Fri Mar 11 16:12:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 16:12:30 +0000 (UTC) Subject: [commit: ghc] master: Add -foptimal-applicative-do (2f45cf3) Message-ID: <20160311161230.3A63E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2f45cf3f48162a5f843005755dafa1c5c1b451a7/ghc >--------------------------------------------------------------- commit 2f45cf3f48162a5f843005755dafa1c5c1b451a7 Author: Simon Marlow Date: Fri Mar 4 13:06:42 2016 +0000 Add -foptimal-applicative-do Summary: The algorithm for ApplicativeDo rearrangement is based on a heuristic that runs in O(n^2). This patch adds the optimal algorithm, which is O(n^3), selected by a flag (-foptimal-applicative-do). It finds better solutions in a small number of cases (about 2% of the cases where ApplicativeDo makes a difference), but it can be very slow for large do expressions. I'm mainly adding it for experimental reasons. ToDo: user guide docs Test Plan: validate Reviewers: simonpj, bgamari, austin, niteria, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1969 >--------------------------------------------------------------- 2f45cf3f48162a5f843005755dafa1c5c1b451a7 compiler/main/DynFlags.hs | 2 + compiler/rename/RnExpr.hs | 226 ++++++++++++++++--------- docs/users_guide/glasgow_exts.rst | 17 ++ testsuite/tests/ado/ado-optimal.hs | 59 +++++++ testsuite/tests/ado/ado-optimal.stdout | 1 + testsuite/tests/ado/ado004.hs | 9 + testsuite/tests/ado/ado004.stderr | 6 + testsuite/tests/ado/all.T | 1 + utils/mkUserGuidePart/Options/Optimizations.hs | 6 + 9 files changed, 251 insertions(+), 76 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 2f45cf3f48162a5f843005755dafa1c5c1b451a7 From git at git.haskell.org Fri Mar 11 23:18:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 11 Mar 2016 23:18:04 +0000 (UTC) Subject: [commit: ghc] master: rts: fix threadStackUnderflow type in cmm (e46742f) Message-ID: <20160311231804.D0B3D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e46742f5c51938bc7c992ac37fecc6df8cab7647/ghc >--------------------------------------------------------------- commit e46742f5c51938bc7c992ac37fecc6df8cab7647 Author: Sergei Trofimovich Date: Fri Mar 11 22:31:58 2016 +0000 rts: fix threadStackUnderflow type in cmm stg_stack_underflow_frame had an incorrect call of C function 'threadStackUnderflow': ("ptr" ret_off) = foreign "C" threadStackUnderflow( MyCapability(), CurrentTSO); Which means it's prototype is: void * (*) (W_, void*); While real prototype is: W_ (*) (Capability *cap, StgTSO *tso); The fix is simple. Fix type annotations: (ret_off) = foreign "C" threadStackUnderflow( MyCapability() "ptr", CurrentTSO "ptr"); Noticed when debugged T9045 test failure on m68k target which distincts between pointer and non pointer return types (uses different registers) While at it noticed and fixed return types for 'throwTo' and 'findSpark'. Trac #11395 Signed-off-by: Sergei Trofimovich >--------------------------------------------------------------- e46742f5c51938bc7c992ac37fecc6df8cab7647 rts/Exception.cmm | 2 +- rts/PrimOps.cmm | 2 +- rts/StgMiscClosures.cmm | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rts/Exception.cmm b/rts/Exception.cmm index a89bd19..2a07eaa 100644 --- a/rts/Exception.cmm +++ b/rts/Exception.cmm @@ -307,7 +307,7 @@ stg_killThreadzh (P_ target, P_ exception) } else { W_ msg; - (msg) = ccall throwTo(MyCapability() "ptr", + ("ptr" msg) = ccall throwTo(MyCapability() "ptr", CurrentTSO "ptr", target "ptr", exception "ptr"); diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 7add835..a802e67 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -2344,7 +2344,7 @@ stg_getSparkzh () #ifndef THREADED_RTS return (0,ghczmprim_GHCziTypes_False_closure); #else - (spark) = ccall findSpark(MyCapability()); + ("ptr" spark) = ccall findSpark(MyCapability() "ptr"); if (spark != 0) { return (1,spark); } else { diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 757730e..905f81e 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -32,8 +32,8 @@ INFO_TABLE_RET (stg_stack_underflow_frame, UNDERFLOW_FRAME, SAVE_STGREGS SAVE_THREAD_STATE(); - ("ptr" ret_off) = foreign "C" threadStackUnderflow(MyCapability(), - CurrentTSO); + (ret_off) = foreign "C" threadStackUnderflow(MyCapability() "ptr", + CurrentTSO); LOAD_THREAD_STATE(); RESTORE_STGREGS From git at git.haskell.org Sat Mar 12 15:45:24 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 15:45:24 +0000 (UTC) Subject: [commit: ghc] master: Simplify: Make generated names more useful (4d791b4) Message-ID: <20160312154524.8AD3A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/4d791b4f77975422df38f6b43084008edd097f1b/ghc >--------------------------------------------------------------- commit 4d791b4f77975422df38f6b43084008edd097f1b Author: Ben Gamari Date: Fri Mar 11 15:24:49 2016 +0100 Simplify: Make generated names more useful makeTrivial is responsible for concocting names during simplification. Previously, however, it would make no attempt to generate a name that might be useful to later readers of the resulting Core. Here we add a bit of state to SimplEnv: a finite depth stack of binders within which we are currently simplifying. We then derive generated binders from this context. See #11676. Open questions: * Is there a better way to accomplish this? * Is `maxContextDepth` too large/small? Test Plan: Validate, look at Core. Reviewers: austin, simonpj Reviewed By: simonpj Subscribers: thomie, simonpj Differential Revision: https://phabricator.haskell.org/D1970 GHC Trac Issues: #11676 >--------------------------------------------------------------- 4d791b4f77975422df38f6b43084008edd097f1b compiler/simplCore/Simplify.hs | 32 +++++++------ .../tests/deSugar/should_compile/T2431.stderr | 30 ++++++++----- .../tests/ghci.debugger/scripts/break009.stdout | 2 +- .../tests/ghci.debugger/scripts/break010.stdout | 4 +- .../tests/ghci.debugger/scripts/break011.stdout | 22 ++++----- .../tests/ghci.debugger/scripts/break012.stdout | 14 +++--- .../tests/ghci.debugger/scripts/break028.stdout | 4 +- .../tests/ghci.debugger/scripts/print018.stdout | 6 +-- .../tests/ghci.debugger/scripts/print031.stdout | 2 +- .../tests/roles/should_compile/Roles13.stderr | 52 +++++++++++++--------- .../tests/simplCore/should_compile/EvalTest.stdout | 2 +- .../tests/simplCore/should_compile/T9400.stderr | 10 ++--- .../simplCore/should_compile/spec-inline.stderr | 18 ++++---- 13 files changed, 111 insertions(+), 87 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 4d791b4f77975422df38f6b43084008edd097f1b From git at git.haskell.org Sat Mar 12 15:45:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 15:45:27 +0000 (UTC) Subject: [commit: ghc] master: ghci: add message when reusing compiled code #9887 (41051dd) Message-ID: <20160312154527.3CA533A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/41051dd846c3a7fc01cbb8ad3b7dd2b4332f7f0b/ghc >--------------------------------------------------------------- commit 41051dd846c3a7fc01cbb8ad3b7dd2b4332f7f0b Author: Alexander Lukyanov Date: Sat Mar 12 12:03:47 2016 +0100 ghci: add message when reusing compiled code #9887 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1991 GHC Trac Issues: #9887 >--------------------------------------------------------------- 41051dd846c3a7fc01cbb8ad3b7dd2b4332f7f0b docs/users_guide/ghci.rst | 4 ++-- ghc/GHCi/UI.hs | 21 ++++++++++++++------- testsuite/tests/ghci/scripts/ghci058.stdout | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst index 20afb89..a29f94c 100644 --- a/docs/users_guide/ghci.rst +++ b/docs/users_guide/ghci.rst @@ -232,7 +232,7 @@ We can compile ``D``, then load the whole program, like this: Compiling B ( B.hs, interpreted ) Compiling C ( C.hs, interpreted ) Compiling A ( A.hs, interpreted ) - Ok, modules loaded: A, B, C, D. + Ok, modules loaded: A, B, C, D (D.o). *Main> In the messages from the compiler, we see that there is no line for @@ -304,7 +304,7 @@ picked up by :ghci-cmd:`:reload`, only :ghci-cmd:`:load`: *Main> :load A Compiling B ( B.hs, interpreted ) Compiling A ( A.hs, interpreted ) - Ok, modules loaded: A, B, C, D. + Ok, modules loaded: A, B, C (C.o), D (D.o). The automatic loading of object files can sometimes lead to confusion, because non-exported top-level definitions of a module are only diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index cc180f2..a335aea 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -51,7 +51,7 @@ import GHC ( LoadHowMuch(..), Target(..), TargetId(..), InteractiveImport(..), import HsImpExp import HsSyn import HscTypes ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC, - setInteractivePrintName, hsc_dflags ) + setInteractivePrintName, hsc_dflags, msObjFilePath ) import Module import Name import Packages ( trusted, getPackageDetails, listVisibleModuleNames, pprFlag ) @@ -1569,10 +1569,9 @@ afterLoad :: SuccessFlag afterLoad ok retain_context = do lift revertCAFs -- always revert CAFs on load. lift discardTickArrays - loaded_mod_summaries <- getLoadedModules - let loaded_mods = map GHC.ms_mod loaded_mod_summaries + loaded_mods <- getLoadedModules modulesLoadedMsg ok loaded_mods - lift $ setContextAfterLoad retain_context loaded_mod_summaries + lift $ setContextAfterLoad retain_context loaded_mods setContextAfterLoad :: Bool -> [GHC.ModSummary] -> GHCi () setContextAfterLoad keep_ctxt [] = do @@ -1646,14 +1645,22 @@ keepPackageImports = filterM is_pkg_import mod_name = unLoc (ideclName d) -modulesLoadedMsg :: SuccessFlag -> [Module] -> InputT GHCi () +modulesLoadedMsg :: SuccessFlag -> [GHC.ModSummary] -> InputT GHCi () modulesLoadedMsg ok mods = do dflags <- getDynFlags unqual <- GHC.getPrintUnqual + let mod_name mod = do + is_interpreted <- GHC.isModuleInterpreted mod + return $ if is_interpreted + then ppr (GHC.ms_mod mod) + else ppr (GHC.ms_mod mod) + <> text " (" + <> text (normalise $ msObjFilePath mod) + <> text ")" -- fix #9887 + mod_names <- mapM mod_name mods let mod_commas | null mods = text "none." - | otherwise = hsep ( - punctuate comma (map ppr mods)) <> text "." + | otherwise = hsep (punctuate comma mod_names) <> text "." status = case ok of Failed -> text "Failed" Succeeded -> text "Ok" diff --git a/testsuite/tests/ghci/scripts/ghci058.stdout b/testsuite/tests/ghci/scripts/ghci058.stdout index 7347571..bc77f05 100644 --- a/testsuite/tests/ghci/scripts/ghci058.stdout +++ b/testsuite/tests/ghci/scripts/ghci058.stdout @@ -1,4 +1,4 @@ -Ok, modules loaded: Ghci058. +Ok, modules loaded: Ghci058 (Ghci058.o). 'a' -Ok, modules loaded: Ghci058. +Ok, modules loaded: Ghci058 (Ghci058.o). 'b' From git at git.haskell.org Sat Mar 12 15:45:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 15:45:30 +0000 (UTC) Subject: [commit: ghc] master: LlvmCodeGen: Fix generation of malformed LLVM blocks (92821ec) Message-ID: <20160312154530.671253A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/92821ec9a57817e1429ae94c756539259488b728/ghc >--------------------------------------------------------------- commit 92821ec9a57817e1429ae94c756539259488b728 Author: Erik de Castro Lopo Date: Sat Mar 12 12:03:56 2016 +0100 LlvmCodeGen: Fix generation of malformed LLVM blocks Commit 673efccb3b uncovered a bug in LLVM code generation that produced LLVM code that the LLVM compiler refused to compile: { clpH: br label %clpH } This may well be a bug in LLVM itself. The solution is to keep the existing entry label and rewrite the function as: { clpH: br label %nPV nPV: br label %nPV } Thanks to Ben Gamari for pointing me in the right direction on this one. Test Plan: Build GHC with BuildFlavour=quick-llvm Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1996 GHC Trac Issues: #11649 >--------------------------------------------------------------- 92821ec9a57817e1429ae94c756539259488b728 compiler/llvmGen/LlvmCodeGen.hs | 34 ++++++++++++++++++++++++++- testsuite/tests/llvm/should_compile/T11649.hs | 16 +++++++++++++ testsuite/tests/llvm/should_compile/all.T | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs index 3c63aa0..872ad8c 100644 --- a/compiler/llvmGen/LlvmCodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen.hs @@ -15,8 +15,10 @@ import LlvmCodeGen.Ppr import LlvmCodeGen.Regs import LlvmMangler +import BlockId import CgUtils ( fixStgRegisters ) import Cmm +import CmmUtils import Hoopl import PprCmm @@ -120,13 +122,43 @@ cmmDataLlvmGens statics renderLlvm $ pprLlvmData (concat gss', concat tss) +-- | LLVM can't handle entry blocks which loop back to themselves (could be +-- seen as an LLVM bug) so we rearrange the code to keep the original entry +-- label which branches to a newly generated second label that branches back +-- to itself. See: Trac #11649 +fixBottom :: RawCmmDecl -> LlvmM RawCmmDecl +fixBottom cp@(CmmProc hdr entry_lbl live g) = + maybe (pure cp) fix_block $ mapLookup (g_entry g) blk_map + where + blk_map = toBlockMap g + + fix_block :: CmmBlock -> LlvmM RawCmmDecl + fix_block blk + | (CmmEntry e_lbl tickscp, middle, CmmBranch b_lbl) <- blockSplit blk + , isEmptyBlock middle + , e_lbl == b_lbl = do + new_lbl <- mkBlockId <$> getUniqueM + + let fst_blk = + BlockCC (CmmEntry e_lbl tickscp) BNil (CmmBranch new_lbl) + snd_blk = + BlockCC (CmmEntry new_lbl tickscp) BNil (CmmBranch new_lbl) + + pure . CmmProc hdr entry_lbl live . ofBlockMap (g_entry g) + $ mapFromList [(e_lbl, fst_blk), (new_lbl, snd_blk)] + + fix_block _ = pure cp + +fixBottom rcd = pure rcd + -- | Complete LLVM code generation phase for a single top-level chunk of Cmm. cmmLlvmGen ::RawCmmDecl -> LlvmM () cmmLlvmGen cmm at CmmProc{} = do -- rewrite assignments to global regs dflags <- getDynFlag id - let fixed_cmm = {-# SCC "llvm_fix_regs" #-} + fixed_cmm <- fixBottom $ + {-# SCC "llvm_fix_regs" #-} fixStgRegisters dflags cmm dumpIfSetLlvm Opt_D_dump_opt_cmm "Optimised Cmm" (pprCmmGroup [fixed_cmm]) diff --git a/testsuite/tests/llvm/should_compile/T11649.hs b/testsuite/tests/llvm/should_compile/T11649.hs new file mode 100644 index 0000000..9d09c3a --- /dev/null +++ b/testsuite/tests/llvm/should_compile/T11649.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Test where +import GHC.Base + +data U1 p = U1 + +instance Functor U1 where + fmap f U1 = U1 + +instance Applicative U1 where + pure _ = U1 + U1 <*> U1 = U1 + +instance Alternative U1 where + empty = U1 + U1 <|> U1 = U1 diff --git a/testsuite/tests/llvm/should_compile/all.T b/testsuite/tests/llvm/should_compile/all.T index 9da136d..6806c25 100644 --- a/testsuite/tests/llvm/should_compile/all.T +++ b/testsuite/tests/llvm/should_compile/all.T @@ -13,3 +13,4 @@ test('T6158', [reqlib('vector'), reqlib('primitive')], compile, ['-package vecto test('T7571', cmm_src, compile, ['']) test('T7575', unless(wordsize(32), skip), compile, ['']) test('T8131b', normal, compile, ['']) +test('T11649', normal, compile, ['']) From git at git.haskell.org Sat Mar 12 21:45:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:45:44 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: LlvmCodeGen: Fix generation of malformed LLVM blocks (1e7764c) Message-ID: <20160312214544.A1FC83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1e7764ce888708cb46dc74a036af92b550bc85eb/ghc >--------------------------------------------------------------- commit 1e7764ce888708cb46dc74a036af92b550bc85eb Author: Erik de Castro Lopo Date: Sat Mar 12 12:03:56 2016 +0100 LlvmCodeGen: Fix generation of malformed LLVM blocks Commit 673efccb3b uncovered a bug in LLVM code generation that produced LLVM code that the LLVM compiler refused to compile: { clpH: br label %clpH } This may well be a bug in LLVM itself. The solution is to keep the existing entry label and rewrite the function as: { clpH: br label %nPV nPV: br label %nPV } Thanks to Ben Gamari for pointing me in the right direction on this one. Test Plan: Build GHC with BuildFlavour=quick-llvm Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1996 GHC Trac Issues: #11649 (cherry picked from commit 92821ec9a57817e1429ae94c756539259488b728) >--------------------------------------------------------------- 1e7764ce888708cb46dc74a036af92b550bc85eb compiler/llvmGen/LlvmCodeGen.hs | 34 ++++++++++++++++++++++++++- testsuite/tests/llvm/should_compile/T11649.hs | 16 +++++++++++++ testsuite/tests/llvm/should_compile/all.T | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs index 3c63aa0..872ad8c 100644 --- a/compiler/llvmGen/LlvmCodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen.hs @@ -15,8 +15,10 @@ import LlvmCodeGen.Ppr import LlvmCodeGen.Regs import LlvmMangler +import BlockId import CgUtils ( fixStgRegisters ) import Cmm +import CmmUtils import Hoopl import PprCmm @@ -120,13 +122,43 @@ cmmDataLlvmGens statics renderLlvm $ pprLlvmData (concat gss', concat tss) +-- | LLVM can't handle entry blocks which loop back to themselves (could be +-- seen as an LLVM bug) so we rearrange the code to keep the original entry +-- label which branches to a newly generated second label that branches back +-- to itself. See: Trac #11649 +fixBottom :: RawCmmDecl -> LlvmM RawCmmDecl +fixBottom cp@(CmmProc hdr entry_lbl live g) = + maybe (pure cp) fix_block $ mapLookup (g_entry g) blk_map + where + blk_map = toBlockMap g + + fix_block :: CmmBlock -> LlvmM RawCmmDecl + fix_block blk + | (CmmEntry e_lbl tickscp, middle, CmmBranch b_lbl) <- blockSplit blk + , isEmptyBlock middle + , e_lbl == b_lbl = do + new_lbl <- mkBlockId <$> getUniqueM + + let fst_blk = + BlockCC (CmmEntry e_lbl tickscp) BNil (CmmBranch new_lbl) + snd_blk = + BlockCC (CmmEntry new_lbl tickscp) BNil (CmmBranch new_lbl) + + pure . CmmProc hdr entry_lbl live . ofBlockMap (g_entry g) + $ mapFromList [(e_lbl, fst_blk), (new_lbl, snd_blk)] + + fix_block _ = pure cp + +fixBottom rcd = pure rcd + -- | Complete LLVM code generation phase for a single top-level chunk of Cmm. cmmLlvmGen ::RawCmmDecl -> LlvmM () cmmLlvmGen cmm at CmmProc{} = do -- rewrite assignments to global regs dflags <- getDynFlag id - let fixed_cmm = {-# SCC "llvm_fix_regs" #-} + fixed_cmm <- fixBottom $ + {-# SCC "llvm_fix_regs" #-} fixStgRegisters dflags cmm dumpIfSetLlvm Opt_D_dump_opt_cmm "Optimised Cmm" (pprCmmGroup [fixed_cmm]) diff --git a/testsuite/tests/llvm/should_compile/T11649.hs b/testsuite/tests/llvm/should_compile/T11649.hs new file mode 100644 index 0000000..9d09c3a --- /dev/null +++ b/testsuite/tests/llvm/should_compile/T11649.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Test where +import GHC.Base + +data U1 p = U1 + +instance Functor U1 where + fmap f U1 = U1 + +instance Applicative U1 where + pure _ = U1 + U1 <*> U1 = U1 + +instance Alternative U1 where + empty = U1 + U1 <|> U1 = U1 diff --git a/testsuite/tests/llvm/should_compile/all.T b/testsuite/tests/llvm/should_compile/all.T index 9da136d..6806c25 100644 --- a/testsuite/tests/llvm/should_compile/all.T +++ b/testsuite/tests/llvm/should_compile/all.T @@ -13,3 +13,4 @@ test('T6158', [reqlib('vector'), reqlib('primitive')], compile, ['-package vecto test('T7571', cmm_src, compile, ['']) test('T7575', unless(wordsize(32), skip), compile, ['']) test('T8131b', normal, compile, ['']) +test('T11649', normal, compile, ['']) From git at git.haskell.org Sat Mar 12 21:45:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:45:47 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add MonadUnique instance for LlvmM (5f66ae5) Message-ID: <20160312214547.68C653A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/5f66ae571b237853953e0e479a012a10980c4307/ghc >--------------------------------------------------------------- commit 5f66ae571b237853953e0e479a012a10980c4307 Author: Ben Gamari Date: Fri Mar 11 10:41:05 2016 +0100 Add MonadUnique instance for LlvmM Reviewers: erikd, austin Reviewed By: erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1994 (cherry picked from commit 6a2992dc4b6582bd95b0cef1a674a99ca8299403) >--------------------------------------------------------------- 5f66ae571b237853953e0e479a012a10980c4307 compiler/llvmGen/LlvmCodeGen/Base.hs | 21 ++++++++++++++------- compiler/llvmGen/LlvmCodeGen/CodeGen.hs | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/compiler/llvmGen/LlvmCodeGen/Base.hs b/compiler/llvmGen/LlvmCodeGen/Base.hs index 82c1eea..cbd4c68 100644 --- a/compiler/llvmGen/LlvmCodeGen/Base.hs +++ b/compiler/llvmGen/LlvmCodeGen/Base.hs @@ -18,7 +18,7 @@ module LlvmCodeGen.Base ( runLlvm, liftStream, withClearVars, varLookup, varInsert, markStackReg, checkStackReg, funLookup, funInsert, getLlvmVer, getDynFlags, getDynFlag, getLlvmPlatform, - dumpIfSetLlvm, renderLlvm, runUs, markUsedVar, getUsedVars, + dumpIfSetLlvm, renderLlvm, markUsedVar, getUsedVars, ghcInternalFunctions, getMetaUniqueId, @@ -228,6 +228,19 @@ instance Monad LlvmM where instance HasDynFlags LlvmM where getDynFlags = LlvmM $ \env -> return (envDynFlags env, env) +instance MonadUnique LlvmM where + getUniqueSupplyM = do + us <- getEnv envUniq + let (us1, us2) = splitUniqSupply us + modifyEnv (\s -> s { envUniq = us2 }) + return us1 + + getUniqueM = do + us <- getEnv envUniq + let (u,us') = takeUniqFromSupply us + modifyEnv (\s -> s { envUniq = us' }) + return u + -- | Lifting of IO actions. Not exported, as we want to encapsulate IO. liftIO :: IO a -> LlvmM a liftIO m = LlvmM $ \env -> do x <- m @@ -327,12 +340,6 @@ renderLlvm sdoc = do dumpIfSetLlvm Opt_D_dump_llvm "LLVM Code" sdoc return () --- | Run a @UniqSM@ action with our unique supply -runUs :: UniqSM a -> LlvmM a -runUs m = LlvmM $ \env -> do - let (x, us') = initUs (envUniq env) m - return (x, env { envUniq = us' }) - -- | Marks a variable as "used" markUsedVar :: LlvmVar -> LlvmM () markUsedVar v = modifyEnv $ \env -> env { envUsedVars = v : envUsedVars env } diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs index 61c059d..04223fd 100644 --- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs @@ -148,7 +148,7 @@ getInstrinct2 fname fty@(LMFunction funSig) = do return [] Nothing -> do funInsert fname fty - un <- runUs getUniqueM + un <- getUniqueM let lbl = mkAsmTempLabel un return [CmmData (Section Data lbl) [([],[fty])]] @@ -1787,7 +1787,7 @@ getHsFunc' name fty -- | Create a new local var mkLocalVar :: LlvmType -> LlvmM LlvmVar mkLocalVar ty = do - un <- runUs getUniqueM + un <- getUniqueM return $ LMLocalVar un ty From git at git.haskell.org Sat Mar 12 21:45:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:45:50 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: rts: fix threadStackUnderflow type in cmm (bd45497) Message-ID: <20160312214550.1DBD83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/bd454972e94a639f57cf16a2d419e879f023e80e/ghc >--------------------------------------------------------------- commit bd454972e94a639f57cf16a2d419e879f023e80e Author: Sergei Trofimovich Date: Fri Mar 11 22:31:58 2016 +0000 rts: fix threadStackUnderflow type in cmm stg_stack_underflow_frame had an incorrect call of C function 'threadStackUnderflow': ("ptr" ret_off) = foreign "C" threadStackUnderflow( MyCapability(), CurrentTSO); Which means it's prototype is: void * (*) (W_, void*); While real prototype is: W_ (*) (Capability *cap, StgTSO *tso); The fix is simple. Fix type annotations: (ret_off) = foreign "C" threadStackUnderflow( MyCapability() "ptr", CurrentTSO "ptr"); Noticed when debugged T9045 test failure on m68k target which distincts between pointer and non pointer return types (uses different registers) While at it noticed and fixed return types for 'throwTo' and 'findSpark'. Trac #11395 Signed-off-by: Sergei Trofimovich (cherry picked from commit e46742f5c51938bc7c992ac37fecc6df8cab7647) >--------------------------------------------------------------- bd454972e94a639f57cf16a2d419e879f023e80e rts/Exception.cmm | 2 +- rts/PrimOps.cmm | 2 +- rts/StgMiscClosures.cmm | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rts/Exception.cmm b/rts/Exception.cmm index a89bd19..2a07eaa 100644 --- a/rts/Exception.cmm +++ b/rts/Exception.cmm @@ -307,7 +307,7 @@ stg_killThreadzh (P_ target, P_ exception) } else { W_ msg; - (msg) = ccall throwTo(MyCapability() "ptr", + ("ptr" msg) = ccall throwTo(MyCapability() "ptr", CurrentTSO "ptr", target "ptr", exception "ptr"); diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 7add835..a802e67 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -2344,7 +2344,7 @@ stg_getSparkzh () #ifndef THREADED_RTS return (0,ghczmprim_GHCziTypes_False_closure); #else - (spark) = ccall findSpark(MyCapability()); + ("ptr" spark) = ccall findSpark(MyCapability() "ptr"); if (spark != 0) { return (1,spark); } else { diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index e3be2cb..871199c 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -32,8 +32,8 @@ INFO_TABLE_RET (stg_stack_underflow_frame, UNDERFLOW_FRAME, SAVE_STGREGS SAVE_THREAD_STATE(); - ("ptr" ret_off) = foreign "C" threadStackUnderflow(MyCapability(), - CurrentTSO); + (ret_off) = foreign "C" threadStackUnderflow(MyCapability() "ptr", + CurrentTSO); LOAD_THREAD_STATE(); RESTORE_STGREGS From git at git.haskell.org Sat Mar 12 21:45:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:45:52 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: ghci: add message when reusing compiled code #9887 (89bec2c) Message-ID: <20160312214552.BFC443A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/89bec2cf1b092b46481c6237ea4e1f879564b32c/ghc >--------------------------------------------------------------- commit 89bec2cf1b092b46481c6237ea4e1f879564b32c Author: Alexander Lukyanov Date: Sat Mar 12 12:03:47 2016 +0100 ghci: add message when reusing compiled code #9887 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1991 GHC Trac Issues: #9887 (cherry picked from commit 41051dd846c3a7fc01cbb8ad3b7dd2b4332f7f0b) >--------------------------------------------------------------- 89bec2cf1b092b46481c6237ea4e1f879564b32c docs/users_guide/ghci.rst | 4 ++-- ghc/GHCi/UI.hs | 21 ++++++++++++++------- testsuite/tests/ghci/scripts/ghci058.stdout | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst index 20afb89..a29f94c 100644 --- a/docs/users_guide/ghci.rst +++ b/docs/users_guide/ghci.rst @@ -232,7 +232,7 @@ We can compile ``D``, then load the whole program, like this: Compiling B ( B.hs, interpreted ) Compiling C ( C.hs, interpreted ) Compiling A ( A.hs, interpreted ) - Ok, modules loaded: A, B, C, D. + Ok, modules loaded: A, B, C, D (D.o). *Main> In the messages from the compiler, we see that there is no line for @@ -304,7 +304,7 @@ picked up by :ghci-cmd:`:reload`, only :ghci-cmd:`:load`: *Main> :load A Compiling B ( B.hs, interpreted ) Compiling A ( A.hs, interpreted ) - Ok, modules loaded: A, B, C, D. + Ok, modules loaded: A, B, C (C.o), D (D.o). The automatic loading of object files can sometimes lead to confusion, because non-exported top-level definitions of a module are only diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index cc180f2..a335aea 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -51,7 +51,7 @@ import GHC ( LoadHowMuch(..), Target(..), TargetId(..), InteractiveImport(..), import HsImpExp import HsSyn import HscTypes ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC, - setInteractivePrintName, hsc_dflags ) + setInteractivePrintName, hsc_dflags, msObjFilePath ) import Module import Name import Packages ( trusted, getPackageDetails, listVisibleModuleNames, pprFlag ) @@ -1569,10 +1569,9 @@ afterLoad :: SuccessFlag afterLoad ok retain_context = do lift revertCAFs -- always revert CAFs on load. lift discardTickArrays - loaded_mod_summaries <- getLoadedModules - let loaded_mods = map GHC.ms_mod loaded_mod_summaries + loaded_mods <- getLoadedModules modulesLoadedMsg ok loaded_mods - lift $ setContextAfterLoad retain_context loaded_mod_summaries + lift $ setContextAfterLoad retain_context loaded_mods setContextAfterLoad :: Bool -> [GHC.ModSummary] -> GHCi () setContextAfterLoad keep_ctxt [] = do @@ -1646,14 +1645,22 @@ keepPackageImports = filterM is_pkg_import mod_name = unLoc (ideclName d) -modulesLoadedMsg :: SuccessFlag -> [Module] -> InputT GHCi () +modulesLoadedMsg :: SuccessFlag -> [GHC.ModSummary] -> InputT GHCi () modulesLoadedMsg ok mods = do dflags <- getDynFlags unqual <- GHC.getPrintUnqual + let mod_name mod = do + is_interpreted <- GHC.isModuleInterpreted mod + return $ if is_interpreted + then ppr (GHC.ms_mod mod) + else ppr (GHC.ms_mod mod) + <> text " (" + <> text (normalise $ msObjFilePath mod) + <> text ")" -- fix #9887 + mod_names <- mapM mod_name mods let mod_commas | null mods = text "none." - | otherwise = hsep ( - punctuate comma (map ppr mods)) <> text "." + | otherwise = hsep (punctuate comma mod_names) <> text "." status = case ok of Failed -> text "Failed" Succeeded -> text "Ok" diff --git a/testsuite/tests/ghci/scripts/ghci058.stdout b/testsuite/tests/ghci/scripts/ghci058.stdout index 7347571..bc77f05 100644 --- a/testsuite/tests/ghci/scripts/ghci058.stdout +++ b/testsuite/tests/ghci/scripts/ghci058.stdout @@ -1,4 +1,4 @@ -Ok, modules loaded: Ghci058. +Ok, modules loaded: Ghci058 (Ghci058.o). 'a' -Ok, modules loaded: Ghci058. +Ok, modules loaded: Ghci058 (Ghci058.o). 'b' From git at git.haskell.org Sat Mar 12 21:45:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:45:55 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add doc to (<$>) explaining its relationship to ($) (8358be7) Message-ID: <20160312214555.7ECEE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/8358be725a19826d862941c2a6e002aa4b366abf/ghc >--------------------------------------------------------------- commit 8358be725a19826d862941c2a6e002aa4b366abf Author: Chris Martin Date: Fri Mar 11 10:40:16 2016 +0100 Add doc to (<$>) explaining its relationship to ($) Reviewers: bgamari, hvr, austin Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1989 (cherry picked from commit 06b70ffc7b17bd34ea771b8be11574c4002db6c8) >--------------------------------------------------------------- 8358be725a19826d862941c2a6e002aa4b366abf libraries/base/Data/Functor.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libraries/base/Data/Functor.hs b/libraries/base/Data/Functor.hs index 72ee965..8eba29e 100644 --- a/libraries/base/Data/Functor.hs +++ b/libraries/base/Data/Functor.hs @@ -33,6 +33,15 @@ infixl 4 <$> -- | An infix synonym for 'fmap'. -- +-- The name of this operator is an allusion to '$'. +-- Note the similarities between their types: +-- +-- > ($) :: (a -> b) -> a -> b +-- > (<$>) :: Functor f => (a -> b) -> f a -> f b +-- +-- Whereas '$' is function application, '<$>' is function +-- application lifted over a 'Functor'. +-- -- ==== __Examples__ -- -- Convert from a @'Maybe' 'Int'@ to a @'Maybe' 'String'@ using 'show': From git at git.haskell.org Sat Mar 12 21:45:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:45:58 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix readme link to FixingBugs wiki page (8be75ec) Message-ID: <20160312214558.35EA23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/8be75ec819bd13b9c12411453cf778652c3e50e9/ghc >--------------------------------------------------------------- commit 8be75ec819bd13b9c12411453cf778652c3e50e9 Author: Chris Martin Date: Fri Mar 11 10:40:06 2016 +0100 Fix readme link to FixingBugs wiki page Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1988 (cherry picked from commit 90b8af05660dc2b36c62a07ff86703cbb9e04766) >--------------------------------------------------------------- 8be75ec819bd13b9c12411453cf778652c3e50e9 README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 227657f..2cecbdc 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ There are two ways to get a source tree: repository from Github] [7]. **DO NOT submit pull request directly to the github repo.** - *See the GHC team's working conventions re [how to contribute a patch to GHC](http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs "ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBug").* + *See the GHC team's working conventions re [how to contribute a patch to GHC](http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs).* Building & Installing From git at git.haskell.org Sat Mar 12 21:46:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:46:00 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix minimum alignment for StgClosure (Trac #11395) (79737db) Message-ID: <20160312214600.D1FA13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/79737db203bed639c525861c5da57224ea663374/ghc >--------------------------------------------------------------- commit 79737db203bed639c525861c5da57224ea663374 Author: Sergei Trofimovich Date: Sun Mar 6 09:55:12 2016 +0000 Fix minimum alignment for StgClosure (Trac #11395) The bug is observed on m68k-linux target as crash in RTS: -- a.hs: main = print 43 $ inplace/bin/ghc-stage1 --make -debug a.hs $ ./a Program terminated with signal SIGSEGV, Segmentation fault. #0 0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858) at includes/rts/storage/ClosureMacros.h:248 (gdb) bt #0 0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858) at includes/rts/storage/ClosureMacros.h:248 #1 0x80463b46 in LOOKS_LIKE_INFO_PTR (p=32858) at includes/rts/storage/ClosureMacros.h:253 #2 0x80463b6c in LOOKS_LIKE_CLOSURE_PTR ( p=0x805aac6e ) at includes/rts/storage/ClosureMacros.h:258 #3 0x80463e4c in initStorage () at rts/sm/Storage.c:121 #4 0x8043ffb4 in hs_init_ghc (...) at rts/RtsStartup.c:181 #5 0x80455982 in hs_main (...) at rts/RtsMain.c:51 #6 0x80003c1c in main () GHC assumes last 2 pointer bits are tags on 32-bit targets. But here 'stg_dummy_ret_closure' address violates the assumption: LOOKS_LIKE_CLOSURE_PTR (p=0x805aac6e ) I've added compiler hint for static StgClosure objects to align closures at least by their natural alignment (what GHC assumes). See Note [StgWord alignment]. Signed-off-by: Sergei Trofimovich Test Plan: ran basic test on m68k qemu, it got past ASSERTs Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1974 GHC Trac Issues: #11395 (cherry picked from commit ade1a461ab4ba3e6de3c4afe9fe9766b7b4e51b3) >--------------------------------------------------------------- 79737db203bed639c525861c5da57224ea663374 compiler/cmm/PprC.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs index 2e2f501..11d804e 100644 --- a/compiler/cmm/PprC.hs +++ b/compiler/cmm/PprC.hs @@ -152,10 +152,34 @@ pprWordArray :: CLabel -> [CmmStatic] -> SDoc pprWordArray lbl ds = sdocWithDynFlags $ \dflags -> hcat [ pprLocalness lbl, text "StgWord" - , space, ppr lbl, text "[] = {" ] + , space, ppr lbl, text "[]" + -- See Note [StgWord alignment] + , pprAlignment (wordWidth dflags) + , text "= {" ] $$ nest 8 (commafy (pprStatics dflags ds)) $$ text "};" +pprAlignment :: Width -> SDoc +pprAlignment words = + text "__attribute__((aligned(" <> int (widthInBytes words) <> text ")))" + +-- Note [StgWord alignment] +-- C codegen builds static closures as StgWord C arrays (pprWordArray). +-- Their real C type is 'StgClosure'. Macros like UNTAG_CLOSURE assume +-- pointers to 'StgClosure' are aligned at pointer size boundary: +-- 4 byte boundary on 32 systems +-- and 8 bytes on 64-bit systems +-- see TAG_MASK and TAG_BITS definition and usage. +-- +-- It's a reasonable assumption also known as natural alignment. +-- Although some architectures have different alignment rules. +-- One of known exceptions is m68k (Trac #11395, comment:16) where: +-- __alignof__(StgWord) == 2, sizeof(StgWord) == 4 +-- +-- Thus we explicitly increase alignment by using +-- __attribute__((aligned(4))) +-- declaration. + -- -- has to be static, if it isn't globally visible -- From git at git.haskell.org Sat Mar 12 21:46:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:46:03 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Split external symbol prototypes (EF_) (Trac #11395) (c769188) Message-ID: <20160312214603.80AE83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/c769188ba88dc8e9011451170c58fdb5b03b4a35/ghc >--------------------------------------------------------------- commit c769188ba88dc8e9011451170c58fdb5b03b4a35 Author: Sergei Trofimovich Date: Tue Mar 8 08:14:08 2016 +0000 Split external symbol prototypes (EF_) (Trac #11395) Before the patch both Cmm and C symbols were declared with 'EF_' macro: #define EF_(f) extern StgFunPtr f() but for Cmm symbols we know exact prototypes. The patch splits there prototypes in to: #define EFF_(f) void f() /* See Note [External function prototypes] */ #define EF_(f) StgFunPtr f(void) Cmm functions are 'EF_' (External Functions), C functions are 'EFF_' (External Foreign Functions). While at it changed external C function prototype to return 'void' to workaround ghc bug on m68k. Described in detail in Trac #11395. This makes simple tests work on m68k-linux target! Thanks to Michael Karcher for awesome analysis happening in Trac #11395. Signed-off-by: Sergei Trofimovich Test Plan: ran "hello world" on m68k successfully Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1975 GHC Trac Issues: #11395 (cherry picked from commit 90e1e160b783644c2d3cc0a05e3a804cea549cf9) >--------------------------------------------------------------- c769188ba88dc8e9011451170c58fdb5b03b4a35 compiler/cmm/CLabel.hs | 8 +++++++- compiler/cmm/PprC.hs | 5 +++-- includes/Stg.h | 20 +++++++++++++++++--- includes/stg/MiscClosures.h | 15 +++++++++++++-- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs index 9304d66..15c5ff3 100644 --- a/compiler/cmm/CLabel.hs +++ b/compiler/cmm/CLabel.hs @@ -88,8 +88,9 @@ module CLabel ( mkForeignLabel, addLabelSize, - foreignLabelStdcallInfo, + foreignLabelStdcallInfo, + isForeignLabel, mkCCLabel, mkCCSLabel, DynamicLinkerLabelInfo(..), @@ -492,6 +493,11 @@ addLabelSize (ForeignLabel str _ src fod) sz addLabelSize label _ = label +-- | Whether label is a non-haskell label (defined in C code) +isForeignLabel :: CLabel -> Bool +isForeignLabel (ForeignLabel _ _ _ _) = True +isForeignLabel _lbl = False + -- | Get the label size field from a ForeignLabel foreignLabelStdcallInfo :: CLabel -> Maybe Int foreignLabelStdcallInfo (ForeignLabel _ info _ _) = info diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs index 11d804e..900adcd 100644 --- a/compiler/cmm/PprC.hs +++ b/compiler/cmm/PprC.hs @@ -268,7 +268,7 @@ pprStmt stmt = -- We also need to cast mem primops to prevent conflicts with GCC -- builtins (see bug #5967). | Just _align <- machOpMemcpyishAlign op - = (text ";EF_(" <> fn <> char ')' <> semi) $$ + = (text ";EFF_(" <> fn <> char ')' <> semi) $$ pprForeignCall fn cconv hresults hargs | otherwise = pprCall fn cconv hresults hargs @@ -1009,7 +1009,8 @@ pprExternDecl _in_srt lbl hcat [ visibility, label_type lbl, lparen, ppr lbl, text ");" ] where - label_type lbl | isCFunctionLabel lbl = text "F_" + label_type lbl | isForeignLabel lbl && isCFunctionLabel lbl = text "FF_" + | isCFunctionLabel lbl = text "F_" | otherwise = text "I_" visibility diff --git a/includes/Stg.h b/includes/Stg.h index 899e685..a8ab5ca 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -222,11 +222,21 @@ typedef StgFunPtr F_; #define II_(X) static StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) #define IF_(f) static StgFunPtr GNUC3_ATTRIBUTE(used) f(void) #define FN_(f) StgFunPtr f(void) -#define EF_(f) extern StgFunPtr f() /* See Note [External function prototypes] */ +#define EF_(f) StgFunPtr f(void) /* External Cmm functions */ +#define EFF_(f) void f() /* See Note [External function prototypes] */ -/* Note [External function prototypes] See Trac #8965 +/* Note [External function prototypes] See Trac #8965, #11395 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The external-function macro EF_(F) used to be defined as +In generated C code we need to distinct between two types +of external symbols: +1. Cmm functions declared by 'EF_' macro (External Functions) +2. C functions declared by 'EFF_' macro (External Foreign Functions) + +Cmm functions are simple as they are internal to GHC. + +C functions are trickier: + +The external-function macro EFF_(F) used to be defined as extern StgFunPtr f(void) i.e a function of zero arguments. On most platforms this doesn't matter very much: calls to these functions put the parameters in the @@ -249,6 +259,10 @@ unspecified argument list rather than a void argument list. This is no worse for platforms that don't care either way, and allows a successful bootstrap of GHC 7.8 on little-endian Linux ppc64 (which uses the ELFv2 ABI). + +Another case is m68k ABI where 'void*' return type is returned by 'a0' +register while 'long' return type is returned by 'd0'. Thus we trick +external prototype return neither of these types to workaround #11395. */ diff --git a/includes/stg/MiscClosures.h b/includes/stg/MiscClosures.h index 6736658..75e59ce 100644 --- a/includes/stg/MiscClosures.h +++ b/includes/stg/MiscClosures.h @@ -491,8 +491,19 @@ extern StgWord RTS_VAR(CCS_LIST); /* registered CCS list */ extern StgWord CCS_SYSTEM[]; extern unsigned int RTS_VAR(CC_ID); /* global ids */ extern unsigned int RTS_VAR(CCS_ID); -RTS_FUN_DECL(enterFunCCS); -RTS_FUN_DECL(pushCostCentre); + +// Calls to these rts functions are generated directly +// by codegen (see compiler/codeGen/StgCmmProf.hs) +// and don't require (don't emit) forward declarations. +// +// In unregisterised mode (when building via .hc files) +// the calls are ordinary C calls. Functions must be in +// scope and must match prototype assumed by +// 'compiler/codeGen/StgCmmProf.hs' +// as opposed to real prototype declared in +// 'includes/rts/prof/CCS.h' +void enterFunCCS (void *reg, void *ccsfn); +void * pushCostCentre (void *ccs, void *cc); // Capability.c extern unsigned int n_capabilities; From git at git.haskell.org Sat Mar 12 21:46:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 12 Mar 2016 21:46:06 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: fix Float/Double unreg cross-compilation (f996692) Message-ID: <20160312214606.2DF8A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/f996692ed93c4d7744242a2212c2886359d29586/ghc >--------------------------------------------------------------- commit f996692ed93c4d7744242a2212c2886359d29586 Author: Sergei Trofimovich Date: Thu Mar 10 21:53:16 2016 +0000 fix Float/Double unreg cross-compilation Looking at more failures on m68k (Trac #11395) I've noticed the arith001 and arith012 test failures. (--host=x86_64-linux --target=m68k-linux). The following example was enough to reproduce a problem: v :: Float v = 43 main = print v m68k binaries printed '0.0' instead of '43.0'. The bug here is how we encode Floats and Double as Words with the same binary representation. Floats: Before the patch we just coerced Float to Int. That breaks when we cross-compile from 64-bit LE to 32-bit BE. The patch fixes conversion by accounting for padding. when we extend 32-bit value to 64-bit value (LE and BE do it slightly differently). Doubles: Before the patch Doubles were coerced to a pair of Ints (not correct as x86_64 can hold Double in one Int) and then trucated this pair of Ints to pair of Word32. The patch fixes conversion by always decomposing in Word32 and accounting for host endianness (newly introduced hostBE) and target endianness (wORDS_BIGENDIAN). I've tested this patch on Double and Float conversion on --host=x86_64-linux --target=m68k-linux crosscompiler. It fixes 10 tests related to printing Floats and Doubles. Thanks to Bertram Felgenhauer who poined out this probem. Signed-off-by: Sergei Trofimovich Test Plan: checked some examples manually, fixed 10 tests in test suite Reviewers: int-e, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1990 GHC Trac Issues: #11395 (cherry picked from commit c42cdb7f6dcfd519d9607ac9fa53f049b2922fb8) >--------------------------------------------------------------- f996692ed93c4d7744242a2212c2886359d29586 compiler/cmm/PprC.hs | 79 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs index 900adcd..ce5a202 100644 --- a/compiler/cmm/PprC.hs +++ b/compiler/cmm/PprC.hs @@ -508,7 +508,7 @@ pprLit1 other = pprLit other pprStatics :: DynFlags -> [CmmStatic] -> [SDoc] pprStatics _ [] = [] pprStatics dflags (CmmStaticLit (CmmFloat f W32) : rest) - -- floats are padded to a word, see #1852 + -- floats are padded to a word by padLitToWord, see #1852 | wORD_SIZE dflags == 8, CmmStaticLit (CmmInt 0 W32) : rest' <- rest = pprLit1 (floatToWord dflags f) : pprStatics dflags rest' | wORD_SIZE dflags == 4 @@ -520,6 +520,7 @@ pprStatics dflags (CmmStaticLit (CmmFloat f W32) : rest) ppr' _other = text "bad static!" pprStatics dflags (CmmStaticLit (CmmFloat f W64) : rest) = map pprLit1 (doubleToWords dflags f) ++ pprStatics dflags rest + pprStatics dflags (CmmStaticLit (CmmInt i W64) : rest) | wordWidth dflags == W32 = if wORDS_BIGENDIAN dflags @@ -1181,54 +1182,72 @@ pprStringInCStyle s = doubleQuotes (text (concatMap charToC s)) -- Initialising static objects with floating-point numbers. We can't -- just emit the floating point number, because C will cast it to an int -- by rounding it. We want the actual bit-representation of the float. +-- +-- Consider a concrete C example: +-- double d = 2.5e-10; +-- float f = 2.5e-10f; +-- +-- int * i2 = &d; printf ("i2: %08X %08X\n", i2[0], i2[1]); +-- long long * l = &d; printf (" l: %016llX\n", l[0]); +-- int * i = &f; printf (" i: %08X\n", i[0]); +-- Result on 64-bit LE (x86_64): +-- i2: E826D695 3DF12E0B +-- l: 3DF12E0BE826D695 +-- i: 2F89705F +-- Result on 32-bit BE (m68k): +-- i2: 3DF12E0B E826D695 +-- l: 3DF12E0BE826D695 +-- i: 2F89705F +-- +-- The trick here is to notice that binary representation does not +-- change much: only Word32 values get swapped on LE hosts / targets. -- This is a hack to turn the floating point numbers into ints that we -- can safely initialise to static locations. -big_doubles :: DynFlags -> Bool -big_doubles dflags - | widthInBytes W64 == 2 * wORD_SIZE dflags = True - | widthInBytes W64 == wORD_SIZE dflags = False - | otherwise = panic "big_doubles" - -castFloatToIntArray :: STUArray s Int Float -> ST s (STUArray s Int Int) -castFloatToIntArray = U.castSTUArray +castFloatToWord32Array :: STUArray s Int Float -> ST s (STUArray s Int Word32) +castFloatToWord32Array = U.castSTUArray -castDoubleToIntArray :: STUArray s Int Double -> ST s (STUArray s Int Int) -castDoubleToIntArray = U.castSTUArray +castDoubleToWord64Array :: STUArray s Int Double -> ST s (STUArray s Int Word64) +castDoubleToWord64Array = U.castSTUArray --- floats are always 1 word floatToWord :: DynFlags -> Rational -> CmmLit floatToWord dflags r = runST (do arr <- newArray_ ((0::Int),0) writeArray arr 0 (fromRational r) - arr' <- castFloatToIntArray arr - i <- readArray arr' 0 - return (CmmInt (toInteger i) (wordWidth dflags)) + arr' <- castFloatToWord32Array arr + w32 <- readArray arr' 0 + return (CmmInt (toInteger w32 `shiftL` wo) (wordWidth dflags)) ) + where wo | wordWidth dflags == W64 + , wORDS_BIGENDIAN dflags = 32 + | otherwise = 0 doubleToWords :: DynFlags -> Rational -> [CmmLit] doubleToWords dflags r - | big_doubles dflags -- doubles are 2 words = runST (do arr <- newArray_ ((0::Int),1) writeArray arr 0 (fromRational r) - arr' <- castDoubleToIntArray arr - i1 <- readArray arr' 0 - i2 <- readArray arr' 1 - return [ CmmInt (toInteger i1) (wordWidth dflags) - , CmmInt (toInteger i2) (wordWidth dflags) - ] - ) - | otherwise -- doubles are 1 word - = runST (do - arr <- newArray_ ((0::Int),0) - writeArray arr 0 (fromRational r) - arr' <- castDoubleToIntArray arr - i <- readArray arr' 0 - return [ CmmInt (toInteger i) (wordWidth dflags) ] + arr' <- castDoubleToWord64Array arr + w64 <- readArray arr' 0 + return (pprWord64 w64) ) + where targetWidth = wordWidth dflags + targetBE = wORDS_BIGENDIAN dflags + pprWord64 w64 + | targetWidth == W64 = + [ CmmInt (toInteger w64) targetWidth ] + | targetWidth == W32 = + [ CmmInt (toInteger targetW1) targetWidth + , CmmInt (toInteger targetW2) targetWidth + ] + | otherwise = panic "doubleToWords.pprWord64" + where (targetW1, targetW2) + | targetBE = (wHi, wLo) + | otherwise = (wLo, wHi) + wHi = w64 `shiftR` 32 + wLo = w64 .&. 0xFFFFffff -- --------------------------------------------------------------------------- -- Utils From git at git.haskell.org Sun Mar 13 22:33:07 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 13 Mar 2016 22:33:07 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add asserts to other substitution functions (0f606fa) Message-ID: <20160313223307.4AE703A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0f606fa8ca330ad2efd9f1d093805d1e38bf1f5f/ghc >--------------------------------------------------------------- commit 0f606fa8ca330ad2efd9f1d093805d1e38bf1f5f Author: Bartosz Nitka Date: Wed Jan 27 08:37:30 2016 -0800 Add asserts to other substitution functions This adds asserts to `substTys`, `substCo` and `substCos` in the same spirit as already existing asserts on `substTy`, protecting every possible entry point to `subst_ty` and `subst_co`. I've replaced the violators with unchecked versions. Test Plan: ./validate --slow Reviewers: simonpj, goldfire, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1862 GHC Trac Issues: #11371 (cherry picked from commit bb956eb8d8774613c1e311655f1359a91a84765b) >--------------------------------------------------------------- 0f606fa8ca330ad2efd9f1d093805d1e38bf1f5f compiler/basicTypes/MkId.hs | 2 +- compiler/coreSyn/CoreLint.hs | 2 +- compiler/coreSyn/CoreUtils.hs | 2 +- compiler/deSugar/DsExpr.hs | 2 +- compiler/typecheck/FunDeps.hs | 2 +- compiler/typecheck/Inst.hs | 10 +- compiler/typecheck/TcExpr.hs | 6 +- compiler/typecheck/TcSMonad.hs | 2 +- compiler/typecheck/TcType.hs | 5 +- compiler/types/Coercion.hs | 6 +- compiler/types/OptCoercion.hs | 2 +- compiler/types/TyCoRep.hs | 232 +++++++++++++++++++++++++++++++++-------- compiler/types/Type.hs | 17 +-- 13 files changed, 220 insertions(+), 70 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 0f606fa8ca330ad2efd9f1d093805d1e38bf1f5f From git at git.haskell.org Sun Mar 13 22:33:09 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 13 Mar 2016 22:33:09 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Suppress substitution assertions to fix tests (3162121) Message-ID: <20160313223309.EEA0F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/3162121b0c23f8535ab55903cdcaa93361a9d403/ghc >--------------------------------------------------------------- commit 3162121b0c23f8535ab55903cdcaa93361a9d403 Author: Bartosz Nitka Date: Mon Feb 1 02:39:50 2016 -0800 Suppress substitution assertions to fix tests This is one place that I've missed with D1862. This doesn't fix the underlying problem and I prefer to suppress it now and fix it later as this is a part of a larger effort (#11371) to fix an old bug with `substTy` called with invalid `in_scope` sets. Test Plan: `make test TEST="hClose002 hClose003 hDuplicateTo001" Reviewers: thomie, austin, bgamari, trofi Reviewed By: trofi Differential Revision: https://phabricator.haskell.org/D1872 GHC Trac Issues: #11371 (cherry picked from commit e5a0a8903715b8717342dabeb72d69b4d5e61e5c) >--------------------------------------------------------------- 3162121b0c23f8535ab55903cdcaa93361a9d403 compiler/basicTypes/MkId.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/basicTypes/MkId.hs b/compiler/basicTypes/MkId.hs index 1941104..0ebd029 100644 --- a/compiler/basicTypes/MkId.hs +++ b/compiler/basicTypes/MkId.hs @@ -695,7 +695,7 @@ wrapCo co rep_ty (unbox_rep, box_rep) -- co :: arg_ty ~ rep_ty UnitBox -> do { rep_id <- newLocal (TcType.substTy subst rep_ty) ; return ([rep_id], Var rep_id) } Boxer boxer -> boxer subst - ; let sco = substCo subst co + ; let sco = substCoUnchecked subst co ; return (rep_ids, rep_expr `Cast` mkSymCo sco) } ------------------------ From git at git.haskell.org Sun Mar 13 22:33:12 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 13 Mar 2016 22:33:12 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Improve piResultTys and friends (6ccb004) Message-ID: <20160313223312.B4D323A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6ccb00466147602e8fc0dccf97f575afbbe1a436/ghc >--------------------------------------------------------------- commit 6ccb00466147602e8fc0dccf97f575afbbe1a436 Author: Simon Peyton Jones Date: Thu Feb 18 11:34:12 2016 +0000 Improve piResultTys and friends Several things here: * Re-implement piResultTys so that its substitution has the correct in-scope set That means paying close attention to performance, since as we discovered in Trac #11371, it's a heavily used function and is often used on ordinary function types, with no foralls to worry about substituting. * Kill off applyTys, which was just the same as piResultTys. * Re-engineer MkCore.mkCoreApps so that it calls piResultTys, rather than repeatedly calling piResultTy. (cherry picked from commit 4d031cf91c5eed9b162703daee274bbbe94bdc42) >--------------------------------------------------------------- 6ccb00466147602e8fc0dccf97f575afbbe1a436 compiler/coreSyn/CoreLint.hs | 2 +- compiler/coreSyn/CoreUtils.hs | 6 +- compiler/coreSyn/MkCore.hs | 26 +++---- compiler/iface/BuildTyCl.hs | 2 +- compiler/typecheck/TcClassDcl.hs | 7 +- compiler/typecheck/TcInstDcls.hs | 2 +- compiler/typecheck/TcType.hs | 2 +- compiler/types/Coercion.hs | 9 ++- compiler/types/Type.hs | 145 ++++++++++++++++++++++----------------- 9 files changed, 109 insertions(+), 92 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 6ccb00466147602e8fc0dccf97f575afbbe1a436 From git at git.haskell.org Sun Mar 13 22:33:15 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 13 Mar 2016 22:33:15 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: (Another) minor refactoring of substitutions (5da67ba) Message-ID: <20160313223315.7F6BA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/5da67bae23313cd5632c903c8369e03865628b34/ghc >--------------------------------------------------------------- commit 5da67bae23313cd5632c903c8369e03865628b34 Author: Simon Peyton Jones Date: Thu Feb 18 11:25:38 2016 +0000 (Another) minor refactoring of substitutions No change in functionality here, but greater clarity: * In FamInstEnv.FlattenEnv, kill off the fi_in_scope field We are already maintaining an in-scope set in the fe_subst field, so it's silly do to it twice. (This isn't strictly connected to the rest of this patch, but the nomenclature changes below affect the same code, so I put them together.) * TyCoRep.extendTCVSubst used to take a TyVar or a CoVar and work out what to do, but in fact we almost always know which of the two we are doing. So: - define extendTvSubst, extendCvSubst - and use them * Similar renamings in TyCoRep: - extendTCvSubstList --> extendTvSubstList - extendTCvSubstBinder --> extendTvSubstBinder - extendTCvSubstAndInScope --> extendTvSubstAndInScope * Add Type.extendTvSubstWithClone, extendCvSubstWithClone * Similar nomenclature changes in Subst, SimplEnv, Specialise * Kill off TyCoRep.substTelescope (never used) (cherry picked from commit b5292557dcf2e3844b4837172230575d40a8917e) >--------------------------------------------------------------- 5da67bae23313cd5632c903c8369e03865628b34 compiler/basicTypes/MkId.hs | 6 +-- compiler/coreSyn/CoreLint.hs | 2 +- compiler/coreSyn/CoreSubst.hs | 47 +++++++++---------- compiler/coreSyn/CoreUtils.hs | 2 +- compiler/iface/IfaceType.hs | 2 +- compiler/main/GhcPlugins.hs | 2 +- compiler/simplCore/SimplEnv.hs | 20 +++++---- compiler/simplCore/Simplify.hs | 16 +++---- compiler/specialise/Specialise.hs | 12 ++--- compiler/typecheck/Inst.hs | 5 ++- compiler/typecheck/TcClassDcl.hs | 2 +- compiler/typecheck/TcExpr.hs | 2 +- compiler/typecheck/TcHsType.hs | 4 +- compiler/typecheck/TcMType.hs | 47 ++++++++----------- compiler/typecheck/TcSMonad.hs | 2 +- compiler/typecheck/TcTyClsDecls.hs | 4 +- compiler/typecheck/TcType.hs | 5 ++- compiler/types/Coercion.hs | 2 +- compiler/types/FamInstEnv.hs | 29 ++++++------ compiler/types/OptCoercion.hs | 2 +- compiler/types/TyCoRep.hs | 92 +++++++++++++++++++------------------- compiler/types/Type.hs | 7 +-- 22 files changed, 150 insertions(+), 162 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 5da67bae23313cd5632c903c8369e03865628b34 From git at git.haskell.org Sun Mar 13 22:33:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 13 Mar 2016 22:33:18 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Address #11471 by putting RuntimeRep in kinds. (223ef8d) Message-ID: <20160313223318.68FD73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/223ef8dba435aeb36afc9f9d76cb579da6651a10/ghc >--------------------------------------------------------------- commit 223ef8dba435aeb36afc9f9d76cb579da6651a10 Author: Richard Eisenberg Date: Thu Feb 4 10:42:56 2016 -0500 Address #11471 by putting RuntimeRep in kinds. See Note [TYPE] in TysPrim. There are still some outstanding pieces in #11471 though, so this doesn't actually nail the bug. This commit also contains a few performance improvements: * Short-cut equality checking of nullary type syns * Compare types before kinds in eqType * INLINE coreViewOneStarKind * Store tycon binders separately from kinds. This resulted in a ~10% performance improvement in compiling the Cabal package. No change in functionality other than performance. (This affects the interface file format, though.) This commit updates the haddock submodule. (cherry picked from commit d8c64e86361f6766ebe26a262bb229fb8301a42a) >--------------------------------------------------------------- 223ef8dba435aeb36afc9f9d76cb579da6651a10 compiler/basicTypes/DataCon.hs | 22 +- compiler/basicTypes/MkId.hs | 30 +- compiler/basicTypes/PatSyn.hs | 4 +- compiler/coreSyn/CoreLint.hs | 4 +- compiler/coreSyn/CorePrep.hs | 2 +- compiler/coreSyn/MkCore.hs | 20 +- compiler/deSugar/DsBinds.hs | 2 +- compiler/deSugar/DsForeign.hs | 8 +- compiler/deSugar/DsUtils.hs | 4 +- compiler/ghci/RtClosureInspect.hs | 4 +- compiler/iface/BinIface.hs | 2 +- compiler/iface/BuildTyCl.hs | 9 +- compiler/iface/IfaceEnv.hs | 2 +- compiler/iface/IfaceSyn.hs | 148 +++++----- compiler/iface/IfaceType.hs | 119 ++++++-- compiler/iface/MkIface.hs | 35 +-- compiler/iface/TcIface.hs | 96 +++--- compiler/prelude/PrelNames.hs | 38 ++- compiler/prelude/PrimOp.hs | 2 +- compiler/prelude/TysPrim.hs | 192 +++++++----- compiler/prelude/TysWiredIn.hs | 267 +++++++++++++---- compiler/prelude/TysWiredIn.hs-boot | 22 +- compiler/typecheck/Inst.hs | 127 +++++++- compiler/typecheck/TcBinds.hs | 2 +- compiler/typecheck/TcCanonical.hs | 4 +- compiler/typecheck/TcDeriv.hs | 2 +- compiler/typecheck/TcErrors.hs | 26 +- compiler/typecheck/TcExpr.hs | 12 +- compiler/typecheck/TcHsSyn.hs | 26 +- compiler/typecheck/TcHsType.hs | 325 +++++++-------------- compiler/typecheck/TcInstDcls.hs | 7 +- compiler/typecheck/TcInteract.hs | 2 +- compiler/typecheck/TcMType.hs | 34 ++- compiler/typecheck/TcPat.hs | 4 +- compiler/typecheck/TcPatSyn.hs | 18 +- compiler/typecheck/TcRnDriver.hs | 2 +- compiler/typecheck/TcSMonad.hs | 6 +- compiler/typecheck/TcSimplify.hs | 22 +- compiler/typecheck/TcSplice.hs | 36 +-- compiler/typecheck/TcTyClsDecls.hs | 196 +++++++------ compiler/typecheck/TcType.hs | 12 +- compiler/typecheck/TcTypeNats.hs | 12 +- compiler/typecheck/TcUnify.hs | 19 +- compiler/typecheck/TcValidity.hs | 6 +- compiler/types/Kind.hs | 30 +- compiler/types/TyCoRep.hs | 106 ++++--- compiler/types/TyCoRep.hs-boot | 2 + compiler/types/TyCon.hs | 302 ++++++++++++------- compiler/types/Type.hs | 131 +++++---- compiler/utils/Util.hs | 16 + compiler/vectorise/Vectorise/Exp.hs | 2 +- compiler/vectorise/Vectorise/Generic/PData.hs | 3 +- compiler/vectorise/Vectorise/Type/Env.hs | 2 +- compiler/vectorise/Vectorise/Type/TyConDecl.hs | 5 +- libraries/base/Data/Data.hs | 2 +- libraries/base/Data/Typeable/Internal.hs | 28 +- libraries/base/GHC/Err.hs | 8 +- libraries/base/GHC/Exts.hs | 4 +- libraries/base/tests/T11334.hs | 4 +- libraries/ghc-prim/GHC/Types.hs | 73 ++++- testsuite/tests/dependent/should_compile/T11405.hs | 2 +- .../dependent/should_fail/BadTelescope4.stderr | 6 +- .../tests/dependent/should_fail/TypeSkolEscape.hs | 2 +- .../dependent/should_fail/TypeSkolEscape.stderr | 10 +- testsuite/tests/ghci/scripts/T4175.stdout | 10 +- testsuite/tests/ghci/scripts/T7627.stdout | 8 +- testsuite/tests/ghci/scripts/T7939.stdout | 19 +- testsuite/tests/ghci/scripts/T8535.stdout | 2 +- testsuite/tests/ghci/scripts/T9181.stdout | 18 +- testsuite/tests/ghci/scripts/ghci020.stdout | 2 +- testsuite/tests/ghci/should_run/T10145.stdout | 2 +- .../indexed-types/should_compile/T3017.stderr | 4 +- .../indexed-types/should_fail/ClosedFam3.stderr | 45 ++- .../indexed-types/should_fail/Overlap4.stderr | 9 +- .../indexed-types/should_fail/SimpleFail1a.stderr | 3 +- .../indexed-types/should_fail/TyFamArity1.stderr | 8 +- .../indexed-types/should_fail/TyFamArity2.stderr | 13 +- .../tests/partial-sigs/should_compile/ADT.stderr | 1 - .../should_compile/DataFamilyInstanceLHS.stderr | 1 - .../partial-sigs/should_compile/Meltdown.stderr | 3 +- .../NamedWildcardInDataFamilyInstanceLHS.stderr | 1 - .../NamedWildcardInTypeFamilyInstanceLHS.stderr | 3 +- .../partial-sigs/should_compile/SkipMany.stderr | 1 - .../should_compile/TypeFamilyInstanceLHS.stderr | 3 +- testsuite/tests/perf/compiler/all.T | 3 +- testsuite/tests/polykinds/T11399.stderr | 4 +- testsuite/tests/polykinds/T7328.stderr | 2 +- testsuite/tests/polykinds/TidyClassKinds.stderr | 2 +- testsuite/tests/roles/should_compile/Roles1.stderr | 7 - testsuite/tests/roles/should_compile/Roles2.stderr | 2 - testsuite/tests/roles/should_compile/Roles3.stderr | 6 +- testsuite/tests/roles/should_compile/T8958.stderr | 1 - .../tests/simplCore/should_compile/T9400.stderr | 2 +- .../simplCore/should_compile/spec-inline.stderr | 2 +- testsuite/tests/th/TH_Roles2.stderr | 5 +- .../tests/typecheck/should_compile/tc231.stderr | 2 - testsuite/tests/typecheck/should_run/TypeOf.hs | 4 +- testsuite/tests/typecheck/should_run/TypeOf.stdout | 4 +- utils/genprimopcode/Main.hs | 2 +- utils/haddock | 2 +- 100 files changed, 1710 insertions(+), 1166 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 223ef8dba435aeb36afc9f9d76cb579da6651a10 From git at git.haskell.org Sun Mar 13 22:33:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 13 Mar 2016 22:33:58 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: LlvmCodeGen: Make it compile with ghc-7.8 (5830ffd) Message-ID: <20160313223358.BC5C73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/5830ffdbd4e579bdf2bf8c02bd00ec1c1ae0a165/ghc >--------------------------------------------------------------- commit 5830ffdbd4e579bdf2bf8c02bd00ec1c1ae0a165 Author: Erik de Castro Lopo Date: Sun Mar 13 23:35:55 2016 +0100 LlvmCodeGen: Make it compile with ghc-7.8 Test Plan: Build Reviewers: bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2003 GHC Trac Issues: #11705 >--------------------------------------------------------------- 5830ffdbd4e579bdf2bf8c02bd00ec1c1ae0a165 compiler/llvmGen/LlvmCodeGen.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs index 872ad8c..80fffea 100644 --- a/compiler/llvmGen/LlvmCodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen.hs @@ -31,6 +31,7 @@ import UniqSupply import SysTools ( figureLlvmVersion ) import qualified Stream +import Control.Applicative ( (<$>), pure ) import Control.Monad ( when ) import Data.Maybe ( fromMaybe, catMaybes ) import System.IO From git at git.haskell.org Mon Mar 14 12:23:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 14 Mar 2016 12:23:23 +0000 (UTC) Subject: [commit: ghc] master: users_guide: Break up -fprint-* description (9ee51da) Message-ID: <20160314122323.2FAB03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/9ee51da1a9a0d0c4215d8fc9dce32db63c57aa99/ghc >--------------------------------------------------------------- commit 9ee51da1a9a0d0c4215d8fc9dce32db63c57aa99 Author: Ben Gamari Date: Sun Mar 13 12:56:37 2016 +0100 users_guide: Break up -fprint-* description This makes it a bit easier to find the description corresponding to particular flags. >--------------------------------------------------------------- 9ee51da1a9a0d0c4215d8fc9dce32db63c57aa99 docs/users_guide/using.rst | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/docs/users_guide/using.rst b/docs/users_guide/using.rst index 47fdd29..96bd0a1 100644 --- a/docs/users_guide/using.rst +++ b/docs/users_guide/using.rst @@ -609,20 +609,30 @@ See also the ``--help``, ``--version``, ``--numeric-version``, and representation after each compilation phase is also printed (excluding preprocessed and C/assembly files). -.. ghc-flag:: --fprint-potential-instances +.. ghc-flag:: -fprint-potential-instances When GHC can't find an instance for a class, it displays a short list of some in the instances it knows about. With this flag it prints *all* the instances it knows about. + +The following flags control the way in which GHC displays types in error +messages and in GHCi: + +.. ghc-flag:: -fprint-unicode-syntax + + When enabled GHC prints type signatures using the unicode symbols from the + :ghc-flag:`-XUnicodeSyntax` extension. For instance, + + .. code-block:: none + + ghci> :set -fprint-unicode-syntax + ghci> :t (>>) + (>>) :: ? (m :: * ? *) a b. Monad m ? m a ? m b ? m b + .. ghc-flag:: -fprint-explicit-foralls - -fprint-explicit-kinds - -fprint-unicode-syntax - -fprint-explicit-coercions - -fprint-equality-relations - These flags control the way in which GHC displays types, in - error messages and in GHCi. Using :ghc-flag:`-fprint-explicit-foralls` makes + Using :ghc-flag:`-fprint-explicit-foralls` makes GHC print explicit ``forall`` quantification at the top level of a type; normally this is suppressed. For example, in GHCi: @@ -656,6 +666,8 @@ See also the ``--help``, ``--version``, ``--numeric-version``, and (a Data.Type.Equality.:~: b) -> b Data.Type.Equality.:~: a -- Defined in Data.Type.Equality +.. ghc-flag:: -fprint-explicit-kinds + Using :ghc-flag:`-fprint-explicit-kinds` makes GHC print kind arguments in types, which are normally suppressed. This can be important when you are using kind polymorphism. For example: @@ -670,21 +682,15 @@ See also the ``--help``, ``--version``, ``--numeric-version``, and ghci> :t MkT MkT :: forall (k :: BOX) (a :: k). T k a - When :ghc-flag:`-fprint-unicode-syntax` is enabled, GHC prints type - signatures using the unicode symbols from the :ghc-flag:`-XUnicodeSyntax` - extension. - - .. code-block:: none - - ghci> :set -fprint-unicode-syntax - ghci> :t (>>) - (>>) :: ? (m :: * ? *) a b. Monad m ? m a ? m b ? m b +.. ghc-flag:: -fprint-explicit-coercions Using :ghc-flag:`-fprint-explicit-coercions` makes GHC print coercions in types. When trying to prove the equality between types of different kinds, GHC uses type-level coercions. Users will rarely need to see these, as they are meant to be internal. +.. ghc-flag:: -fprint-equality-relations + Using :ghc-flag:`-fprint-equality-relations` tells GHC to distinguish between its equality relations when printing. For example, ``~`` is homogeneous lifted equality (the kinds of its arguments are the same) while From git at git.haskell.org Mon Mar 14 12:23:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 14 Mar 2016 12:23:26 +0000 (UTC) Subject: [commit: ghc] master: Add regression test for #11702 (3f60ce8) Message-ID: <20160314122326.4E9C73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3f60ce8751c860a2bd0ddbe87429136a9d97449b/ghc >--------------------------------------------------------------- commit 3f60ce8751c860a2bd0ddbe87429136a9d97449b Author: Ben Gamari Date: Sun Mar 13 21:29:19 2016 +0100 Add regression test for #11702 Test Plan: Validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2002 GHC Trac Issues: #11702 >--------------------------------------------------------------- 3f60ce8751c860a2bd0ddbe87429136a9d97449b testsuite/tests/numeric/should_run/T11702.hs | 9 +++++++++ .../should_run/T9844.stdout => numeric/should_run/T11702.stdout} | 0 testsuite/tests/numeric/should_run/all.T | 1 + 3 files changed, 10 insertions(+) diff --git a/testsuite/tests/numeric/should_run/T11702.hs b/testsuite/tests/numeric/should_run/T11702.hs new file mode 100644 index 0000000..0aeb77d --- /dev/null +++ b/testsuite/tests/numeric/should_run/T11702.hs @@ -0,0 +1,9 @@ +module Main where + +testfn :: Word -> IO () +testfn wseq = do + print $ wseq `mod` 1 + +main = do + testfn 5 + print $ (5 :: Word) `mod` 1 diff --git a/testsuite/tests/deSugar/should_run/T9844.stdout b/testsuite/tests/numeric/should_run/T11702.stdout similarity index 100% copy from testsuite/tests/deSugar/should_run/T9844.stdout copy to testsuite/tests/numeric/should_run/T11702.stdout diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T index 527ce27..515005f 100644 --- a/testsuite/tests/numeric/should_run/all.T +++ b/testsuite/tests/numeric/should_run/all.T @@ -66,3 +66,4 @@ test('T9407', normal, compile_and_run, ['']) test('T9810', normal, compile_and_run, ['']) test('T10011', normal, compile_and_run, ['']) test('T10962', omit_ways(['ghci']), compile_and_run, ['']) +test('T11702', expect_broken(11702), compile_and_run, ['']) From git at git.haskell.org Mon Mar 14 12:23:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 14 Mar 2016 12:23:28 +0000 (UTC) Subject: [commit: ghc] master: Fix the name of the Word16ElemRep wired-in datacon (d12166a) Message-ID: <20160314122328.EF1663A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/d12166ad905ad8b014d672b9fc3b9a0e10ba80df/ghc >--------------------------------------------------------------- commit d12166ad905ad8b014d672b9fc3b9a0e10ba80df Author: mniip Date: Sun Mar 13 18:12:55 2016 +0100 Fix the name of the Word16ElemRep wired-in datacon Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1999 >--------------------------------------------------------------- d12166ad905ad8b014d672b9fc3b9a0e10ba80df compiler/prelude/TysWiredIn.hs | 2 +- testsuite/tests/th/T11145.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs index c58bf32..98a5665 100644 --- a/compiler/prelude/TysWiredIn.hs +++ b/compiler/prelude/TysWiredIn.hs @@ -323,7 +323,7 @@ vecElemTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "VecElem") vec vecElemDataConNames :: [Name] vecElemDataConNames = zipWith3Lazy mk_special_dc_name [ fsLit "Int8ElemRep", fsLit "Int16ElemRep", fsLit "Int32ElemRep" - , fsLit "Int64ElemRep", fsLit "Word8ElemRep", fsLit "Word16elemRep" + , fsLit "Int64ElemRep", fsLit "Word8ElemRep", fsLit "Word16ElemRep" , fsLit "Word32ElemRep", fsLit "Word64ElemRep" , fsLit "FloatElemRep", fsLit "DoubleElemRep" ] vecElemDataConKeys diff --git a/testsuite/tests/th/T11145.stderr b/testsuite/tests/th/T11145.stderr index 98e518c..d198739 100644 --- a/testsuite/tests/th/T11145.stderr +++ b/testsuite/tests/th/T11145.stderr @@ -3,6 +3,6 @@ T11145.hs:8:1: error: ? Data constructor ?MkFuggle? returns type ?Fuggle Int (Maybe Bool)? instead of an instance of its parent type ?Fuggle - Int (Maybe (a_a4MU, b_a4MV))? + Int (Maybe (a_a4MT, b_a4MU))? ? In the definition of data constructor ?MkFuggle? In the data instance declaration for ?Fuggle? From git at git.haskell.org Tue Mar 15 03:50:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:26 +0000 (UTC) Subject: [commit: ghc] master: Fix #11407. (e9bf7bb) Message-ID: <20160315035026.D4BFD3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e9bf7bb5cc9fb3f87dd05111aa23da76b86a8967/ghc >--------------------------------------------------------------- commit e9bf7bb5cc9fb3f87dd05111aa23da76b86a8967 Author: Richard Eisenberg Date: Mon Feb 22 12:54:56 2016 -0500 Fix #11407. This removes the `defer_me` check that was in checkTauTvUpdate and uses only a type family check instead. The old defer_me check repeated work done by fast_check in occurCheckExpand. There is also some error message improvement, necessitated by the terrible error message that the test case produced, even when it didn't consume all of memory. test case: dependent/should_fail/T11407 [skip ci] >--------------------------------------------------------------- e9bf7bb5cc9fb3f87dd05111aa23da76b86a8967 compiler/typecheck/TcErrors.hs | 15 +++++++- compiler/typecheck/TcUnify.hs | 45 +++++----------------- compiler/types/TyCoRep.hs | 25 ++++++------ compiler/types/Type.hs | 9 ++++- compiler/types/Type.hs-boot | 5 +++ testsuite/tests/dependent/should_fail/T11407.hs | 10 +++++ .../tests/dependent/should_fail/T11407.stderr | 8 ++++ testsuite/tests/dependent/should_fail/all.T | 1 + 8 files changed, 70 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e9bf7bb5cc9fb3f87dd05111aa23da76b86a8967 From git at git.haskell.org Tue Mar 15 03:50:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:29 +0000 (UTC) Subject: [commit: ghc] master: Move and expand (slightly) TypeApplications docs (18fbfa3) Message-ID: <20160315035029.884E83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/18fbfa39104b92a05061ec5f6f5bf3b84b462605/ghc >--------------------------------------------------------------- commit 18fbfa39104b92a05061ec5f6f5bf3b84b462605 Author: Richard Eisenberg Date: Sun Feb 21 20:51:27 2016 -0500 Move and expand (slightly) TypeApplications docs [skip ci] >--------------------------------------------------------------- 18fbfa39104b92a05061ec5f6f5bf3b84b462605 docs/users_guide/glasgow_exts.rst | 143 ++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 66 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 5b4fe06..341a2ee 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1771,72 +1771,6 @@ data constructor in an import or export list with the keyword ``pattern``, to allow the import or export of a data constructor without its parent type constructor (see :ref:`patsyn-impexp`). -.. _visible-type-application: - -Visible type application -~~~~~~~~~~~~~~~~~~~~~~~~ - -.. ghc-flag:: -XTypeApplications - - :implies: :ghc-flag:`-XAllowAmbiguousTypes` - :since: 8.0.1 - - Allow the use of type application syntax. - -The :ghc-flag:`-XTypeApplications` extension allows you to use -*visible type application* in expressions. Here is an -example: ``show (read @Int "5")``. The ``@Int`` -is the visible type application; it specifies the value of the type variable -in ``read``'s type. - -A visible type application is preceded with an ``@`` -sign. (To disambiguate the syntax, the ``@`` must be -preceded with a non-identifier letter, usually a space. For example, -``read at Int 5`` would not parse.) It can be used whenever -the full polymorphic type of the function is known. If the function -is an identifier (the common case), its type is considered known only when -the identifier has been given a type signature. If the identifier does -not have a type signature, visible type application cannot be used. - -Here are the details: - -- If an identifier's type signature does not include an - explicit ``forall``, the type variable arguments appear - in the left-to-right order in which the variables appear in the type. - So, ``foo :: Monad m => a b -> m (a c)`` - will have its type variables - ordered as ``m, a, b, c``. - -- If any of the variables depend on other variables (that is, if some - of the variables are *kind* variables), the variables are reordered - so that kind variables come before type variables, preserving the - left-to-right order as much as possible. That is, GHC performs a - stable topological sort on the variables. - - For example: if we have ``bar :: Proxy (a :: (j, k)) -> b``, then - the variables are ordered ``j``, ``k``, ``a``, ``b``. - -- Class methods' type arguments include the class type - variables, followed by any variables an individual method is polymorphic - in. So, ``class Monad m where return :: a -> m a`` means - that ``return``'s type arguments are ``m, a``. - -- With the :ghc-flag:`-XRankNTypes` extension - (:ref:`universal-quantification`), it is possible to declare - type arguments somewhere other than the beginning of a type. For example, - we can have ``pair :: forall a. a -> forall b. b -> (a, b)`` - and then say ``pair @Bool True @Char`` which would have - type ``Char -> (Bool, Char)``. - -- Partial type signatures (:ref:`partial-type-signatures`) - work nicely with visible type - application. If you want to specify only the second type argument to - ``wurble``, then you can say ``wurble @_ @Int``. - The first argument is a wildcard, just like in a partial type signature. - However, if used in a visible type application, it is *not* - necessary to specify :ghc-flag:`-XPartialTypeSignatures` and your - code will not generate a warning informing you of the omitted type. - .. _syntax-stolen: Summary of stolen syntax @@ -8310,6 +8244,83 @@ and :ghc-flag:`-XGADTs`. You can switch it off again with :ghc-flag:`-XNoMonoLocalBinds <-XMonoLocalBinds>` but type inference becomes less predicatable if you do so. (Read the papers!) +.. _visible-type-application: + +Visible type application +======================== + +.. ghc-flag:: -XTypeApplications + + :implies: :ghc-flag:`-XAllowAmbiguousTypes` + :since: 8.0.1 + + Allow the use of type application syntax. + +The :ghc-flag:`-XTypeApplications` extension allows you to use +*visible type application* in expressions. Here is an +example: ``show (read @Int "5")``. The ``@Int`` +is the visible type application; it specifies the value of the type variable +in ``read``'s type. + +A visible type application is preceded with an ``@`` +sign. (To disambiguate the syntax, the ``@`` must be +preceded with a non-identifier letter, usually a space. For example, +``read at Int 5`` would not parse.) It can be used whenever +the full polymorphic type of the function is known. If the function +is an identifier (the common case), its type is considered known only when +the identifier has been given a type signature. If the identifier does +not have a type signature, visible type application cannot be used. + +Here are the details: + +- If an identifier's type signature does not include an + explicit ``forall``, the type variable arguments appear + in the left-to-right order in which the variables appear in the type. + So, ``foo :: Monad m => a b -> m (a c)`` + will have its type variables + ordered as ``m, a, b, c``. + +- If any of the variables depend on other variables (that is, if some + of the variables are *kind* variables), the variables are reordered + so that kind variables come before type variables, preserving the + left-to-right order as much as possible. That is, GHC performs a + stable topological sort on the variables. + + For example: if we have ``bar :: Proxy (a :: (j, k)) -> b``, then + the variables are ordered ``j``, ``k``, ``a``, ``b``. + +- Visible type application is available to instantiate only user-specified + type variables. This means that in ``data Proxy a = Proxy``, the unmentioned + kind variable used in ``a``'s kind is *not* available for visible type + application. + +- Class methods' type arguments include the class type + variables, followed by any variables an individual method is polymorphic + in. So, ``class Monad m where return :: a -> m a`` means + that ``return``'s type arguments are ``m, a``. + +- With the :ghc-flag:`-XRankNTypes` extension + (:ref:`universal-quantification`), it is possible to declare + type arguments somewhere other than the beginning of a type. For example, + we can have ``pair :: forall a. a -> forall b. b -> (a, b)`` + and then say ``pair @Bool True @Char`` which would have + type ``Char -> (Bool, Char)``. + +- Partial type signatures (:ref:`partial-type-signatures`) + work nicely with visible type + application. If you want to specify only the second type argument to + ``wurble``, then you can say ``wurble @_ @Int``. + The first argument is a wildcard, just like in a partial type signature. + However, if used in a visible type application, it is *not* + necessary to specify :ghc-flag:`-XPartialTypeSignatures` and your + code will not generate a warning informing you of the omitted type. + +- When printing types with :ghc-flag:`-fprint-explicit-foralls` enabled, + type variables not available for visible type application are printed + in braces. Thus, if you write ``myLength = length`` without a type + signature, ``myLength``'s inferred type will be + ``forall {f} {a}. Foldable f => f a -> Int``. + .. _implicit-parameters: Implicit parameters From git at git.haskell.org Tue Mar 15 03:50:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:32 +0000 (UTC) Subject: [commit: ghc] master: Refactor visible type application. (972730c) Message-ID: <20160315035032.B453B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/972730cc42a419b8cd148abaa927e03415da3a68/ghc >--------------------------------------------------------------- commit 972730cc42a419b8cd148abaa927e03415da3a68 Author: Richard Eisenberg Date: Tue Feb 23 09:51:50 2016 -0500 Refactor visible type application. This replaces the old HsType and HsTypeOut constructors with HsAppType and HsAppTypeOut, leading to some simplification. (This refactoring addresses #11329.) This also fixes #11456, which stumbled over HsType (which is not an expression). test case: ghci/scripts/T11456 [skip ci] >--------------------------------------------------------------- 972730cc42a419b8cd148abaa927e03415da3a68 compiler/deSugar/Coverage.hs | 23 ++--- compiler/deSugar/DsExpr.hs | 15 +-- compiler/deSugar/DsMeta.hs | 4 +- compiler/hsSyn/HsExpr.hs | 63 ++++++----- compiler/hsSyn/HsUtils.hs | 26 ++--- compiler/parser/Parser.y | 11 +- compiler/rename/RnExpr.hs | 10 +- compiler/rename/RnSource.hs | 1 + compiler/typecheck/TcExpr.hs | 115 +++++++++++---------- compiler/typecheck/TcHsSyn.hs | 8 +- compiler/typecheck/TcRnTypes.hs | 4 +- testsuite/tests/ghci/scripts/T11456.hs | 5 + testsuite/tests/ghci/scripts/T11456.script | 2 + testsuite/tests/ghci/scripts/T11456.stdout | 1 + testsuite/tests/ghci/scripts/all.T | 1 + testsuite/tests/typecheck/should_fail/T9605.stderr | 20 ++-- .../tests/typecheck/should_fail/VtaFail.stderr | 2 +- 17 files changed, 167 insertions(+), 144 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 972730cc42a419b8cd148abaa927e03415da3a68 From git at git.haskell.org Tue Mar 15 03:50:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:35 +0000 (UTC) Subject: [commit: ghc] master: Fix #11401. (35d37ff) Message-ID: <20160315035035.B2E5C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/35d37ff8a0bb9f64f347c8e4b6a24d49fd08c9dc/ghc >--------------------------------------------------------------- commit 35d37ff8a0bb9f64f347c8e4b6a24d49fd08c9dc Author: Richard Eisenberg Date: Mon Feb 22 22:15:44 2016 -0500 Fix #11401. This commit teaches shortCutReduction about Derived constraints. [skip ci] >--------------------------------------------------------------- 35d37ff8a0bb9f64f347c8e4b6a24d49fd08c9dc compiler/typecheck/TcInteract.hs | 40 +++++++++------------- testsuite/tests/typecheck/should_compile/T11401.hs | 33 ++++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs index 90f7243..a0654d2 100644 --- a/compiler/typecheck/TcInteract.hs +++ b/compiler/typecheck/TcInteract.hs @@ -1527,47 +1527,39 @@ shortCutReduction :: CtEvidence -> TcTyVar -> TcCoercion -> TyCon -> [TcType] -> TcS (StopOrContinue Ct) -- See Note [Top-level reductions for type functions] shortCutReduction old_ev fsk ax_co fam_tc tc_args - | isGiven old_ev - = ASSERT( ctEvEqRel old_ev == NomEq ) + = ASSERT( ctEvEqRel old_ev == NomEq) do { (xis, cos) <- flattenManyNom old_ev tc_args -- ax_co :: F args ~ G tc_args -- cos :: xis ~ tc_args -- old_ev :: F args ~ fsk -- G cos ; sym ax_co ; old_ev :: G xis ~ fsk - ; new_ev <- newGivenEvVar deeper_loc + ; new_ev <- case ctEvFlavour old_ev of + Given -> newGivenEvVar deeper_loc ( mkPrimEqPred (mkTyConApp fam_tc xis) (mkTyVarTy fsk) , EvCoercion (mkTcTyConAppCo Nominal fam_tc cos `mkTcTransCo` mkTcSymCo ax_co `mkTcTransCo` ctEvCoercion old_ev) ) - ; let new_ct = CFunEqCan { cc_ev = new_ev, cc_fun = fam_tc, cc_tyargs = xis, cc_fsk = fsk } - ; updWorkListTcS (extendWorkListFunEq new_ct) - ; stopWith old_ev "Fun/Top (given, shortcut)" } + Derived -> newDerivedNC deeper_loc $ + mkPrimEqPred (mkTyConApp fam_tc xis) + (mkTyVarTy fsk) - | otherwise - = ASSERT( not (isDerived old_ev) ) -- Caller ensures this - ASSERT( ctEvEqRel old_ev == NomEq ) - do { (xis, cos) <- flattenManyNom old_ev tc_args - -- ax_co :: F args ~ G tc_args - -- cos :: xis ~ tc_args - -- G cos ; sym ax_co ; old_ev :: G xis ~ fsk - -- new_ev :: G xis ~ fsk - -- old_ev :: F args ~ fsk := ax_co ; sym (G cos) ; new_ev - - ; (new_ev, new_co) <- newWantedEq deeper_loc Nominal - (mkTyConApp fam_tc xis) (mkTyVarTy fsk) - ; setWantedEq (ctev_dest old_ev) - (ax_co `mkTcTransCo` mkTcSymCo (mkTcTyConAppCo Nominal fam_tc cos) - `mkTcTransCo` new_co) + Wanted -> + do { (new_ev, new_co) <- newWantedEq deeper_loc Nominal + (mkTyConApp fam_tc xis) (mkTyVarTy fsk) + ; setWantedEq (ctev_dest old_ev) $ + ax_co `mkTcTransCo` mkTcSymCo (mkTcTyConAppCo Nominal + fam_tc cos) + `mkTcTransCo` new_co + ; return new_ev } ; let new_ct = CFunEqCan { cc_ev = new_ev, cc_fun = fam_tc , cc_tyargs = xis, cc_fsk = fsk } ; updWorkListTcS (extendWorkListFunEq new_ct) - ; stopWith old_ev "Fun/Top (wanted, shortcut)" } + ; stopWith old_ev "Fun/Top (shortcut)" } where - loc = ctEvLoc old_ev - deeper_loc = bumpCtLocDepth loc + deeper_loc = bumpCtLocDepth (ctEvLoc old_ev) dischargeFmv :: CtEvidence -> TcTyVar -> TcCoercion -> TcType -> TcS () -- (dischargeFmv x fmv co ty) diff --git a/testsuite/tests/typecheck/should_compile/T11401.hs b/testsuite/tests/typecheck/should_compile/T11401.hs new file mode 100644 index 0000000..5235aaf --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11401.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE FlexibleInstances #-} +module T11401 where + +newtype Value a = Value a +newtype CodeGen r a = CodeGen a + +bind :: CodeGen r a -> (a -> CodeGen r b) -> CodeGen r b +bind (CodeGen a) k = k a + +class + (f ~ CalledFunction g, r ~ CallerResult g, g ~ CallerFunction f r) => + CallArgs f g r where + type CalledFunction g :: * + type CallerResult g :: * + type CallerFunction f r :: * + call :: f -> g + +instance CallArgs (IO a) (CodeGen r (Value a)) r where + type CalledFunction (CodeGen r (Value a)) = IO a + type CallerResult (CodeGen r (Value a)) = r + type CallerFunction (IO a) r = CodeGen r (Value a) + call = undefined + +instance CallArgs b b' r => CallArgs (a -> b) (Value a -> b') r where + type CalledFunction (Value a -> b') = a -> CalledFunction b' + type CallerResult (Value a -> b') = CallerResult b' + type CallerFunction (a -> b) r = Value a -> CallerFunction b r + call = undefined + +test :: IO a -> (a -> IO ()) -> CodeGen () (Value ()) +test start stop = bind (call start) (call stop) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index ca8cd0a..8974153 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -507,3 +507,4 @@ test('T11524', normal, compile, ['']) test('T11552', normal, compile, ['']) test('T11246', normal, compile, ['']) test('T11608', normal, compile, ['']) +test('T11401', normal, compile, ['']) From git at git.haskell.org Tue Mar 15 03:50:39 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:39 +0000 (UTC) Subject: [commit: ghc] master: Fix #11334. (84c773e) Message-ID: <20160315035039.25FEE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/84c773e1bc5c551b0f922c6fe9c70762d184a394/ghc >--------------------------------------------------------------- commit 84c773e1bc5c551b0f922c6fe9c70762d184a394 Author: Richard Eisenberg Date: Mon Feb 22 21:47:32 2016 -0500 Fix #11334. Now we fail when trying to default non-*-kinded kind variables with -XNoPolyKinds. test case: dependent/should_fail/T11334 [skip ci] >--------------------------------------------------------------- 84c773e1bc5c551b0f922c6fe9c70762d184a394 compiler/typecheck/TcMType.hs | 36 ++++++++++++++++++++-- compiler/types/TyCoRep.hs | 4 ++- testsuite/tests/dependent/should_fail/T11334.hs | 8 +++++ .../tests/dependent/should_fail/T11334.stderr | 24 +++++++++++++++ testsuite/tests/dependent/should_fail/all.T | 1 + 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index e8c120d..b905f53 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -84,6 +84,7 @@ module TcMType ( import TyCoRep import TcType import Type +import Kind import Coercion import Class import Var @@ -936,15 +937,23 @@ zonkQuantifiedTyVarOrType tv else Left `liftM` skolemiseUnboundMetaTyVar tv vanillaSkolemTv _other -> pprPanic "zonkQuantifiedTyVar" (ppr tv) -- FlatSkol, RuntimeUnk --- | Take an (unconstrained) meta tyvar and default it. Works only for --- kind vars (of type *) and RuntimeRep vars (of type RuntimeRep). +-- | Take an (unconstrained) meta tyvar and default it. Works only on +-- vars of type RuntimeRep and of type *. For other kinds, it issues +-- an error. See Note [Defaulting with -XNoPolyKinds] defaultKindVar :: TcTyVar -> TcM Kind defaultKindVar kv | ASSERT( isMetaTyVar kv ) isRuntimeRepVar kv = writeMetaTyVar kv ptrRepLiftedTy >> return ptrRepLiftedTy - | otherwise + | isStarKind (tyVarKind kv) = writeMetaTyVar kv liftedTypeKind >> return liftedTypeKind + | otherwise + = do { addErr (vcat [ text "Cannot default kind variable" <+> quotes (ppr kv') + , text "of kind:" <+> ppr (tyVarKind kv') + , text "Perhaps enable PolyKinds or add a kind signature" ]) + ; return (mkTyVarTy kv) } + where + (_, kv') = tidyOpenTyCoVar emptyTidyEnv kv skolemiseUnboundMetaTyVar :: TcTyVar -> TcTyVarDetails -> TcM TyVar -- We have a Meta tyvar with a ref-cell inside it @@ -970,6 +979,27 @@ skolemiseUnboundMetaTyVar tv details ; return final_tv } {- +Note [Defaulting with -XNoPolyKinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + + data Compose f g a = Mk (f (g a)) + +We infer + + Compose :: forall k1 k2. (k2 -> *) -> (k1 -> k2) -> k1 -> * + Mk :: forall k1 k2 (f :: k2 -> *) (g :: k1 -> k2) (a :: k1). + f (g a) -> Compose k1 k2 f g a + +Now, in another module, we have -XNoPolyKinds -XDataKinds in effect. +What does 'Mk mean? Pre GHC-8.0 with -XNoPolyKinds, +we just defaulted all kind variables to *. But that's no good here, +because the kind variables in 'Mk aren't of kind *, so defaulting to * +is ill-kinded. + +After some debate on #11334, we decided to issue an error in this case. +The code is in defaultKindVar. + Note [What is a meta variable?] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A "meta type-variable", also know as a "unification variable" is a placeholder diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index 78adcd2..7ca9b26 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -2882,7 +2882,9 @@ tidyOpenTyCoVar :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) tidyOpenTyCoVar env@(_, subst) tyvar = case lookupVarEnv subst tyvar of Just tyvar' -> (env, tyvar') -- Already substituted - Nothing -> tidyTyCoVarBndr env tyvar -- Treat it as a binder + Nothing -> + let env' = tidyFreeTyCoVars env (tyCoVarsOfType (tyVarKind tyvar)) in + tidyTyCoVarBndr env' tyvar -- Treat it as a binder --------------- tidyTyVarOcc :: TidyEnv -> TyVar -> TyVar diff --git a/testsuite/tests/dependent/should_fail/T11334.hs b/testsuite/tests/dependent/should_fail/T11334.hs new file mode 100644 index 0000000..1f9970f --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T11334.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE DataKinds, NoPolyKinds #-} + +module T11334 where + +import Data.Functor.Compose +import Data.Proxy + +p = Proxy :: Proxy 'Compose diff --git a/testsuite/tests/dependent/should_fail/T11334.stderr b/testsuite/tests/dependent/should_fail/T11334.stderr new file mode 100644 index 0000000..f7c87a3 --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T11334.stderr @@ -0,0 +1,24 @@ + +T11334.hs:8:14: error: + ? Cannot default kind variable ?f0? + of kind: k0 -> * + Perhaps enable PolyKinds or add a kind signature + ? In an expression type signature: Proxy Compose + In the expression: Proxy :: Proxy Compose + In an equation for ?p?: p = Proxy :: Proxy Compose + +T11334.hs:8:14: error: + ? Cannot default kind variable ?g0? + of kind: k10 -> k0 + Perhaps enable PolyKinds or add a kind signature + ? In an expression type signature: Proxy Compose + In the expression: Proxy :: Proxy Compose + In an equation for ?p?: p = Proxy :: Proxy Compose + +T11334.hs:8:14: error: + ? Cannot default kind variable ?a0? + of kind: k10 + Perhaps enable PolyKinds or add a kind signature + ? In an expression type signature: Proxy Compose + In the expression: Proxy :: Proxy Compose + In an equation for ?p?: p = Proxy :: Proxy Compose diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index 08f6cf6..63f08d2 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -9,3 +9,4 @@ test('SelfDep', normal, compile_fail, ['']) test('BadTelescope4', normal, compile_fail, ['']) test('RenamingStar', normal, compile_fail, ['']) test('T11407', normal, compile_fail, ['']) +test('T11334', normal, compile_fail, ['']) From git at git.haskell.org Tue Mar 15 03:50:41 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:41 +0000 (UTC) Subject: [commit: ghc] master: Expand Note [Non-trivial definitional equality] (6c768fc) Message-ID: <20160315035041.D52843A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/6c768fcf0d6749bf5029baf6b7f99271b48b1037/ghc >--------------------------------------------------------------- commit 6c768fcf0d6749bf5029baf6b7f99271b48b1037 Author: Richard Eisenberg Date: Wed Feb 24 14:41:37 2016 -0500 Expand Note [Non-trivial definitional equality] This adapts the text from D1944. [skip ci] >--------------------------------------------------------------- 6c768fcf0d6749bf5029baf6b7f99271b48b1037 compiler/types/TyCoRep.hs | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index 7ca9b26..fa123a0 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -354,6 +354,58 @@ two types have the same kind. This allows us to be a little sloppier in keeping track of coercions, which is a good thing. It also means that eqType does not depend on eqCoercion, which is also a good thing. +Why is this sensible? That is, why is something different than ?-equivalence +appropriate for the implementation of eqType? + +Anything smaller than ~ and homogeneous is an appropriate definition for +equality. The type safety of FC depends only on ~. Let's say ? : ? ~ ?. Any +expression of type ? can be transmuted to one of type ? at any point by +casting. The same is true of types of type ?. So in some sense, ? and ? are +interchangeable. + +But let's be more precise. If we examine the typing rules of FC (say, those in +http://www.cis.upenn.edu/~eir/papers/2015/equalities/equalities-extended.pdf) +there are several places where the same metavariable is used in two different +premises to a rule. (For example, see Ty_App.) There is an implicit equality +check here. What definition of equality should we use? By convention, we use +?-equivalence. Take any rule with one (or more) of these implicit equality +checks. Then there is an admissible rule that uses ~ instead of the implicit +check, adding in casts as appropriate. + +The only problem here is that ~ is heterogeneous. To make the kinds work out +in the admissible rule that uses ~, it is necessary to homogenize the +coercions. That is, if we have ? : (? : ?1) ~ (? : ?2), then we don't use ?; +we use ? |> kind ?, which is homogeneous. + +The effect of this all is that eqType, the implementation of the implicit +equality check, can use any homogeneous relation that is smaller than ~, as +those rules must also be admissible. + +What would go wrong if we insisted on the casts matching? See the beginning of +Section 8 in the unpublished paper above. Theoretically, nothing at all goes +wrong. But in practical terms, getting the coercions right proved to be +nightmarish. And types would explode: during kind-checking, we often produce +reflexive kind coercions. When we try to cast by these, mkCastTy just discards +them. But if we used an eqType that distinguished between Int and Int |> <*>, +then we couldn't discard -- the output of kind-checking would be enormous, +and we would need enormous casts with lots of CoherenceCo's to straighten +them out. + +Would anything go wrong if eqType respected type families? No, not at all. But +that makes eqType rather hard to implement. + +Thus, the guideline for eqType is that it should be the largest +easy-to-implement relation that is still smaller than ~ and homogeneous. The +precise choice of relation is somewhat incidental, as long as the smart +constructors and destructors in Type respect whatever relation is chosen. + +Another helpful principle with eqType is this: + + ** If (t1 eqType t2) then I can replace t1 by t2 anywhere. ** + +This principle also tells us that eqType must relate only types with the +same kinds. + Note [VisibilityFlag] ~~~~~~~~~~~~~~~~~~~~~ All named binders are equipped with a visibility flag, which says From git at git.haskell.org Tue Mar 15 03:50:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:44 +0000 (UTC) Subject: [commit: ghc] master: Test case for #11699 in typecheck/should_compile (693b38c) Message-ID: <20160315035044.DA1B03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/693b38cbf5cd298b793b3179fb6cc57e196b55d0/ghc >--------------------------------------------------------------- commit 693b38cbf5cd298b793b3179fb6cc57e196b55d0 Author: Richard Eisenberg Date: Fri Mar 11 10:27:53 2016 -0500 Test case for #11699 in typecheck/should_compile [skip ci] >--------------------------------------------------------------- 693b38cbf5cd298b793b3179fb6cc57e196b55d0 testsuite/tests/typecheck/should_compile/T11699.hs | 5 +++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 2 files changed, 6 insertions(+) diff --git a/testsuite/tests/typecheck/should_compile/T11699.hs b/testsuite/tests/typecheck/should_compile/T11699.hs new file mode 100644 index 0000000..2334f29 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11699.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TypeFamilies, PolyKinds #-} + +module T11699 where + +type family F a where F (f a) = f a diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 8974153..7e6a175 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -508,3 +508,4 @@ test('T11552', normal, compile, ['']) test('T11246', normal, compile, ['']) test('T11608', normal, compile, ['']) test('T11401', normal, compile, ['']) +test('T11699', normal, compile, ['']) From git at git.haskell.org Tue Mar 15 03:50:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:50 +0000 (UTC) Subject: [commit: ghc] master: Allow eager unification with type families. (3f5d1a1) Message-ID: <20160315035050.78A093A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3f5d1a13f112f34d992f6b74656d64d95a3f506d/ghc >--------------------------------------------------------------- commit 3f5d1a13f112f34d992f6b74656d64d95a3f506d Author: Richard Eisenberg Date: Mon Mar 14 22:09:36 2016 -0400 Allow eager unification with type families. Previously, checkTauTvUpdate, used in the eager unifier (TcUnify) right before writing to a metavar, refused to write a metavar to a type involving type functions. The reason for this was given in a Note, but the Note didn't make all that much sense and even admitted that it was a bit confused. The Note, in turn, referred to another Note, which it was quite sceptical of, as well. The type-family check was slowing down performance, so I tried removing it, running the tests referred to in the Note. The tests all passed without the check. Looking at more test results, I saw several error messages improve without the check, and some cases where GHC looped (T7788, in particular) it now doesn't. So, all in all, quite a win: Two hairy Notes removed, several lines of code removed, better performance, and improved output. [skip ci] >--------------------------------------------------------------- 3f5d1a13f112f34d992f6b74656d64d95a3f506d compiler/typecheck/TcUnify.hs | 72 +--------------------- .../{should_fail => should_compile}/T7788.hs | 0 testsuite/tests/indexed-types/should_compile/all.T | 1 + .../tests/indexed-types/should_fail/T2693.stderr | 17 +++-- .../tests/indexed-types/should_fail/T4179.stderr | 6 +- .../tests/indexed-types/should_fail/T5439.stderr | 13 ++-- .../tests/indexed-types/should_fail/T7354.stderr | 9 ++- .../tests/indexed-types/should_fail/T7729.stderr | 8 +-- .../tests/indexed-types/should_fail/T7786.stderr | 12 ++-- .../tests/indexed-types/should_fail/T7788.stderr | 10 --- .../tests/indexed-types/should_fail/T9554.stderr | 13 ---- .../tests/indexed-types/should_fail/T9662.stderr | 16 ++--- testsuite/tests/indexed-types/should_fail/all.T | 1 - 13 files changed, 40 insertions(+), 138 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 3f5d1a13f112f34d992f6b74656d64d95a3f506d From git at git.haskell.org Tue Mar 15 03:50:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:47 +0000 (UTC) Subject: [commit: ghc] master: Document TypeInType (#11614) (e7a8cb1) Message-ID: <20160315035047.BA1D83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e7a8cb145c2450ae12abfb9e30a2b7c1544abf67/ghc >--------------------------------------------------------------- commit e7a8cb145c2450ae12abfb9e30a2b7c1544abf67 Author: Richard Eisenberg Date: Fri Mar 11 11:14:04 2016 -0500 Document TypeInType (#11614) [skip ci] >--------------------------------------------------------------- e7a8cb145c2450ae12abfb9e30a2b7c1544abf67 docs/users_guide/glasgow_exts.rst | 854 ++++++++++++++++++++++++++------------ docs/users_guide/using.rst | 4 +- libraries/ghc-prim/GHC/Types.hs | 6 +- 3 files changed, 599 insertions(+), 265 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e7a8cb145c2450ae12abfb9e30a2b7c1544abf67 From git at git.haskell.org Tue Mar 15 03:50:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:54 +0000 (UTC) Subject: [commit: ghc] master: Fix #11648. (55577a9) Message-ID: <20160315035054.2FE103A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/55577a9130738932d022d442d0773ffd79d0945d/ghc >--------------------------------------------------------------- commit 55577a9130738932d022d442d0773ffd79d0945d Author: Richard Eisenberg Date: Sat Mar 12 20:59:44 2016 -0500 Fix #11648. We now check that a CUSK is really a CUSK and issue an error if it isn't. This also involves more solving and zonking in kcHsTyVarBndrs, which was the outright bug reported in #11648. Test cases: polykinds/T11648{,b} This updates the haddock submodule. [skip ci] >--------------------------------------------------------------- 55577a9130738932d022d442d0773ffd79d0945d compiler/deSugar/DsMeta.hs | 19 +- compiler/hsSyn/Convert.hs | 2 + compiler/hsSyn/HsDecls.hs | 26 ++- compiler/hsSyn/HsTypes.hs | 13 +- compiler/parser/RdrHsSyn.hs | 1 + compiler/rename/RnSource.hs | 42 ++-- compiler/rename/RnTypes.hs | 63 +++--- compiler/typecheck/TcHsType.hs | 234 +++++++++++++-------- compiler/typecheck/TcMType.hs | 2 +- compiler/typecheck/TcTyClsDecls.hs | 83 +++++--- compiler/typecheck/TcType.hs | 27 +++ compiler/typecheck/TcValidity.hs | 2 +- docs/users_guide/glasgow_exts.rst | 62 +++++- .../tests/dependent/should_compile/KindLevels.hs | 4 +- .../tests/dependent/should_fail/InferDependency.hs | 6 + .../dependent/should_fail/InferDependency.stderr | 8 + .../KindLevels.hs => should_fail/KindLevelsB.hs} | 0 .../tests/dependent/should_fail/KindLevelsB.stderr | 5 + testsuite/tests/dependent/should_fail/all.T | 2 + testsuite/tests/polykinds/T11648.hs | 8 + testsuite/tests/polykinds/T11648b.hs | 7 + testsuite/tests/polykinds/T11648b.stderr | 8 + testsuite/tests/polykinds/T6039.stderr | 5 + testsuite/tests/polykinds/all.T | 4 +- utils/haddock | 2 +- 25 files changed, 444 insertions(+), 191 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 55577a9130738932d022d442d0773ffd79d0945d From git at git.haskell.org Tue Mar 15 03:50:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 03:50:56 +0000 (UTC) Subject: [commit: ghc] master: Testsuite wibbles from previous commits. (de4df6b) Message-ID: <20160315035056.D7BAD3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/de4df6b41a227f527e9eb77733cd6c87b069d3d0/ghc >--------------------------------------------------------------- commit de4df6b41a227f527e9eb77733cd6c87b069d3d0 Author: Richard Eisenberg Date: Sat Mar 12 15:52:22 2016 -0500 Testsuite wibbles from previous commits. >--------------------------------------------------------------- de4df6b41a227f527e9eb77733cd6c87b069d3d0 testsuite/tests/indexed-types/should_fail/T5439.stderr | 3 +++ testsuite/tests/perf/compiler/all.T | 3 ++- testsuite/tests/polykinds/T9222.stderr | 2 +- testsuite/tests/typecheck/should_fail/T9260.stderr | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/testsuite/tests/indexed-types/should_fail/T5439.stderr b/testsuite/tests/indexed-types/should_fail/T5439.stderr index b0cf937..b76b0f9 100644 --- a/testsuite/tests/indexed-types/should_fail/T5439.stderr +++ b/testsuite/tests/indexed-types/should_fail/T5439.stderr @@ -7,6 +7,9 @@ T5439.hs:82:33: error: ?inj $ Failure (e :: SomeException)? In a stmt of a 'do' block: c <- complete ev $ inj $ Failure (e :: SomeException) + In the expression: + do { c <- complete ev $ inj $ Failure (e :: SomeException); + return $ c || not first } ? Relevant bindings include register :: Bool -> Peano n -> WaitOps (HDrop n rs) -> IO Bool (bound at T5439.hs:64:9) diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index e7e467c..c19d51d 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -364,7 +364,7 @@ test('T5030', # of family-applications leads to less sharing, I think # 2015-07-11: 201882912 reason unknown - (wordsize(64), 653710960, 10)]), + (wordsize(64), 342331936, 10)]), # Previously 530000000 (+/- 10%) # 17/1/13: 602993184 (x86_64/Linux) # (new demand analyser) @@ -382,6 +382,7 @@ test('T5030', # of family-applications leads to less sharing, I think # 2015-03-17 403932600 tweak to solver algorithm # 2015-12-11 653710960 TypeInType (see #11196) + # 2016-03-14 342331936 unify type families eagerly only_ways(['normal']) ], diff --git a/testsuite/tests/polykinds/T9222.stderr b/testsuite/tests/polykinds/T9222.stderr index 69e850c..b3d31ef 100644 --- a/testsuite/tests/polykinds/T9222.stderr +++ b/testsuite/tests/polykinds/T9222.stderr @@ -8,7 +8,7 @@ T9222.hs:13:3: error: at T9222.hs:13:3 ?b? is a rigid type variable bound by the type of the constructor ?Want?: - forall i j (a :: (i, j)) (b :: i) (c :: j). + forall i1 j1 (a :: (i1, j1)) (b :: i1) (c :: j1). ((a ~ '(b, c)) => Proxy b) -> Want a at T9222.hs:13:3 Expected type: Proxy b0 diff --git a/testsuite/tests/typecheck/should_fail/T9260.stderr b/testsuite/tests/typecheck/should_fail/T9260.stderr index 0773da2..37c37bd 100644 --- a/testsuite/tests/typecheck/should_fail/T9260.stderr +++ b/testsuite/tests/typecheck/should_fail/T9260.stderr @@ -2,6 +2,6 @@ T9260.hs:12:8: error: ? Couldn't match type ?2? with ?1? Expected type: Fin 1 - Actual type: Fin (1 + 1) + Actual type: Fin ((0 + 1) + 1) ? In the expression: Fsucc Fzero In an equation for ?test?: test = Fsucc Fzero From git at git.haskell.org Tue Mar 15 17:21:24 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 17:21:24 +0000 (UTC) Subject: [commit: ghc] wip/rae: Remove redundant anonymiseTyBinders (#11648) (19be538) Message-ID: <20160315172124.A99B23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/19be5385e2875578c3a7d1154238580f0ef3c754/ghc >--------------------------------------------------------------- commit 19be5385e2875578c3a7d1154238580f0ef3c754 Author: Richard Eisenberg Date: Tue Mar 15 11:37:00 2016 -0400 Remove redundant anonymiseTyBinders (#11648) This was necessary in an earlier version of the patch for #11648, but not in the final version. I forgot to remove it. >--------------------------------------------------------------- 19be5385e2875578c3a7d1154238580f0ef3c754 compiler/typecheck/TcTyClsDecls.hs | 5 ++--- compiler/typecheck/TcType.hs | 27 --------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/compiler/typecheck/TcTyClsDecls.hs b/compiler/typecheck/TcTyClsDecls.hs index 2b19b62..cfd9559 100644 --- a/compiler/typecheck/TcTyClsDecls.hs +++ b/compiler/typecheck/TcTyClsDecls.hs @@ -317,15 +317,14 @@ kcTyClGroup (TyClGroup { group_tyclds = decls }) kc_res_kind = tyConResKind tc ; kvs <- kindGeneralize (mkForAllTys kc_binders kc_res_kind) ; (kc_binders', kc_res_kind') <- zonkTcKindToKind kc_binders kc_res_kind - ; let kc_binders'' = anonymiseTyBinders kc_binders' kc_res_kind' -- Make sure kc_kind' has the final, zonked kind variables ; traceTc "Generalise kind" $ vcat [ ppr name, ppr kc_binders, ppr kc_res_kind - , ppr kvs, ppr kc_binders'', ppr kc_res_kind' ] + , ppr kvs, ppr kc_binders', ppr kc_res_kind' ] ; return (mkTcTyCon name - (map (mkNamedBinder Invisible) kvs ++ kc_binders'') + (map (mkNamedBinder Invisible) kvs ++ kc_binders') kc_res_kind' (mightBeUnsaturatedTyCon tc)) } diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs index b3bd4ee..40821e5 100644 --- a/compiler/typecheck/TcType.hs +++ b/compiler/typecheck/TcType.hs @@ -87,7 +87,6 @@ module TcType ( orphNamesOfTypes, orphNamesOfCoCon, getDFunTyKey, evVarPred_maybe, evVarPred, - anonymiseTyBinders, --------------------------------- -- Predicate types @@ -223,7 +222,6 @@ import qualified GHC.LanguageExtensions as LangExt import Data.IORef import Control.Monad (liftM, ap) import Data.Functor.Identity -import Data.List ( mapAccumR ) {- ************************************************************************ @@ -2360,28 +2358,3 @@ sizeType = go sizeTypes :: [Type] -> TypeSize sizeTypes tys = sum (map sizeType tys) - -{- -************************************************************************ -* * - Binders -* * -************************************************************************ --} - --- | Given a list of binders and a type they bind in, turn any --- superfluous Named binders into Anon ones. -anonymiseTyBinders :: [TyBinder] -> Type -> [TyBinder] -anonymiseTyBinders binders res_ty = binders' - where - (_, binders') = mapAccumR go (tyCoVarsOfTypeAcc res_ty) binders - - go :: FV -> TyBinder -> (FV, TyBinder) - go fv (Named tv Visible) - | not (tv `elemVarSet` runFVSet fv) - = ( (tv `FV.delFV` fv) `unionFV` tyCoVarsOfTypeAcc kind - , Anon kind ) - where - kind = tyVarKind tv - - go fv binder = (tyCoVarsBndrAcc binder fv, binder) From git at git.haskell.org Tue Mar 15 17:21:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 17:21:27 +0000 (UTC) Subject: [commit: ghc] wip/rae: Incorporate bgamari's suggestions for #11614. (857e9b0) Message-ID: <20160315172127.631ED3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/857e9b0231db80b838d78e341954d3e75db7e94b/ghc >--------------------------------------------------------------- commit 857e9b0231db80b838d78e341954d3e75db7e94b Author: Richard Eisenberg Date: Tue Mar 15 13:21:20 2016 -0400 Incorporate bgamari's suggestions for #11614. >--------------------------------------------------------------- 857e9b0231db80b838d78e341954d3e75db7e94b docs/users_guide/8.0.1-notes.rst | 10 +++++++- docs/users_guide/glasgow_exts.rst | 51 ++++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst index b9d7472..2ebba6e 100644 --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -26,7 +26,9 @@ The highlights, since the 7.10 branch, are: - TODO FIXME -- nokinds +- The new :ghc-flag:`-XTypeInType` allows promotion of all types into + kinds, allowing kind synonyms, kind families, promoted GADTs, and other + goodies. - Support for :ref:`record pattern synonyms ` @@ -78,6 +80,12 @@ Language - TODO FIXME. +- :ghc-flag:`-XTypeInType` supports universal type promotion and merges + the type and kind language. This allows, for example, higher-rank + kinds, along with kind families and type-level GADTs. Support is still + experimental, and it is expected to improve over the next several + releases. See :ref:`type-in-type` for the details. + - The parser now supports Haddock comments on GADT data constructors. For example :: diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 8295009..fe4d40c 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -131,7 +131,8 @@ Unboxed type kinds ------------------ Because unboxed types are represented without the use of pointers, we -cannot store them in standard datatypes. For example, the ``Just`` node +cannot store them in use a polymorphic datatype at an unboxed type. +For example, the ``Just`` node of ``Just 42#`` would have to be different from the ``Just`` node of ``Just 42``; the former stores an integer directly, while the latter stores a pointer. GHC currently does not support this variety of ``Just`` @@ -145,10 +146,11 @@ specifies their runtime representation. For example, the type ``Int#`` has kind ``TYPE 'IntRep`` and ``Double#`` has kind ``TYPE 'DoubleRep``. These kinds say that the runtime representation of an ``Int#`` is a machine integer, and the runtime representation of a ``Double#`` is a machine double-precision -floating point. More details of the ``TYPE`` mechanisms appear in +floating point. In constrast, the kind ``*`` is actually just a synonym +for ``TYPE 'PtrRepLifted``. More details of the ``TYPE`` mechanisms appear in the `section on runtime representation polymorphism <#runtime-rep>`__. -Given that ``Int#``'s kind is not ``*``, it then is easy to see that +Given that ``Int#``'s kind is not ``*``, it then it follows that ``Maybe Int#`` is disallowed. Similarly, because type variables tend to be of kind ``*`` (for example, in ``(.) :: (b -> c) -> (a -> b) -> a -> c``, all the type variables have kind ``*``), polymorphism tends not to work @@ -6934,7 +6936,7 @@ With :ghc-flag:`-XDataKinds`, GHC automatically promotes every datatype to be a kind and its (value) constructors to be type constructors. The following types :: - data Nat = Ze | Su Nat + data Nat = Zero | Succ Nat data List a = Nil | Cons a (List a) @@ -6942,11 +6944,12 @@ following types :: data Sum a b = L a | R b -give rise to the following kinds and type constructors: :: +give rise to the following kinds and type constructors (where promoted +constructors are prefixed by a tick ``'``): :: Nat :: * - 'Ze :: Nat - 'Su :: Nat -> Nat + 'Zero :: Nat + 'Succ :: Nat -> Nat List :: * -> * 'Nil :: forall k. List k @@ -6961,8 +6964,8 @@ give rise to the following kinds and type constructors: :: The following restrictions apply to promotion: -- We promote ``data`` types and ``newtypes``, but not type synonyms, or - type/data families (:ref:`type-families`). +- We promote ``data`` types and ``newtypes``; type synonyms and + type/data families are not promoted (:ref:`type-families`). - We only promote types whose kinds are of the form ``* -> ... -> * -> *``. In particular, we do not promote @@ -7078,7 +7081,8 @@ not mentioned in the arguments, and thus it would seem that an instance would have to return a member of ``k`` *for any* ``k``. However, this is not the case. The type family ``UnEx`` is a kind-indexed type family. The return kind ``k`` is an implicit parameter to ``UnEx``. The -elaborated definitions are as follows: :: +elaborated definitions are as follows (where implicit parameters are +denoted by braces): :: type family UnEx {k :: *} (ex :: Ex) :: k type instance UnEx {k} (MkEx @k x) = x @@ -7101,7 +7105,9 @@ Kind polymorphism and Type-in-Type :implies: :ghc-flag:`-XPolyKinds`, :ghc-flag:`-XDataKinds`, :ghc-flag:`-XKindSignatures` :since: 8.0.1 - Allow kinds to be as intricate as types. + Allow kinds to be as intricate as types, allowing explicit quantification + over kind variables, higher-rank kinds, and the use of type synonyms and + families in kinds, among other features. .. ghc-flag:: -XPolyKinds @@ -7242,6 +7248,10 @@ This rule has occasionally-surprising consequences (see The kind-polymorphism from the class declaration makes ``D1`` kind-polymorphic, but not so ``D2``; and similarly ``F1``, ``F1``. +.. index:: + single: CUSK + single: complete user-supplied kind signature + .. _complete-kind-signatures: Complete user-supplied kind signatures and polymorphic recursion @@ -7626,6 +7636,10 @@ kind polymorphism and are confused as to why GHC is rejecting (or accepting) your program, we encourage you to turn on these flags, especially :ghc-flag:`-fprint-explicit-kinds`. +.. index:: + single: TYPE + single: runtime representation polymorphism + .. _runtime-rep: Runtime representation polymorphism @@ -7650,8 +7664,8 @@ Here are the key definitions, all available from ``GHC.Exts``: :: data RuntimeRep = PtrRepLifted -- for things like `Int` | PtrRepUnlifted -- for things like `Array#` - | IntRep -- for things like `Int#` - | ... + | IntRep -- for things like `Int#` + | ... type * = TYPE PtrRepLifted -- * is just an ordinary type synonym @@ -7730,7 +7744,7 @@ by supposing all type variables of type ``RuntimeType`` to be ``'PtrRepLifted`` when printing, and printing ``TYPE 'PtrRepLifted`` as ``*``. Should you wish to see representation polymorphism in your types, enable -the flag :ghc-flag:`-Wprint-explicit-runtime-rep`. +the flag :ghc-flag:`-fprint-explicit-runtime-reps`. .. _type-level-literals: @@ -7893,12 +7907,15 @@ dependency. In class instances, we define the type instances of FD families in accordance with the class head. Method signatures are not affected by that process. +.. index:: + pair: Type equality constraints; kind heterogeneous + Heterogeneous equality ---------------------- -GHC also supports *heterogeneous* equality, which relates two types of potentially -different kinds. Heterogeneous equality is spelled ``~~``. Here are the -kinds of ``~`` and ``~~`` to better understand their difference: :: +GHC also supports *kind-heterogeneous* equality, which relates two types of +potentially different kinds. Heterogeneous equality is spelled ``~~``. Here +are the kinds of ``~`` and ``~~`` to better understand their difference: :: (~) :: forall k. k -> k -> Constraint (~~) :: forall k1 k2. k1 -> k2 -> Constraint From git at git.haskell.org Tue Mar 15 17:21:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 15 Mar 2016 17:21:30 +0000 (UTC) Subject: [commit: ghc] wip/rae's head updated: Incorporate bgamari's suggestions for #11614. (857e9b0) Message-ID: <20160315172130.0C1A63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/rae' now includes: a9dc62a Remove "use mask" from StgAlt syntax 009a999 TyCoRep: Add haddock sections c1efdcc Overload the static form to reduce verbosity. feb19ea testsuite: mark tests broken on powerpc64 8e19d3a base: A selection of fixes to the comments in GHC.Stats 0c7db61 ApplicativeDo: Handle terminal `pure` statements 6319a8c HscMain: Delete some unused code 673efcc Add more type class instances for GHC.Generics 6658491 Make warning names more consistent 52879d1 Reconstruct record expression in bidir pattern synonym ebaa638 Bump haddock.base allocations 073e20e cmpTypeX: Avoid kind comparison when possible 6739397 (Alternative way to) address #8710 6350eb1 Handle multiline named haddock comments properly e38c07b Improve accuracy of suggestion to use TypeApplications 20ab2ad Note new GHC.Generics instances in release notes 116528c Improve pattern synonym error messages (add `PatSynOrigin`) 8e6e022 Testsuite: Introduce config.plugin_way_flags. e02b8c8 Testsuite: for tests that use TH, omit *all* prof_ways 90fa8cf Mark tests for #11643, #11644, #11645 and #9406 expect_broken 9b49c65 Testsuite: delete empty files [skip ci] 1badf15 Testsuite: do not write empty files on 'make accept' bb5afd3 Print which warning-flag controls an emitted warning bbfff22 Unconditionally handle TH known key names. a026112 Typos in comments, etc. e3f341f Fix and refactor strict pattern bindings a81e9d5 Special case for desugaring AbsBinds 4ddfe13 Get the right in-scope set in specUnfolding 7496be5 Exclude TyVars from the constraint solver 253ccdf Comments and white space only b4dfe04 Fix kind generalisation for pattern synonyms e193f66 Filter out BuiltinRules in occurrence analysis ef7b1d5 Test Trac #11611 eee040c Update transformer submodule to v0.5.2.0 release 890e2bb GHC.Generics: Ensure some, many for U1 don't bottom 3ee4fc0 rts: drop unused global 'blackhole_queue' b9c697e Print which flag controls emitted desugaring warnings 869d9c6 Print which flag controls emitted lexer warnings 82f200b Annotate `[-Wredundant-constraints]` in warnings (re #10752) b6c61e3 Print which flag controls emitted SafeHaskell warnings 3cd4c9c Annotate `[-Wdeferred-type-errors]` in warnings (re #10752) 46f3775 Default to -fno-show-warning-groups (re #10752) 171d95d Missing Proxy instances, make U1 instance more Proxy-like ad4428d base: Mark Data.Type.Equality as Trustworthy 2535c82 Fix bug where reexports of wired-in packages don't work. f72bdbd Refactor `warnMissingSignatures` in `RnNames.hs` 16e97c1 Build system: Correctly pass `TARGETPLATFORM` as host 2e49a31 DynFlags: Add -Wredundant-constraints to -Wall e3b9dbf Testsuite: check actual_prof_file only when needed de01de7 Remove some more Windows line endings [skip ci] f8a5dd0 Only add -fshow-warning-groups for ghc >= 7.11 (#10752) 49c55e6 Skip TEST=TcCoercibleFail when compiler_debugged 3c29c77 Do not check synonym RHS for ambiguity 243e2ab Comments only 2d52c3a A bit more tracing in TcHsType.tcTyVar a0899b2 Remove unnecessary isTyVar tests in TcType 57b4c55 Don't complain about unused Rule binders 286dc02 Fix an outright bug in expandTypeSynonyms aea1e5d Use tyConArity rather than (length tvs) 91a6a9c Add Monoid instance for FastString 15517f3 SimplEnv: Add Haddock headings to export list 1f3d953 users-guide: Mention #11558 in release notes 120b9cd rts/timer: use timerfd_* on Linux instead of alarm signals 6ca9b15 GHCi: Fix load/reload space leaks (#4029) 3801262 Fix printing of an `IfacePatSyn` 1d6177b Using unsafe foreign import for rtsSupportsBoundThreads (part of #9696) bd681bc Drop module qualifier from punned record fields (#11662) ade1a46 Fix minimum alignment for StgClosure (Trac #11395) 5e2605e GhcMake: Clang/ASSERT fix 13a801a Revert "Mark tests for #11643, #11644, #11645 and #9406 expect_broken" 82e36ed Reduce fragmentation from m32_allocator 90e1e16 Split external symbol prototypes (EF_) (Trac #11395) 1a9734a template-haskell: Drop use of Rank2Types/PolymorphicComponents 941b8f5 template-haskell: remove redundant CPP use 1c76e16 template-haskell: define `MonadFail Q` instance 4c3a0a4 Fix the implementation of lazyId 5a494d8 Refactoring around TcPatSyn.tcPatToExpr 374f919 Update Cabal submodule to latest HEAD snapshot c42cdb7 fix Float/Double unreg cross-compilation fc16690 Fix #11624, cannot declare hs-boot if already one in scope. c937f42 Add regression test for #11555 a1c4230 Use catchException in a few more places 30ee910 Make `catch` lazy in the action f3def76 add regression test for #11145. 767ff7c Document Quasi-quotes/list comprehension ambiguity a74a384 Include version in AC_PACKAGE_TARNAME f8056fc Make integer-gmp operations more strict d48220e Add Note [Running splices in the Renamer] 90b8af0 Fix readme link to FixingBugs wiki page 06b70ff Add doc to (<$>) explaining its relationship to ($) 8626d76 rtx/posix/Itimer.c: Handle return value of `read` 6a2992d Add MonadUnique instance for LlvmM e764ede Add ghc-flag directory for -XPatternGuards 2908ae8 Handle unset HOME environment variable more gracefully 3ea11eb Move getOccFS to Name 7ba817c Bump allocations for T6048 2f45cf3 Add -foptimal-applicative-do e46742f rts: fix threadStackUnderflow type in cmm 4d791b4 Simplify: Make generated names more useful 41051dd ghci: add message when reusing compiled code #9887 92821ec LlvmCodeGen: Fix generation of malformed LLVM blocks 9ee51da users_guide: Break up -fprint-* description d12166a Fix the name of the Word16ElemRep wired-in datacon 3f60ce8 Add regression test for #11702 18fbfa3 Move and expand (slightly) TypeApplications docs e9bf7bb Fix #11407. 84c773e Fix #11334. 35d37ff Fix #11401. 972730c Refactor visible type application. 6c768fc Expand Note [Non-trivial definitional equality] 693b38c Test case for #11699 in typecheck/should_compile e7a8cb1 Document TypeInType (#11614) 55577a9 Fix #11648. 3f5d1a1 Allow eager unification with type families. de4df6b Testsuite wibbles from previous commits. 19be538 Remove redundant anonymiseTyBinders (#11648) 857e9b0 Incorporate bgamari's suggestions for #11614. From git at git.haskell.org Wed Mar 16 01:17:21 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 01:17:21 +0000 (UTC) Subject: [commit: ghc] master: Fix #11357. (1eefedf) Message-ID: <20160316011721.562683A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1eefedf7371778d1721d9af9247c2eff12ae7417/ghc >--------------------------------------------------------------- commit 1eefedf7371778d1721d9af9247c2eff12ae7417 Author: Richard Eisenberg Date: Tue Mar 15 13:49:15 2016 -0400 Fix #11357. We were looking at a data instance tycon for visibility info, which is the wrong place to look. Look at the data family tycon instead. Also improved the pretty-printing near there to suppress kind arguments when appropriate. >--------------------------------------------------------------- 1eefedf7371778d1721d9af9247c2eff12ae7417 compiler/typecheck/TcDeriv.hs | 4 ++-- compiler/typecheck/TcGenGenerics.hs | 29 ++++++++++++++++------- testsuite/tests/deriving/should_compile/T11357.hs | 10 ++++++++ testsuite/tests/deriving/should_compile/all.T | 1 + 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs index e98ca88..90d9816 100644 --- a/compiler/typecheck/TcDeriv.hs +++ b/compiler/typecheck/TcDeriv.hs @@ -1240,10 +1240,10 @@ no_cons_why rep_tc = quotes (pprSourceTyCon rep_tc) <+> text "must have at least one data constructor" cond_RepresentableOk :: Condition -cond_RepresentableOk (_, tc, tc_args) = canDoGenerics tc tc_args +cond_RepresentableOk (dflags, tc, tc_args) = canDoGenerics dflags tc tc_args cond_Representable1Ok :: Condition -cond_Representable1Ok (_, tc, tc_args) = canDoGenerics1 tc tc_args +cond_Representable1Ok (dflags, tc, tc_args) = canDoGenerics1 dflags tc tc_args cond_enumOrProduct :: Class -> Condition cond_enumOrProduct cls = cond_isEnumeration `orCond` diff --git a/compiler/typecheck/TcGenGenerics.hs b/compiler/typecheck/TcGenGenerics.hs index 08b3c9a..0477767 100644 --- a/compiler/typecheck/TcGenGenerics.hs +++ b/compiler/typecheck/TcGenGenerics.hs @@ -18,6 +18,7 @@ import Type import TcType import TcGenDeriv import DataCon +import DynFlags ( DynFlags, GeneralFlag(Opt_PrintExplicitKinds), gopt ) import TyCon import FamInstEnv ( FamInst, FamFlavor(..), mkSingleCoAxiom ) import FamInst @@ -128,7 +129,7 @@ following constraints are satisfied. -} -canDoGenerics :: TyCon -> [Type] -> Validity +canDoGenerics :: DynFlags -> TyCon -> [Type] -> Validity -- canDoGenerics rep_tc tc_args determines if Generic/Rep can be derived for a -- type expression (rep_tc tc_arg0 tc_arg1 ... tc_argn). -- @@ -136,7 +137,7 @@ canDoGenerics :: TyCon -> [Type] -> Validity -- care of because canDoGenerics is applied to rep tycons. -- -- It returns Nothing if deriving is possible. It returns (Just reason) if not. -canDoGenerics tc tc_args +canDoGenerics dflags tc tc_args = mergeErrors ( -- Check (c) from Note [Requirements for deriving Generic and Rep]. (if (not (null (tyConStupidTheta tc))) @@ -146,7 +147,12 @@ canDoGenerics tc tc_args -- -- Data family indices can be instantiated; the `tc_args` here are -- the representation tycon args - (if (all isTyVarTy (filterOutInvisibleTypes tc tc_args)) + -- + -- NB: Use user_tc here. In the case of a data *instance*, the + -- user_tc is the family tc, which has the right visibility settings. + -- (For a normal datatype, user_tc == tc.) Getting this wrong + -- led to #11357. + (if (all isTyVarTy (filterOutInvisibleTypes user_tc tc_args)) then IsValid else NotValid (tc_name <+> text "must not be instantiated;" <+> text "try deriving `" <> tc_name <+> tc_tys <> @@ -156,9 +162,14 @@ canDoGenerics tc tc_args where -- The tc can be a representation tycon. When we want to display it to the -- user (in an error message) we should print its parent - (tc_name, tc_tys) = case tyConFamInst_maybe tc of - Just (ptc, tys) -> (ppr ptc, hsep (map ppr (tys ++ drop (length tys) tc_args))) - _ -> (ppr tc, hsep (map ppr (tyConTyVars tc))) + (user_tc, tc_name, tc_tys) = case tyConFamInst_maybe tc of + Just (ptc, tys) -> (ptc, ppr ptc, hsep (map ppr (filter_kinds $ tys ++ drop (length tys) tc_args))) + _ -> (tc, ppr tc, hsep (map ppr (filter_kinds $ mkTyVarTys $ tyConTyVars tc))) + + filter_kinds | gopt Opt_PrintExplicitKinds dflags + = id + | otherwise + = filterOutInvisibleTypes user_tc -- Check (d) from Note [Requirements for deriving Generic and Rep]. -- @@ -228,9 +239,9 @@ explicitly, even though foldDataConArgs is also doing this internally. -- are taken care of by the call to canDoGenerics. -- -- It returns Nothing if deriving is possible. It returns (Just reason) if not. -canDoGenerics1 :: TyCon -> [Type] -> Validity -canDoGenerics1 rep_tc tc_args = - canDoGenerics rep_tc tc_args `andValid` additionalChecks +canDoGenerics1 :: DynFlags -> TyCon -> [Type] -> Validity +canDoGenerics1 dflags rep_tc tc_args = + canDoGenerics dflags rep_tc tc_args `andValid` additionalChecks where additionalChecks -- check (f) from Note [Requirements for deriving Generic and Rep] diff --git a/testsuite/tests/deriving/should_compile/T11357.hs b/testsuite/tests/deriving/should_compile/T11357.hs new file mode 100644 index 0000000..f3dc715 --- /dev/null +++ b/testsuite/tests/deriving/should_compile/T11357.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} +module T11357 where + +import GHC.Generics (Generic1) + +data family ProxyFam (a :: k) +data instance ProxyFam (a :: k) = ProxyCon deriving Generic1 diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T index ad235d6..e62c50c 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -64,3 +64,4 @@ test('T9968', normal, compile, ['']) test('T11174', normal, compile, ['']) test('T11416', normal, compile, ['']) test('T11396', normal, compile, ['']) +test('T11357', normal, compile, ['']) From git at git.haskell.org Wed Mar 16 01:17:24 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 01:17:24 +0000 (UTC) Subject: [commit: ghc] master: Fix #11473. (aade111) Message-ID: <20160316011724.AFA203A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/aade111248dce0834ed83dc4f18c234967b32024/ghc >--------------------------------------------------------------- commit aade111248dce0834ed83dc4f18c234967b32024 Author: Richard Eisenberg Date: Tue Mar 15 14:27:22 2016 -0400 Fix #11473. I've added a check in the zonker for representation polymorphism. I don't like having this be in the zonker, but I don't know where else to put it. It can't go in TcValidity, because a clever enough user could convince the solver to do bogus representation polymorphism even though there's nothing obviously wrong in what they wrote. Note that TcValidity doesn't run over *expressions*, which is where this problem arises. In any case, the check is simple and it works. test case: dependent/should_fail/T11473 >--------------------------------------------------------------- aade111248dce0834ed83dc4f18c234967b32024 compiler/typecheck/TcHsSyn.hs | 64 +++++++++++++++++++--- .../{typecheck => dependent}/should_fail/T11473.hs | 13 ++++- .../tests/dependent/should_fail/T11473.stderr | 7 +++ testsuite/tests/dependent/should_fail/all.T | 1 + 4 files changed, 75 insertions(+), 10 deletions(-) diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs index 6e35a2b..c1609c0 100644 --- a/compiler/typecheck/TcHsSyn.hs +++ b/compiler/typecheck/TcHsSyn.hs @@ -279,6 +279,7 @@ zonkIdOccs env ids = map (zonkIdOcc env) ids zonkIdBndr :: ZonkEnv -> TcId -> TcM Id zonkIdBndr env id = do ty' <- zonkTcTypeToType env (idType id) + ensureNotRepresentationPolymorphic id ty' return (setIdType id ty') zonkIdBndrs :: ZonkEnv -> [TcId] -> TcM [Id] @@ -459,19 +460,34 @@ zonk_bind env (AbsBinds { abs_tvs = tyvars, abs_ev_vars = evs , abe_mono = zonkIdOcc env mono_id , abe_prags = new_prags }) -zonk_bind env (AbsBindsSig { abs_tvs = tyvars - , abs_ev_vars = evs - , abs_sig_export = poly - , abs_sig_prags = prags - , abs_sig_ev_bind = ev_bind - , abs_sig_bind = bind }) +zonk_bind env outer_bind@(AbsBindsSig { abs_tvs = tyvars + , abs_ev_vars = evs + , abs_sig_export = poly + , abs_sig_prags = prags + , abs_sig_ev_bind = ev_bind + , abs_sig_bind = lbind }) + | L bind_loc bind@(FunBind { fun_id = L loc local + , fun_matches = ms + , fun_co_fn = co_fn }) <- lbind = ASSERT( all isImmutableTyVar tyvars ) do { (env0, new_tyvars) <- zonkTyBndrsX env tyvars ; (env1, new_evs) <- zonkEvBndrsX env0 evs ; (env2, new_ev_bind) <- zonkTcEvBinds env1 ev_bind - ; new_val_bind <- zonk_lbind env2 bind + -- Inline zonk_bind (FunBind ...) because we wish to skip + -- the check for representation-polymorphic binders. The + -- local binder in the FunBind in an AbsBindsSig is never actually + -- bound in Core -- indeed, that's the whole point of AbsBindsSig. + -- just calling zonk_bind causes #11405. + ; new_local <- updateVarTypeM (zonkTcTypeToType env2) local + ; (env3, new_co_fn) <- zonkCoFn env2 co_fn + ; new_ms <- zonkMatchGroup env3 zonkLExpr ms + -- If there is a representation polymorphism problem, it will + -- be caught here: ; new_poly_id <- zonkIdBndr env2 poly ; new_prags <- zonkSpecPrags env2 prags + ; let new_val_bind = L bind_loc (bind { fun_id = L loc new_local + , fun_matches = new_ms + , fun_co_fn = new_co_fn }) ; return (AbsBindsSig { abs_tvs = new_tyvars , abs_ev_vars = new_evs , abs_sig_export = new_poly_id @@ -479,6 +495,9 @@ zonk_bind env (AbsBindsSig { abs_tvs = tyvars , abs_sig_ev_bind = new_ev_bind , abs_sig_bind = new_val_bind }) } + | otherwise + = pprPanic "zonk_bind" (ppr outer_bind) + zonk_bind env (PatSynBind bind@(PSB { psb_id = L loc id , psb_args = details , psb_def = lpat @@ -1628,3 +1647,34 @@ zonkTypeZapping tv | otherwise = anyTypeOfKind (tyVarKind tv) ; writeMetaTyVar tv ty ; return ty } + +--------------------------------------- +-- | According to the rules around representation polymorphism +-- (see https://ghc.haskell.org/trac/ghc/wiki/NoSubKinds), no binder +-- can have a representation-polymorphic type. This check ensures +-- that we respect this rule. It is a bit regrettable that this error +-- occurs in zonking, after which we should have reported all errors. +-- But it's hard to see where else to do it, because this can be discovered +-- only after all solving is done. And, perhaps most importantly, this +-- isn't really a compositional property of a type system, so it's +-- not a terrible surprise that the check has to go in an awkward spot. +ensureNotRepresentationPolymorphic + :: TcId -- the id we're checking (for errors only) + -> Type -- its zonked type + -> TcM () +ensureNotRepresentationPolymorphic id ty + = whenNoErrs $ -- sometimes we end up zonking bogus definitions of type + -- forall a. a. See, for example, test ghci/scripts/T9140 + unless (isEmptyVarSet (tyCoVarsOfType ki)) $ + addErrAt (nameSrcSpan $ idName id) $ + vcat [ text "The following variable has an unknown runtime representation:" + , text " Var name:" <+> ppr id + , text " Var type:" <+> ppr tidy_ty + , text " Type's kind:" <+> ppr tidy_ki + , text "Perhaps add a type or kind signature to fix the representation." + ] + where + ki = typeKind ty + + (tidy_env, tidy_ty) = tidyOpenType emptyTidyEnv ty + tidy_ki = tidyType tidy_env ki diff --git a/testsuite/tests/typecheck/should_fail/T11473.hs b/testsuite/tests/dependent/should_fail/T11473.hs similarity index 67% copy from testsuite/tests/typecheck/should_fail/T11473.hs copy to testsuite/tests/dependent/should_fail/T11473.hs index cb9f791..12d95ca 100644 --- a/testsuite/tests/typecheck/should_fail/T11473.hs +++ b/testsuite/tests/dependent/should_fail/T11473.hs @@ -1,6 +1,7 @@ {-# LANGUAGE PolyKinds, TypeFamilies, MagicHash, DataKinds, TypeInType, RankNTypes #-} module T11473 where + import GHC.Exts import GHC.Types @@ -14,7 +15,13 @@ class BoxIt (a :: TYPE lev) where instance BoxIt Char# where boxed x = C# x instance BoxIt Char where boxed = id --- This should be an error: there is no way we can produce code for both Lifted --- and Unlifted levities -hello :: forall (lev :: Levity). forall (a :: TYPE lev). BoxIt a => a -> Boxed a +hello :: forall (r :: RuntimeRep). forall (a :: TYPE r). BoxIt a => a -> Boxed a hello x = boxed x +{-# NOINLINE hello #-} + +main :: IO () +main = do + print $ boxed 'c'# + print $ boxed 'c' + print $ hello 'c' + print $ hello 'c'# diff --git a/testsuite/tests/dependent/should_fail/T11473.stderr b/testsuite/tests/dependent/should_fail/T11473.stderr new file mode 100644 index 0000000..7a7cc32 --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T11473.stderr @@ -0,0 +1,7 @@ + +T11473.hs:19:7: error: + The following variable has an unknown runtime representation: + Var name: x + Var type: a + Type's kind: TYPE r + Perhaps add a type or kind signature to fix the representation. diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index a90b7bb..c75a9c6 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -12,3 +12,4 @@ test('T11407', normal, compile_fail, ['']) test('T11334', normal, compile_fail, ['']) test('InferDependency', normal, compile_fail, ['']) test('KindLevelsB', normal, compile_fail, ['']) +test('T11473', normal, compile_fail, ['']) From git at git.haskell.org Wed Mar 16 01:17:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 01:17:28 +0000 (UTC) Subject: [commit: ghc] master: Fix printing of "kind" vs. "type" (f602f4a) Message-ID: <20160316011728.037333A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/f602f4a6fbf40d1a3c3c02294e90fcb2d5866d04/ghc >--------------------------------------------------------------- commit f602f4a6fbf40d1a3c3c02294e90fcb2d5866d04 Author: Richard Eisenberg Date: Tue Mar 15 14:54:48 2016 -0400 Fix printing of "kind" vs. "type" This is as reported in #11471, though it's not the focus of that ticket. test case: polykinds/KindVType >--------------------------------------------------------------- f602f4a6fbf40d1a3c3c02294e90fcb2d5866d04 compiler/typecheck/TcUnify.hs | 10 +--------- testsuite/tests/polykinds/KindVType.hs | 8 ++++++++ testsuite/tests/polykinds/KindVType.stderr | 7 +++++++ testsuite/tests/polykinds/all.T | 1 + 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/compiler/typecheck/TcUnify.hs b/compiler/typecheck/TcUnify.hs index affdd59..8eeef4e 100644 --- a/compiler/typecheck/TcUnify.hs +++ b/compiler/typecheck/TcUnify.hs @@ -1170,16 +1170,8 @@ uType origin t_or_k orig_ty1 orig_ty2 -- See Note [Mismatched type lists and application decomposition] | tc1 == tc2, length tys1 == length tys2 = ASSERT2( isGenerativeTyCon tc1 Nominal, ppr tc1 ) - do { cos <- zipWith3M (uType origin) t_or_ks tys1 tys2 + do { cos <- zipWithM (uType origin t_or_k) tys1 tys2 ; return $ mkTyConAppCo Nominal tc1 cos } - where - bndrs = tyConBinders tc1 - t_or_ks = case t_or_k of - KindLevel -> repeat KindLevel - TypeLevel -> map (\bndr -> if isNamedBinder bndr - then KindLevel - else TypeLevel) bndrs ++ - repeat TypeLevel go (LitTy m) ty@(LitTy n) | m == n diff --git a/testsuite/tests/polykinds/KindVType.hs b/testsuite/tests/polykinds/KindVType.hs new file mode 100644 index 0000000..16815c8 --- /dev/null +++ b/testsuite/tests/polykinds/KindVType.hs @@ -0,0 +1,8 @@ +module KindVType where + +-- test printing of "type" in output, not "kind" + +import Data.Proxy + +foo :: Proxy Maybe +foo = (Proxy :: Proxy Int) diff --git a/testsuite/tests/polykinds/KindVType.stderr b/testsuite/tests/polykinds/KindVType.stderr new file mode 100644 index 0000000..7ce3404 --- /dev/null +++ b/testsuite/tests/polykinds/KindVType.stderr @@ -0,0 +1,7 @@ + +KindVType.hs:8:8: error: + ? Couldn't match type ?*? with ?* -> *? + Expected type: Proxy Maybe + Actual type: Proxy Int + ? In the expression: (Proxy :: Proxy Int) + In an equation for ?foo?: foo = (Proxy :: Proxy Int) diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index 45981e9..17d0211 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -145,3 +145,4 @@ test('T11399', normal, compile_fail, ['']) test('T11611', normal, compile_fail, ['']) test('T11648', normal, compile, ['']) test('T11648b', normal, compile_fail, ['']) +test('KindVType', normal, compile_fail, ['']) From git at git.haskell.org Wed Mar 16 01:17:31 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 01:17:31 +0000 (UTC) Subject: [commit: ghc] master: Clean up some pretty-printing in errors. (5d98b8b) Message-ID: <20160316011731.B05753A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/5d98b8bf249fab9bb0be6c5d4e8ddd4578994abb/ghc >--------------------------------------------------------------- commit 5d98b8bf249fab9bb0be6c5d4e8ddd4578994abb Author: Richard Eisenberg Date: Tue Mar 15 16:56:51 2016 -0400 Clean up some pretty-printing in errors. It turns out that there were some pretty egregious mistakes in the code that suggested -fprint-explicit-kinds, which are fixed. This commit also reorders a bunch of error messages, which I think is an improvement. This also adds the test case for #11471, which is what triggered the cleanup in TcErrors. Now that #11473 is done, there is nothing more outstanding for #11471. test case: dependent/should_fail/T11471 >--------------------------------------------------------------- 5d98b8bf249fab9bb0be6c5d4e8ddd4578994abb compiler/typecheck/TcErrors.hs | 15 +++++++++++---- compiler/typecheck/TcType.hs | 14 ++++++++++---- testsuite/tests/dependent/should_fail/T11471.hs | 15 +++++++++++++++ testsuite/tests/dependent/should_fail/T11471.stderr | 18 ++++++++++++++++++ testsuite/tests/dependent/should_fail/all.T | 1 + .../tests/indexed-types/should_fail/NoMatchErr.stderr | 4 ++-- .../tests/indexed-types/should_fail/T1897b.stderr | 4 ++-- testsuite/tests/indexed-types/should_fail/T1900.stderr | 4 ++-- testsuite/tests/indexed-types/should_fail/T2544.stderr | 8 ++++---- testsuite/tests/indexed-types/should_fail/T2693.stderr | 2 +- testsuite/tests/indexed-types/should_fail/T4179.stderr | 2 +- testsuite/tests/indexed-types/should_fail/T7729.stderr | 2 +- .../tests/indexed-types/should_fail/T7729a.stderr | 2 +- testsuite/tests/indexed-types/should_fail/T9036.stderr | 4 ++-- testsuite/tests/indexed-types/should_fail/T9171.stderr | 1 + testsuite/tests/polykinds/T9144.stderr | 1 + testsuite/tests/typecheck/should_fail/T8030.stderr | 4 ++-- testsuite/tests/typecheck/should_fail/T8034.stderr | 4 ++-- testsuite/tests/typecheck/should_fail/T8142.stderr | 4 ++-- 19 files changed, 79 insertions(+), 30 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 5d98b8bf249fab9bb0be6c5d4e8ddd4578994abb From git at git.haskell.org Wed Mar 16 01:17:34 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 01:17:34 +0000 (UTC) Subject: [commit: ghc] master's head updated: Clean up some pretty-printing in errors. (5d98b8b) Message-ID: <20160316011734.0E6FE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'master' now includes: 19be538 Remove redundant anonymiseTyBinders (#11648) 857e9b0 Incorporate bgamari's suggestions for #11614. 1eefedf Fix #11357. aade111 Fix #11473. f602f4a Fix printing of "kind" vs. "type" 5d98b8b Clean up some pretty-printing in errors. From git at git.haskell.org Wed Mar 16 08:40:42 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:40:42 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix the name of the Word16ElemRep wired-in datacon (6960d52) Message-ID: <20160316084042.BDF013A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6960d52329bdd37d9d56a86dc80848e1129602c1/ghc >--------------------------------------------------------------- commit 6960d52329bdd37d9d56a86dc80848e1129602c1 Author: mniip Date: Sun Mar 13 18:12:55 2016 +0100 Fix the name of the Word16ElemRep wired-in datacon Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1999 (cherry picked from commit d12166ad905ad8b014d672b9fc3b9a0e10ba80df) >--------------------------------------------------------------- 6960d52329bdd37d9d56a86dc80848e1129602c1 compiler/prelude/TysWiredIn.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs index 1ee6cfa..c84b1cc 100644 --- a/compiler/prelude/TysWiredIn.hs +++ b/compiler/prelude/TysWiredIn.hs @@ -323,7 +323,7 @@ vecElemTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "VecElem") vec vecElemDataConNames :: [Name] vecElemDataConNames = zipWith3Lazy mk_special_dc_name [ fsLit "Int8ElemRep", fsLit "Int16ElemRep", fsLit "Int32ElemRep" - , fsLit "Int64ElemRep", fsLit "Word8ElemRep", fsLit "Word16elemRep" + , fsLit "Int64ElemRep", fsLit "Word8ElemRep", fsLit "Word16ElemRep" , fsLit "Word32ElemRep", fsLit "Word64ElemRep" , fsLit "FloatElemRep", fsLit "DoubleElemRep" ] vecElemDataConKeys From git at git.haskell.org Wed Mar 16 08:40:45 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:40:45 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add regression test for #11702 (cd585d6) Message-ID: <20160316084045.DF8EB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/cd585d6d7b840d034b93644bdd8efa624cc81714/ghc >--------------------------------------------------------------- commit cd585d6d7b840d034b93644bdd8efa624cc81714 Author: Ben Gamari Date: Sun Mar 13 21:29:19 2016 +0100 Add regression test for #11702 Test Plan: Validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2002 GHC Trac Issues: #11702 (cherry picked from commit 3f60ce8751c860a2bd0ddbe87429136a9d97449b) >--------------------------------------------------------------- cd585d6d7b840d034b93644bdd8efa624cc81714 testsuite/tests/numeric/should_run/T11702.hs | 9 +++++++++ .../should_run/T9844.stdout => numeric/should_run/T11702.stdout} | 0 testsuite/tests/numeric/should_run/all.T | 1 + 3 files changed, 10 insertions(+) diff --git a/testsuite/tests/numeric/should_run/T11702.hs b/testsuite/tests/numeric/should_run/T11702.hs new file mode 100644 index 0000000..0aeb77d --- /dev/null +++ b/testsuite/tests/numeric/should_run/T11702.hs @@ -0,0 +1,9 @@ +module Main where + +testfn :: Word -> IO () +testfn wseq = do + print $ wseq `mod` 1 + +main = do + testfn 5 + print $ (5 :: Word) `mod` 1 diff --git a/testsuite/tests/deSugar/should_run/T9844.stdout b/testsuite/tests/numeric/should_run/T11702.stdout similarity index 100% copy from testsuite/tests/deSugar/should_run/T9844.stdout copy to testsuite/tests/numeric/should_run/T11702.stdout diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T index 7ebdd44..050de91 100644 --- a/testsuite/tests/numeric/should_run/all.T +++ b/testsuite/tests/numeric/should_run/all.T @@ -65,3 +65,4 @@ test('CarryOverflow', omit_ways(['ghci']), compile_and_run, ['']) test('T9810', normal, compile_and_run, ['']) test('T10011', normal, compile_and_run, ['']) test('T10962', omit_ways(['ghci']), compile_and_run, ['']) +test('T11702', expect_broken(11702), compile_and_run, ['']) From git at git.haskell.org Wed Mar 16 08:40:48 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:40:48 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Move and expand (slightly) TypeApplications docs (b9093a5) Message-ID: <20160316084048.A36FA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/b9093a582e3b218ac6d603892b5732f9f0db6e9a/ghc >--------------------------------------------------------------- commit b9093a582e3b218ac6d603892b5732f9f0db6e9a Author: Richard Eisenberg Date: Sun Feb 21 20:51:27 2016 -0500 Move and expand (slightly) TypeApplications docs [skip ci] (cherry picked from commit 18fbfa39104b92a05061ec5f6f5bf3b84b462605) >--------------------------------------------------------------- b9093a582e3b218ac6d603892b5732f9f0db6e9a docs/users_guide/glasgow_exts.rst | 143 ++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 66 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 9518c9f..2074c62 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1754,72 +1754,6 @@ data constructor in an import or export list with the keyword ``pattern``, to allow the import or export of a data constructor without its parent type constructor (see :ref:`patsyn-impexp`). -.. _visible-type-application: - -Visible type application -~~~~~~~~~~~~~~~~~~~~~~~~ - -.. ghc-flag:: -XTypeApplications - - :implies: :ghc-flag:`-XAllowAmbiguousTypes` - :since: 8.0.1 - - Allow the use of type application syntax. - -The :ghc-flag:`-XTypeApplications` extension allows you to use -*visible type application* in expressions. Here is an -example: ``show (read @Int "5")``. The ``@Int`` -is the visible type application; it specifies the value of the type variable -in ``read``'s type. - -A visible type application is preceded with an ``@`` -sign. (To disambiguate the syntax, the ``@`` must be -preceded with a non-identifier letter, usually a space. For example, -``read at Int 5`` would not parse.) It can be used whenever -the full polymorphic type of the function is known. If the function -is an identifier (the common case), its type is considered known only when -the identifier has been given a type signature. If the identifier does -not have a type signature, visible type application cannot be used. - -Here are the details: - -- If an identifier's type signature does not include an - explicit ``forall``, the type variable arguments appear - in the left-to-right order in which the variables appear in the type. - So, ``foo :: Monad m => a b -> m (a c)`` - will have its type variables - ordered as ``m, a, b, c``. - -- If any of the variables depend on other variables (that is, if some - of the variables are *kind* variables), the variables are reordered - so that kind variables come before type variables, preserving the - left-to-right order as much as possible. That is, GHC performs a - stable topological sort on the variables. - - For example: if we have ``bar :: Proxy (a :: (j, k)) -> b``, then - the variables are ordered ``j``, ``k``, ``a``, ``b``. - -- Class methods' type arguments include the class type - variables, followed by any variables an individual method is polymorphic - in. So, ``class Monad m where return :: a -> m a`` means - that ``return``'s type arguments are ``m, a``. - -- With the :ghc-flag:`-XRankNTypes` extension - (:ref:`universal-quantification`), it is possible to declare - type arguments somewhere other than the beginning of a type. For example, - we can have ``pair :: forall a. a -> forall b. b -> (a, b)`` - and then say ``pair @Bool True @Char`` which would have - type ``Char -> (Bool, Char)``. - -- Partial type signatures (:ref:`partial-type-signatures`) - work nicely with visible type - application. If you want to specify only the second type argument to - ``wurble``, then you can say ``wurble @_ @Int``. - The first argument is a wildcard, just like in a partial type signature. - However, if used in a visible type application, it is *not* - necessary to specify :ghc-flag:`-XPartialTypeSignatures` and your - code will not generate a warning informing you of the omitted type. - .. _syntax-stolen: Summary of stolen syntax @@ -8293,6 +8227,83 @@ and :ghc-flag:`-XGADTs`. You can switch it off again with :ghc-flag:`-XNoMonoLocalBinds <-XMonoLocalBinds>` but type inference becomes less predicatable if you do so. (Read the papers!) +.. _visible-type-application: + +Visible type application +======================== + +.. ghc-flag:: -XTypeApplications + + :implies: :ghc-flag:`-XAllowAmbiguousTypes` + :since: 8.0.1 + + Allow the use of type application syntax. + +The :ghc-flag:`-XTypeApplications` extension allows you to use +*visible type application* in expressions. Here is an +example: ``show (read @Int "5")``. The ``@Int`` +is the visible type application; it specifies the value of the type variable +in ``read``'s type. + +A visible type application is preceded with an ``@`` +sign. (To disambiguate the syntax, the ``@`` must be +preceded with a non-identifier letter, usually a space. For example, +``read at Int 5`` would not parse.) It can be used whenever +the full polymorphic type of the function is known. If the function +is an identifier (the common case), its type is considered known only when +the identifier has been given a type signature. If the identifier does +not have a type signature, visible type application cannot be used. + +Here are the details: + +- If an identifier's type signature does not include an + explicit ``forall``, the type variable arguments appear + in the left-to-right order in which the variables appear in the type. + So, ``foo :: Monad m => a b -> m (a c)`` + will have its type variables + ordered as ``m, a, b, c``. + +- If any of the variables depend on other variables (that is, if some + of the variables are *kind* variables), the variables are reordered + so that kind variables come before type variables, preserving the + left-to-right order as much as possible. That is, GHC performs a + stable topological sort on the variables. + + For example: if we have ``bar :: Proxy (a :: (j, k)) -> b``, then + the variables are ordered ``j``, ``k``, ``a``, ``b``. + +- Visible type application is available to instantiate only user-specified + type variables. This means that in ``data Proxy a = Proxy``, the unmentioned + kind variable used in ``a``'s kind is *not* available for visible type + application. + +- Class methods' type arguments include the class type + variables, followed by any variables an individual method is polymorphic + in. So, ``class Monad m where return :: a -> m a`` means + that ``return``'s type arguments are ``m, a``. + +- With the :ghc-flag:`-XRankNTypes` extension + (:ref:`universal-quantification`), it is possible to declare + type arguments somewhere other than the beginning of a type. For example, + we can have ``pair :: forall a. a -> forall b. b -> (a, b)`` + and then say ``pair @Bool True @Char`` which would have + type ``Char -> (Bool, Char)``. + +- Partial type signatures (:ref:`partial-type-signatures`) + work nicely with visible type + application. If you want to specify only the second type argument to + ``wurble``, then you can say ``wurble @_ @Int``. + The first argument is a wildcard, just like in a partial type signature. + However, if used in a visible type application, it is *not* + necessary to specify :ghc-flag:`-XPartialTypeSignatures` and your + code will not generate a warning informing you of the omitted type. + +- When printing types with :ghc-flag:`-fprint-explicit-foralls` enabled, + type variables not available for visible type application are printed + in braces. Thus, if you write ``myLength = length`` without a type + signature, ``myLength``'s inferred type will be + ``forall {f} {a}. Foldable f => f a -> Int``. + .. _implicit-parameters: Implicit parameters From git at git.haskell.org Wed Mar 16 08:40:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:40:52 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11407. (d23e9ef) Message-ID: <20160316084052.28CAA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/d23e9effcd23c9522e97eedc839c4ab819f4c1fb/ghc >--------------------------------------------------------------- commit d23e9effcd23c9522e97eedc839c4ab819f4c1fb Author: Richard Eisenberg Date: Mon Feb 22 12:54:56 2016 -0500 Fix #11407. This removes the `defer_me` check that was in checkTauTvUpdate and uses only a type family check instead. The old defer_me check repeated work done by fast_check in occurCheckExpand. There is also some error message improvement, necessitated by the terrible error message that the test case produced, even when it didn't consume all of memory. test case: dependent/should_fail/T11407 [skip ci] (cherry picked from commit e9bf7bb5cc9fb3f87dd05111aa23da76b86a8967) >--------------------------------------------------------------- d23e9effcd23c9522e97eedc839c4ab819f4c1fb compiler/typecheck/TcErrors.hs | 15 +++++++- compiler/typecheck/TcUnify.hs | 45 +++++----------------- compiler/types/TyCoRep.hs | 25 ++++++------ compiler/types/Type.hs | 9 ++++- compiler/types/Type.hs-boot | 5 +++ testsuite/tests/dependent/should_fail/T11407.hs | 10 +++++ .../tests/dependent/should_fail/T11407.stderr | 8 ++++ testsuite/tests/dependent/should_fail/all.T | 1 + 8 files changed, 70 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc d23e9effcd23c9522e97eedc839c4ab819f4c1fb From git at git.haskell.org Wed Mar 16 08:40:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:40:55 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11334. (44a95c6) Message-ID: <20160316084055.CD1F93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/44a95c6f2421c265da6d20af8c2968933b0d1878/ghc >--------------------------------------------------------------- commit 44a95c6f2421c265da6d20af8c2968933b0d1878 Author: Richard Eisenberg Date: Mon Feb 22 21:47:32 2016 -0500 Fix #11334. Now we fail when trying to default non-*-kinded kind variables with -XNoPolyKinds. test case: dependent/should_fail/T11334 [skip ci] (cherry picked from commit 84c773e1bc5c551b0f922c6fe9c70762d184a394) >--------------------------------------------------------------- 44a95c6f2421c265da6d20af8c2968933b0d1878 compiler/typecheck/TcMType.hs | 87 +++++++++++++++++++++- compiler/types/TyCoRep.hs | 4 +- testsuite/tests/dependent/should_fail/T11334.hs | 8 ++ .../tests/dependent/should_fail/T11334.stderr | 24 ++++++ testsuite/tests/dependent/should_fail/all.T | 1 + 5 files changed, 119 insertions(+), 5 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 44a95c6f2421c265da6d20af8c2968933b0d1878 From git at git.haskell.org Wed Mar 16 08:40:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:40:58 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11401. (e0ca94e) Message-ID: <20160316084058.E81253A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/e0ca94e3111349c0cef96a20950bdc591e586548/ghc >--------------------------------------------------------------- commit e0ca94e3111349c0cef96a20950bdc591e586548 Author: Richard Eisenberg Date: Mon Feb 22 22:15:44 2016 -0500 Fix #11401. This commit teaches shortCutReduction about Derived constraints. [skip ci] (cherry picked from commit 35d37ff8a0bb9f64f347c8e4b6a24d49fd08c9dc) >--------------------------------------------------------------- e0ca94e3111349c0cef96a20950bdc591e586548 compiler/typecheck/TcInteract.hs | 40 +++++++++------------- testsuite/tests/typecheck/should_compile/T11401.hs | 33 ++++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs index 87f4beb..4b99691 100644 --- a/compiler/typecheck/TcInteract.hs +++ b/compiler/typecheck/TcInteract.hs @@ -1524,47 +1524,39 @@ shortCutReduction :: CtEvidence -> TcTyVar -> TcCoercion -> TyCon -> [TcType] -> TcS (StopOrContinue Ct) -- See Note [Top-level reductions for type functions] shortCutReduction old_ev fsk ax_co fam_tc tc_args - | isGiven old_ev - = ASSERT( ctEvEqRel old_ev == NomEq ) + = ASSERT( ctEvEqRel old_ev == NomEq) do { (xis, cos) <- flattenManyNom old_ev tc_args -- ax_co :: F args ~ G tc_args -- cos :: xis ~ tc_args -- old_ev :: F args ~ fsk -- G cos ; sym ax_co ; old_ev :: G xis ~ fsk - ; new_ev <- newGivenEvVar deeper_loc + ; new_ev <- case ctEvFlavour old_ev of + Given -> newGivenEvVar deeper_loc ( mkPrimEqPred (mkTyConApp fam_tc xis) (mkTyVarTy fsk) , EvCoercion (mkTcTyConAppCo Nominal fam_tc cos `mkTcTransCo` mkTcSymCo ax_co `mkTcTransCo` ctEvCoercion old_ev) ) - ; let new_ct = CFunEqCan { cc_ev = new_ev, cc_fun = fam_tc, cc_tyargs = xis, cc_fsk = fsk } - ; updWorkListTcS (extendWorkListFunEq new_ct) - ; stopWith old_ev "Fun/Top (given, shortcut)" } + Derived -> newDerivedNC deeper_loc $ + mkPrimEqPred (mkTyConApp fam_tc xis) + (mkTyVarTy fsk) - | otherwise - = ASSERT( not (isDerived old_ev) ) -- Caller ensures this - ASSERT( ctEvEqRel old_ev == NomEq ) - do { (xis, cos) <- flattenManyNom old_ev tc_args - -- ax_co :: F args ~ G tc_args - -- cos :: xis ~ tc_args - -- G cos ; sym ax_co ; old_ev :: G xis ~ fsk - -- new_ev :: G xis ~ fsk - -- old_ev :: F args ~ fsk := ax_co ; sym (G cos) ; new_ev - - ; (new_ev, new_co) <- newWantedEq deeper_loc Nominal - (mkTyConApp fam_tc xis) (mkTyVarTy fsk) - ; setWantedEq (ctev_dest old_ev) - (ax_co `mkTcTransCo` mkTcSymCo (mkTcTyConAppCo Nominal fam_tc cos) - `mkTcTransCo` new_co) + Wanted -> + do { (new_ev, new_co) <- newWantedEq deeper_loc Nominal + (mkTyConApp fam_tc xis) (mkTyVarTy fsk) + ; setWantedEq (ctev_dest old_ev) $ + ax_co `mkTcTransCo` mkTcSymCo (mkTcTyConAppCo Nominal + fam_tc cos) + `mkTcTransCo` new_co + ; return new_ev } ; let new_ct = CFunEqCan { cc_ev = new_ev, cc_fun = fam_tc , cc_tyargs = xis, cc_fsk = fsk } ; updWorkListTcS (extendWorkListFunEq new_ct) - ; stopWith old_ev "Fun/Top (wanted, shortcut)" } + ; stopWith old_ev "Fun/Top (shortcut)" } where - loc = ctEvLoc old_ev - deeper_loc = bumpCtLocDepth loc + deeper_loc = bumpCtLocDepth (ctEvLoc old_ev) dischargeFmv :: CtEvidence -> TcTyVar -> TcCoercion -> TcType -> TcS () -- (dischargeFmv x fmv co ty) diff --git a/testsuite/tests/typecheck/should_compile/T11401.hs b/testsuite/tests/typecheck/should_compile/T11401.hs new file mode 100644 index 0000000..5235aaf --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11401.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE FlexibleInstances #-} +module T11401 where + +newtype Value a = Value a +newtype CodeGen r a = CodeGen a + +bind :: CodeGen r a -> (a -> CodeGen r b) -> CodeGen r b +bind (CodeGen a) k = k a + +class + (f ~ CalledFunction g, r ~ CallerResult g, g ~ CallerFunction f r) => + CallArgs f g r where + type CalledFunction g :: * + type CallerResult g :: * + type CallerFunction f r :: * + call :: f -> g + +instance CallArgs (IO a) (CodeGen r (Value a)) r where + type CalledFunction (CodeGen r (Value a)) = IO a + type CallerResult (CodeGen r (Value a)) = r + type CallerFunction (IO a) r = CodeGen r (Value a) + call = undefined + +instance CallArgs b b' r => CallArgs (a -> b) (Value a -> b') r where + type CalledFunction (Value a -> b') = a -> CalledFunction b' + type CallerResult (Value a -> b') = CallerResult b' + type CallerFunction (a -> b) r = Value a -> CallerFunction b r + call = undefined + +test :: IO a -> (a -> IO ()) -> CodeGen () (Value ()) +test start stop = bind (call start) (call stop) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 22c55e3..83c6106 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -505,3 +505,4 @@ test('T11458', normal, compile, ['']) test('T11524', normal, compile, ['']) test('T11246', normal, compile, ['']) test('T11608', normal, compile, ['']) +test('T11401', normal, compile, ['']) From git at git.haskell.org Wed Mar 16 08:41:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:02 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Refactor visible type application. (7293209) Message-ID: <20160316084102.357E23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/729320938b17a101c4a6b43c824edace9ebb53f6/ghc >--------------------------------------------------------------- commit 729320938b17a101c4a6b43c824edace9ebb53f6 Author: Richard Eisenberg Date: Tue Feb 23 09:51:50 2016 -0500 Refactor visible type application. This replaces the old HsType and HsTypeOut constructors with HsAppType and HsAppTypeOut, leading to some simplification. (This refactoring addresses #11329.) This also fixes #11456, which stumbled over HsType (which is not an expression). test case: ghci/scripts/T11456 [skip ci] (cherry picked from commit 972730cc42a419b8cd148abaa927e03415da3a68) >--------------------------------------------------------------- 729320938b17a101c4a6b43c824edace9ebb53f6 compiler/deSugar/Coverage.hs | 23 ++--- compiler/deSugar/DsExpr.hs | 15 +-- compiler/deSugar/DsMeta.hs | 4 +- compiler/hsSyn/HsExpr.hs | 63 ++++++----- compiler/hsSyn/HsUtils.hs | 26 ++--- compiler/parser/Parser.y | 11 +- compiler/rename/RnExpr.hs | 10 +- compiler/rename/RnSource.hs | 1 + compiler/typecheck/TcExpr.hs | 115 +++++++++++---------- compiler/typecheck/TcHsSyn.hs | 8 +- compiler/typecheck/TcRnTypes.hs | 4 +- testsuite/tests/ghci/scripts/T11456.hs | 5 + testsuite/tests/ghci/scripts/T11456.script | 2 + testsuite/tests/ghci/scripts/T11456.stdout | 1 + testsuite/tests/ghci/scripts/all.T | 1 + testsuite/tests/typecheck/should_fail/T9605.stderr | 20 ++-- .../tests/typecheck/should_fail/VtaFail.stderr | 2 +- 17 files changed, 167 insertions(+), 144 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 729320938b17a101c4a6b43c824edace9ebb53f6 From git at git.haskell.org Wed Mar 16 08:41:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:04 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Expand Note [Non-trivial definitional equality] (4aef864) Message-ID: <20160316084104.E17A53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/4aef864a738845316ddb526182e418d8c7faa969/ghc >--------------------------------------------------------------- commit 4aef864a738845316ddb526182e418d8c7faa969 Author: Richard Eisenberg Date: Wed Feb 24 14:41:37 2016 -0500 Expand Note [Non-trivial definitional equality] This adapts the text from D1944. [skip ci] (cherry picked from commit 6c768fcf0d6749bf5029baf6b7f99271b48b1037) >--------------------------------------------------------------- 4aef864a738845316ddb526182e418d8c7faa969 compiler/types/TyCoRep.hs | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index 1666857..0b06510 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -354,6 +354,58 @@ two types have the same kind. This allows us to be a little sloppier in keeping track of coercions, which is a good thing. It also means that eqType does not depend on eqCoercion, which is also a good thing. +Why is this sensible? That is, why is something different than ?-equivalence +appropriate for the implementation of eqType? + +Anything smaller than ~ and homogeneous is an appropriate definition for +equality. The type safety of FC depends only on ~. Let's say ? : ? ~ ?. Any +expression of type ? can be transmuted to one of type ? at any point by +casting. The same is true of types of type ?. So in some sense, ? and ? are +interchangeable. + +But let's be more precise. If we examine the typing rules of FC (say, those in +http://www.cis.upenn.edu/~eir/papers/2015/equalities/equalities-extended.pdf) +there are several places where the same metavariable is used in two different +premises to a rule. (For example, see Ty_App.) There is an implicit equality +check here. What definition of equality should we use? By convention, we use +?-equivalence. Take any rule with one (or more) of these implicit equality +checks. Then there is an admissible rule that uses ~ instead of the implicit +check, adding in casts as appropriate. + +The only problem here is that ~ is heterogeneous. To make the kinds work out +in the admissible rule that uses ~, it is necessary to homogenize the +coercions. That is, if we have ? : (? : ?1) ~ (? : ?2), then we don't use ?; +we use ? |> kind ?, which is homogeneous. + +The effect of this all is that eqType, the implementation of the implicit +equality check, can use any homogeneous relation that is smaller than ~, as +those rules must also be admissible. + +What would go wrong if we insisted on the casts matching? See the beginning of +Section 8 in the unpublished paper above. Theoretically, nothing at all goes +wrong. But in practical terms, getting the coercions right proved to be +nightmarish. And types would explode: during kind-checking, we often produce +reflexive kind coercions. When we try to cast by these, mkCastTy just discards +them. But if we used an eqType that distinguished between Int and Int |> <*>, +then we couldn't discard -- the output of kind-checking would be enormous, +and we would need enormous casts with lots of CoherenceCo's to straighten +them out. + +Would anything go wrong if eqType respected type families? No, not at all. But +that makes eqType rather hard to implement. + +Thus, the guideline for eqType is that it should be the largest +easy-to-implement relation that is still smaller than ~ and homogeneous. The +precise choice of relation is somewhat incidental, as long as the smart +constructors and destructors in Type respect whatever relation is chosen. + +Another helpful principle with eqType is this: + + ** If (t1 eqType t2) then I can replace t1 by t2 anywhere. ** + +This principle also tells us that eqType must relate only types with the +same kinds. + Note [VisibilityFlag] ~~~~~~~~~~~~~~~~~~~~~ All named binders are equipped with a visibility flag, which says From git at git.haskell.org Wed Mar 16 08:41:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:08 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Test case for #11699 in typecheck/should_compile (397362e) Message-ID: <20160316084108.084533A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/397362e6eaee30e0650dd8f8681160eaf5227407/ghc >--------------------------------------------------------------- commit 397362e6eaee30e0650dd8f8681160eaf5227407 Author: Richard Eisenberg Date: Fri Mar 11 10:27:53 2016 -0500 Test case for #11699 in typecheck/should_compile [skip ci] (cherry picked from commit 693b38cbf5cd298b793b3179fb6cc57e196b55d0) >--------------------------------------------------------------- 397362e6eaee30e0650dd8f8681160eaf5227407 testsuite/tests/typecheck/should_compile/T11699.hs | 5 +++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 2 files changed, 6 insertions(+) diff --git a/testsuite/tests/typecheck/should_compile/T11699.hs b/testsuite/tests/typecheck/should_compile/T11699.hs new file mode 100644 index 0000000..2334f29 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11699.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE TypeFamilies, PolyKinds #-} + +module T11699 where + +type family F a where F (f a) = f a diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 83c6106..98f6ef0 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -506,3 +506,4 @@ test('T11524', normal, compile, ['']) test('T11246', normal, compile, ['']) test('T11608', normal, compile, ['']) test('T11401', normal, compile, ['']) +test('T11699', normal, compile, ['']) From git at git.haskell.org Wed Mar 16 08:41:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:10 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users_guide: Break up -fprint-* description (0c64467) Message-ID: <20160316084110.AC2DE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0c64467d349bcc038e622e5131ed21838ebf018d/ghc >--------------------------------------------------------------- commit 0c64467d349bcc038e622e5131ed21838ebf018d Author: Ben Gamari Date: Sun Mar 13 12:56:37 2016 +0100 users_guide: Break up -fprint-* description This makes it a bit easier to find the description corresponding to particular flags. (cherry picked from commit 9ee51da1a9a0d0c4215d8fc9dce32db63c57aa99) >--------------------------------------------------------------- 0c64467d349bcc038e622e5131ed21838ebf018d docs/users_guide/using.rst | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/docs/users_guide/using.rst b/docs/users_guide/using.rst index 47fdd29..96bd0a1 100644 --- a/docs/users_guide/using.rst +++ b/docs/users_guide/using.rst @@ -609,20 +609,30 @@ See also the ``--help``, ``--version``, ``--numeric-version``, and representation after each compilation phase is also printed (excluding preprocessed and C/assembly files). -.. ghc-flag:: --fprint-potential-instances +.. ghc-flag:: -fprint-potential-instances When GHC can't find an instance for a class, it displays a short list of some in the instances it knows about. With this flag it prints *all* the instances it knows about. + +The following flags control the way in which GHC displays types in error +messages and in GHCi: + +.. ghc-flag:: -fprint-unicode-syntax + + When enabled GHC prints type signatures using the unicode symbols from the + :ghc-flag:`-XUnicodeSyntax` extension. For instance, + + .. code-block:: none + + ghci> :set -fprint-unicode-syntax + ghci> :t (>>) + (>>) :: ? (m :: * ? *) a b. Monad m ? m a ? m b ? m b + .. ghc-flag:: -fprint-explicit-foralls - -fprint-explicit-kinds - -fprint-unicode-syntax - -fprint-explicit-coercions - -fprint-equality-relations - These flags control the way in which GHC displays types, in - error messages and in GHCi. Using :ghc-flag:`-fprint-explicit-foralls` makes + Using :ghc-flag:`-fprint-explicit-foralls` makes GHC print explicit ``forall`` quantification at the top level of a type; normally this is suppressed. For example, in GHCi: @@ -656,6 +666,8 @@ See also the ``--help``, ``--version``, ``--numeric-version``, and (a Data.Type.Equality.:~: b) -> b Data.Type.Equality.:~: a -- Defined in Data.Type.Equality +.. ghc-flag:: -fprint-explicit-kinds + Using :ghc-flag:`-fprint-explicit-kinds` makes GHC print kind arguments in types, which are normally suppressed. This can be important when you are using kind polymorphism. For example: @@ -670,21 +682,15 @@ See also the ``--help``, ``--version``, ``--numeric-version``, and ghci> :t MkT MkT :: forall (k :: BOX) (a :: k). T k a - When :ghc-flag:`-fprint-unicode-syntax` is enabled, GHC prints type - signatures using the unicode symbols from the :ghc-flag:`-XUnicodeSyntax` - extension. - - .. code-block:: none - - ghci> :set -fprint-unicode-syntax - ghci> :t (>>) - (>>) :: ? (m :: * ? *) a b. Monad m ? m a ? m b ? m b +.. ghc-flag:: -fprint-explicit-coercions Using :ghc-flag:`-fprint-explicit-coercions` makes GHC print coercions in types. When trying to prove the equality between types of different kinds, GHC uses type-level coercions. Users will rarely need to see these, as they are meant to be internal. +.. ghc-flag:: -fprint-equality-relations + Using :ghc-flag:`-fprint-equality-relations` tells GHC to distinguish between its equality relations when printing. For example, ``~`` is homogeneous lifted equality (the kinds of its arguments are the same) while From git at git.haskell.org Wed Mar 16 08:41:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:13 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Document TypeInType (#11614) (ace3dd9) Message-ID: <20160316084113.7880B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/ace3dd93ac0c3ba4214c6928df14a0eb3652822e/ghc >--------------------------------------------------------------- commit ace3dd93ac0c3ba4214c6928df14a0eb3652822e Author: Richard Eisenberg Date: Fri Mar 11 11:14:04 2016 -0500 Document TypeInType (#11614) [skip ci] (cherry picked from commit e7a8cb145c2450ae12abfb9e30a2b7c1544abf67) >--------------------------------------------------------------- ace3dd93ac0c3ba4214c6928df14a0eb3652822e docs/users_guide/glasgow_exts.rst | 854 ++++++++++++++++++++++++++------------ docs/users_guide/using.rst | 4 +- libraries/ghc-prim/GHC/Types.hs | 6 +- 3 files changed, 599 insertions(+), 265 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc ace3dd93ac0c3ba4214c6928df14a0eb3652822e From git at git.haskell.org Wed Mar 16 08:41:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:17 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11648. (eda74a7) Message-ID: <20160316084117.3DE583A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/eda74a7aa57f5de4157cac7202c4fdaf72fed76c/ghc >--------------------------------------------------------------- commit eda74a7aa57f5de4157cac7202c4fdaf72fed76c Author: Richard Eisenberg Date: Sat Mar 12 20:59:44 2016 -0500 Fix #11648. We now check that a CUSK is really a CUSK and issue an error if it isn't. This also involves more solving and zonking in kcHsTyVarBndrs, which was the outright bug reported in #11648. Test cases: polykinds/T11648{,b} This updates the haddock submodule. [skip ci] (cherry picked from commit 55577a9130738932d022d442d0773ffd79d0945d) >--------------------------------------------------------------- eda74a7aa57f5de4157cac7202c4fdaf72fed76c compiler/deSugar/DsMeta.hs | 19 +- compiler/hsSyn/Convert.hs | 2 + compiler/hsSyn/HsDecls.hs | 26 ++- compiler/hsSyn/HsTypes.hs | 13 +- compiler/parser/RdrHsSyn.hs | 1 + compiler/rename/RnSource.hs | 42 ++-- compiler/rename/RnTypes.hs | 63 +++--- compiler/typecheck/TcHsType.hs | 234 +++++++++++++-------- compiler/typecheck/TcMType.hs | 2 +- compiler/typecheck/TcTyClsDecls.hs | 83 +++++--- compiler/typecheck/TcType.hs | 27 +++ compiler/typecheck/TcValidity.hs | 2 +- docs/users_guide/glasgow_exts.rst | 62 +++++- .../tests/dependent/should_compile/KindLevels.hs | 4 +- .../tests/dependent/should_fail/InferDependency.hs | 6 + .../dependent/should_fail/InferDependency.stderr | 8 + .../KindLevels.hs => should_fail/KindLevelsB.hs} | 0 .../tests/dependent/should_fail/KindLevelsB.stderr | 5 + testsuite/tests/dependent/should_fail/all.T | 2 + testsuite/tests/polykinds/T11648.hs | 8 + testsuite/tests/polykinds/T11648b.hs | 7 + testsuite/tests/polykinds/T11648b.stderr | 8 + testsuite/tests/polykinds/T6039.stderr | 5 + testsuite/tests/polykinds/all.T | 4 +- utils/haddock | 2 +- 25 files changed, 444 insertions(+), 191 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc eda74a7aa57f5de4157cac7202c4fdaf72fed76c From git at git.haskell.org Wed Mar 16 08:41:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:19 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Allow eager unification with type families. (d3991f3) Message-ID: <20160316084120.0087E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/d3991f33738eec7154ced87bd36f32f35b76bd1f/ghc >--------------------------------------------------------------- commit d3991f33738eec7154ced87bd36f32f35b76bd1f Author: Richard Eisenberg Date: Mon Mar 14 22:09:36 2016 -0400 Allow eager unification with type families. Previously, checkTauTvUpdate, used in the eager unifier (TcUnify) right before writing to a metavar, refused to write a metavar to a type involving type functions. The reason for this was given in a Note, but the Note didn't make all that much sense and even admitted that it was a bit confused. The Note, in turn, referred to another Note, which it was quite sceptical of, as well. The type-family check was slowing down performance, so I tried removing it, running the tests referred to in the Note. The tests all passed without the check. Looking at more test results, I saw several error messages improve without the check, and some cases where GHC looped (T7788, in particular) it now doesn't. So, all in all, quite a win: Two hairy Notes removed, several lines of code removed, better performance, and improved output. [skip ci] (cherry picked from commit 3f5d1a13f112f34d992f6b74656d64d95a3f506d) >--------------------------------------------------------------- d3991f33738eec7154ced87bd36f32f35b76bd1f compiler/typecheck/TcUnify.hs | 72 +--------------------- .../{should_fail => should_compile}/T7788.hs | 0 testsuite/tests/indexed-types/should_compile/all.T | 1 + .../tests/indexed-types/should_fail/T2693.stderr | 17 +++-- .../tests/indexed-types/should_fail/T4179.stderr | 6 +- .../tests/indexed-types/should_fail/T5439.stderr | 13 ++-- .../tests/indexed-types/should_fail/T7354.stderr | 9 ++- .../tests/indexed-types/should_fail/T7729.stderr | 8 +-- .../tests/indexed-types/should_fail/T7786.stderr | 12 ++-- .../tests/indexed-types/should_fail/T7788.stderr | 10 --- .../tests/indexed-types/should_fail/T9554.stderr | 13 ---- .../tests/indexed-types/should_fail/T9662.stderr | 16 ++--- testsuite/tests/indexed-types/should_fail/all.T | 1 - 13 files changed, 40 insertions(+), 138 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc d3991f33738eec7154ced87bd36f32f35b76bd1f From git at git.haskell.org Wed Mar 16 08:41:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:41:22 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Testsuite wibbles from previous commits. (7ce1ef0) Message-ID: <20160316084122.BDB073A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/7ce1ef0cef53c55b47b052802873bdc318fe3817/ghc >--------------------------------------------------------------- commit 7ce1ef0cef53c55b47b052802873bdc318fe3817 Author: Richard Eisenberg Date: Sat Mar 12 15:52:22 2016 -0500 Testsuite wibbles from previous commits. (cherry picked from commit de4df6b41a227f527e9eb77733cd6c87b069d3d0) >--------------------------------------------------------------- 7ce1ef0cef53c55b47b052802873bdc318fe3817 testsuite/tests/indexed-types/should_fail/T5439.stderr | 3 +++ testsuite/tests/perf/compiler/all.T | 3 ++- testsuite/tests/polykinds/T9222.stderr | 2 +- testsuite/tests/typecheck/should_fail/T9260.stderr | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/testsuite/tests/indexed-types/should_fail/T5439.stderr b/testsuite/tests/indexed-types/should_fail/T5439.stderr index b0cf937..b76b0f9 100644 --- a/testsuite/tests/indexed-types/should_fail/T5439.stderr +++ b/testsuite/tests/indexed-types/should_fail/T5439.stderr @@ -7,6 +7,9 @@ T5439.hs:82:33: error: ?inj $ Failure (e :: SomeException)? In a stmt of a 'do' block: c <- complete ev $ inj $ Failure (e :: SomeException) + In the expression: + do { c <- complete ev $ inj $ Failure (e :: SomeException); + return $ c || not first } ? Relevant bindings include register :: Bool -> Peano n -> WaitOps (HDrop n rs) -> IO Bool (bound at T5439.hs:64:9) diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index 73ab4af..5c7a6c7 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -364,7 +364,7 @@ test('T5030', # of family-applications leads to less sharing, I think # 2015-07-11: 201882912 reason unknown - (wordsize(64), 653710960, 10)]), + (wordsize(64), 342331936, 10)]), # Previously 530000000 (+/- 10%) # 17/1/13: 602993184 (x86_64/Linux) # (new demand analyser) @@ -382,6 +382,7 @@ test('T5030', # of family-applications leads to less sharing, I think # 2015-03-17 403932600 tweak to solver algorithm # 2015-12-11 653710960 TypeInType (see #11196) + # 2016-03-14 342331936 unify type families eagerly only_ways(['normal']) ], diff --git a/testsuite/tests/polykinds/T9222.stderr b/testsuite/tests/polykinds/T9222.stderr index 69e850c..b3d31ef 100644 --- a/testsuite/tests/polykinds/T9222.stderr +++ b/testsuite/tests/polykinds/T9222.stderr @@ -8,7 +8,7 @@ T9222.hs:13:3: error: at T9222.hs:13:3 ?b? is a rigid type variable bound by the type of the constructor ?Want?: - forall i j (a :: (i, j)) (b :: i) (c :: j). + forall i1 j1 (a :: (i1, j1)) (b :: i1) (c :: j1). ((a ~ '(b, c)) => Proxy b) -> Want a at T9222.hs:13:3 Expected type: Proxy b0 diff --git a/testsuite/tests/typecheck/should_fail/T9260.stderr b/testsuite/tests/typecheck/should_fail/T9260.stderr index 0773da2..37c37bd 100644 --- a/testsuite/tests/typecheck/should_fail/T9260.stderr +++ b/testsuite/tests/typecheck/should_fail/T9260.stderr @@ -2,6 +2,6 @@ T9260.hs:12:8: error: ? Couldn't match type ?2? with ?1? Expected type: Fin 1 - Actual type: Fin (1 + 1) + Actual type: Fin ((0 + 1) + 1) ? In the expression: Fsucc Fzero In an equation for ?test?: test = Fsucc Fzero From git at git.haskell.org Wed Mar 16 08:47:45 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 08:47:45 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Incorporate bgamari's suggestions for #11614. (a969330) Message-ID: <20160316084745.86C8D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/a96933017470d03a1c9414c9c90dfd5c0f0903ed/ghc >--------------------------------------------------------------- commit a96933017470d03a1c9414c9c90dfd5c0f0903ed Author: Richard Eisenberg Date: Tue Mar 15 13:21:20 2016 -0400 Incorporate bgamari's suggestions for #11614. (cherry picked from commit 857e9b0231db80b838d78e341954d3e75db7e94b) >--------------------------------------------------------------- a96933017470d03a1c9414c9c90dfd5c0f0903ed docs/users_guide/8.0.1-notes.rst | 10 +++++++- docs/users_guide/glasgow_exts.rst | 51 ++++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst index df12e8a..288141b 100644 --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -26,7 +26,9 @@ The highlights, since the 7.10 branch, are: - TODO FIXME -- nokinds +- The new :ghc-flag:`-XTypeInType` allows promotion of all types into + kinds, allowing kind synonyms, kind families, promoted GADTs, and other + goodies. - Support for :ref:`record pattern synonyms ` @@ -76,6 +78,12 @@ Language - TODO FIXME. +- :ghc-flag:`-XTypeInType` supports universal type promotion and merges + the type and kind language. This allows, for example, higher-rank + kinds, along with kind families and type-level GADTs. Support is still + experimental, and it is expected to improve over the next several + releases. See :ref:`type-in-type` for the details. + - The parser now supports Haddock comments on GADT data constructors. For example :: diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 4fd0b72..be8de73 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -131,7 +131,8 @@ Unboxed type kinds ------------------ Because unboxed types are represented without the use of pointers, we -cannot store them in standard datatypes. For example, the ``Just`` node +cannot store them in use a polymorphic datatype at an unboxed type. +For example, the ``Just`` node of ``Just 42#`` would have to be different from the ``Just`` node of ``Just 42``; the former stores an integer directly, while the latter stores a pointer. GHC currently does not support this variety of ``Just`` @@ -145,10 +146,11 @@ specifies their runtime representation. For example, the type ``Int#`` has kind ``TYPE 'IntRep`` and ``Double#`` has kind ``TYPE 'DoubleRep``. These kinds say that the runtime representation of an ``Int#`` is a machine integer, and the runtime representation of a ``Double#`` is a machine double-precision -floating point. More details of the ``TYPE`` mechanisms appear in +floating point. In constrast, the kind ``*`` is actually just a synonym +for ``TYPE 'PtrRepLifted``. More details of the ``TYPE`` mechanisms appear in the `section on runtime representation polymorphism <#runtime-rep>`__. -Given that ``Int#``'s kind is not ``*``, it then is easy to see that +Given that ``Int#``'s kind is not ``*``, it then it follows that ``Maybe Int#`` is disallowed. Similarly, because type variables tend to be of kind ``*`` (for example, in ``(.) :: (b -> c) -> (a -> b) -> a -> c``, all the type variables have kind ``*``), polymorphism tends not to work @@ -6917,7 +6919,7 @@ With :ghc-flag:`-XDataKinds`, GHC automatically promotes every datatype to be a kind and its (value) constructors to be type constructors. The following types :: - data Nat = Ze | Su Nat + data Nat = Zero | Succ Nat data List a = Nil | Cons a (List a) @@ -6925,11 +6927,12 @@ following types :: data Sum a b = L a | R b -give rise to the following kinds and type constructors: :: +give rise to the following kinds and type constructors (where promoted +constructors are prefixed by a tick ``'``): :: Nat :: * - 'Ze :: Nat - 'Su :: Nat -> Nat + 'Zero :: Nat + 'Succ :: Nat -> Nat List :: * -> * 'Nil :: forall k. List k @@ -6944,8 +6947,8 @@ give rise to the following kinds and type constructors: :: The following restrictions apply to promotion: -- We promote ``data`` types and ``newtypes``, but not type synonyms, or - type/data families (:ref:`type-families`). +- We promote ``data`` types and ``newtypes``; type synonyms and + type/data families are not promoted (:ref:`type-families`). - We only promote types whose kinds are of the form ``* -> ... -> * -> *``. In particular, we do not promote @@ -7061,7 +7064,8 @@ not mentioned in the arguments, and thus it would seem that an instance would have to return a member of ``k`` *for any* ``k``. However, this is not the case. The type family ``UnEx`` is a kind-indexed type family. The return kind ``k`` is an implicit parameter to ``UnEx``. The -elaborated definitions are as follows: :: +elaborated definitions are as follows (where implicit parameters are +denoted by braces): :: type family UnEx {k :: *} (ex :: Ex) :: k type instance UnEx {k} (MkEx @k x) = x @@ -7084,7 +7088,9 @@ Kind polymorphism and Type-in-Type :implies: :ghc-flag:`-XPolyKinds`, :ghc-flag:`-XDataKinds`, :ghc-flag:`-XKindSignatures` :since: 8.0.1 - Allow kinds to be as intricate as types. + Allow kinds to be as intricate as types, allowing explicit quantification + over kind variables, higher-rank kinds, and the use of type synonyms and + families in kinds, among other features. .. ghc-flag:: -XPolyKinds @@ -7225,6 +7231,10 @@ This rule has occasionally-surprising consequences (see The kind-polymorphism from the class declaration makes ``D1`` kind-polymorphic, but not so ``D2``; and similarly ``F1``, ``F1``. +.. index:: + single: CUSK + single: complete user-supplied kind signature + .. _complete-kind-signatures: Complete user-supplied kind signatures and polymorphic recursion @@ -7609,6 +7619,10 @@ kind polymorphism and are confused as to why GHC is rejecting (or accepting) your program, we encourage you to turn on these flags, especially :ghc-flag:`-fprint-explicit-kinds`. +.. index:: + single: TYPE + single: runtime representation polymorphism + .. _runtime-rep: Runtime representation polymorphism @@ -7633,8 +7647,8 @@ Here are the key definitions, all available from ``GHC.Exts``: :: data RuntimeRep = PtrRepLifted -- for things like `Int` | PtrRepUnlifted -- for things like `Array#` - | IntRep -- for things like `Int#` - | ... + | IntRep -- for things like `Int#` + | ... type * = TYPE PtrRepLifted -- * is just an ordinary type synonym @@ -7713,7 +7727,7 @@ by supposing all type variables of type ``RuntimeType`` to be ``'PtrRepLifted`` when printing, and printing ``TYPE 'PtrRepLifted`` as ``*``. Should you wish to see representation polymorphism in your types, enable -the flag :ghc-flag:`-Wprint-explicit-runtime-rep`. +the flag :ghc-flag:`-fprint-explicit-runtime-reps`. .. _type-level-literals: @@ -7876,12 +7890,15 @@ dependency. In class instances, we define the type instances of FD families in accordance with the class head. Method signatures are not affected by that process. +.. index:: + pair: Type equality constraints; kind heterogeneous + Heterogeneous equality ---------------------- -GHC also supports *heterogeneous* equality, which relates two types of potentially -different kinds. Heterogeneous equality is spelled ``~~``. Here are the -kinds of ``~`` and ``~~`` to better understand their difference: :: +GHC also supports *kind-heterogeneous* equality, which relates two types of +potentially different kinds. Heterogeneous equality is spelled ``~~``. Here +are the kinds of ``~`` and ``~~`` to better understand their difference: :: (~) :: forall k. k -> k -> Constraint (~~) :: forall k1 k2. k1 -> k2 -> Constraint From git at git.haskell.org Wed Mar 16 20:41:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 16 Mar 2016 20:41:17 +0000 (UTC) Subject: [commit: ghc] master: DriverPipeline: Fix 'unused arguments' warnings from Clang (46f9a47) Message-ID: <20160316204117.2307B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/46f9a476e17714e27d893b491cc0dcf68c745249/ghc >--------------------------------------------------------------- commit 46f9a476e17714e27d893b491cc0dcf68c745249 Author: Erik de Castro Lopo Date: Sun Mar 13 15:28:11 2016 +1100 DriverPipeline: Fix 'unused arguments' warnings from Clang When using Clang as the C compiler, over 100 tests were failing due to Clang reporting that some command line arguments were not being used. These warnings only occur when Clang is compiling assembler files which happens in two places, one of which already conditionally adding `-Qunused-arguments` to the command line when the compiler was Clang. This fixes the other. Test Plan: validate with clang as the C compiler Reviewers: bgamari, hvr, austin, rwbarton Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1998 GHC Trac Issues: #11684 >--------------------------------------------------------------- 46f9a476e17714e27d893b491cc0dcf68c745249 compiler/main/DriverPipeline.hs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index c384248..41a7c5b 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1574,16 +1574,32 @@ mkExtraObj dflags extn xs = do cFile <- newTempName dflags extn oFile <- newTempName dflags "o" writeFile cFile xs - let rtsDetails = getPackageDetails dflags rtsUnitId - pic_c_flags = picCCOpts dflags + ccInfo <- liftIO $ getCompilerInfo dflags SysTools.runCc dflags - ([Option "-c", - FileOption "" cFile, - Option "-o", - FileOption "" oFile] - ++ map (FileOption "-I") (includeDirs rtsDetails) - ++ map Option pic_c_flags) + ([Option "-c", + FileOption "" cFile, + Option "-o", + FileOption "" oFile] + ++ if extn /= "s" + then cOpts + else asmOpts ccInfo) return oFile + where + -- Pass a different set of options to the C compiler depending one whether + -- we're compiling C or assembler. When compiling C, we pass the usual + -- set of include directories and PIC flags. + cOpts = map Option (picCCOpts dflags) + ++ map (FileOption "-I") + (includeDirs $ getPackageDetails dflags rtsUnitId) + + -- When compiling assembler code, we drop the usual C options, and if the + -- compiler is Clang, we add an extra argument to tell Clang to ignore + -- unused command line options. See trac #11684. + asmOpts ccInfo = + if any (ccInfo ==) [Clang, AppleClang, AppleClang51] + then [Option "-Qunused-arguments"] + else [] + -- When linking a binary, we need to create a C main() function that -- starts everything off. This used to be compiled statically as part From git at git.haskell.org Thu Mar 17 14:05:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 17 Mar 2016 14:05:17 +0000 (UTC) Subject: [commit: ghc] master: Fix #11711. (b5565f1) Message-ID: <20160317140517.5D7353A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/b5565f1a79fd24fc45a6f1a58821a317852d4b89/ghc >--------------------------------------------------------------- commit b5565f1a79fd24fc45a6f1a58821a317852d4b89 Author: Richard Eisenberg Date: Wed Mar 16 14:30:00 2016 -0400 Fix #11711. There were two bugs here, both simple: we need to filter out covars before calling isMetaTyVar in the solver, and TcPat had a tcSubType the wrong way round. test case: dependent/should_compile/T11711 >--------------------------------------------------------------- b5565f1a79fd24fc45a6f1a58821a317852d4b89 compiler/hsSyn/HsPat.hs | 8 +-- compiler/typecheck/TcPat.hs | 2 +- compiler/typecheck/TcSimplify.hs | 4 +- testsuite/tests/dependent/should_compile/T11711.hs | 58 ++++++++++++++++++++++ testsuite/tests/dependent/should_compile/all.T | 1 + testsuite/tests/patsyn/should_fail/mono.stderr | 20 ++++---- 6 files changed, 78 insertions(+), 15 deletions(-) diff --git a/compiler/hsSyn/HsPat.hs b/compiler/hsSyn/HsPat.hs index 36c4faf..e01c6b9 100644 --- a/compiler/hsSyn/HsPat.hs +++ b/compiler/hsSyn/HsPat.hs @@ -419,9 +419,11 @@ pprPat (TuplePat pats bx _) = tupleParens (boxityTupleSort bx) (pprWithCommas pprPat (ConPatIn con details) = pprUserCon (unLoc con) details pprPat (ConPatOut { pat_con = con, pat_tvs = tvs, pat_dicts = dicts, pat_binds = binds, pat_args = details }) - = getPprStyle $ \ sty -> -- Tiresome; in TcBinds.tcRhs we print out a - if debugStyle sty then -- typechecked Pat in an error message, - -- and we want to make sure it prints nicely + = sdocWithDynFlags $ \dflags -> + -- Tiresome; in TcBinds.tcRhs we print out a + -- typechecked Pat in an error message, + -- and we want to make sure it prints nicely + if gopt Opt_PrintTypecheckerElaboration dflags then ppr con <> braces (sep [ hsep (map pprPatBndr (tvs ++ dicts)) , ppr binds]) diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs index 9594646..ae3c202 100644 --- a/compiler/typecheck/TcPat.hs +++ b/compiler/typecheck/TcPat.hs @@ -816,7 +816,7 @@ tcPatSynPat penv (L con_span _) pat_syn pat_ty arg_pats thing_inside prov_theta' = substTheta tenv prov_theta req_theta' = substTheta tenv req_theta - ; wrap <- tcSubTypeO (pe_orig penv) GenSigCtxt ty' pat_ty + ; wrap <- tcSubTypeET (pe_orig penv) pat_ty ty' ; traceTc "tcPatSynPat" (ppr pat_syn $$ ppr pat_ty $$ ppr ty' $$ diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs index b99823e..0d1e754 100644 --- a/compiler/typecheck/TcSimplify.hs +++ b/compiler/typecheck/TcSimplify.hs @@ -125,10 +125,12 @@ simpl_top wanteds = return wc | otherwise = do { free_tvs <- TcS.zonkTyCoVarsAndFV (tyCoVarsOfWC wc) - ; let meta_tvs = varSetElems (filterVarSet isMetaTyVar free_tvs) + ; let meta_tvs = varSetElems $ + filterVarSet (isTyVar <&&> isMetaTyVar) free_tvs -- zonkTyCoVarsAndFV: the wc_first_go is not yet zonked -- filter isMetaTyVar: we might have runtime-skolems in GHCi, -- and we definitely don't want to try to assign to those! + -- the isTyVar needs to weed out coercion variables ; defaulted <- mapM defaultTyVarTcS meta_tvs -- Has unification side effects ; if or defaulted diff --git a/testsuite/tests/dependent/should_compile/T11711.hs b/testsuite/tests/dependent/should_compile/T11711.hs new file mode 100644 index 0000000..633ae35 --- /dev/null +++ b/testsuite/tests/dependent/should_compile/T11711.hs @@ -0,0 +1,58 @@ +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE TypeInType #-} +{-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE FlexibleInstances #-} + +module T11711 where + +import Data.Kind (Type) + +data (:~~:) (a :: k1) (b :: k2) where + HRefl :: a :~~: a + +data TypeRep (a :: k) where + TrTyCon :: String -> TypeRep k -> TypeRep (a :: k) + TrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). + TypeRep (a :: k1 -> k2) + -> TypeRep (b :: k1) + -> TypeRep (a b) + +class Typeable (a :: k) where + typeRep :: TypeRep a + +data TypeRepX where + TypeRepX :: forall k (a :: k). TypeRep a -> TypeRepX + +eqTypeRep :: TypeRep a -> TypeRep b -> Maybe (a :~~: b) +eqTypeRep = undefined + +typeRepKind :: forall k (a :: k). TypeRep a -> TypeRep k +typeRepKind = undefined + +instance Typeable Type where + typeRep = TrTyCon "Type" typeRep + +funResultTy :: TypeRepX -> TypeRepX -> Maybe TypeRepX +funResultTy (TypeRepX f) (TypeRepX x) + | Just HRefl <- (typeRep :: TypeRep Type) `eqTypeRep` typeRepKind f + , TRFun arg res <- f + , Just HRefl <- arg `eqTypeRep` x + = Just (TypeRepX res) + | otherwise + = Nothing + +trArrow :: TypeRep (->) +trArrow = undefined + +pattern TRFun :: forall fun. () + => forall arg res. (fun ~ (arg -> res)) + => TypeRep arg + -> TypeRep res + -> TypeRep fun +pattern TRFun arg res <- TrApp (TrApp (eqTypeRep trArrow -> Just HRefl) arg) res diff --git a/testsuite/tests/dependent/should_compile/all.T b/testsuite/tests/dependent/should_compile/all.T index 783fa16..8ecd105 100644 --- a/testsuite/tests/dependent/should_compile/all.T +++ b/testsuite/tests/dependent/should_compile/all.T @@ -17,3 +17,4 @@ test('dynamic-paper', expect_fail_for(['optasm', 'optllvm']), compile, ['']) test('T11311', normal, compile, ['']) test('T11405', normal, compile, ['']) test('T11241', normal, compile, ['']) +test('T11711', normal, compile, ['']) diff --git a/testsuite/tests/patsyn/should_fail/mono.stderr b/testsuite/tests/patsyn/should_fail/mono.stderr index 2bed60e..20714e7 100644 --- a/testsuite/tests/patsyn/should_fail/mono.stderr +++ b/testsuite/tests/patsyn/should_fail/mono.stderr @@ -1,12 +1,12 @@ -mono.hs:7:4: - Couldn't match type ?Int? with ?Bool? - Expected type: [Bool] - Actual type: [Int] - In the pattern: Single x - In an equation for ?f?: f (Single x) = x +mono.hs:7:4: error: + ? Couldn't match type ?Bool? with ?Int? + Expected type: [Int] + Actual type: [Bool] + ? In the pattern: Single x + In an equation for ?f?: f (Single x) = x -mono.hs:7:16: - Couldn't match expected type ?Bool? with actual type ?Int? - In the expression: x - In an equation for ?f?: f (Single x) = x +mono.hs:7:16: error: + ? Couldn't match expected type ?Bool? with actual type ?Int? + ? In the expression: x + In an equation for ?f?: f (Single x) = x From git at git.haskell.org Thu Mar 17 14:05:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 17 Mar 2016 14:05:20 +0000 (UTC) Subject: [commit: ghc] master: typechecker: fix trac issue #11708 (c5ed41c) Message-ID: <20160317140520.1199C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c5ed41cbcaa40068763c8bd01badcada38cdbd03/ghc >--------------------------------------------------------------- commit c5ed41cbcaa40068763c8bd01badcada38cdbd03 Author: Csongor Kiss Date: Wed Mar 16 15:26:59 2016 -0400 typechecker: fix trac issue #11708 Summary: Fixes T11708 Reviewers: austin, bgamari, goldfire, simonpj Reviewed By: goldfire, simonpj Subscribers: simonpj, goldfire, thomie Differential Revision: https://phabricator.haskell.org/D2006 GHC Trac Issues: #11708 >--------------------------------------------------------------- c5ed41cbcaa40068763c8bd01badcada38cdbd03 compiler/typecheck/TcHsType.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index f931073..37a8675 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -938,8 +938,11 @@ tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon | otherwise = do { (tc_ty, kind) <- instantiateTyN 0 ty tc_kind - ; traceTc "tcTyVar2b" (vcat [ ppr tc <+> dcolon <+> ppr tc_kind - , ppr tc_ty $$ ppr kind ]) + -- tc and tc_ty must not be traced here, because that would + -- force the evaluation of a potentially knot-tied variable (tc), + -- and the typechecker would hang, as per #11708 + ; traceTc "tcTyVar2b" (vcat [ ppr tc_tc <+> dcolon <+> ppr tc_kind + , ppr kind ]) ; return (tc_ty, kind) } where ty = mkNakedTyConApp tc [] From git at git.haskell.org Thu Mar 17 14:05:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 17 Mar 2016 14:05:23 +0000 (UTC) Subject: [commit: ghc] master: Fix #11716. (3fe87aa) Message-ID: <20160317140523.6E0633A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3fe87aa00ac05f1abea22ea58d51ecc1e3073d19/ghc >--------------------------------------------------------------- commit 3fe87aa00ac05f1abea22ea58d51ecc1e3073d19 Author: Richard Eisenberg Date: Wed Mar 16 15:20:32 2016 -0400 Fix #11716. There were several smallish bugs here: - We had too small an InScopeSet when rejigging GADT return types. - When adding the extra_tvs with a datatype kind signature, we were sometimes changing Uniques of an explicitly bound kind var. - Using coercionKind in the flattener got the wrong visibility for a binder. Now we just zonk to get what we need. Test case: dependent/should_compile/RaeJobTalk >--------------------------------------------------------------- 3fe87aa00ac05f1abea22ea58d51ecc1e3073d19 compiler/typecheck/TcCanonical.hs | 4 +- compiler/typecheck/TcFlatten.hs | 4 +- compiler/typecheck/TcHsType.hs | 12 +- compiler/typecheck/TcPat.hs | 9 +- compiler/typecheck/TcTyClsDecls.hs | 7 +- compiler/typecheck/TcType.hs | 1 + .../tests/dependent/should_compile/RaeJobTalk.hs | 697 +++++++++++++++++++++ testsuite/tests/dependent/should_compile/all.T | 1 + 8 files changed, 723 insertions(+), 12 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 3fe87aa00ac05f1abea22ea58d51ecc1e3073d19 From git at git.haskell.org Thu Mar 17 14:05:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 17 Mar 2016 14:05:26 +0000 (UTC) Subject: [commit: ghc] master: Fix #11512 by getting visibility right for methods (f4f315a) Message-ID: <20160317140526.887083A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/f4f315a37470ce86e3eadeb328d0d3a9242f3097/ghc >--------------------------------------------------------------- commit f4f315a37470ce86e3eadeb328d0d3a9242f3097 Author: Richard Eisenberg Date: Wed Mar 16 23:37:30 2016 -0400 Fix #11512 by getting visibility right for methods Test case: typecheck/should_compile/T11512 >--------------------------------------------------------------- f4f315a37470ce86e3eadeb328d0d3a9242f3097 compiler/basicTypes/MkId.hs | 19 ++++++++++++++----- compiler/typecheck/TcExpr.hs | 5 ++++- .../tests/dependent/should_compile/RaeJobTalk.hs | 4 ++-- testsuite/tests/typecheck/should_compile/T11512.hs | 11 +++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/compiler/basicTypes/MkId.hs b/compiler/basicTypes/MkId.hs index 92d6b5e..5bab875 100644 --- a/compiler/basicTypes/MkId.hs +++ b/compiler/basicTypes/MkId.hs @@ -262,9 +262,6 @@ Then the top-level type for op is forall b. Ord b => a -> b -> b -This is unlike ordinary record selectors, which have all the for-alls -at the outside. When dealing with classes it's very convenient to -recover the original type signature from the class op selector. -} mkDictSelId :: Name -- Name of one of the *value* selectors @@ -278,11 +275,23 @@ mkDictSelId name clas new_tycon = isNewTyCon tycon [data_con] = tyConDataCons tycon tyvars = dataConUnivTyVars data_con + tc_binders = tyConBinders tycon arg_tys = dataConRepArgTys data_con -- Includes the dictionary superclasses val_index = assoc "MkId.mkDictSelId" (sel_names `zip` [0..]) name - sel_ty = mkSpecForAllTys tyvars (mkFunTy (mkClassPred clas (mkTyVarTys tyvars)) - (getNth arg_tys val_index)) + sel_ty = mkForAllTys (zipWith mk_binder tc_binders tyvars) $ + mkFunTy (mkClassPred clas (mkTyVarTys tyvars)) $ + getNth arg_tys val_index + + -- copy the visibility from the tycon binders. Consider: + -- class C a where foo :: Proxy a + -- In the type of foo, `a` must be Specified but `k` must be Invisible + mk_binder tc_binder tyvar + | Invisible <- binderVisibility tc_binder + = mkNamedBinder Invisible tyvar + | otherwise + = mkNamedBinder Specified tyvar -- don't just copy from tc_binder, because + -- tc_binders can be Visible base_info = noCafIdInfo `setArityInfo` 1 diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs index 23d0de9..4d6a109 100644 --- a/compiler/typecheck/TcExpr.hs +++ b/compiler/typecheck/TcExpr.hs @@ -1175,7 +1175,10 @@ tcArgs fun orig_fun_ty fun_orig orig_args herald ; case tcSplitForAllTy_maybe upsilon_ty of Just (binder, inner_ty) | Just tv <- binderVar_maybe binder -> - ASSERT( binderVisibility binder == Specified ) + ASSERT2( binderVisibility binder == Specified + , (vcat [ ppr fun_ty, ppr upsilon_ty, ppr binder + , ppr inner_ty, pprTvBndr tv + , ppr (binderVisibility binder) ]) ) do { let kind = tyVarKind tv ; ty_arg <- tcHsTypeApp hs_ty_arg kind ; let insted_ty = substTyWithUnchecked [tv] [ty_arg] inner_ty diff --git a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs index 705c0ef..c03503d 100644 --- a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs +++ b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs @@ -217,7 +217,7 @@ instance TyConAble RuntimeRep where tyCon = RuntimeRep -- Can't just define Typeable the way we want, because the instances -- overlap. So we have to mock up instance chains via closed type families. -class Typeable' (a :: k) (b :: Bool) where +class Typeable' a (b :: Bool) where typeRep' :: TypeRep a type family CheckPrim a where @@ -236,7 +236,7 @@ instance (Typeable a, Typeable b) => Typeable' (a b) 'False where typeRep' = TyApp typeRep typeRep typeRep :: forall a. Typeable a => TypeRep a -typeRep = typeRep' @_ @_ @(CheckPrim a) -- RAE: #11512 says we need the extra @_. +typeRep = typeRep' @_ @(CheckPrim a) ----------------------------- -- Useful instances diff --git a/testsuite/tests/typecheck/should_compile/T11512.hs b/testsuite/tests/typecheck/should_compile/T11512.hs new file mode 100644 index 0000000..49100e0 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11512.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds, TypeApplications, ScopedTypeVariables #-} + +module Bug where + +import Data.Proxy + +class C a where + foo :: Proxy a + +bar :: forall a. C a => Proxy a +bar = foo @a diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 7e6a175..267795b 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -509,3 +509,4 @@ test('T11246', normal, compile, ['']) test('T11608', normal, compile, ['']) test('T11401', normal, compile, ['']) test('T11699', normal, compile, ['']) +test('T11512', normal, compile, ['']) From git at git.haskell.org Sat Mar 19 19:23:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 19 Mar 2016 19:23:25 +0000 (UTC) Subject: [commit: ghc] master: Add test for #9646 (220a0b9) Message-ID: <20160319192325.115853A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/220a0b934c71a8844a14dd8cd67fa0e23f807182/ghc >--------------------------------------------------------------- commit 220a0b934c71a8844a14dd8cd67fa0e23f807182 Author: Erik de Castro Lopo Date: Wed Mar 16 20:19:28 2016 +1100 Add test for #9646 Test Plan: Test that it passes git HEAD and fails with GHC 7.8. Reviewers: bgamari, hvr, austin, goldfire, thomie Differential Revision: https://phabricator.haskell.org/D2009 GHC Trac Issues: #9646 >--------------------------------------------------------------- 220a0b934c71a8844a14dd8cd67fa0e23f807182 testsuite/tests/simplCore/T9646/Main.hs | 47 +++++++++ testsuite/tests/simplCore/T9646/Makefile | 9 ++ testsuite/tests/simplCore/T9646/Natural.hs | 84 ++++++++++++++++ testsuite/tests/simplCore/T9646/StrictPrim.hs | 70 +++++++++++++ testsuite/tests/simplCore/T9646/T9646.stdout | 5 + testsuite/tests/simplCore/T9646/Type.hs | 79 +++++++++++++++ .../tests/simplCore/T9646/cbits/primitive-memops.c | 25 +++++ .../tests/simplCore/T9646/cbits/primitive-memops.h | 10 ++ testsuite/tests/simplCore/T9646/readme.txt | 112 +++++++++++++++++++++ .../tests/{programs/lex => simplCore/T9646}/test.T | 2 +- 10 files changed, 442 insertions(+), 1 deletion(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 220a0b934c71a8844a14dd8cd67fa0e23f807182 From git at git.haskell.org Sun Mar 20 16:32:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 16:32:59 +0000 (UTC) Subject: [commit: ghc] master: Ensure T11702 always runs with optasm (c095ec5) Message-ID: <20160320163259.DFC253A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c095ec5d970ec3a3a00a1920c01f67df52d07060/ghc >--------------------------------------------------------------- commit c095ec5d970ec3a3a00a1920c01f67df52d07060 Author: Ben Gamari Date: Wed Mar 16 10:00:12 2016 +0100 Ensure T11702 always runs with optasm >--------------------------------------------------------------- c095ec5d970ec3a3a00a1920c01f67df52d07060 testsuite/tests/numeric/should_run/all.T | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T index 8c80305..d1f05fd 100644 --- a/testsuite/tests/numeric/should_run/all.T +++ b/testsuite/tests/numeric/should_run/all.T @@ -66,4 +66,4 @@ test('T9407', normal, compile_and_run, ['']) test('T9810', normal, compile_and_run, ['']) test('T10011', normal, compile_and_run, ['']) test('T10962', omit_ways(['ghci']), compile_and_run, ['']) -test('T11702', normal, compile_and_run, ['']) +test('T11702', extra_ways(['optasm']), compile_and_run, ['']) From git at git.haskell.org Sun Mar 20 16:33:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 16:33:02 +0000 (UTC) Subject: [commit: ghc] master: PrelRules: Fix constant folding for WordRemOp (3ddfcc9) Message-ID: <20160320163302.889B63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3ddfcc95cd41dac19c8f4d55e8fc03128b77b738/ghc >--------------------------------------------------------------- commit 3ddfcc95cd41dac19c8f4d55e8fc03128b77b738 Author: Ben Gamari Date: Mon Mar 14 13:27:00 2016 +0100 PrelRules: Fix constant folding for WordRemOp Test Plan: Validate with testcase in D2002 Reviewers: austin, simonpj Reviewed By: simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D2004 GHC Trac Issues: #11702 >--------------------------------------------------------------- 3ddfcc95cd41dac19c8f4d55e8fc03128b77b738 compiler/prelude/PrelRules.hs | 7 ++++++- testsuite/tests/numeric/should_run/all.T | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs index 314dd85..a57609a 100644 --- a/compiler/prelude/PrelRules.hs +++ b/compiler/prelude/PrelRules.hs @@ -134,7 +134,12 @@ primOpRules nm WordMulOp = mkPrimOpRule nm 2 [ binaryLit (wordOp2 (*)) primOpRules nm WordQuotOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 quot) , rightIdentityDynFlags onew ] primOpRules nm WordRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 rem) - , rightIdentityDynFlags onew ] + , leftZero zerow + , do l <- getLiteral 1 + dflags <- getDynFlags + guard (l == onew dflags) + retLit zerow + , equalArgs >> retLit zerow ] primOpRules nm AndOp = mkPrimOpRule nm 2 [ binaryLit (wordOp2 (.&.)) , idempotent , zeroElem zerow ] diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T index 515005f..8c80305 100644 --- a/testsuite/tests/numeric/should_run/all.T +++ b/testsuite/tests/numeric/should_run/all.T @@ -66,4 +66,4 @@ test('T9407', normal, compile_and_run, ['']) test('T9810', normal, compile_and_run, ['']) test('T10011', normal, compile_and_run, ['']) test('T10962', omit_ways(['ghci']), compile_and_run, ['']) -test('T11702', expect_broken(11702), compile_and_run, ['']) +test('T11702', normal, compile_and_run, ['']) From git at git.haskell.org Sun Mar 20 16:33:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 16:33:05 +0000 (UTC) Subject: [commit: ghc] master: Mark GHC.Real.even and odd as INLINEABLE (2841cca) Message-ID: <20160320163305.36CF73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2841ccab595ce38fb86b789574f057c3abe3d630/ghc >--------------------------------------------------------------- commit 2841ccab595ce38fb86b789574f057c3abe3d630 Author: Ben Gamari Date: Mon Mar 14 13:27:23 2016 +0100 Mark GHC.Real.even and odd as INLINEABLE Previously they were merely specialised at Int and Integer. It seems to me that these are cheap enough to be worth inlining. See #11701 for motivation. Test Plan: Validate Reviewers: austin, hvr, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1997 GHC Trac Issues: #11701 >--------------------------------------------------------------- 2841ccab595ce38fb86b789574f057c3abe3d630 libraries/base/GHC/Real.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/base/GHC/Real.hs b/libraries/base/GHC/Real.hs index 186be27..3a97f1f 100644 --- a/libraries/base/GHC/Real.hs +++ b/libraries/base/GHC/Real.hs @@ -463,10 +463,8 @@ showSigned showPos p x even, odd :: (Integral a) => a -> Bool even n = n `rem` 2 == 0 odd = not . even -{-# SPECIALISE even :: Int -> Bool #-} -{-# SPECIALISE odd :: Int -> Bool #-} -{-# SPECIALISE even :: Integer -> Bool #-} -{-# SPECIALISE odd :: Integer -> Bool #-} +{-# INLINEABLE even #-} +{-# INLINEABLE odd #-} ------------------------------------------------------- -- | raise a number to a non-negative integral power From git at git.haskell.org Sun Mar 20 16:33:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 16:33:08 +0000 (UTC) Subject: [commit: ghc] master: Revert "Add test for #11473" (c0f628d) Message-ID: <20160320163308.1BB483A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c0f628dc6f604028acc665e5b37019750a30c852/ghc >--------------------------------------------------------------- commit c0f628dc6f604028acc665e5b37019750a30c852 Author: Ben Gamari Date: Fri Mar 18 16:49:13 2016 +0100 Revert "Add test for #11473" This reverts commit 89bdac7635e6ed08927d760aa885d3e7ef3edb81 as this test is duplicated with dependent/should_fail/T11473, added by aade111248dce0834ed83dc4f18c234967b3202. >--------------------------------------------------------------- c0f628dc6f604028acc665e5b37019750a30c852 testsuite/tests/typecheck/should_fail/T11473.hs | 20 -------------------- testsuite/tests/typecheck/should_fail/all.T | 1 - 2 files changed, 21 deletions(-) diff --git a/testsuite/tests/typecheck/should_fail/T11473.hs b/testsuite/tests/typecheck/should_fail/T11473.hs deleted file mode 100644 index cb9f791..0000000 --- a/testsuite/tests/typecheck/should_fail/T11473.hs +++ /dev/null @@ -1,20 +0,0 @@ -{-# LANGUAGE PolyKinds, TypeFamilies, MagicHash, DataKinds, TypeInType, RankNTypes #-} - -module T11473 where -import GHC.Exts -import GHC.Types - -type family Boxed (a :: k) :: * -type instance Boxed Char# = Char -type instance Boxed Char = Char - -class BoxIt (a :: TYPE lev) where - boxed :: a -> Boxed a - -instance BoxIt Char# where boxed x = C# x -instance BoxIt Char where boxed = id - --- This should be an error: there is no way we can produce code for both Lifted --- and Unlifted levities -hello :: forall (lev :: Levity). forall (a :: TYPE lev). BoxIt a => a -> Boxed a -hello x = boxed x diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 485ac2f..c4510ea 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -406,7 +406,6 @@ test('T11347', normal, compile_fail, ['']) test('T11356', normal, compile_fail, ['']) test('T11355', normal, compile_fail, ['']) test('T11464', normal, compile_fail, ['']) -test('T11473', expect_broken(11473), compile_fail, ['']) test('T11563', normal, compile_fail, ['']) test('T11541', normal, compile_fail, ['']) test('T11313', normal, compile_fail, ['']) From git at git.haskell.org Sun Mar 20 16:33:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 16:33:10 +0000 (UTC) Subject: [commit: ghc] master: Fix duplicate T11334 test (cb7ecda) Message-ID: <20160320163310.BC8D03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/cb7ecdad9b56be1e2cbdf249664521d6261ccd71/ghc >--------------------------------------------------------------- commit cb7ecdad9b56be1e2cbdf249664521d6261ccd71 Author: Ben Gamari Date: Sun Mar 20 16:02:32 2016 +0100 Fix duplicate T11334 test >--------------------------------------------------------------- cb7ecdad9b56be1e2cbdf249664521d6261ccd71 libraries/base/tests/{T11334.hs => T11334a.hs} | 0 libraries/base/tests/{T11334.stdout => T11334a.stdout} | 0 libraries/base/tests/all.T | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/base/tests/T11334.hs b/libraries/base/tests/T11334a.hs similarity index 100% rename from libraries/base/tests/T11334.hs rename to libraries/base/tests/T11334a.hs diff --git a/libraries/base/tests/T11334.stdout b/libraries/base/tests/T11334a.stdout similarity index 100% rename from libraries/base/tests/T11334.stdout rename to libraries/base/tests/T11334a.stdout diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T index 574aba6..4ca3cda 100644 --- a/libraries/base/tests/all.T +++ b/libraries/base/tests/all.T @@ -211,5 +211,5 @@ test('T9848', compile_and_run, ['-O']) test('T10149', normal, compile_and_run, ['']) -test('T11334', normal, compile_and_run, ['']) +test('T11334a', normal, compile_and_run, ['']) test('T11555', normal, compile_and_run, ['']) \ No newline at end of file From git at git.haskell.org Sun Mar 20 16:33:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 16:33:13 +0000 (UTC) Subject: [commit: ghc] master: Fix T9646 (08d254b) Message-ID: <20160320163313.836AB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/08d254bc8452cdb12f852805f20d346ad4181ed8/ghc >--------------------------------------------------------------- commit 08d254bc8452cdb12f852805f20d346ad4181ed8 Author: Ben Gamari Date: Sun Mar 20 16:47:31 2016 +0100 Fix T9646 For #9646. >--------------------------------------------------------------- 08d254bc8452cdb12f852805f20d346ad4181ed8 testsuite/tests/simplCore/T9646/test.T | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tests/simplCore/T9646/test.T b/testsuite/tests/simplCore/T9646/test.T index 2baae52..1456217 100644 --- a/testsuite/tests/simplCore/T9646/test.T +++ b/testsuite/tests/simplCore/T9646/test.T @@ -2,5 +2,5 @@ test('T9646', [when(fast(), skip), extra_clean(['Main.hi', 'Main.o'])], multimod_compile_and_run, - ['Main', '']) + ['Main -ddump-simpl -ddump-to-file', '']) From git at git.haskell.org Sun Mar 20 21:11:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 21:11:51 +0000 (UTC) Subject: [commit: ghc] master: Dwarf: Add support for labels in unwind expressions (7186a01) Message-ID: <20160320211151.835713A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/7186a01ab4278102ec4e21d3cf67795d51973365/ghc >--------------------------------------------------------------- commit 7186a01ab4278102ec4e21d3cf67795d51973365 Author: Ben Gamari Date: Sun Mar 20 17:47:57 2016 +0100 Dwarf: Add support for labels in unwind expressions Test Plan: Look at DWARF output. Reviewers: scpmw, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1734 >--------------------------------------------------------------- 7186a01ab4278102ec4e21d3cf67795d51973365 compiler/cmm/Debug.hs | 3 +++ compiler/nativeGen/Dwarf/Constants.hs | 3 ++- compiler/nativeGen/Dwarf/Types.hs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/cmm/Debug.hs b/compiler/cmm/Debug.hs index fa4d645..7b93835 100644 --- a/compiler/cmm/Debug.hs +++ b/compiler/cmm/Debug.hs @@ -258,6 +258,7 @@ type UnwindTable = Map.Map GlobalReg UnwindExpr data UnwindExpr = UwConst Int -- ^ literal value | UwReg GlobalReg Int -- ^ register plus offset | UwDeref UnwindExpr -- ^ pointer dereferencing + | UwLabel CLabel | UwPlus UnwindExpr UnwindExpr | UwMinus UnwindExpr UnwindExpr | UwTimes UnwindExpr UnwindExpr @@ -268,6 +269,7 @@ instance Outputable UnwindExpr where pprPrec _ (UwReg g 0) = ppr g pprPrec p (UwReg g x) = pprPrec p (UwPlus (UwReg g 0) (UwConst x)) pprPrec _ (UwDeref e) = char '*' <> pprPrec 3 e + pprPrec _ (UwLabel l) = pprPrec 3 l pprPrec p (UwPlus e0 e1) | p <= 0 = pprPrec 0 e0 <> char '+' <> pprPrec 0 e1 pprPrec p (UwMinus e0 e1) | p <= 0 @@ -292,6 +294,7 @@ extractUnwind b = go $ blockToList mid -- possible. toUnwindExpr :: CmmExpr -> UnwindExpr toUnwindExpr (CmmLit (CmmInt i _)) = UwConst (fromIntegral i) +toUnwindExpr (CmmLit (CmmLabel l)) = UwLabel l toUnwindExpr (CmmRegOff (CmmGlobal g) i) = UwReg g i toUnwindExpr (CmmReg (CmmGlobal g)) = UwReg g 0 toUnwindExpr (CmmLoad e _) = UwDeref (toUnwindExpr e) diff --git a/compiler/nativeGen/Dwarf/Constants.hs b/compiler/nativeGen/Dwarf/Constants.hs index 40e4e7d..880c7d7 100644 --- a/compiler/nativeGen/Dwarf/Constants.hs +++ b/compiler/nativeGen/Dwarf/Constants.hs @@ -126,9 +126,10 @@ dW_CFA_val_expression = 0x16 dW_CFA_offset = 0x80 -- * Operations -dW_OP_deref, dW_OP_consts, +dW_OP_addr, dW_OP_deref, dW_OP_consts, dW_OP_minus, dW_OP_mul, dW_OP_plus, dW_OP_lit0, dW_OP_breg0, dW_OP_call_frame_cfa :: Word8 +dW_OP_addr = 0x03 dW_OP_deref = 0x06 dW_OP_consts = 0x11 dW_OP_minus = 0x1c diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs index e0214e5..0db2419 100644 --- a/compiler/nativeGen/Dwarf/Types.hs +++ b/compiler/nativeGen/Dwarf/Types.hs @@ -446,6 +446,7 @@ pprUnwindExpr spIsCFA expr pprE (UwReg g i) = pprByte (dW_OP_breg0+dwarfGlobalRegNo plat g) $$ pprLEBInt i pprE (UwDeref u) = pprE u $$ pprByte dW_OP_deref + pprE (UwLabel l) = pprByte dW_OP_addr $$ pprWord (ppr l) pprE (UwPlus u1 u2) = pprE u1 $$ pprE u2 $$ pprByte dW_OP_plus pprE (UwMinus u1 u2) = pprE u1 $$ pprE u2 $$ pprByte dW_OP_minus pprE (UwTimes u1 u2) = pprE u1 $$ pprE u2 $$ pprByte dW_OP_mul From git at git.haskell.org Sun Mar 20 21:11:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 21:11:54 +0000 (UTC) Subject: [commit: ghc] master: prof: Fix heap census for large ARR_WORDS (#11627) (ba95f22) Message-ID: <20160320211154.DBA4E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/ba95f22eb98cc2ee2d8d76e56df80769c379413d/ghc >--------------------------------------------------------------- commit ba95f22eb98cc2ee2d8d76e56df80769c379413d Author: Jason Eisenberg Date: Sun Mar 20 17:49:24 2016 +0100 prof: Fix heap census for large ARR_WORDS (#11627) The heap census now handles large ARR_WORDS objects which have been shrunk by shrinkMutableByteArray# or resizeMutableByteArray#. Test Plan: ./validate && make test WAY=profasm Reviewers: hvr, bgamari, austin, thomie Reviewed By: thomie Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2005 GHC Trac Issues: #11627 >--------------------------------------------------------------- ba95f22eb98cc2ee2d8d76e56df80769c379413d rts/ProfHeap.c | 14 ++++++++ .../should_run/T11627a.hs} | 1 + .../should_run/T11627a.stdout} | 0 testsuite/tests/profiling/should_run/T11627b.hs | 42 ++++++++++++++++++++++ testsuite/tests/profiling/should_run/all.T | 8 +++++ 5 files changed, 65 insertions(+) diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c index a7ea3eb..819faeb 100644 --- a/rts/ProfHeap.c +++ b/rts/ProfHeap.c @@ -937,6 +937,20 @@ heapCensusChain( Census *census, bdescr *bd ) } p = bd->start; + + // When we shrink a large ARR_WORDS, we do not adjust the free pointer + // of the associated block descriptor, thus introducing slop at the end + // of the object. This slop remains after GC, violating the assumption + // of the loop below that all slop has been eliminated (#11627). + // Consequently, we handle large ARR_WORDS objects as a special case. + if (bd->flags & BF_LARGE + && get_itbl((StgClosure *)p)->type == ARR_WORDS) { + size = arr_words_sizeW((StgArrBytes *)p); + prim = rtsTrue; + heapProfObject(census, (StgClosure *)p, size, prim); + continue; + } + while (p < bd->free) { info = get_itbl((StgClosure *)p); prim = rtsFalse; diff --git a/testsuite/tests/perf/space_leaks/space_leak_001.hs b/testsuite/tests/profiling/should_run/T11627a.hs similarity index 65% copy from testsuite/tests/perf/space_leaks/space_leak_001.hs copy to testsuite/tests/profiling/should_run/T11627a.hs index cabde0a..3e1ce3c 100644 --- a/testsuite/tests/perf/space_leaks/space_leak_001.hs +++ b/testsuite/tests/profiling/should_run/T11627a.hs @@ -1,3 +1,4 @@ +-- Original test case for #11627 (space_leak_001.hs) import Data.List diff --git a/testsuite/tests/perf/space_leaks/space_leak_001.stdout b/testsuite/tests/profiling/should_run/T11627a.stdout similarity index 100% copy from testsuite/tests/perf/space_leaks/space_leak_001.stdout copy to testsuite/tests/profiling/should_run/T11627a.stdout diff --git a/testsuite/tests/profiling/should_run/T11627b.hs b/testsuite/tests/profiling/should_run/T11627b.hs new file mode 100644 index 0000000..5e5545a --- /dev/null +++ b/testsuite/tests/profiling/should_run/T11627b.hs @@ -0,0 +1,42 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + + +-- A reduced test case for #11627 + + +import GHC.Prim +import GHC.Types (Int(..),IO(..)) +import System.Mem + + +main :: IO () +main = do + -- Allocate a large object (size >= 8/10 of one block = 8/10 * 4096 B) + let nBytes = 123 * 4096 + b <- newBlob nBytes + + -- Shrink it by at least one word + let delta = 100 + shrinkBlob b $ nBytes - delta + + -- Perform a heap census (assumes we are running with -i0, so a census is + -- run after every GC) + performGC + + -- Hold on to b so it is not GCed before the census + shrinkBlob b $ nBytes - delta + +------------------------------------------------------------------------------ + +data Blob = Blob# !(MutableByteArray# RealWorld) + +newBlob :: Int -> IO Blob +newBlob (I# n#) = + IO $ \s -> case newByteArray# n# s of + (# s', mba# #) -> (# s', Blob# mba# #) + +shrinkBlob :: Blob -> Int -> IO () +shrinkBlob (Blob# mba#) (I# n#) = + IO $ \s -> case shrinkMutableByteArray# mba# n# s of + s' -> (# s', () #) diff --git a/testsuite/tests/profiling/should_run/all.T b/testsuite/tests/profiling/should_run/all.T index 41597a4..c6ce6d4 100644 --- a/testsuite/tests/profiling/should_run/all.T +++ b/testsuite/tests/profiling/should_run/all.T @@ -98,3 +98,11 @@ test('callstack002', [], compile_and_run, test('T5363', [], compile_and_run, ['']) test('profinline001', [], compile_and_run, ['']) + +test('T11627a', [extra_ways(extra_prof_ways)], compile_and_run, ['']) + +test('T11627b', [ extra_run_opts('+RTS -i0 -RTS') # census after each GC + , extra_ways(extra_prof_ways) + ] + , compile_and_run + , ['']) From git at git.haskell.org Sun Mar 20 21:11:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 21:11:58 +0000 (UTC) Subject: [commit: ghc] master: Add test for incompatible flags (issue #11580) (289d57a) Message-ID: <20160320211158.0CD053A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/289d57a6894b5d3eb5daf696a75275a8146f0092/ghc >--------------------------------------------------------------- commit 289d57a6894b5d3eb5daf696a75275a8146f0092 Author: Kai Harries Date: Sun Mar 20 17:51:39 2016 +0100 Add test for incompatible flags (issue #11580) Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2013 GHC Trac Issues: #11580 >--------------------------------------------------------------- 289d57a6894b5d3eb5daf696a75275a8146f0092 testsuite/tests/safeHaskell/flags/SafeFlags30.hs | 7 +++++++ testsuite/tests/safeHaskell/flags/SafeFlags30.stderr | 3 +++ testsuite/tests/safeHaskell/flags/all.T | 1 + 3 files changed, 11 insertions(+) diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags30.hs b/testsuite/tests/safeHaskell/flags/SafeFlags30.hs new file mode 100644 index 0000000..27790a4 --- /dev/null +++ b/testsuite/tests/safeHaskell/flags/SafeFlags30.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE Safe, Unsafe, Trustworthy #-} +-- | Basic test to see that incompatible flags give a nice error +-- message and ghc do not panic (see issue #11580). +module SafeFlags30 where + +f :: Int +f = 1 diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags30.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags30.stderr new file mode 100644 index 0000000..11ff3a6 --- /dev/null +++ b/testsuite/tests/safeHaskell/flags/SafeFlags30.stderr @@ -0,0 +1,3 @@ +ghc: SafeFlags30.hs:1:20-25: Incompatible Safe Haskell flags! (Safe, Unsafe) +SafeFlags30.hs:1:28-38: Incompatible Safe Haskell flags! (Safe, Trustworthy) +Usage: For basic information, try the `--help' option. diff --git a/testsuite/tests/safeHaskell/flags/all.T b/testsuite/tests/safeHaskell/flags/all.T index fff8841..0fa30e5 100644 --- a/testsuite/tests/safeHaskell/flags/all.T +++ b/testsuite/tests/safeHaskell/flags/all.T @@ -62,3 +62,4 @@ test('SafeFlags29', normal, compile_fail, ['']) test('Flags01', normal, compile, ['-XSafe']) test('Flags02', normal, compile, ['-XSafe']) +test('SafeFlags30', normal, compile_fail, ['']) From git at git.haskell.org Sun Mar 20 21:12:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 21:12:01 +0000 (UTC) Subject: [commit: ghc] master: base: Rework System.CPUTime (cb3456d) Message-ID: <20160320211201.9DB803A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/cb3456d82eaa8cea6b393273f0c81c57fb760ee5/ghc >--------------------------------------------------------------- commit cb3456d82eaa8cea6b393273f0c81c57fb760ee5 Author: Ben Gamari Date: Sun Mar 20 17:56:24 2016 +0100 base: Rework System.CPUTime This started when I noticed that `getCPUTime` only provides 1 millisecond resolution on Linux. Unfortunately the previous implementation was quite unmaintainable, so this ended up being a bit more involved than I expected. Here we do several things, * Split up `System.CPUTime` * Add support for `clock_gettime`, allowing for significantly more precise timing information when available * Fix System.CPUTime resolution for Windows. While it's hard to get reliable numbers, the consensus is that Windows only provides 16 millisecond resolution in GetProcessTimes (see Python PEP 0418 [1]) * Eliminate terrible hack wherein we would cast between `CTime` and `Integer` through `Double` [1] https://www.python.org/dev/peps/pep-0418/#id59 Test Plan: Validate on various platforms Reviewers: austin, hvr, erikd Reviewed By: erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2001 >--------------------------------------------------------------- cb3456d82eaa8cea6b393273f0c81c57fb760ee5 libraries/base/System/CPUTime.hsc | 148 ++++----------------- .../base/System/CPUTime/Posix/ClockGetTime.hsc | 55 ++++++++ libraries/base/System/CPUTime/Posix/RUsage.hsc | 42 ++++++ libraries/base/System/CPUTime/Posix/Times.hsc | 39 ++++++ libraries/base/System/CPUTime/Unsupported.hs | 20 +++ libraries/base/System/CPUTime/Utils.hs | 19 +++ libraries/base/System/CPUTime/Windows.hsc | 66 +++++++++ libraries/base/base.cabal | 8 ++ 8 files changed, 276 insertions(+), 121 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc cb3456d82eaa8cea6b393273f0c81c57fb760ee5 From git at git.haskell.org Sun Mar 20 21:12:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 21:12:04 +0000 (UTC) Subject: [commit: ghc] master: DsExpr: Don't build/foldr huge lists (b735e99) Message-ID: <20160320211204.4B4473A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/b735e99d79448bd7f416b35d8b0473d8eb5271f1/ghc >--------------------------------------------------------------- commit b735e99d79448bd7f416b35d8b0473d8eb5271f1 Author: Ben Gamari Date: Sun Mar 20 17:49:58 2016 +0100 DsExpr: Don't build/foldr huge lists Desugaring long lists with build trades large static data for large code, which is likely a poor trade-off. See #11707. Test Plan: Validate, nofib Reviewers: simonpj, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2007 GHC Trac Issues: #11707 >--------------------------------------------------------------- b735e99d79448bd7f416b35d8b0473d8eb5271f1 compiler/deSugar/DsExpr.hs | 29 ++++++++++++++++++++++++++++- testsuite/tests/perf/compiler/all.T | 3 ++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/compiler/deSugar/DsExpr.hs b/compiler/deSugar/DsExpr.hs index 59c8c4d..8a64a68 100644 --- a/compiler/deSugar/DsExpr.hs +++ b/compiler/deSugar/DsExpr.hs @@ -788,6 +788,12 @@ allocation in some nofib programs. Specifically Of course, if rules aren't turned on then there is pretty much no point doing this fancy stuff, and it may even be harmful. +Moreover, for large lists (with a dynamic prefix longer than maxBuildLength) we +choose not to perform this optimization as it will trade large static data for +large code, which is generally a poor trade-off. See #11707 and the +documentation for maxBuildLength. + + =======> Note by SLPJ Dec 08. I'm unconvinced that we should *ever* generate a build for an explicit @@ -803,10 +809,29 @@ We do not want to generate a build invocation on the LHS of this RULE! We fix this by disabling rules in rule LHSs, and testing that flag here; see Note [Desugaring RULE left hand sides] in Desugar -To test this I've added a (static) flag -fsimple-list-literals, which +To test this I've added a flag -fsimple-list-literals, which makes all list literals be generated via the simple route. -} +{- | The longest list length which we will desugar using @build at . + +This is essentially a magic number and its setting is unfortunate rather +arbitrary. The idea here, as mentioned in Note [Desugaring explicit lists], +is to avoid deforesting large static data into large(r) code. Ideally we'd +want a smaller threshold with larger consumers and vice-versa, but we have no +way of knowing what will be consuming our list in the desugaring impossible to +set generally correctly. + +The effect of reducing this number will be that 'build' fusion is applied +less often. From a runtime performance perspective, applying 'build' more +liberally on "moderately" sized lists should rarely hurt and will often it can +only expose further optimization opportunities; if no fusion is possible it will +eventually get rule-rewritten back to a list). We do, however, pay in compile +time. +-} +maxBuildLength :: Int +maxBuildLength = 32 + dsExplicitList :: Type -> Maybe (SyntaxExpr Id) -> [LHsExpr Id] -> DsM CoreExpr -- See Note [Desugaring explicit lists] @@ -815,6 +840,8 @@ dsExplicitList elt_ty Nothing xs ; xs' <- mapM dsLExpr xs ; let (dynamic_prefix, static_suffix) = spanTail is_static xs' ; if gopt Opt_SimpleListLiterals dflags -- -fsimple-list-literals + || length dynamic_prefix > maxBuildLength + -- Don't generate builds if the list is very long. || not (gopt Opt_EnableRewriteRules dflags) -- Rewrite rules off -- Don't generate a build if there are no rules to eliminate it! -- See Note [Desugaring RULE left hand sides] in Desugar diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index c19d51d..a1ebe11 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -722,12 +722,13 @@ test('T9872d', test('T9961', [ only_ways(['normal']), compiler_stats_num_field('bytes allocated', - [(wordsize(64), 745044392, 5), + [(wordsize(64), 519436672, 5), # 2015-01-12 807117816 Initally created # 2015-spring 772510192 Got better # 2015-05-22 663978160 Fix for #10370 improves it more # 2015-10-28 708680480 x86_64/Linux Emit Typeable at definition site # 2015-12-17 745044392 x86_64/Darwin Creep upwards + # 2016-03-20 519436672 x64_64/Linux Don't use build desugaring for large lists (D2007) (wordsize(32), 375647160, 5) ]), ], From git at git.haskell.org Sun Mar 20 21:12:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 21:12:06 +0000 (UTC) Subject: [commit: ghc] master: T11145: Fix expected output (e6a44f2) Message-ID: <20160320211206.E9D2A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e6a44f2ae38aaa53834297305030d1b462d8b039/ghc >--------------------------------------------------------------- commit e6a44f2ae38aaa53834297305030d1b462d8b039 Author: Ben Gamari Date: Sun Mar 20 20:44:19 2016 +0100 T11145: Fix expected output The uniques seem to keep changing here. >--------------------------------------------------------------- e6a44f2ae38aaa53834297305030d1b462d8b039 testsuite/tests/th/T11145.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tests/th/T11145.stderr b/testsuite/tests/th/T11145.stderr index d198739..98e518c 100644 --- a/testsuite/tests/th/T11145.stderr +++ b/testsuite/tests/th/T11145.stderr @@ -3,6 +3,6 @@ T11145.hs:8:1: error: ? Data constructor ?MkFuggle? returns type ?Fuggle Int (Maybe Bool)? instead of an instance of its parent type ?Fuggle - Int (Maybe (a_a4MT, b_a4MU))? + Int (Maybe (a_a4MU, b_a4MV))? ? In the definition of data constructor ?MkFuggle? In the data instance declaration for ?Fuggle? From git at git.haskell.org Sun Mar 20 23:32:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 20 Mar 2016 23:32:33 +0000 (UTC) Subject: [commit: ghc] master: base: Fix CPUTime on Windows (286c65f) Message-ID: <20160320233233.016D13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/286c65f2c7b193311d0710e7de30f4e8c76a84cf/ghc >--------------------------------------------------------------- commit 286c65f2c7b193311d0710e7de30f4e8c76a84cf Author: Ben Gamari Date: Sun Mar 20 22:15:46 2016 +0100 base: Fix CPUTime on Windows Arg, silly CPP. >--------------------------------------------------------------- 286c65f2c7b193311d0710e7de30f4e8c76a84cf libraries/base/System/CPUTime/Windows.hsc | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/libraries/base/System/CPUTime/Windows.hsc b/libraries/base/System/CPUTime/Windows.hsc index d1ca856..3f8c9ea 100644 --- a/libraries/base/System/CPUTime/Windows.hsc +++ b/libraries/base/System/CPUTime/Windows.hsc @@ -1,4 +1,4 @@ -{-# LANGUAGE CPP, CApiFFI, NumDecimals #-} +{-# LANGUAGE CPP, CApiFFI, NondecreasingIndentation, NumDecimals #-} #include "HsFFI.h" #include "HsBaseConfig.h" @@ -8,7 +8,6 @@ module System.CPUTime.Windows , getCpuTimePrecision ) where -import Data.Ratio import Foreign import Foreign.C @@ -17,16 +16,6 @@ import Foreign.C #include #endif -#ifdef mingw32_HOST_OS -# if defined(i386_HOST_ARCH) -# define WINDOWS_CCONV stdcall -# elif defined(x86_64_HOST_ARCH) -# define WINDOWS_CCONV ccall -# else -# error Unknown mingw32 arch -# endif -#endif - getCPUTime :: IO Integer getCPUTime = do -- NOTE: GetProcessTimes() is only supported on NT-based OSes. @@ -61,6 +50,14 @@ getCpuTimePrecision = return 16e9 type FILETIME = () type HANDLE = () + -- need proper Haskell names (initial lower-case character) -foreign import WINDOWS_CCONV unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE) -foreign import WINDOWS_CCONV unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt +#if defined(i386_HOST_ARCH) +foreign import stdcall unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE) +foreign import stdcall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt +#elif defined(x86_64_HOST_ARCH) +foreign import ccall unsafe "GetCurrentProcess" getCurrentProcess :: IO (Ptr HANDLE) +foreign import ccall unsafe "GetProcessTimes" getProcessTimes :: Ptr HANDLE -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> Ptr FILETIME -> IO CInt +#else +#error Unknown mingw32 arch +#endif From git at git.haskell.org Mon Mar 21 10:30:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 10:30:52 +0000 (UTC) Subject: [commit: ghc] master: Delete a misleading comment in TyCon (3ade8bc) Message-ID: <20160321103052.B132F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3ade8bc790c74c676f75001373247835d3b23ff5/ghc >--------------------------------------------------------------- commit 3ade8bc790c74c676f75001373247835d3b23ff5 Author: Bartosz Nitka Date: Mon Mar 21 03:30:59 2016 -0700 Delete a misleading comment in TyCon `Ord` for `TyCon` uses `Uniques` and it's not lexicographic. I did some archeology and in rGHC6c381e873e222417d9a67aeec77b9555eca7b7a8 the comment was introduced, where there was something like `Ord3 Tycon` which *was* lexicographic. In rGHC9dd6e1c216993624a2cd74b62ca0f0569c02c26b `Ord3 TyCon` was already not lexicographic and `Ord3` got removed. Test Plan: make someone take a look Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2017 >--------------------------------------------------------------- 3ade8bc790c74c676f75001373247835d3b23ff5 compiler/types/TyCon.hs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs index 3c0a945..b980c9b 100644 --- a/compiler/types/TyCon.hs +++ b/compiler/types/TyCon.hs @@ -2026,9 +2026,6 @@ tyConRuntimeRepInfo _ = NoRRI ************************************************************************ @TyCon at s are compared by comparing their @Unique at s. - -The strictness analyser needs @Ord at . It is a lexicographic order with -the property @(a<=b) || (b<=a)@. -} instance Eq TyCon where From git at git.haskell.org Mon Mar 21 10:40:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 10:40:36 +0000 (UTC) Subject: [commit: ghc] master: Remove unnecessary Ord instance for ConLike (2cb5577) Message-ID: <20160321104036.3AD163A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2cb55772c5359e5d71d34e5d42a4a7deb6a5d3db/ghc >--------------------------------------------------------------- commit 2cb55772c5359e5d71d34e5d42a4a7deb6a5d3db Author: Bartosz Nitka Date: Mon Mar 21 03:34:03 2016 -0700 Remove unnecessary Ord instance for ConLike The Ord instance for ConLike uses Unique order which is bad for determinism. Fortunately it's not used, so we can just delete it. The is part of the effort to make Unique comparisons explicit. Test Plan: ./validate Reviewers: austin, simonmar, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2018 GHC Trac Issues: #4012 >--------------------------------------------------------------- 2cb55772c5359e5d71d34e5d42a4a7deb6a5d3db compiler/basicTypes/ConLike.hs | 9 +++------ compiler/basicTypes/ConLike.hs-boot | 1 - compiler/types/TyCoRep.hs | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/basicTypes/ConLike.hs b/compiler/basicTypes/ConLike.hs index c25f822..69d1836 100644 --- a/compiler/basicTypes/ConLike.hs +++ b/compiler/basicTypes/ConLike.hs @@ -65,12 +65,9 @@ instance Eq ConLike where (==) = (==) `on` getUnique (/=) = (/=) `on` getUnique -instance Ord ConLike where - (<=) = (<=) `on` getUnique - (<) = (<) `on` getUnique - (>=) = (>=) `on` getUnique - (>) = (>) `on` getUnique - compare = compare `on` getUnique +-- There used to be an Ord ConLike instance here that used Unique for ordering. +-- It was intentionally removed to prevent determinism problems. +-- See Note [Unique Determinism] in Unique. instance Uniquable ConLike where getUnique (RealDataCon dc) = getUnique dc diff --git a/compiler/basicTypes/ConLike.hs-boot b/compiler/basicTypes/ConLike.hs-boot index 3463287..c915364 100644 --- a/compiler/basicTypes/ConLike.hs-boot +++ b/compiler/basicTypes/ConLike.hs-boot @@ -11,7 +11,6 @@ data ConLike = RealDataCon DataCon instance Eq ConLike instance Typeable ConLike -instance Ord ConLike instance NamedThing ConLike instance Data ConLike instance Outputable ConLike diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index fa123a0..6fe1ce3 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -1456,7 +1456,7 @@ data TyThing | AConLike ConLike | ATyCon TyCon -- TyCons and classes; see Note [ATyCon for classes] | ACoAxiom (CoAxiom Branched) - deriving (Eq, Ord) + deriving (Eq) instance Outputable TyThing where ppr = pprTyThing From git at git.haskell.org Mon Mar 21 12:31:48 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 12:31:48 +0000 (UTC) Subject: [commit: ghc] master: Remove unused substTyWithBinders functions (c37a583) Message-ID: <20160321123148.0AE293A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c37a583fb9059053f83f1ab0c3cb7eb7047b1a31/ghc >--------------------------------------------------------------- commit c37a583fb9059053f83f1ab0c3cb7eb7047b1a31 Author: Bartosz Nitka Date: Mon Mar 21 05:33:44 2016 -0700 Remove unused substTyWithBinders functions Originally I wanted to only remove substTyWithBindersUnchecked, but since both of them are unused maybe we don't need them. Test Plan: ./validate Reviewers: austin, goldfire, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2025 GHC Trac Issues: #11371 >--------------------------------------------------------------- c37a583fb9059053f83f1ab0c3cb7eb7047b1a31 compiler/typecheck/TcType.hs | 2 +- compiler/types/TyCoRep.hs | 26 ++------------------------ compiler/types/Type.hs | 2 +- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs index 5b37a00..cf3b317 100644 --- a/compiler/typecheck/TcType.hs +++ b/compiler/typecheck/TcType.hs @@ -156,7 +156,7 @@ module TcType ( Type.substTy, substTys, substTyWith, substTyWithCoVars, substTyAddInScope, substTyUnchecked, substTysUnchecked, substThetaUnchecked, - substTyWithBindersUnchecked, substTyWithUnchecked, + substTyWithUnchecked, substCoUnchecked, substCoWithUnchecked, substTheta, diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index 6fe1ce3..9a2036a 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -97,9 +97,9 @@ module TyCoRep ( substCoWith, substTy, substTyAddInScope, substTyUnchecked, substTysUnchecked, substThetaUnchecked, - substTyWithBindersUnchecked, substTyWithUnchecked, + substTyWithUnchecked, substCoUnchecked, substCoWithUnchecked, - substTyWithBinders, substTyWithInScope, + substTyWithInScope, substTys, substTheta, lookupTyVar, substTyVarBndr, substCo, substCos, substCoVar, substCoVars, lookupCoVar, @@ -1944,28 +1944,6 @@ substTysWithCoVars :: [CoVar] -> [Coercion] -> [Type] -> [Type] substTysWithCoVars cvs cos = ASSERT( length cvs == length cos ) substTys (zipCvSubst cvs cos) --- | Type substitution using 'Binder's. Anonymous binders --- simply ignore their matching type. -substTyWithBinders :: --- CallStack wasn't present in GHC 7.10.1, disable callstacks in stage 1 -#if MIN_VERSION_GLASGOW_HASKELL(7,10,2,0) - (?callStack :: CallStack) => -#endif - [TyBinder] -> [Type] -> Type -> Type -substTyWithBinders bndrs tys = ASSERT( length bndrs == length tys ) - substTy (zipTyBinderSubst bndrs tys) - --- | Type substitution using 'Binder's disabling the sanity checks. --- Anonymous binders simply ignore their matching type. --- The problems that the sanity checks in substTy catch are described in --- Note [The substitution invariant]. --- The goal of #11371 is to migrate all the calls of substTyUnchecked to --- substTy and remove this function. Please don't use in new code. -substTyWithBindersUnchecked :: [TyBinder] -> [Type] -> Type -> Type -substTyWithBindersUnchecked bndrs tys - = ASSERT( length bndrs == length tys ) - substTyUnchecked (zipTyBinderSubst bndrs tys) - -- | Substitute within a 'Type' after adding the free variables of the type -- to the in-scope set. This is useful for the case when the free variables -- aren't already in the in-scope set or easily available. diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index a3efac0..f7aea67 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -166,7 +166,7 @@ module Type ( substTy, substTys, substTyWith, substTysWith, substTheta, substTyAddInScope, substTyUnchecked, substTysUnchecked, substThetaUnchecked, - substTyWithBindersUnchecked, substTyWithUnchecked, + substTyWithUnchecked, substCoUnchecked, substCoWithUnchecked, substTyVarBndr, substTyVar, substTyVars, cloneTyVarBndr, cloneTyVarBndrs, lookupTyVar, From git at git.haskell.org Mon Mar 21 15:13:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 15:13:20 +0000 (UTC) Subject: [commit: ghc] branch 'wip/T10613' created Message-ID: <20160321151320.DDB2E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc New branch : wip/T10613 Referencing: 06961f82505942965adbb8ee88c98ebadb610022 From git at git.haskell.org Mon Mar 21 15:13:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 15:13:23 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Remove all mentions of IND_OLDGEN outside of docs/rts (fe95ed2) Message-ID: <20160321151323.992B03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/fe95ed2f8c1461baa39b8112c352ea03390c3812/ghc >--------------------------------------------------------------- commit fe95ed2f8c1461baa39b8112c352ea03390c3812 Author: Joachim Breitner Date: Fri Jan 22 10:31:25 2016 +0100 Remove all mentions of IND_OLDGEN outside of docs/rts >--------------------------------------------------------------- fe95ed2f8c1461baa39b8112c352ea03390c3812 compiler/codeGen/StgCmmProf.hs | 3 +-- rts/sm/Scav.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs index c1b149d..434d7b5 100644 --- a/compiler/codeGen/StgCmmProf.hs +++ b/compiler/codeGen/StgCmmProf.hs @@ -328,8 +328,7 @@ ldvRecordCreate closure = do -- -- | Called when a closure is entered, marks the closure as having -- been "used". The closure is not an "inherently used" one. The --- closure is not @IND@ or @IND_OLDGEN@ because neither is considered --- for LDV profiling. +-- closure is not @IND@ because that is not considered for LDV profiling. -- ldvEnterClosure :: ClosureInfo -> CmmReg -> FCode () ldvEnterClosure closure_info node_reg = do diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index 953f055..abb7726 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -1533,7 +1533,7 @@ scavenge_one(StgPtr p) } else { size = gen->scan - start; } - debugBelch("evac IND_OLDGEN: %ld bytes", size * sizeof(W_)); + debugBelch("evac IND: %ld bytes", size * sizeof(W_)); } #endif break; From git at git.haskell.org Mon Mar 21 15:13:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 15:13:26 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Be more explicit about thunk types in ticky-ticky-report (e222a63) Message-ID: <20160321151326.4B7793A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/e222a63fd871ce92de85177d616b399c10bbed0c/ghc >--------------------------------------------------------------- commit e222a63fd871ce92de85177d616b399c10bbed0c Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Be more explicit about thunk types in ticky-ticky-report and also, for standard thunks (AP and selector), do not count an entry when they are allocated. It is not possible to count their entries, as their code is shared, but better count nothing than count the wrong thing. (The removed line was added in 11a85cc7ea50d4b7c12ea2cc3c0ce39734dc4217) >--------------------------------------------------------------- e222a63fd871ce92de85177d616b399c10bbed0c compiler/codeGen/StgCmmBind.hs | 10 ++++--- compiler/codeGen/StgCmmTicky.hs | 62 ++++++++++++++++++++++++++++++----------- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index f34186a..b265153 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -206,7 +206,7 @@ cgRhs :: Id ) cgRhs id (StgRhsCon cc con args) - = withNewTickyCounterThunk False (idName id) $ -- False for "not static" + = withNewTickyCounterCon (idName id) $ buildDynCon id True cc con args {- See Note [GC recovery] in compiler/codeGen/StgCmmClosure.hs -} @@ -386,7 +386,7 @@ cgRhsStdThunk bndr lf_info payload } where gen_code reg -- AHA! A STANDARD-FORM THUNK - = withNewTickyCounterStdThunk False (idName bndr) $ -- False for "not static" + = withNewTickyCounterStdThunk (lfUpdatable lf_info) (idName bndr) $ do { -- LAY OUT THE OBJECT mod_name <- getModuleName @@ -402,7 +402,6 @@ cgRhsStdThunk bndr lf_info payload -- ; (use_cc, blame_cc) <- chooseDynCostCentres cc [{- no args-}] body ; let use_cc = curCCS; blame_cc = curCCS - ; tickyEnterStdThunk closure_info -- BUILD THE OBJECT ; let info_tbl = mkCmmInfo closure_info @@ -453,7 +452,10 @@ closureCodeBody :: Bool -- whether this is a top-level binding closureCodeBody top_lvl bndr cl_info cc _args arity body fv_details | arity == 0 -- No args i.e. thunk - = withNewTickyCounterThunk (isStaticClosure cl_info) (closureName cl_info) $ + = withNewTickyCounterThunk + (isStaticClosure cl_info) + (closureUpdReqd cl_info) + (closureName cl_info) $ emitClosureProcAndInfoTable top_lvl bndr lf_info info_tbl [] $ \(_, node, _) -> thunkCode cl_info fv_details cc node arity body where diff --git a/compiler/codeGen/StgCmmTicky.hs b/compiler/codeGen/StgCmmTicky.hs index 95dfa99..45b88da 100644 --- a/compiler/codeGen/StgCmmTicky.hs +++ b/compiler/codeGen/StgCmmTicky.hs @@ -70,6 +70,7 @@ module StgCmmTicky ( withNewTickyCounterLNE, withNewTickyCounterThunk, withNewTickyCounterStdThunk, + withNewTickyCounterCon, tickyDynAlloc, tickyAllocHeap, @@ -143,7 +144,13 @@ import Control.Monad ( unless, when ) -- ----------------------------------------------------------------------------- -data TickyClosureType = TickyFun | TickyThunk | TickyLNE +data TickyClosureType + = TickyFun + | TickyCon + | TickyThunk + Bool -- ^ True <-> updateable + Bool -- ^ True <-> standard thunk (AP or selector), has no entry counter + | TickyLNE withNewTickyCounterFun, withNewTickyCounterLNE :: Name -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterFun = withNewTickyCounter TickyFun @@ -152,15 +159,38 @@ withNewTickyCounterLNE nm args code = do b <- tickyLNEIsOn if not b then code else withNewTickyCounter TickyLNE nm args code -withNewTickyCounterThunk,withNewTickyCounterStdThunk :: - Bool -> Name -> FCode a -> FCode a -withNewTickyCounterThunk isStatic name code = do +withNewTickyCounterThunk + :: Bool -- ^ static + -> Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterThunk isStatic isUpdatable name code = do b <- tickyDynThunkIsOn if isStatic || not b -- ignore static thunks then code - else withNewTickyCounter TickyThunk name [] code + else withNewTickyCounter (TickyThunk isUpdatable False) name [] code + +withNewTickyCounterStdThunk + :: Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterStdThunk isUpdatable name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter (TickyThunk isUpdatable True) name [] code -withNewTickyCounterStdThunk = withNewTickyCounterThunk +withNewTickyCounterCon + :: Name + -> FCode a + -> FCode a +withNewTickyCounterCon name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter TickyCon name [] code -- args does not include the void arguments withNewTickyCounter :: TickyClosureType -> Name -> [NonVoid Id] -> FCode a -> FCode a @@ -184,21 +214,21 @@ emitTickyCounter cloType name args ; let ppr_for_ticky_name :: SDoc ppr_for_ticky_name = let n = ppr name + ext = case cloType of + TickyFun -> empty + TickyCon -> parens (text "con") + TickyThunk upd std -> parens $ hcat $ punctuate comma $ + [text "thk"] ++ [text "se"|not upd] ++ [text "std"|std] + TickyLNE | isInternalName name -> parens (text "LNE") + | otherwise -> panic "emitTickyCounter: how is this an external LNE?" p = case hasHaskellName parent of -- NB the default "top" ticky ctr does not -- have a Haskell name Just pname -> text "in" <+> ppr (nameUnique pname) _ -> empty - in (<+> p) $ if isInternalName name - then let s = n <+> (parens (ppr mod_name)) - in case cloType of - TickyFun -> s - TickyThunk -> s <+> parens (text "thk") - TickyLNE -> s <+> parens (text "LNE") - else case cloType of - TickyFun -> n - TickyThunk -> n <+> parens (text "thk") - TickyLNE -> panic "emitTickyCounter: how is this an external LNE?" + in if isInternalName name + then n <+> parens (ppr mod_name) <+> ext <+> p + else n <+> ext <+> p ; fun_descr_lit <- newStringCLit $ showSDocDebug dflags ppr_for_ticky_name ; arg_descr_lit <- newStringCLit $ map (showTypeCategory . idType . unsafe_stripNV) args From git at git.haskell.org Mon Mar 21 15:13:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 15:13:28 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Ticky: Do not count every entry twice (a29db5b) Message-ID: <20160321151328.EE6723A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/a29db5bf1a2971c343b10f3fce90dea5ab440e29/ghc >--------------------------------------------------------------- commit a29db5bf1a2971c343b10f3fce90dea5ab440e29 Author: Joachim Breitner Date: Thu Mar 17 17:25:36 2016 +0100 Ticky: Do not count every entry twice (likely introduced by 99d4e5b4a0bd32813ff8c74e91d2dcf6b3555176, possibly due to a merge mistake). >--------------------------------------------------------------- a29db5bf1a2971c343b10f3fce90dea5ab440e29 compiler/codeGen/StgCmmBind.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index b265153..eae599c 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -578,8 +578,7 @@ thunkCode cl_info fv_details _cc node arity body -- that cc of enclosing scope will be recorded -- in update frame CAF/DICT functions will be -- subsumed by this enclosing cc - do { tickyEnterThunk cl_info - ; enterCostCentreThunk (CmmReg nodeReg) + do { enterCostCentreThunk (CmmReg nodeReg) ; let lf_info = closureLFInfo cl_info ; fv_bindings <- mapM bind_fv fv_details ; load_fvs node lf_info fv_bindings From git at git.haskell.org Mon Mar 21 15:13:31 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 15:13:31 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (06961f8) Message-ID: <20160321151331.D67D83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/06961f82505942965adbb8ee88c98ebadb610022/ghc >--------------------------------------------------------------- commit 06961f82505942965adbb8ee88c98ebadb610022 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- 06961f82505942965adbb8ee88c98ebadb610022 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 22 +++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 16 ++++++-- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 324 insertions(+), 87 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 06961f82505942965adbb8ee88c98ebadb610022 From git at git.haskell.org Mon Mar 21 16:01:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 16:01:47 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (f42ba66) Message-ID: <20160321160147.BB9533A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/f42ba666b62c26b7cdd8f2093b490b2912cd62a8/ghc >--------------------------------------------------------------- commit f42ba666b62c26b7cdd8f2093b490b2912cd62a8 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- f42ba666b62c26b7cdd8f2093b490b2912cd62a8 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 22 +++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 327 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc f42ba666b62c26b7cdd8f2093b490b2912cd62a8 From git at git.haskell.org Mon Mar 21 17:05:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:05:10 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (40bc83c) Message-ID: <20160321170510.1A9DE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/40bc83c0af9e019dd6a4cc2bc73b893188fa63bf/ghc >--------------------------------------------------------------- commit 40bc83c0af9e019dd6a4cc2bc73b893188fa63bf Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- 40bc83c0af9e019dd6a4cc2bc73b893188fa63bf compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 40bc83c0af9e019dd6a4cc2bc73b893188fa63bf From git at git.haskell.org Mon Mar 21 17:10:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:08 +0000 (UTC) Subject: [commit: ghc] branch 'wip/generalized-arrow' created Message-ID: <20160321171008.ED30A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc New branch : wip/generalized-arrow Referencing: fe20273afc26d3668d927d0d2002537c8a204ae1 From git at git.haskell.org Mon Mar 21 17:10:11 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:11 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix warnings (dd91807) Message-ID: <20160321171011.CA3433A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/dd9180748695f84d941472ecccaf19781dd0e6ea/ghc >--------------------------------------------------------------- commit dd9180748695f84d941472ecccaf19781dd0e6ea Author: Ben Gamari Date: Fri Mar 11 17:51:26 2016 +0100 Fix warnings >--------------------------------------------------------------- dd9180748695f84d941472ecccaf19781dd0e6ea libraries/base/Data/Typeable/Internal.hs | 17 ++++++++++++----- libraries/ghc-boot/GHC/Serialized.hs | 1 - 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 6704154..7a3344e 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -68,7 +68,7 @@ module Data.Typeable.Internal ( -- * Construction -- | These are for internal use only - mkTrCon, mkTrApp, mkTyCon, + mkTrCon, mkTrApp, mkTyCon, mkTyCon#, typeSymbolTypeRep, typeNatTypeRep, -- * Representations for primitive types @@ -220,6 +220,7 @@ mkTrCon tc kind = TrTyCon fpr tc kind fpr = fingerprintFingerprints [fpr_tc, fpr_k] -- | Construct a representation for a type application. +-- TODO: Is this necessary? mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep (a :: k1 -> k2) -> TypeRep (b :: k1) @@ -250,7 +251,7 @@ pattern TRCon con <- TrTyCon _ con _ -- | Splits a type application. splitApp :: TypeRep a -> Maybe (AppResult a) -splitApp (TrTyCon _ a _) = Nothing +splitApp (TrTyCon _ _ _) = Nothing splitApp (TrApp _ f x) = Just $ App f x ----------------- Observation --------------------- @@ -259,7 +260,9 @@ typeRepKind :: forall k (a :: k). TypeRep a -> TypeRep k typeRepKind (TrTyCon _ _ k) = k typeRepKind (TrApp _ f _) = case typeRepKind f of - TRFun arg res -> res + TRFun _arg res -> res + -- TODO: why is this case needed? + _ -> error "typeRepKind: impossible" -- | Observe the type constructor of a quantified type representation. typeRepXTyCon :: TypeRepX -> TyCon @@ -316,13 +319,16 @@ typeRepXFingerprint (TypeRepX t) = typeRepFingerprint t ----------------- Showing TypeReps -------------------- instance Show (TypeRep a) where - showsPrec p (TrTyCon _ tycon _) = shows tycon - showsPrec p (TrApp _ f x) = shows f . showString " " . shows x + showsPrec p (TrTyCon _ tycon _) = showsPrec p tycon + showsPrec p (TrApp _ f x) = showsPrec p f . showString " " . showsPrec p x + -- TODO: Reconsider precedence instance Show TypeRepX where showsPrec p (TypeRepX ty) = showsPrec p ty -- Some (Show.TypeRepX) helpers: +{- +-- FIXME: Handle tuples, etc. showArgs :: Show a => ShowS -> [a] -> ShowS showArgs _ [] = id showArgs _ [a] = showsPrec 10 a @@ -332,6 +338,7 @@ showTuple :: [TypeRepX] -> ShowS showTuple args = showChar '(' . showArgs (showChar ',') args . showChar ')' +-} -- | Helper to fully evaluate 'TypeRep' for use as @NFData(rnf)@ implementation -- diff --git a/libraries/ghc-boot/GHC/Serialized.hs b/libraries/ghc-boot/GHC/Serialized.hs index 7f86df9..8653049 100644 --- a/libraries/ghc-boot/GHC/Serialized.hs +++ b/libraries/ghc-boot/GHC/Serialized.hs @@ -22,7 +22,6 @@ module GHC.Serialized ( import Data.Bits import Data.Word ( Word8 ) import Data.Data -import Data.Typeable -- | Represents a serialized value of a particular type. Attempts can be made to deserialize it at certain types From git at git.haskell.org Mon Mar 21 17:10:14 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:14 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Outputable: Refactor handling of CallStacks (a901d98) Message-ID: <20160321171014.A168A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/a901d98a3b7d3625cfed98a0fdab0309400ee350/ghc >--------------------------------------------------------------- commit a901d98a3b7d3625cfed98a0fdab0309400ee350 Author: Ben Gamari Date: Sun Jan 31 20:29:18 2016 +0100 Outputable: Refactor handling of CallStacks Provide callstacks in more places and consolidate handling >--------------------------------------------------------------- a901d98a3b7d3625cfed98a0fdab0309400ee350 compiler/utils/Outputable.hs | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index 259b554..78ef28d 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -1,4 +1,7 @@ -{-# LANGUAGE CPP, ImplicitParams #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE ImplicitParams #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE ConstraintKinds #-} {- (c) The University of Glasgow 2006-2012 (c) The GRASP Project, Glasgow University, 1992-1998 @@ -79,6 +82,9 @@ module Outputable ( pprTrace, pprTraceIt, warnPprTrace, pprSTrace, trace, pgmError, panic, sorry, assertPanic, pprDebugAndThen, + + -- * Re-exported + HasCallStack, ) where import {-# SOURCE #-} DynFlags( DynFlags, @@ -115,8 +121,9 @@ import Data.Graph (SCC(..)) import GHC.Fingerprint import GHC.Show ( showMultiLineString ) +import GHC.Exts (Constraint) #if __GLASGOW_HASKELL__ > 710 -import GHC.Stack +import GHC.Exception (CallStack, prettyCallStackLines) #endif {- @@ -1055,9 +1062,21 @@ doOrDoes _ = text "do" ************************************************************************ -} -pprPanic :: String -> SDoc -> a +#if __GLASGOW_HASKELL__ > 710 +type HasCallStack = ((?callStack :: CallStack) :: Constraint) + +pprCallStack :: (?callStack :: CallStack) => SDoc +pprCallStack = vcat $ map text $ prettyCallStackLines ?callStack +#else +type HasCallStack = (() :: Constraint) + +pprCallStack :: SDoc +pprCallStack = empty +#endif + +pprPanic :: HasCallStack => String -> SDoc -> a -- ^ Throw an exception saying "bug in GHC" -pprPanic = panicDoc +pprPanic msg doc = panicDoc msg (pprCallStack $$ doc) pprSorry :: String -> SDoc -> a -- ^ Throw an exception saying "this isn't finished yet" @@ -1083,11 +1102,11 @@ pprTraceIt desc x = pprTrace desc (ppr x) x -- | If debug output is on, show some 'SDoc' on the screen along -- with a call stack when available. #if __GLASGOW_HASKELL__ > 710 -pprSTrace :: (?callStack :: CallStack) => SDoc -> a -> a -pprSTrace = pprTrace (prettyCallStack ?callStack) +pprSTrace :: HasCallStack => String -> SDoc -> a -> a +pprSTrace msg doc = pprTrace msg (pprCallStack $$ doc) #else -pprSTrace :: SDoc -> a -> a -pprSTrace = pprTrace "no callstack info" +pprSTrace :: String -> SDoc -> a -> a +pprSTrace msg doc = pprTrace msg (text "no callstack info" $$ doc) #endif warnPprTrace :: Bool -> String -> Int -> SDoc -> a -> a @@ -1104,11 +1123,11 @@ warnPprTrace True file line msg x -- | Panic with an assertation failure, recording the given file and -- line number. Should typically be accessed with the ASSERT family of macros #if __GLASGOW_HASKELL__ > 710 -assertPprPanic :: (?callStack :: CallStack) => String -> Int -> SDoc -> a +assertPprPanic :: HasCallStack => String -> Int -> SDoc -> a assertPprPanic _file _line msg = pprPanic "ASSERT failed!" doc where - doc = sep [ text (prettyCallStack ?callStack) + doc = sep [ pprCallStack , msg ] #else assertPprPanic :: String -> Int -> SDoc -> a From git at git.haskell.org Mon Mar 21 17:10:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:18 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Start implementing library side of TTypeable (5f08b98) Message-ID: <20160321171018.119513A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/5f08b9821980dd42a7f9f9a9a62acacbdb539e7c/ghc >--------------------------------------------------------------- commit 5f08b9821980dd42a7f9f9a9a62acacbdb539e7c Author: Ben Gamari Date: Sat Jan 30 00:04:54 2016 +0100 Start implementing library side of TTypeable >--------------------------------------------------------------- 5f08b9821980dd42a7f9f9a9a62acacbdb539e7c compiler/deSugar/DsBinds.hs | 79 +++-- compiler/prelude/PrelNames.hs | 72 +++-- compiler/typecheck/TcEvidence.hs | 20 +- compiler/typecheck/TcHsSyn.hs | 8 +- compiler/typecheck/TcInteract.hs | 58 +++- compiler/utils/Binary.hs | 55 +++- libraries/base/Data/Dynamic.hs | 51 +-- libraries/base/Data/Type/Equality.hs | 6 + libraries/base/Data/Typeable.hs | 192 ++++++++---- libraries/base/Data/Typeable/Internal.hs | 518 +++++++++++++++++-------------- libraries/base/GHC/Conc/Sync.hs | 4 - libraries/base/GHC/Show.hs | 2 +- libraries/base/Type/Reflection.hs | 43 +++ libraries/base/Type/Reflection/Unsafe.hs | 20 ++ libraries/base/base.cabal | 4 +- libraries/ghc-boot/GHC/Serialized.hs | 16 +- libraries/ghc-prim/GHC/Types.hs | 18 +- libraries/ghci/GHCi/TH/Binary.hs | 57 ++++ nofib | 2 +- 19 files changed, 795 insertions(+), 430 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 5f08b9821980dd42a7f9f9a9a62acacbdb539e7c From git at git.haskell.org Mon Mar 21 17:10:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:20 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: TcSMonad: Introduce tcLookupId (7b90d64) Message-ID: <20160321171020.E589E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/7b90d649a1921c251eab437fc1a34d3ed4d0e47f/ghc >--------------------------------------------------------------- commit 7b90d649a1921c251eab437fc1a34d3ed4d0e47f Author: Ben Gamari Date: Sun Jan 31 17:42:57 2016 +0100 TcSMonad: Introduce tcLookupId >--------------------------------------------------------------- 7b90d649a1921c251eab437fc1a34d3ed4d0e47f compiler/typecheck/TcSMonad.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/TcSMonad.hs b/compiler/typecheck/TcSMonad.hs index 303fee8..d935d72 100644 --- a/compiler/typecheck/TcSMonad.hs +++ b/compiler/typecheck/TcSMonad.hs @@ -43,7 +43,7 @@ module TcSMonad ( getTopEnv, getGblEnv, getLclEnv, getTcEvBinds, getTcEvBindsFromVar, getTcLevel, getTcEvBindsMap, - tcLookupClass, + tcLookupClass, tcLookupId, -- Inerts InertSet(..), InertCans(..), @@ -121,7 +121,7 @@ import FamInstEnv import qualified TcRnMonad as TcM import qualified TcMType as TcM import qualified TcEnv as TcM - ( checkWellStaged, topIdLvl, tcGetDefaultTys, tcLookupClass ) + ( checkWellStaged, topIdLvl, tcGetDefaultTys, tcLookupClass, tcLookupId ) import Kind import TcType import DynFlags @@ -2720,6 +2720,9 @@ getLclEnv = wrapTcS $ TcM.getLclEnv tcLookupClass :: Name -> TcS Class tcLookupClass c = wrapTcS $ TcM.tcLookupClass c +tcLookupId :: Name -> TcS Id +tcLookupId n = wrapTcS $ TcM.tcLookupId n + -- Setting names as used (used in the deriving of Coercible evidence) -- Too hackish to expose it to TcS? In that case somehow extract the used -- constructors from the result of solveInteract From git at git.haskell.org Mon Mar 21 17:10:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:23 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: HACK: CoreLint: Kill unsaturated unlifted types check (a7c39f9) Message-ID: <20160321171023.AD3FF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/a7c39f98af585ebe0119a147520006af1549c41e/ghc >--------------------------------------------------------------- commit a7c39f98af585ebe0119a147520006af1549c41e Author: Ben Gamari Date: Sat Jan 30 19:53:05 2016 +0100 HACK: CoreLint: Kill unsaturated unlifted types check >--------------------------------------------------------------- a7c39f98af585ebe0119a147520006af1549c41e compiler/coreSyn/CoreLint.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index 99625c9..2c401de 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -1040,7 +1040,7 @@ lintType ty@(TyConApp tc tys) = lintType ty' -- Expand type synonyms, so that we do not bogusly complain -- about un-saturated type synonyms - | isUnliftedTyCon tc || isTypeSynonymTyCon tc || isTypeFamilyTyCon tc + | isTypeSynonymTyCon tc || isTypeFamilyTyCon tc -- Also type synonyms and type families , length tys < tyConArity tc = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) From git at git.haskell.org Mon Mar 21 17:10:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:26 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix rebase (1099a96) Message-ID: <20160321171026.650353A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/1099a960764ce1e67e6955c2e06be71ba9a6381b/ghc >--------------------------------------------------------------- commit 1099a960764ce1e67e6955c2e06be71ba9a6381b Author: Ben Gamari Date: Fri Mar 11 17:23:30 2016 +0100 Fix rebase >--------------------------------------------------------------- 1099a960764ce1e67e6955c2e06be71ba9a6381b compiler/prelude/PrelNames.hs | 38 +++++++++++++-------------- compiler/typecheck/TcInteract.hs | 14 +++++----- libraries/base/Data/Typeable/Internal.hs | 44 ++++++++++++++++---------------- 3 files changed, 48 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 1099a960764ce1e67e6955c2e06be71ba9a6381b From git at git.haskell.org Mon Mar 21 17:10:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:29 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix serialization (4f3c051) Message-ID: <20160321171029.2741C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/4f3c05163b39337180df62b990a3e1c4f36c6a7a/ghc >--------------------------------------------------------------- commit 4f3c05163b39337180df62b990a3e1c4f36c6a7a Author: Ben Gamari Date: Fri Mar 11 19:23:16 2016 +0100 Fix serialization >--------------------------------------------------------------- 4f3c05163b39337180df62b990a3e1c4f36c6a7a compiler/utils/Binary.hs | 12 +++++++----- libraries/ghci/GHCi/TH/Binary.hs | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index c8f1d44..fcf9ce7 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -594,14 +594,16 @@ getTypeRepX bh = do case tag of 0 -> do con <- get bh TypeRepX rep_k <- getTypeRepX bh - Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep Type) - pure $ TypeRepX $ mkTrCon con rep_k + case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of + Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k + Nothing -> fail "getTypeRepX: Kind mismatch" + 1 -> do TypeRepX f <- getTypeRepX bh TypeRepX x <- getTypeRepX bh case typeRepKind f of - TRFun arg _ -> do - Just HRefl <- pure $ eqTypeRep arg x - pure $ TypeRepX $ mkTrApp f x + TRFun arg _ | Just HRefl <- arg `eqTypeRep` x -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" _ -> fail "Binary: Invalid TypeRepX" instance Typeable a => Binary (TypeRep (a :: k)) where diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index d067e54..2433057 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -95,15 +95,17 @@ getTypeRepX = do case tag of 0 -> do con <- get :: Get TyCon TypeRepX rep_k <- getTypeRepX - Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep Type) - pure $ TypeRepX $ mkTrCon con rep_k + case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of + Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k + Nothing -> fail "getTypeRepX: Kind mismatch" + 1 -> do TypeRepX f <- getTypeRepX TypeRepX x <- getTypeRepX case typeRepKind f of - TRFun arg _ -> do - Just HRefl <- pure $ eqTypeRep arg x - pure $ TypeRepX $ mkTrApp f x - _ -> fail "Binary: Invalid TTypeRep" + TRFun arg _ | Just HRefl <- arg `eqTypeRep` x -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" + _ -> fail "getTypeRepX: Invalid TypeRepX" instance Typeable a => Binary (TypeRep (a :: k)) where put = putTypeRep From git at git.haskell.org Mon Mar 21 17:10:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:32 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Various fixes (4034bdf) Message-ID: <20160321171032.1FB783A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/4034bdfc5ed517b2bc6d98b1266450ac25ac7cb3/ghc >--------------------------------------------------------------- commit 4034bdfc5ed517b2bc6d98b1266450ac25ac7cb3 Author: Ben Gamari Date: Fri Mar 11 19:16:55 2016 +0100 Various fixes >--------------------------------------------------------------- 4034bdfc5ed517b2bc6d98b1266450ac25ac7cb3 compiler/utils/Binary.hs | 6 +++--- libraries/ghci/GHCi/TH/Binary.hs | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index bd9b585..c8f1d44 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -81,7 +81,7 @@ import Data.Time #if MIN_VERSION_base(4,9,0) import Type.Reflection import Type.Reflection.Unsafe -import GHC.Exts ( TYPE, Levity(..) ) +import Data.Kind (Type) #else import Data.Typeable #endif @@ -594,7 +594,7 @@ getTypeRepX bh = do case tag of 0 -> do con <- get bh TypeRepX rep_k <- getTypeRepX bh - Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep (TYPE 'Lifted)) + Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep Type) pure $ TypeRepX $ mkTrCon con rep_k 1 -> do TypeRepX f <- getTypeRepX bh TypeRepX x <- getTypeRepX bh @@ -608,7 +608,7 @@ instance Typeable a => Binary (TypeRep (a :: k)) where put_ = putTypeRep get bh = do TypeRepX rep <- getTypeRepX bh - case rep `eqTypeRep` typeRep of + case rep `eqTypeRep` (typeRep :: TypeRep a) of Just HRefl -> pure rep Nothing -> fail "Binary: Type mismatch" diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index b1eaf72..d067e54 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -14,10 +14,10 @@ import qualified Data.ByteString as B import Control.Monad (when) import Type.Reflection import Type.Reflection.Unsafe +import Data.Kind (Type) #else import Data.Typeable #endif -import GHC.Exts (TYPE, Levity(..)) import GHC.Serialized import qualified Language.Haskell.TH as TH import qualified Language.Haskell.TH.Syntax as TH @@ -94,11 +94,11 @@ getTypeRepX = do tag <- get :: Get Word8 case tag of 0 -> do con <- get :: Get TyCon - TypeRep rep_k <- getTypeRepX - Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep (TYPE 'Lifted)) + TypeRepX rep_k <- getTypeRepX + Just HRefl <- pure $ eqTypeRep rep_k (typeRep :: TypeRep Type) pure $ TypeRepX $ mkTrCon con rep_k - 1 -> do TypeRep f <- getTypeRepX - TypeRep x <- getTypeRepX + 1 -> do TypeRepX f <- getTypeRepX + TypeRepX x <- getTypeRepX case typeRepKind f of TRFun arg _ -> do Just HRefl <- pure $ eqTypeRep arg x @@ -109,13 +109,13 @@ instance Typeable a => Binary (TypeRep (a :: k)) where put = putTypeRep get = do TypeRepX rep <- getTypeRepX - case rep `eqTypeRep` typeRef of + case rep `eqTypeRep` (typeRep :: TypeRep a) of Just HRefl -> pure rep Nothing -> fail "Binary: Type mismatch" instance Binary TypeRepX where put (TypeRepX rep) = putTypeRep rep - get = getTypeRep + get = getTypeRepX #else instance Binary TyCon where put tc = put (tyConPackage tc) >> put (tyConModule tc) >> put (tyConName tc) From git at git.haskell.org Mon Mar 21 17:10:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:35 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Implement Data.Typeable.funResultTy (79d404c) Message-ID: <20160321171035.505E73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/79d404c7934c44b183466d898cb3693eea2df7da/ghc >--------------------------------------------------------------- commit 79d404c7934c44b183466d898cb3693eea2df7da Author: Ben Gamari Date: Tue Mar 15 16:21:58 2016 +0100 Implement Data.Typeable.funResultTy >--------------------------------------------------------------- 79d404c7934c44b183466d898cb3693eea2df7da libraries/base/Data/Typeable.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libraries/base/Data/Typeable.hs b/libraries/base/Data/Typeable.hs index 486c5b8..7718cf3 100644 --- a/libraries/base/Data/Typeable.hs +++ b/libraries/base/Data/Typeable.hs @@ -69,6 +69,9 @@ module Data.Typeable , rnfTypeRep , showsTypeRep + -- * Observing type representations + , funResultTy + -- * Type constructors , I.TyCon -- abstract, instance of: Eq, Show, Typeable -- For now don't export Module to avoid name clashes @@ -147,6 +150,18 @@ gcast2 x = fmap (\Refl -> x) (eqT :: Maybe (t :~: t')) typeRepTyCon :: TypeRep -> TyCon typeRepTyCon = I.typeRepXTyCon +-- | Applies a type to a function type. Returns: @Just u@ if the first argument +-- represents a function of type @t -> u@ and the second argument represents a +-- function of type @t at . Otherwise, returns @Nothing at . +funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep +funResultTy (I.TypeRepX f) (I.TypeRepX x) + | Just HRefl <- (I.typeRep :: I.TypeRep Type) `I.eqTypeRep` I.typeRepKind f + , I.TRFun arg res <- f + , Just HRefl <- arg `I.eqTypeRep` x + = Just (I.TypeRepX res) + | otherwise + = Nothing + -- | Force a 'TypeRep' to normal form. rnfTypeRep :: TypeRep -> () rnfTypeRep = I.rnfTypeRepX From git at git.haskell.org Mon Mar 21 17:10:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:38 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Add quick compatibility note (49f625d) Message-ID: <20160321171038.247FA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/49f625d2f7defcecf6db0a77373e4a6629bc3a08/ghc >--------------------------------------------------------------- commit 49f625d2f7defcecf6db0a77373e4a6629bc3a08 Author: Ben Gamari Date: Fri Mar 11 17:32:13 2016 +0100 Add quick compatibility note >--------------------------------------------------------------- 49f625d2f7defcecf6db0a77373e4a6629bc3a08 libraries/base/Data/Typeable.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/base/Data/Typeable.hs b/libraries/base/Data/Typeable.hs index f33ac48..486c5b8 100644 --- a/libraries/base/Data/Typeable.hs +++ b/libraries/base/Data/Typeable.hs @@ -28,6 +28,11 @@ -- -- == Compatibility Notes -- +-- Since GHC 8.2, GHC has supported type-indexed type representations. +-- "Data.Typeable" provides type representations which are qualified over this +-- index, providing an interface very similar to the "Typeable" notion seen in +-- previous releases. For the type-indexed interface, see "Data.Reflection". +-- -- Since GHC 7.8, 'Typeable' is poly-kinded. The changes required for this might -- break some old programs involving 'Typeable'. More details on this, including -- how to fix your code, can be found on the From git at git.haskell.org Mon Mar 21 17:10:40 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:40 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: CoreLint: Improve debug output (7db1b47) Message-ID: <20160321171040.D5A3F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/7db1b4784109a93a8256b3434a3a13148855b123/ghc >--------------------------------------------------------------- commit 7db1b4784109a93a8256b3434a3a13148855b123 Author: Ben Gamari Date: Sun Jan 31 21:35:20 2016 +0100 CoreLint: Improve debug output >--------------------------------------------------------------- 7db1b4784109a93a8256b3434a3a13148855b123 compiler/coreSyn/CoreLint.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index 2c401de..472f29f 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -816,7 +816,7 @@ lintTyKind tyvar arg_ty -- and then apply it to both boxed and unboxed types. = do { arg_kind <- lintType arg_ty ; unless (arg_kind `eqType` tyvar_kind) - (addErrL (mkKindErrMsg tyvar arg_ty $$ (text "xx" <+> ppr arg_kind))) } + (addErrL (mkKindErrMsg tyvar arg_ty $$ (text "Linted Arg kind:" <+> ppr arg_kind))) } where tyvar_kind = tyVarKind tyvar From git at git.haskell.org Mon Mar 21 17:10:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:43 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Binary: More explicit pattern matching (2f88acc) Message-ID: <20160321171043.9FDF23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/2f88acc723502c0fd858b166ff9f59102bed7171/ghc >--------------------------------------------------------------- commit 2f88acc723502c0fd858b166ff9f59102bed7171 Author: Ben Gamari Date: Wed Mar 16 09:40:54 2016 +0100 Binary: More explicit pattern matching >--------------------------------------------------------------- 2f88acc723502c0fd858b166ff9f59102bed7171 compiler/utils/Binary.hs | 9 ++++++--- libraries/ghci/GHCi/TH/Binary.hs | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index fcf9ce7..431b187 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -601,9 +601,12 @@ getTypeRepX bh = do 1 -> do TypeRepX f <- getTypeRepX bh TypeRepX x <- getTypeRepX bh case typeRepKind f of - TRFun arg _ | Just HRefl <- arg `eqTypeRep` x -> - pure $ TypeRepX $ mkTrApp f x - _ -> fail "getTypeRepX: Kind mismatch" + TRFun arg _ -> + case arg `eqTypeRep` x of + Just HRefl -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" + _ -> fail "getTypeRepX: Applied non-arrow type" _ -> fail "Binary: Invalid TypeRepX" instance Typeable a => Binary (TypeRep (a :: k)) where diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index 2433057..522cc80 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -102,9 +102,12 @@ getTypeRepX = do 1 -> do TypeRepX f <- getTypeRepX TypeRepX x <- getTypeRepX case typeRepKind f of - TRFun arg _ | Just HRefl <- arg `eqTypeRep` x -> - pure $ TypeRepX $ mkTrApp f x - _ -> fail "getTypeRepX: Kind mismatch" + TRFun arg _ -> + case arg `eqTypeRep` x of + Just HRefl -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" + _ -> fail "getTypeRepX: Applied non-arrow type" _ -> fail "getTypeRepX: Invalid TypeRepX" instance Typeable a => Binary (TypeRep (a :: k)) where From git at git.haskell.org Mon Mar 21 17:10:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:46 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: More serialization (660b13e) Message-ID: <20160321171046.6794E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/660b13e29b2f8f668a2e62e4b3c996c12e1e7b29/ghc >--------------------------------------------------------------- commit 660b13e29b2f8f668a2e62e4b3c996c12e1e7b29 Author: Ben Gamari Date: Wed Mar 16 10:33:37 2016 +0100 More serialization >--------------------------------------------------------------- 660b13e29b2f8f668a2e62e4b3c996c12e1e7b29 compiler/utils/Binary.hs | 14 +++++++++----- libraries/base/Data/Typeable.hs | 20 +++++++++++++------- libraries/ghci/GHCi/TH/Binary.hs | 13 ++++++++----- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index 431b187..2dd2182 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -587,12 +587,13 @@ putTypeRep bh (TRApp f x) = do put_ bh (1 :: Word8) putTypeRep bh f putTypeRep bh x +putTypeRep _ _ = fail "putTypeRep: Impossible" getTypeRepX :: BinHandle -> IO TypeRepX getTypeRepX bh = do tag <- get bh :: IO Word8 case tag of - 0 -> do con <- get bh + 0 -> do con <- get bh :: IO TyCon TypeRepX rep_k <- getTypeRepX bh case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k @@ -602,10 +603,13 @@ getTypeRepX bh = do TypeRepX x <- getTypeRepX bh case typeRepKind f of TRFun arg _ -> - case arg `eqTypeRep` x of - Just HRefl -> - pure $ TypeRepX $ mkTrApp f x - _ -> fail "getTypeRepX: Kind mismatch" + case (typeRep :: TypeRep Type) `eqTypeRep` arg of + Just HRefl -> -- FIXME: Generalize (->) + case x `eqTypeRep` arg of + Just HRefl -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" + Nothing -> fail "getTypeRepX: Arrow of non-Type argument" _ -> fail "getTypeRepX: Applied non-arrow type" _ -> fail "Binary: Invalid TypeRepX" diff --git a/libraries/base/Data/Typeable.hs b/libraries/base/Data/Typeable.hs index 7718cf3..21f93d2 100644 --- a/libraries/base/Data/Typeable.hs +++ b/libraries/base/Data/Typeable.hs @@ -154,13 +154,19 @@ typeRepTyCon = I.typeRepXTyCon -- represents a function of type @t -> u@ and the second argument represents a -- function of type @t at . Otherwise, returns @Nothing at . funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep -funResultTy (I.TypeRepX f) (I.TypeRepX x) - | Just HRefl <- (I.typeRep :: I.TypeRep Type) `I.eqTypeRep` I.typeRepKind f - , I.TRFun arg res <- f - , Just HRefl <- arg `I.eqTypeRep` x - = Just (I.TypeRepX res) - | otherwise - = Nothing +{- +funResultTy (I.TypeRepX f) (I.TypeRepX x) = + case (I.typeRep :: I.TypeRep Type) `I.eqTypeRep` I.typeRepKind f of + Just HRefl -> + case f of + I.TRFun arg res -> + case arg `I.eqTypeRep` x of + Just HRefl -> Just (I.TypeRepX res) + Nothing -> Nothing + _ -> Nothing + Nothing -> Nothing +-} +funResultTy _ _ = Nothing -- | Force a 'TypeRep' to normal form. rnfTypeRep :: TypeRep -> () diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index 522cc80..e0f0ba2 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -11,7 +11,6 @@ module GHCi.TH.Binary () where import Data.Binary import qualified Data.ByteString as B #if MIN_VERSION_base(4,9,0) -import Control.Monad (when) import Type.Reflection import Type.Reflection.Unsafe import Data.Kind (Type) @@ -88,6 +87,7 @@ putTypeRep (TRApp f x) = do put (1 :: Word8) putTypeRep f putTypeRep x +putTypeRep _ = fail "putTypeRep: Impossible" getTypeRepX :: Get TypeRepX getTypeRepX = do @@ -103,10 +103,13 @@ getTypeRepX = do TypeRepX x <- getTypeRepX case typeRepKind f of TRFun arg _ -> - case arg `eqTypeRep` x of - Just HRefl -> - pure $ TypeRepX $ mkTrApp f x - _ -> fail "getTypeRepX: Kind mismatch" + case (typeRep :: TypeRep Type) `eqTypeRep` arg of + Just HRefl -> -- FIXME: Generalize (->) + case arg `eqTypeRep` x of + Just HRefl -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" + _ -> fail "getTypeRepX: Arrow of non-Type argument" _ -> fail "getTypeRepX: Applied non-arrow type" _ -> fail "getTypeRepX: Invalid TypeRepX" From git at git.haskell.org Mon Mar 21 17:10:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:49 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Message: Import Data.Typeable.TypeRep (6e9eaff) Message-ID: <20160321171049.4BDC03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/6e9eaffe919ea16c1be2685f499994c2e5c354ce/ghc >--------------------------------------------------------------- commit 6e9eaffe919ea16c1be2685f499994c2e5c354ce Author: Ben Gamari Date: Wed Mar 16 10:35:59 2016 +0100 Message: Import Data.Typeable.TypeRep >--------------------------------------------------------------- 6e9eaffe919ea16c1be2685f499994c2e5c354ce libraries/ghci/GHCi/Message.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/ghci/GHCi/Message.hs b/libraries/ghci/GHCi/Message.hs index b8f9fcc..4bc8d2c 100644 --- a/libraries/ghci/GHCi/Message.hs +++ b/libraries/ghci/GHCi/Message.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, DeriveGeneric, StandaloneDeriving, +{-# LANGUAGE GADTs, DeriveGeneric, StandaloneDeriving, CPP, GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-} @@ -29,6 +29,10 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as LB import Data.Dynamic +#if MIN_VERSION_base(4,9,0) +-- Previously this was re-exported by Data.Dynamic +import Data.Typeable (TypeRep) +#endif import Data.IORef import Data.Map (Map) import GHC.Generics From git at git.haskell.org Mon Mar 21 17:10:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:52 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: TcInteract: Unused parameter (d3cc620) Message-ID: <20160321171052.106413A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/d3cc6209358aa1dfe1b5cc0e5f9f36662279e459/ghc >--------------------------------------------------------------- commit d3cc6209358aa1dfe1b5cc0e5f9f36662279e459 Author: Ben Gamari Date: Wed Mar 16 11:04:54 2016 +0100 TcInteract: Unused parameter >--------------------------------------------------------------- d3cc6209358aa1dfe1b5cc0e5f9f36662279e459 compiler/typecheck/TcInteract.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs index d98a748..e93f303 100644 --- a/compiler/typecheck/TcInteract.hs +++ b/compiler/typecheck/TcInteract.hs @@ -2002,7 +2002,7 @@ matchTypeable clas [k,t] -- clas = Typeable | t `eqType` liftedTypeKind = doPrimRep trTYPE'PtrRepLiftedName t | t `eqType` runtimeRepTy = doPrimRep trRuntimeRepName t | Just (tc, ks) <- splitTyConApp_maybe t -- See Note [Typeable (T a b c)] - , onlyNamedBndrsApplied tc ks = doTyConApp clas t tc ks + , onlyNamedBndrsApplied tc ks = doTyConApp clas t tc | Just (arg,ret) <- splitFunTy_maybe t = doFunTy clas t arg ret | Just (f,kt) <- splitAppTy_maybe t = doTyApp clas t f kt @@ -2037,8 +2037,8 @@ doPrimRep rep_name ty -- kind variables have been instantiated). -- -- TODO: Do we want to encode the applied kinds in the representation? -doTyConApp :: Class -> Type -> TyCon -> [Kind] -> TcS LookupInstResult -doTyConApp clas ty tc ks +doTyConApp :: Class -> Type -> TyCon -> TcS LookupInstResult +doTyConApp clas ty tc = return $ GenInst [mk_typeable_pred clas $ typeKind ty] (\[ev] -> EvTypeable ty $ EvTypeableTyCon tc ev) True From git at git.haskell.org Mon Mar 21 17:10:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:54 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix nofib submodule (fda1534) Message-ID: <20160321171054.CFD5F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/fda1534def248e9ab6c831133e727ce634c23205/ghc >--------------------------------------------------------------- commit fda1534def248e9ab6c831133e727ce634c23205 Author: Ben Gamari Date: Wed Mar 16 11:07:27 2016 +0100 Fix nofib submodule >--------------------------------------------------------------- fda1534def248e9ab6c831133e727ce634c23205 nofib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nofib b/nofib index ebec858..a82ea5f 160000 --- a/nofib +++ b/nofib @@ -1 +1 @@ -Subproject commit ebec858a920200692bda55fa5fc4a266c2661f68 +Subproject commit a82ea5f29607275b56bc03fc1747734af1cae575 From git at git.haskell.org Mon Mar 21 17:10:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:10:57 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Update deepseq submodule (be0471d) Message-ID: <20160321171057.A45313A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/be0471d07cd02cac06793043163e73f2d9bc88d1/ghc >--------------------------------------------------------------- commit be0471d07cd02cac06793043163e73f2d9bc88d1 Author: Ben Gamari Date: Wed Mar 16 11:26:25 2016 +0100 Update deepseq submodule >--------------------------------------------------------------- be0471d07cd02cac06793043163e73f2d9bc88d1 libraries/deepseq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/deepseq b/libraries/deepseq index 40d4db0..c3a0a16 160000 --- a/libraries/deepseq +++ b/libraries/deepseq @@ -1 +1 @@ -Subproject commit 40d4db0a4e81a07ecd0f1bc77b8772088e75e478 +Subproject commit c3a0a16f17e593cb6a64b01a22015497738bfed6 From git at git.haskell.org Mon Mar 21 17:11:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:00 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Render type equality more readably (90ad65d) Message-ID: <20160321171100.559603A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/90ad65d3c487d6e7c6f6303b0487ce4caa8eae9b/ghc >--------------------------------------------------------------- commit 90ad65d3c487d6e7c6f6303b0487ce4caa8eae9b Author: Ben Gamari Date: Wed Mar 16 11:37:27 2016 +0100 Render type equality more readably >--------------------------------------------------------------- 90ad65d3c487d6e7c6f6303b0487ce4caa8eae9b compiler/types/TyCoRep.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index fa123a0..86d236c 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -2801,6 +2801,19 @@ pprTcApp_help to_type p pp tc tys dflags style -- we know nothing of precedence though = pprInfixApp p pp pp_tc ty1 ty2 + -- Handle equalities specifically + | is_het_equality + , [k1,k2,ty1,ty2] <- map to_type tys_wo_kinds + = parens (pprType ty1 <+> dcolon <+> pprKind k1) + <+> text "~~" + <+> parens (pprType ty2 <+> dcolon <+> pprKind k2) + + | is_equality + , [k,ty1,ty2] <- map to_type tys_wo_kinds + = parens (pprType ty1 <+> dcolon <+> pprKind k) + <+> text "~" + <+> parens (pprType ty2 <+> dcolon <+> pprKind k) + | tc_name `hasKey` starKindTyConKey || tc_name `hasKey` unicodeStarKindTyConKey || tc_name `hasKey` unliftedTypeKindTyConKey @@ -2810,12 +2823,14 @@ pprTcApp_help to_type p pp tc tys dflags style = pprPrefixApp p (parens pp_tc) (map (pp TyConPrec) tys_wo_kinds) where tc_name = tyConName tc + is_het_equality = tc `hasKey` heqTyConKey + is_equality = tc `hasKey` eqPrimTyConKey || is_het_equality -- With the solver working in unlifted equality, it will want to -- to print unlifted equality constraints sometimes. But these are -- confusing to users. So fix them up here. (print_prefix, pp_tc) - | (tc `hasKey` eqPrimTyConKey || tc `hasKey` heqTyConKey) && not print_eqs + | is_equality && not print_eqs = (False, text "~") | tc `hasKey` eqReprPrimTyConKey && not print_eqs = (True, text "Coercible") From git at git.haskell.org Mon Mar 21 17:11:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:03 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix a few TTypeRep references (f508c88) Message-ID: <20160321171103.2A23D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/f508c8821c4997a8dda2460c07a23e8c5efc9504/ghc >--------------------------------------------------------------- commit f508c8821c4997a8dda2460c07a23e8c5efc9504 Author: Ben Gamari Date: Wed Mar 16 11:51:00 2016 +0100 Fix a few TTypeRep references >--------------------------------------------------------------- f508c8821c4997a8dda2460c07a23e8c5efc9504 compiler/deSugar/DsBinds.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/deSugar/DsBinds.hs b/compiler/deSugar/DsBinds.hs index 2943b2b..a41bb27 100644 --- a/compiler/deSugar/DsBinds.hs +++ b/compiler/deSugar/DsBinds.hs @@ -1119,10 +1119,10 @@ type TypeRepExpr = CoreExpr ds_ev_typeable :: Type -> EvTypeable -> DsM CoreExpr ds_ev_typeable ty (EvTypeableTyCon tc kind_ev) = do { mkTrCon <- dsLookupGlobalId mkTrConName - -- mkTrCon :: forall k (a :: k). TyCon -> TTypeRep k -> TTypeRep a + -- mkTrCon :: forall k (a :: k). TyCon -> TypeRep k -> TypeRep a ; tc_rep <- tyConRep tc -- :: TyCon - ; kind_rep <- getRep kind_ev (typeKind ty) -- :: TTypeRep k + ; kind_rep <- getRep kind_ev (typeKind ty) -- :: TypeRep k -- Note that we use the kind of the type, not the TyCon from which it is -- constructed since the latter may be kind polymorphic whereas the @@ -1153,8 +1153,8 @@ ds_ev_typeable ty (EvTypeableTyLit ev) ty_kind = typeKind ty -- tr_fun is the Name of - -- typeNatTypeRep :: KnownNat a => Proxy# a -> TTypeRep a - -- of typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TTypeRep a + -- typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a + -- of typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a tr_fun | ty_kind `eqType` typeNatKind = typeNatTypeRepName | ty_kind `eqType` typeSymbolKind = typeSymbolTypeRepName | otherwise = panic "dsEvTypeable: unknown type lit kind" @@ -1168,10 +1168,10 @@ ds_ev_typeable ty ev getRep :: EvTerm -- ^ EvTerm for @Typeable ty@ -> Type -- ^ The type @ty@ - -> DsM TypeRepExpr -- ^ Return @CoreExpr :: TTypeRep ty@ + -> DsM TypeRepExpr -- ^ Return @CoreExpr :: TypeRep ty@ -- namely @typeRep# dict@ -- Remember that --- typeRep# :: forall k (a::k). Typeable k a -> TTypeRep a +-- typeRep# :: forall k (a::k). Typeable k a -> TypeRep a getRep ev ty = do { typeable_expr <- dsEvTerm ev ; typeRepId <- dsLookupGlobalId typeRepIdName From git at git.haskell.org Mon Mar 21 17:11:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:05 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Bump haskeline submodule (b848d6d) Message-ID: <20160321171105.F14993A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/b848d6d9dce6e0dc438ba077b9f1b15af0dfd069/ghc >--------------------------------------------------------------- commit b848d6d9dce6e0dc438ba077b9f1b15af0dfd069 Author: Ben Gamari Date: Wed Mar 16 11:51:10 2016 +0100 Bump haskeline submodule >--------------------------------------------------------------- b848d6d9dce6e0dc438ba077b9f1b15af0dfd069 libraries/haskeline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/haskeline b/libraries/haskeline index 5e53651..8dd9e8b 160000 --- a/libraries/haskeline +++ b/libraries/haskeline @@ -1 +1 @@ -Subproject commit 5e53651b2683f31bf5efc842c33f07afc05ec287 +Subproject commit 8dd9e8be13b364048f57cc276be6ad5fb66fad21 From git at git.haskell.org Mon Mar 21 17:11:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:08 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Finally serialization is both general and correct (485cd9e) Message-ID: <20160321171108.C8D5B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/485cd9ea33d449ee16afea3ec986c2188b263532/ghc >--------------------------------------------------------------- commit 485cd9ea33d449ee16afea3ec986c2188b263532 Author: Ben Gamari Date: Wed Mar 16 12:16:20 2016 +0100 Finally serialization is both general and correct >--------------------------------------------------------------- 485cd9ea33d449ee16afea3ec986c2188b263532 compiler/utils/Binary.hs | 13 +++++-------- libraries/ghci/GHCi/TH/Binary.hs | 11 ++++------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index 2dd2182..a346e0d 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -603,15 +603,12 @@ getTypeRepX bh = do TypeRepX x <- getTypeRepX bh case typeRepKind f of TRFun arg _ -> - case (typeRep :: TypeRep Type) `eqTypeRep` arg of - Just HRefl -> -- FIXME: Generalize (->) - case x `eqTypeRep` arg of - Just HRefl -> - pure $ TypeRepX $ mkTrApp f x - _ -> fail "getTypeRepX: Kind mismatch" - Nothing -> fail "getTypeRepX: Arrow of non-Type argument" + case arg `eqTypeRep` typeRepKind x of + Just HRefl -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" _ -> fail "getTypeRepX: Applied non-arrow type" - _ -> fail "Binary: Invalid TypeRepX" + _ -> fail "getTypeRepX: Invalid TypeRepX" instance Typeable a => Binary (TypeRep (a :: k)) where put_ = putTypeRep diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index e0f0ba2..2f41645 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -103,13 +103,10 @@ getTypeRepX = do TypeRepX x <- getTypeRepX case typeRepKind f of TRFun arg _ -> - case (typeRep :: TypeRep Type) `eqTypeRep` arg of - Just HRefl -> -- FIXME: Generalize (->) - case arg `eqTypeRep` x of - Just HRefl -> - pure $ TypeRepX $ mkTrApp f x - _ -> fail "getTypeRepX: Kind mismatch" - _ -> fail "getTypeRepX: Arrow of non-Type argument" + case arg `eqTypeRep` typeRepKind x of + Just HRefl -> + pure $ TypeRepX $ mkTrApp f x + _ -> fail "getTypeRepX: Kind mismatch" _ -> fail "getTypeRepX: Applied non-arrow type" _ -> fail "getTypeRepX: Invalid TypeRepX" From git at git.haskell.org Mon Mar 21 17:11:11 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:11 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix recursive fingerprints (06ede7f) Message-ID: <20160321171111.9C16F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/06ede7f4ce148fdda5ec5f8a24f8f7f5ca3fa7cd/ghc >--------------------------------------------------------------- commit 06ede7f4ce148fdda5ec5f8a24f8f7f5ca3fa7cd Author: Ben Gamari Date: Wed Mar 16 11:53:01 2016 +0100 Fix recursive fingerprints >--------------------------------------------------------------- 06ede7f4ce148fdda5ec5f8a24f8f7f5ca3fa7cd libraries/base/Data/Typeable/Internal.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 7a3344e..bb2bcc2 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -429,11 +429,20 @@ For this reason we are forced to define their representations manually. -} +-- | We can't use 'mkTrCon' here as it requires the fingerprint of the kind +-- which is knot-tied. +mkPrimTrCon :: forall k (a :: k). TyCon -> TypeRep k -> TypeRep a +mkPrimTrCon tc kind = TrTyCon fpr tc kind + where + fpr_tc = tyConFingerprint tc + fpr_tag = fingerprintString "prim" + fpr = fingerprintFingerprints [fpr_tag, fpr_tc] + mkPrimTyCon :: String -> TyCon mkPrimTyCon = mkTyCon "ghc-prim" "GHC.Prim" trTYPE :: TypeRep TYPE -trTYPE = mkTrCon (mkPrimTyCon "TYPE") runtimeRep_arr_type +trTYPE = mkPrimTrCon (mkPrimTyCon "TYPE") runtimeRep_arr_type where runtimeRep_arr :: TypeRep ((->) RuntimeRep) runtimeRep_arr = mkTrApp trArrow trRuntimeRep @@ -442,10 +451,10 @@ trTYPE = mkTrCon (mkPrimTyCon "TYPE") runtimeRep_arr_type runtimeRep_arr_type = mkTrApp runtimeRep_arr star trRuntimeRep :: TypeRep RuntimeRep -trRuntimeRep = mkTrCon (mkPrimTyCon "RuntimeRep") star +trRuntimeRep = mkPrimTrCon (mkPrimTyCon "RuntimeRep") star tr'PtrRepLifted :: TypeRep 'PtrRepLifted -tr'PtrRepLifted = mkTrCon (mkPrimTyCon "'PtrRepLifted") trRuntimeRep +tr'PtrRepLifted = mkPrimTrCon (mkPrimTyCon "'PtrRepLifted") trRuntimeRep trTYPE'PtrRepLifted :: TypeRep (TYPE 'PtrRepLifted) trTYPE'PtrRepLifted = mkTrApp trTYPE tr'PtrRepLifted @@ -454,7 +463,7 @@ trArrowTyCon :: TyCon trArrowTyCon = mkPrimTyCon "->" trArrow :: TypeRep (->) -trArrow = mkTrCon trArrowTyCon star_arr_star_arr_star +trArrow = mkPrimTrCon trArrowTyCon star_arr_star_arr_star -- Some useful aliases star :: TypeRep (TYPE 'PtrRepLifted) From git at git.haskell.org Mon Mar 21 17:11:14 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:14 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Break recursive loop in serialization (228dbdb) Message-ID: <20160321171114.6AE6E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/228dbdb9a7b6d454fe92d4861299c936f265f0ef/ghc >--------------------------------------------------------------- commit 228dbdb9a7b6d454fe92d4861299c936f265f0ef Author: Ben Gamari Date: Wed Mar 16 13:01:45 2016 +0100 Break recursive loop in serialization >--------------------------------------------------------------- 228dbdb9a7b6d454fe92d4861299c936f265f0ef compiler/utils/Binary.hs | 18 ++++++++++++++---- libraries/ghci/GHCi/TH/Binary.hs | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index a346e0d..b26778e 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -82,6 +82,7 @@ import Data.Time import Type.Reflection import Type.Reflection.Unsafe import Data.Kind (Type) +import GHC.Exts (RuntimeRep) #else import Data.Typeable #endif @@ -579,12 +580,19 @@ instance Binary TyCon where #if MIN_VERSION_base(4,9,0) putTypeRep :: BinHandle -> TypeRep a -> IO () +-- Special handling for Type and RuntimeRep due to recursive kind relations. +-- See Note [Mutually recursive representations of primitive types] +putTypeRep bh rep + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type) + = put_ bh (0 :: Word8) + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep RuntimeRep) + = put_ bh (1 :: Word8) putTypeRep bh rep@(TRCon con) = do - put_ bh (0 :: Word8) + put_ bh (2 :: Word8) put_ bh con putTypeRep bh (typeRepKind rep) putTypeRep bh (TRApp f x) = do - put_ bh (1 :: Word8) + put_ bh (3 :: Word8) putTypeRep bh f putTypeRep bh x putTypeRep _ _ = fail "putTypeRep: Impossible" @@ -593,13 +601,15 @@ getTypeRepX :: BinHandle -> IO TypeRepX getTypeRepX bh = do tag <- get bh :: IO Word8 case tag of - 0 -> do con <- get bh :: IO TyCon + 0 -> return $ TypeRepX (typeRep :: TypeRep Type) + 1 -> return $ TypeRepX (typeRep :: TypeRep RuntimeRep) + 2 -> do con <- get bh :: IO TyCon TypeRepX rep_k <- getTypeRepX bh case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k Nothing -> fail "getTypeRepX: Kind mismatch" - 1 -> do TypeRepX f <- getTypeRepX bh + 3 -> do TypeRepX f <- getTypeRepX bh TypeRepX x <- getTypeRepX bh case typeRepKind f of TRFun arg _ -> diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index 2f41645..fcd81d3 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -14,6 +14,7 @@ import qualified Data.ByteString as B import Type.Reflection import Type.Reflection.Unsafe import Data.Kind (Type) +import GHC.Exts (RuntimeRep) #else import Data.Typeable #endif @@ -79,12 +80,19 @@ instance Binary TyCon where get = mkTyCon <$> get <*> get <*> get putTypeRep :: TypeRep a -> Put +-- Special handling for Type and RuntimeRep due to recursive kind relations. +-- See Note [Mutually recursive representations of primitive types] +putTypeRep rep + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type) + = put (0 :: Word8) + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep RuntimeRep) + = put (1 :: Word8) putTypeRep rep@(TRCon con) = do - put (0 :: Word8) + put (2 :: Word8) put con putTypeRep (typeRepKind rep) putTypeRep (TRApp f x) = do - put (1 :: Word8) + put (3 :: Word8) putTypeRep f putTypeRep x putTypeRep _ = fail "putTypeRep: Impossible" @@ -93,13 +101,15 @@ getTypeRepX :: Get TypeRepX getTypeRepX = do tag <- get :: Get Word8 case tag of - 0 -> do con <- get :: Get TyCon + 0 -> return $ TypeRepX (typeRep :: TypeRep Type) + 1 -> return $ TypeRepX (typeRep :: TypeRep RuntimeRep) + 2 -> do con <- get :: Get TyCon TypeRepX rep_k <- getTypeRepX case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k Nothing -> fail "getTypeRepX: Kind mismatch" - 1 -> do TypeRepX f <- getTypeRepX + 3 -> do TypeRepX f <- getTypeRepX TypeRepX x <- getTypeRepX case typeRepKind f of TRFun arg _ -> From git at git.haskell.org Mon Mar 21 17:11:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:17 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Kill todo (8700769) Message-ID: <20160321171117.5AC5D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/8700769c923c5fdde510b4598c4751b1b0cd9cd0/ghc >--------------------------------------------------------------- commit 8700769c923c5fdde510b4598c4751b1b0cd9cd0 Author: Ben Gamari Date: Wed Mar 16 13:36:24 2016 +0100 Kill todo >--------------------------------------------------------------- 8700769c923c5fdde510b4598c4751b1b0cd9cd0 libraries/base/Data/Typeable/Internal.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index bb2bcc2..2252634 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -261,8 +261,7 @@ typeRepKind (TrTyCon _ _ k) = k typeRepKind (TrApp _ f _) = case typeRepKind f of TRFun _arg res -> res - -- TODO: why is this case needed? - _ -> error "typeRepKind: impossible" + _ -> error "typeRepKind: impossible" -- | Observe the type constructor of a quantified type representation. typeRepXTyCon :: TypeRepX -> TyCon From git at git.haskell.org Mon Mar 21 17:11:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:20 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix up representation pretty-printer (a604ce9) Message-ID: <20160321171120.22FE13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/a604ce9471cec93050929fa0a34df10cb936fe29/ghc >--------------------------------------------------------------- commit a604ce9471cec93050929fa0a34df10cb936fe29 Author: Ben Gamari Date: Wed Mar 16 13:36:30 2016 +0100 Fix up representation pretty-printer >--------------------------------------------------------------- a604ce9471cec93050929fa0a34df10cb936fe29 libraries/base/Data/Typeable/Internal.hs | 44 +++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 2252634..3b84aba 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -317,28 +317,48 @@ typeRepXFingerprint (TypeRepX t) = typeRepFingerprint t ----------------- Showing TypeReps -------------------- -instance Show (TypeRep a) where +instance Show (TypeRep (a :: k)) where + showsPrec _ rep + | isListTyCon tc, [ty] <- tys = + showChar '[' . shows ty . showChar ']' + | isTupleTyCon tc = + showChar '(' . showArgs (showChar ',') tys . showChar ')' + where (tc, tys) = splitApps rep showsPrec p (TrTyCon _ tycon _) = showsPrec p tycon - showsPrec p (TrApp _ f x) = showsPrec p f . showString " " . showsPrec p x - -- TODO: Reconsider precedence + showsPrec p (TrApp _ f x) + | Just HRefl <- f `eqTypeRep` (typeRep :: TypeRep (->)) = + shows x . showString " -> " + | otherwise = + showsPrec p f . space . showParen need_parens (showsPrec 10 x) + where + space = showChar ' ' + need_parens = case x of + TrApp {} -> True + TrTyCon {} -> False instance Show TypeRepX where showsPrec p (TypeRepX ty) = showsPrec p ty --- Some (Show.TypeRepX) helpers: -{- --- FIXME: Handle tuples, etc. +splitApps :: TypeRep a -> (TyCon, [TypeRepX]) +splitApps = go [] + where + go :: [TypeRepX] -> TypeRep a -> (TyCon, [TypeRepX]) + go xs (TrTyCon _ tc _) = (tc, xs) + go xs (TrApp _ f x) = go (TypeRepX x : xs) f + +isListTyCon :: TyCon -> Bool +isListTyCon tc = tc == typeRepTyCon (typeRep :: TypeRep [Int]) + +isTupleTyCon :: TyCon -> Bool +isTupleTyCon tc + | ('(':',':_) <- tyConName tc = True + | otherwise = False + showArgs :: Show a => ShowS -> [a] -> ShowS showArgs _ [] = id showArgs _ [a] = showsPrec 10 a showArgs sep (a:as) = showsPrec 10 a . sep . showArgs sep as -showTuple :: [TypeRepX] -> ShowS -showTuple args = showChar '(' - . showArgs (showChar ',') args - . showChar ')' --} - -- | Helper to fully evaluate 'TypeRep' for use as @NFData(rnf)@ implementation -- -- @since TODO From git at git.haskell.org Mon Mar 21 17:11:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:22 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Another recursive serialization case (9453c38) Message-ID: <20160321171122.CF21F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/9453c38a9b71312190d4c63baf95c7d08e124042/ghc >--------------------------------------------------------------- commit 9453c38a9b71312190d4c63baf95c7d08e124042 Author: Ben Gamari Date: Wed Mar 16 14:05:43 2016 +0100 Another recursive serialization case >--------------------------------------------------------------- 9453c38a9b71312190d4c63baf95c7d08e124042 compiler/utils/Binary.hs | 14 +++++++++----- libraries/ghci/GHCi/TH/Binary.hs | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index b26778e..879a67f 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -580,19 +580,22 @@ instance Binary TyCon where #if MIN_VERSION_base(4,9,0) putTypeRep :: BinHandle -> TypeRep a -> IO () --- Special handling for Type and RuntimeRep due to recursive kind relations. +-- Special handling for Type, (->), and RuntimeRep due to recursive kind +-- relations. -- See Note [Mutually recursive representations of primitive types] putTypeRep bh rep | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type) = put_ bh (0 :: Word8) | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep RuntimeRep) = put_ bh (1 :: Word8) + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep (->)) + = put_ bh (2 :: Word8) putTypeRep bh rep@(TRCon con) = do - put_ bh (2 :: Word8) + put_ bh (3 :: Word8) put_ bh con putTypeRep bh (typeRepKind rep) putTypeRep bh (TRApp f x) = do - put_ bh (3 :: Word8) + put_ bh (4 :: Word8) putTypeRep bh f putTypeRep bh x putTypeRep _ _ = fail "putTypeRep: Impossible" @@ -603,13 +606,14 @@ getTypeRepX bh = do case tag of 0 -> return $ TypeRepX (typeRep :: TypeRep Type) 1 -> return $ TypeRepX (typeRep :: TypeRep RuntimeRep) - 2 -> do con <- get bh :: IO TyCon + 2 -> return $ TypeRepX (typeRep :: TypeRep (->)) + 3 -> do con <- get bh :: IO TyCon TypeRepX rep_k <- getTypeRepX bh case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k Nothing -> fail "getTypeRepX: Kind mismatch" - 3 -> do TypeRepX f <- getTypeRepX bh + 4 -> do TypeRepX f <- getTypeRepX bh TypeRepX x <- getTypeRepX bh case typeRepKind f of TRFun arg _ -> diff --git a/libraries/ghci/GHCi/TH/Binary.hs b/libraries/ghci/GHCi/TH/Binary.hs index fcd81d3..e1782f9 100644 --- a/libraries/ghci/GHCi/TH/Binary.hs +++ b/libraries/ghci/GHCi/TH/Binary.hs @@ -80,19 +80,22 @@ instance Binary TyCon where get = mkTyCon <$> get <*> get <*> get putTypeRep :: TypeRep a -> Put --- Special handling for Type and RuntimeRep due to recursive kind relations. +-- Special handling for Type, (->), and RuntimeRep due to recursive kind +-- relations. -- See Note [Mutually recursive representations of primitive types] putTypeRep rep | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type) = put (0 :: Word8) | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep RuntimeRep) = put (1 :: Word8) + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep (->)) + = put (2 :: Word8) putTypeRep rep@(TRCon con) = do - put (2 :: Word8) + put (3 :: Word8) put con putTypeRep (typeRepKind rep) putTypeRep (TRApp f x) = do - put (3 :: Word8) + put (4 :: Word8) putTypeRep f putTypeRep x putTypeRep _ = fail "putTypeRep: Impossible" @@ -103,13 +106,14 @@ getTypeRepX = do case tag of 0 -> return $ TypeRepX (typeRep :: TypeRep Type) 1 -> return $ TypeRepX (typeRep :: TypeRep RuntimeRep) - 2 -> do con <- get :: Get TyCon + 2 -> return $ TypeRepX (typeRep :: TypeRep (->)) + 3 -> do con <- get :: Get TyCon TypeRepX rep_k <- getTypeRepX case rep_k `eqTypeRep` (typeRep :: TypeRep Type) of Just HRefl -> pure $ TypeRepX $ mkTrCon con rep_k Nothing -> fail "getTypeRepX: Kind mismatch" - 3 -> do TypeRepX f <- getTypeRepX + 4 -> do TypeRepX f <- getTypeRepX TypeRepX x <- getTypeRepX case typeRepKind f of TRFun arg _ -> From git at git.haskell.org Mon Mar 21 17:11:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:25 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: TcTypeable: Don't generate bindings for special primitive tycons (5812687) Message-ID: <20160321171125.95FAC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/5812687c24fe95ed524ab53f750e9af9189c6ad6/ghc >--------------------------------------------------------------- commit 5812687c24fe95ed524ab53f750e9af9189c6ad6 Author: Ben Gamari Date: Wed Mar 16 15:34:03 2016 +0100 TcTypeable: Don't generate bindings for special primitive tycons >--------------------------------------------------------------- 5812687c24fe95ed524ab53f750e9af9189c6ad6 compiler/typecheck/TcTypeable.hs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/TcTypeable.hs b/compiler/typecheck/TcTypeable.hs index 3b380f7..b59489d 100644 --- a/compiler/typecheck/TcTypeable.hs +++ b/compiler/typecheck/TcTypeable.hs @@ -13,7 +13,8 @@ import IfaceEnv( newGlobalBinder ) import TcEnv import TcRnMonad import PrelNames -import TysPrim ( primTyCons ) +import TysPrim ( primTyCons, tYPETyConName, funTyConName ) +import TysWiredIn ( runtimeRepTyCon ) import Id import Type import TyCon @@ -21,6 +22,7 @@ import DataCon import Name( getOccName ) import OccName import Module +import NameSet import HsSyn import DynFlags import Bag @@ -164,6 +166,17 @@ mkTypeableTyConBinds tycons ; gbl_env <- tcExtendGlobalValEnv tycon_rep_ids getGblEnv ; return (gbl_env `addTypecheckedBinds` tc_binds) } +-- | The names of the 'TyCon's which we handle explicitly in "Data.Typeable.Internal" +-- and should not generate bindings for in "GHC.Types". +-- +-- See Note [Mutually recursive representations of primitive types] +specialPrimTyCons :: NameSet +specialPrimTyCons = mkNameSet + [ tYPETyConName + , tyConName runtimeRepTyCon + , funTyConName + ] + -- | Generate bindings for the type representation of a wired-in TyCon defined -- by the virtual "GHC.Prim" module. This is where we inject the representation -- bindings for primitive types into "GHC.Types" @@ -207,7 +220,9 @@ ghcPrimTypeableBinds stuff where all_prim_tys :: [TyCon] all_prim_tys = [ tc' | tc <- funTyCon : primTyCons - , tc' <- tc : tyConATs tc ] + , tc' <- tc : tyConATs tc + , not $ tyConName tc' `elemNameSet` specialPrimTyCons + ] mkBind :: TyCon -> LHsBinds Id mkBind = mk_typeable_binds stuff From git at git.haskell.org Mon Mar 21 17:11:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:28 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Move special tycons (0a6cd5b) Message-ID: <20160321171128.633FB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/0a6cd5b1a58c8222b970d3efc222f97ce748be09/ghc >--------------------------------------------------------------- commit 0a6cd5b1a58c8222b970d3efc222f97ce748be09 Author: Ben Gamari Date: Wed Mar 16 17:51:01 2016 +0100 Move special tycons >--------------------------------------------------------------- 0a6cd5b1a58c8222b970d3efc222f97ce748be09 compiler/prelude/TysPrim.hs | 16 +++++++++++++++- compiler/typecheck/TcTypeable.hs | 18 +++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/compiler/prelude/TysPrim.hs b/compiler/prelude/TysPrim.hs index ce25c30..34f020c 100644 --- a/compiler/prelude/TysPrim.hs +++ b/compiler/prelude/TysPrim.hs @@ -27,6 +27,7 @@ module TysPrim( funTyCon, funTyConName, primTyCons, + primTypeableTyCons, charPrimTyCon, charPrimTy, intPrimTyCon, intPrimTy, @@ -79,7 +80,7 @@ module TysPrim( #include "HsVersions.h" import {-# SOURCE #-} TysWiredIn - ( runtimeRepTy, liftedTypeKind + ( runtimeRepTyCon, runtimeRepTy, liftedTypeKind , vecRepDataConTyCon, ptrRepUnliftedDataConTyCon , voidRepDataConTy, intRepDataConTy , wordRepDataConTy, int64RepDataConTy, word64RepDataConTy, addrRepDataConTy @@ -93,6 +94,7 @@ import {-# SOURCE #-} TysWiredIn import Var ( TyVar, KindVar, mkTyVar ) import Name +import NameEnv import TyCon import SrcLoc import Unique @@ -155,6 +157,18 @@ primTyCons #include "primop-vector-tycons.hs-incl" ] +-- | The names of the 'TyCon's which we define 'Typeable' bindings for +-- explicitly in "Data.Typeable.Internal" +-- and should not generate bindings for in "GHC.Types". +-- +-- See Note [Mutually recursive representations of primitive types] +primTypeableTyCons :: NameEnv TyConRepName +primTypeableTyCons = mkNameEnv + [ (tYPETyConName, trTYPEName) + , (tyConName runtimeRepTyCon, trRuntimeRepName) + , (funTyConName, trArrowName) + ] + mkPrimTc :: FastString -> Unique -> TyCon -> Name mkPrimTc fs unique tycon = mkWiredInName gHC_PRIM (mkTcOccFS fs) diff --git a/compiler/typecheck/TcTypeable.hs b/compiler/typecheck/TcTypeable.hs index b59489d..d0360f5 100644 --- a/compiler/typecheck/TcTypeable.hs +++ b/compiler/typecheck/TcTypeable.hs @@ -13,8 +13,7 @@ import IfaceEnv( newGlobalBinder ) import TcEnv import TcRnMonad import PrelNames -import TysPrim ( primTyCons, tYPETyConName, funTyConName ) -import TysWiredIn ( runtimeRepTyCon ) +import TysPrim ( primTyCons, primTypeableTyCons ) import Id import Type import TyCon @@ -22,7 +21,7 @@ import DataCon import Name( getOccName ) import OccName import Module -import NameSet +import NameEnv import HsSyn import DynFlags import Bag @@ -166,17 +165,6 @@ mkTypeableTyConBinds tycons ; gbl_env <- tcExtendGlobalValEnv tycon_rep_ids getGblEnv ; return (gbl_env `addTypecheckedBinds` tc_binds) } --- | The names of the 'TyCon's which we handle explicitly in "Data.Typeable.Internal" --- and should not generate bindings for in "GHC.Types". --- --- See Note [Mutually recursive representations of primitive types] -specialPrimTyCons :: NameSet -specialPrimTyCons = mkNameSet - [ tYPETyConName - , tyConName runtimeRepTyCon - , funTyConName - ] - -- | Generate bindings for the type representation of a wired-in TyCon defined -- by the virtual "GHC.Prim" module. This is where we inject the representation -- bindings for primitive types into "GHC.Types" @@ -221,7 +209,7 @@ ghcPrimTypeableBinds stuff all_prim_tys :: [TyCon] all_prim_tys = [ tc' | tc <- funTyCon : primTyCons , tc' <- tc : tyConATs tc - , not $ tyConName tc' `elemNameSet` specialPrimTyCons + , not $ tyConName tc' `elemNameEnv` primTypeableTyCons ] mkBind :: TyCon -> LHsBinds Id From git at git.haskell.org Mon Mar 21 17:11:31 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:31 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix pretty-printer (f4a82ef) Message-ID: <20160321171131.5A01B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/f4a82ef1647378634d87cff2b3b7eab8d0954cc2/ghc >--------------------------------------------------------------- commit f4a82ef1647378634d87cff2b3b7eab8d0954cc2 Author: Ben Gamari Date: Wed Mar 16 22:07:23 2016 +0100 Fix pretty-printer >--------------------------------------------------------------- f4a82ef1647378634d87cff2b3b7eab8d0954cc2 libraries/base/Data/Typeable/Internal.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index dd66283..7a2e914 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -343,14 +343,18 @@ instance Show (TypeRep (a :: k)) where showChar '(' . showArgs (showChar ',') tys . showChar ')' where (tc, tys) = splitApps rep showsPrec p (TrTyCon _ tycon _) = showsPrec p tycon - showsPrec _ (TrApp _ (TrTyCon _ tycon _) x) + --showsPrec p (TRFun x r) = + -- showParen (p > 8) $ + -- showsPrec 9 x . showString " -> " . showsPrec 8 r + showsPrec p (TrApp _ (TrApp _ (TrTyCon _ tycon _) x) r) | isArrowTyCon tycon = - shows x . showString " ->" + showParen (p > 8) $ + showsPrec 9 x . showString " -> " . showsPrec p r showsPrec p (TrApp _ f x) | otherwise = showParen (p > 9) $ - showsPrec p f . + showsPrec 8 f . space . showsPrec 9 x where From git at git.haskell.org Mon Mar 21 17:11:34 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:34 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Kill debugShow (13e8b88) Message-ID: <20160321171134.2FB0D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/13e8b88fa7d6b15e7ebd771b0d44c615c597cd87/ghc >--------------------------------------------------------------- commit 13e8b88fa7d6b15e7ebd771b0d44c615c597cd87 Author: Ben Gamari Date: Wed Mar 16 22:08:49 2016 +0100 Kill debugShow >--------------------------------------------------------------- 13e8b88fa7d6b15e7ebd771b0d44c615c597cd87 libraries/base/Data/Typeable/Internal.hs | 18 ------------------ libraries/base/Type/Reflection.hs | 1 - 2 files changed, 19 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 7a2e914..09db187 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -71,8 +71,6 @@ module Data.Typeable.Internal ( mkTrCon, mkTrApp, mkTyCon, mkTyCon#, typeSymbolTypeRep, typeNatTypeRep, - debugShow, - -- * Representations for primitive types trTYPE, trTYPE'PtrRepLifted, @@ -319,22 +317,6 @@ typeRepXFingerprint (TypeRepX t) = typeRepFingerprint t ----------------- Showing TypeReps -------------------- -debugShow :: TypeRep a -> String -debugShow rep - | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type) = "Type" - | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep RuntimeRep) = "RuntimeRep" - | (tc, _) <- splitApps rep - , isArrowTyCon tc = "Arrow" -debugShow (TrApp _ f x) = "App ("++debugShow f++") ("++debugShow x++")" -debugShow (TrTyCon _ x k) - | isArrowTyCon x = "Arrow" - | "->" <- show x = "Arrow #" ++ show ( tyConFingerprint x - , tyConFingerprint trArrowTyCon - , tyConFingerprint $ typeRepTyCon (typeRep :: TypeRep (->)) - , typeRepTyCon (typeRep :: TypeRep (->)) - ) - | otherwise = show x++" :: "++debugShow k - instance Show (TypeRep (a :: k)) where showsPrec _ rep | isListTyCon tc, [ty] <- tys = diff --git a/libraries/base/Type/Reflection.hs b/libraries/base/Type/Reflection.hs index 480e148..8057a2e 100644 --- a/libraries/base/Type/Reflection.hs +++ b/libraries/base/Type/Reflection.hs @@ -37,7 +37,6 @@ module Type.Reflection , I.tyConModule , I.tyConName , I.rnfTyCon - , I.debugShow ) where import qualified Data.Typeable.Internal as I From git at git.haskell.org Mon Mar 21 17:11:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:36 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix primitive types (e19c41e) Message-ID: <20160321171136.F2FB33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/e19c41e95b087992debda468cf79e23854a9808e/ghc >--------------------------------------------------------------- commit e19c41e95b087992debda468cf79e23854a9808e Author: Ben Gamari Date: Wed Mar 16 19:52:17 2016 +0100 Fix primitive types >--------------------------------------------------------------- e19c41e95b087992debda468cf79e23854a9808e compiler/prelude/TysPrim.hs | 2 +- compiler/typecheck/TcInteract.hs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/prelude/TysPrim.hs b/compiler/prelude/TysPrim.hs index 34f020c..81fc3f9 100644 --- a/compiler/prelude/TysPrim.hs +++ b/compiler/prelude/TysPrim.hs @@ -20,7 +20,7 @@ module TysPrim( kKiVar, -- Kind constructors... - tYPETyConName, unliftedTypeKindTyConName, + tYPETyCon, tYPETyConName, unliftedTypeKindTyConName, -- Kinds tYPE, diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs index e93f303..b1f138f 100644 --- a/compiler/typecheck/TcInteract.hs +++ b/compiler/typecheck/TcInteract.hs @@ -24,10 +24,10 @@ import Name import PrelNames ( knownNatClassName, knownSymbolClassName, typeableClassName, coercibleTyConKey, heqTyConKey, ipClassKey, - trTYPE'PtrRepLiftedName, trRuntimeRepName, trArrowName ) + trTYPEName, trTYPE'PtrRepLiftedName, trRuntimeRepName, trArrowName ) import TysWiredIn ( typeNatKind, typeSymbolKind, heqDataCon, coercibleDataCon, runtimeRepTy ) -import TysPrim ( eqPrimTyCon, eqReprPrimTyCon ) +import TysPrim ( eqPrimTyCon, eqReprPrimTyCon, tYPETyCon ) import Id( idType ) import CoAxiom ( Eqn, CoAxiom(..), CoAxBranch(..), fromBranches ) import Class @@ -2000,7 +2000,9 @@ matchTypeable clas [k,t] -- clas = Typeable | k `eqType` typeNatKind = doTyLit knownNatClassName t | k `eqType` typeSymbolKind = doTyLit knownSymbolClassName t | t `eqType` liftedTypeKind = doPrimRep trTYPE'PtrRepLiftedName t + | t `eqType` mkTyConTy tYPETyCon = doPrimRep trTYPEName t | t `eqType` runtimeRepTy = doPrimRep trRuntimeRepName t + | t `eqType` mkTyConTy funTyCon = doPrimRep trArrowName t | Just (tc, ks) <- splitTyConApp_maybe t -- See Note [Typeable (T a b c)] , onlyNamedBndrsApplied tc ks = doTyConApp clas t tc | Just (arg,ret) <- splitFunTy_maybe t = doFunTy clas t arg ret From git at git.haskell.org Mon Mar 21 17:11:39 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:39 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Internal things (1f0ffda) Message-ID: <20160321171139.AD0313A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/1f0ffda9e636bd78628619b81a59683cdf3ef20c/ghc >--------------------------------------------------------------- commit 1f0ffda9e636bd78628619b81a59683cdf3ef20c Author: Ben Gamari Date: Wed Mar 16 17:51:27 2016 +0100 Internal things >--------------------------------------------------------------- 1f0ffda9e636bd78628619b81a59683cdf3ef20c libraries/base/Data/Typeable/Internal.hs | 35 ++++++++++++++++++++++++++------ libraries/base/Type/Reflection.hs | 1 + 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 3b84aba..dd66283 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -71,6 +71,8 @@ module Data.Typeable.Internal ( mkTrCon, mkTrApp, mkTyCon, mkTyCon#, typeSymbolTypeRep, typeNatTypeRep, + debugShow, + -- * Representations for primitive types trTYPE, trTYPE'PtrRepLifted, @@ -317,6 +319,22 @@ typeRepXFingerprint (TypeRepX t) = typeRepFingerprint t ----------------- Showing TypeReps -------------------- +debugShow :: TypeRep a -> String +debugShow rep + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep Type) = "Type" + | Just HRefl <- rep `eqTypeRep` (typeRep :: TypeRep RuntimeRep) = "RuntimeRep" + | (tc, _) <- splitApps rep + , isArrowTyCon tc = "Arrow" +debugShow (TrApp _ f x) = "App ("++debugShow f++") ("++debugShow x++")" +debugShow (TrTyCon _ x k) + | isArrowTyCon x = "Arrow" + | "->" <- show x = "Arrow #" ++ show ( tyConFingerprint x + , tyConFingerprint trArrowTyCon + , tyConFingerprint $ typeRepTyCon (typeRep :: TypeRep (->)) + , typeRepTyCon (typeRep :: TypeRep (->)) + ) + | otherwise = show x++" :: "++debugShow k + instance Show (TypeRep (a :: k)) where showsPrec _ rep | isListTyCon tc, [ty] <- tys = @@ -325,16 +343,18 @@ instance Show (TypeRep (a :: k)) where showChar '(' . showArgs (showChar ',') tys . showChar ')' where (tc, tys) = splitApps rep showsPrec p (TrTyCon _ tycon _) = showsPrec p tycon + showsPrec _ (TrApp _ (TrTyCon _ tycon _) x) + | isArrowTyCon tycon = + shows x . showString " ->" + showsPrec p (TrApp _ f x) - | Just HRefl <- f `eqTypeRep` (typeRep :: TypeRep (->)) = - shows x . showString " -> " | otherwise = - showsPrec p f . space . showParen need_parens (showsPrec 10 x) + showParen (p > 9) $ + showsPrec p f . + space . + showsPrec 9 x where space = showChar ' ' - need_parens = case x of - TrApp {} -> True - TrTyCon {} -> False instance Show TypeRepX where showsPrec p (TypeRepX ty) = showsPrec p ty @@ -346,6 +366,9 @@ splitApps = go [] go xs (TrTyCon _ tc _) = (tc, xs) go xs (TrApp _ f x) = go (TypeRepX x : xs) f +isArrowTyCon :: TyCon -> Bool +isArrowTyCon tc = tc == typeRepTyCon (typeRep :: TypeRep (->)) + isListTyCon :: TyCon -> Bool isListTyCon tc = tc == typeRepTyCon (typeRep :: TypeRep [Int]) diff --git a/libraries/base/Type/Reflection.hs b/libraries/base/Type/Reflection.hs index 8057a2e..480e148 100644 --- a/libraries/base/Type/Reflection.hs +++ b/libraries/base/Type/Reflection.hs @@ -37,6 +37,7 @@ module Type.Reflection , I.tyConModule , I.tyConName , I.rnfTyCon + , I.debugShow ) where import qualified Data.Typeable.Internal as I From git at git.haskell.org Mon Mar 21 17:11:42 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:42 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Inline space (947b310) Message-ID: <20160321171142.6D3A83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/947b310cd2011177ec12ea3ae6c3a6e2ffcde79f/ghc >--------------------------------------------------------------- commit 947b310cd2011177ec12ea3ae6c3a6e2ffcde79f Author: Ben Gamari Date: Wed Mar 16 22:10:16 2016 +0100 Inline space >--------------------------------------------------------------- 947b310cd2011177ec12ea3ae6c3a6e2ffcde79f libraries/base/Data/Typeable/Internal.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 09db187..c145773 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -337,10 +337,8 @@ instance Show (TypeRep (a :: k)) where | otherwise = showParen (p > 9) $ showsPrec 8 f . - space . + showChar ' ' . showsPrec 9 x - where - space = showChar ' ' instance Show TypeRepX where showsPrec p (TypeRepX ty) = showsPrec p ty From git at git.haskell.org Mon Mar 21 17:11:45 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:45 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Accept easy test output (c92c1dc) Message-ID: <20160321171145.3FDBC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/c92c1dc498d734844b2124dc957365ea53cd8b9f/ghc >--------------------------------------------------------------- commit c92c1dc498d734844b2124dc957365ea53cd8b9f Author: Ben Gamari Date: Wed Mar 16 22:58:53 2016 +0100 Accept easy test output >--------------------------------------------------------------- c92c1dc498d734844b2124dc957365ea53cd8b9f testsuite/tests/ghci.debugger/scripts/print019.stderr | 6 +++--- testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/testsuite/tests/ghci.debugger/scripts/print019.stderr b/testsuite/tests/ghci.debugger/scripts/print019.stderr index cc62fa1..c266bc8 100644 --- a/testsuite/tests/ghci.debugger/scripts/print019.stderr +++ b/testsuite/tests/ghci.debugger/scripts/print019.stderr @@ -5,10 +5,10 @@ Use :print or :force to determine these types Relevant bindings include it :: a1 (bound at :10:1) These potential instances exist: - instance Show TypeRep -- Defined in ?Data.Typeable.Internal? instance Show Ordering -- Defined in ?GHC.Show? instance Show TyCon -- Defined in ?GHC.Show? - ...plus 30 others - ...plus 10 instances involving out-of-scope types + instance Show Integer -- Defined in ?GHC.Show? + ...plus 29 others + ...plus 12 instances involving out-of-scope types (use -fprint-potential-instances to see them all) ? In a stmt of an interactive GHCi command: print it diff --git a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr index e6e637c..b48d63f 100644 --- a/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr +++ b/testsuite/tests/typecheck/should_fail/TcStaticPointersFail02.stderr @@ -1,13 +1,13 @@ TcStaticPointersFail02.hs:9:6: error: - ? No instance for (Data.Typeable.Internal.Typeable b) + ? No instance for (base-4.9.0.0:Data.Typeable.Internal.Typeable b) arising from a static form ? In the expression: static (undefined :: (forall a. a -> a) -> b) In an equation for ?f1?: f1 = static (undefined :: (forall a. a -> a) -> b) TcStaticPointersFail02.hs:12:6: error: - ? No instance for (Data.Typeable.Internal.Typeable + ? No instance for (base-4.9.0.0:Data.Typeable.Internal.Typeable (Monad m => a -> m a)) arising from a static form (maybe you haven't applied a function to enough arguments?) From git at git.haskell.org Mon Mar 21 17:11:48 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:48 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Add mkFunTy (e3242bd) Message-ID: <20160321171148.317B43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/e3242bd82331b1afd225c154ca44e0482db103d9/ghc >--------------------------------------------------------------- commit e3242bd82331b1afd225c154ca44e0482db103d9 Author: Ben Gamari Date: Wed Mar 16 23:15:36 2016 +0100 Add mkFunTy >--------------------------------------------------------------- e3242bd82331b1afd225c154ca44e0482db103d9 libraries/base/Data/Typeable.hs | 14 ++++++++++++++ libraries/base/Data/Typeable/Internal.hs | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libraries/base/Data/Typeable.hs b/libraries/base/Data/Typeable.hs index 21f93d2..3eb53c5 100644 --- a/libraries/base/Data/Typeable.hs +++ b/libraries/base/Data/Typeable.hs @@ -68,6 +68,7 @@ module Data.Typeable , typeRepTyCon , rnfTypeRep , showsTypeRep + , mkFunTy -- * Observing type representations , funResultTy @@ -168,6 +169,19 @@ funResultTy (I.TypeRepX f) (I.TypeRepX x) = -} funResultTy _ _ = Nothing +-- | Build a function type. +mkFunTy :: TypeRep -> TypeRep -> TypeRep +mkFunTy (I.TypeRepX arg) (I.TypeRepX res) + | Just HRefl <- arg `I.eqTypeRep` liftedTy + , Just HRefl <- res `I.eqTypeRep` liftedTy + = I.TypeRepX (I.TRFun arg res) + | otherwise + = error $ "mkFunTy: Attempted to construct function type from non-lifted "++ + "type: arg="++show arg++", res="++show res + where liftedTy = I.typeRep :: I.TypeRep * + -- TODO: We should be able to support this but the kind of (->) must be + -- generalized + -- | Force a 'TypeRep' to normal form. rnfTypeRep :: TypeRep -> () rnfTypeRep = I.rnfTypeRepX diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index c145773..2053adb 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -187,7 +187,8 @@ pattern TRFun :: forall fun. () => TypeRep arg -> TypeRep res -> TypeRep fun -pattern TRFun arg res <- TrApp _ (TrApp _ (eqTypeRep trArrow -> Just HRefl) arg) res +pattern TRFun arg res <- TrApp _ (TrApp _ (eqTypeRep trArrow -> Just HRefl) arg) res where + TRFun arg res = mkTrApp (mkTrApp trArrow arg) res decomposeFun :: forall fun r. TypeRep fun From git at git.haskell.org Mon Mar 21 17:11:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:50 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: More test fixes (40b7367) Message-ID: <20160321171150.EC5D93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/40b7367003948074b04666d886b4c1adb53f5990/ghc >--------------------------------------------------------------- commit 40b7367003948074b04666d886b4c1adb53f5990 Author: Ben Gamari Date: Wed Mar 16 23:15:48 2016 +0100 More test fixes >--------------------------------------------------------------- 40b7367003948074b04666d886b4c1adb53f5990 libraries/base/tests/dynamic002.hs | 5 +++++ libraries/base/tests/dynamic004.hs | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/base/tests/dynamic002.hs b/libraries/base/tests/dynamic002.hs index 6d53d2e..fff14ec 100644 --- a/libraries/base/tests/dynamic002.hs +++ b/libraries/base/tests/dynamic002.hs @@ -1,7 +1,12 @@ +{-# LANGUAGE CPP #-} + -- !!! Testing Typeable instances module Main(main) where import Data.Dynamic +#if MIN_VERSION_base(4,9,0) +import Data.Typeable (TypeCon, TypeRep) +#endif import Data.Array import Data.Array.MArray import Data.Array.ST diff --git a/libraries/base/tests/dynamic004.hs b/libraries/base/tests/dynamic004.hs index e6b7a82..2091646 100644 --- a/libraries/base/tests/dynamic004.hs +++ b/libraries/base/tests/dynamic004.hs @@ -1,7 +1,6 @@ module Main where import Data.Typeable -import Data.Typeable.Internal import GHC.Fingerprint import Text.Printf From git at git.haskell.org Mon Mar 21 17:11:53 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:53 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fix T8132 (8833f38) Message-ID: <20160321171153.C22C93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/8833f38d31f6a390cd663cadbcdcdc689a69be84/ghc >--------------------------------------------------------------- commit 8833f38d31f6a390cd663cadbcdcdc689a69be84 Author: Ben Gamari Date: Wed Mar 16 23:22:32 2016 +0100 Fix T8132 >--------------------------------------------------------------- 8833f38d31f6a390cd663cadbcdcdc689a69be84 testsuite/tests/polykinds/T8132.hs | 5 +++-- testsuite/tests/polykinds/T8132.stderr | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/testsuite/tests/polykinds/T8132.hs b/testsuite/tests/polykinds/T8132.hs index 337e288..cdbfd7f 100644 --- a/testsuite/tests/polykinds/T8132.hs +++ b/testsuite/tests/polykinds/T8132.hs @@ -1,6 +1,7 @@ {-# LANGUAGE MagicHash #-} -import Data.Typeable.Internal +import Data.Typeable data K = K -instance Typeable K where typeRep# _ = undefined +-- This used to have a RHS but now we hide typeRep# +instance Typeable K -- where typeRep# _ = undefined diff --git a/testsuite/tests/polykinds/T8132.stderr b/testsuite/tests/polykinds/T8132.stderr index 4a1ca2b..b6b60c9 100644 --- a/testsuite/tests/polykinds/T8132.stderr +++ b/testsuite/tests/polykinds/T8132.stderr @@ -1,3 +1,3 @@ -T8132.hs:6:10: error: +T8132.hs:7:10: error: Class ?Typeable? does not support user-specified instances From git at git.haskell.org Mon Mar 21 17:11:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 17:11:56 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: TysPrim: Generalize kind of (->) (fe20273) Message-ID: <20160321171156.81D793A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/fe20273afc26d3668d927d0d2002537c8a204ae1/ghc >--------------------------------------------------------------- commit fe20273afc26d3668d927d0d2002537c8a204ae1 Author: Ben Gamari Date: Wed Mar 16 23:28:59 2016 +0100 TysPrim: Generalize kind of (->) >--------------------------------------------------------------- fe20273afc26d3668d927d0d2002537c8a204ae1 compiler/prelude/TysPrim.hs | 20 +++++++++----------- compiler/types/TyCon.hs | 6 +++--- compiler/types/Type.hs | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/compiler/prelude/TysPrim.hs b/compiler/prelude/TysPrim.hs index 81fc3f9..fda987b 100644 --- a/compiler/prelude/TysPrim.hs +++ b/compiler/prelude/TysPrim.hs @@ -283,20 +283,18 @@ kKiVar = (mkTemplateTyVars $ repeat liftedTypeKind) !! 10 funTyConName :: Name funTyConName = mkPrimTyConName (fsLit "(->)") funTyConKey funTyCon +-- | The @(->)@ type constructor. +-- +-- @ +-- (->) :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). +-- TYPE rep1 -> TYPE rep2 -> * +-- @ funTyCon :: TyCon -funTyCon = mkFunTyCon funTyConName (map Anon [liftedTypeKind, liftedTypeKind]) - tc_rep_nm +funTyCon = mkFunTyCon funTyConName tyvars kind tc_rep_nm where - -- You might think that (->) should have type (?? -> ? -> *), and you'd be right - -- But if we do that we get kind errors when saying - -- instance Control.Arrow (->) - -- because the expected kind is (*->*->*). The trouble is that the - -- expected/actual stuff in the unifier does not go contra-variant, whereas - -- the kind sub-typing does. Sigh. It really only matters if you use (->) in - -- a prefix way, thus: (->) Int# Int#. And this is unusual. - -- because they are never in scope in the source - + tyvars = map (\tv -> Named tv Invisible) [runtimeRep1TyVar, runtimeRep2TyVar] tc_rep_nm = mkPrelTyConRepName funTyConName + kind = mkFunTys [tYPE runtimeRep1Ty, tYPE runtimeRep2Ty] liftedTypeKind {- ************************************************************************ diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs index 3c0a945..6c18b4e 100644 --- a/compiler/types/TyCon.hs +++ b/compiler/types/TyCon.hs @@ -1194,14 +1194,14 @@ So we compromise, and move their Kind calculation to the call site. -- | Given the name of the function type constructor and it's kind, create the -- corresponding 'TyCon'. It is reccomended to use 'TyCoRep.funTyCon' if you want -- this functionality -mkFunTyCon :: Name -> [TyBinder] -> Name -> TyCon -mkFunTyCon name binders rep_nm +mkFunTyCon :: Name -> [TyBinder] -> Kind -> Name -> TyCon +mkFunTyCon name binders kind rep_nm = FunTyCon { tyConUnique = nameUnique name, tyConName = name, tyConBinders = binders, tyConResKind = liftedTypeKind, - tyConKind = mkForAllTys binders liftedTypeKind, + tyConKind = mkForAllTys binders kind, tyConArity = 2, tcRepName = rep_nm } diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index a3efac0..d9a5d99 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -209,7 +209,7 @@ import Class import TyCon import TysPrim import {-# SOURCE #-} TysWiredIn ( listTyCon, typeNatKind - , typeSymbolKind, liftedTypeKind ) + , typeSymbolKind, runtimeRepTy, liftedTypeKind ) import PrelNames import CoAxiom import {-# SOURCE #-} Coercion @@ -964,6 +964,14 @@ tyConAppArgN n ty Just tys -> ASSERT2( n < length tys, ppr n <+> ppr tys ) tys `getNth` n Nothing -> pprPanic "tyConAppArgN" (ppr n <+> ppr ty) +-- | If given a type @TYPE (rr :: RuntimeRep)@ then returns @Just rr@ +-- otherwise @Nothing at . +tyRuntimeRep :: Type -> Maybe Type +tyRuntimeRep (TyConApp tc [rr]) + | tc == tYPETyCon = ASSERT(typeKind rr `eqType` runtimeRepTy) + Just rr +tyRuntimeRep _ = Nothing + -- | Attempts to tease a type apart into a type constructor and the application -- of a number of arguments to that constructor. Panics if that is not possible. -- See also 'splitTyConApp_maybe' @@ -982,7 +990,9 @@ splitTyConApp_maybe ty = repSplitTyConApp_maybe ty -- assumes the synonyms have already been dealt with. repSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type]) repSplitTyConApp_maybe (TyConApp tc tys) = Just (tc, tys) -repSplitTyConApp_maybe (ForAllTy (Anon arg) res) = Just (funTyCon, [arg,res]) +repSplitTyConApp_maybe (ForAllTy (Anon arg) res) + | Just rep1 <- tyRuntimeRep arg + , Just rep2 <- tyRuntimeRep res = Just (funTyCon, [rep1, rep2, arg,res]) repSplitTyConApp_maybe _ = Nothing -- | Attempts to tease a list type apart and gives the type of the elements if From git at git.haskell.org Mon Mar 21 20:10:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:13 +0000 (UTC) Subject: [commit: ghc] master: Fix exponential algorithm in pure unifier. (af2f7f9) Message-ID: <20160321201013.5B1CF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/af2f7f90dd0aaae0e33d1f8064377d1657f180a6/ghc >--------------------------------------------------------------- commit af2f7f90dd0aaae0e33d1f8064377d1657f180a6 Author: Richard Eisenberg Date: Thu Mar 17 15:40:58 2016 -0400 Fix exponential algorithm in pure unifier. >--------------------------------------------------------------- af2f7f90dd0aaae0e33d1f8064377d1657f180a6 compiler/types/Unify.hs | 52 ++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/compiler/types/Unify.hs b/compiler/types/Unify.hs index fe77370..5edb09d 100644 --- a/compiler/types/Unify.hs +++ b/compiler/types/Unify.hs @@ -704,11 +704,11 @@ unify_ty ty1 ty2 _kco -- so if one type is an App the other one jolly well better be too unify_ty (AppTy ty1a ty1b) ty2 _kco | Just (ty2a, ty2b) <- tcRepSplitAppTy_maybe ty2 - = unify_ty_app ty1a ty1b ty2a ty2b + = unify_ty_app ty1a [ty1b] ty2a [ty2b] unify_ty ty1 (AppTy ty2a ty2b) _kco | Just (ty1a, ty1b) <- tcRepSplitAppTy_maybe ty1 - = unify_ty_app ty1a ty1b ty2a ty2b + = unify_ty_app ty1a [ty1b] ty2a [ty2b] unify_ty (LitTy x) (LitTy y) _kco | x == y = return () @@ -751,15 +751,18 @@ unify_ty _ ty2 _ unify_ty _ _ _ = surelyApart -unify_ty_app :: Type -> Type -> Type -> Type -> UM () -unify_ty_app ty1a ty1b ty2a ty2b - = do { -- TODO (RAE): Remove this exponential behavior. - let ki1a = typeKind ty1a - ki2a = typeKind ty2a - ; unify_ty ki1a ki2a (mkNomReflCo liftedTypeKind) - ; let kind_co = mkNomReflCo ki1a - ; unify_ty ty1a ty2a kind_co - ; unify_ty ty1b ty2b (mkNthCo 0 kind_co) } +unify_ty_app :: Type -> [Type] -> Type -> [Type] -> UM () +unify_ty_app ty1 ty1args ty2 ty2args + | Just (ty1', ty1a) <- repSplitAppTy_maybe ty1 + , Just (ty2', ty2a) <- repSplitAppTy_maybe ty2 + = unify_ty_app ty1' (ty1a : ty1args) ty2' (ty2a : ty2args) + + | otherwise + = do { let ki1 = typeKind ty1 + ki2 = typeKind ty2 + ; unify_ty ki1 ki2 (mkNomReflCo liftedTypeKind) + ; unify_ty ty1 ty2 (mkNomReflCo ki1) + ; unify_tys ty1args ty2args } unify_tys :: [Type] -> [Type] -> UM () unify_tys orig_xs orig_ys @@ -1136,11 +1139,11 @@ ty_co_match menv subst ty (SubCo co) lkco rkco ty_co_match menv subst (AppTy ty1a ty1b) co _lkco _rkco | Just (co2, arg2) <- splitAppCo_maybe co -- c.f. Unify.match on AppTy - = ty_co_match_app menv subst ty1a ty1b co2 arg2 + = ty_co_match_app menv subst ty1a [ty1b] co2 [arg2] ty_co_match menv subst ty1 (AppCo co2 arg2) _lkco _rkco | Just (ty1a, ty1b) <- repSplitAppTy_maybe ty1 -- yes, the one from Type, not TcType; this is for coercion optimization - = ty_co_match_app menv subst ty1a ty1b co2 arg2 + = ty_co_match_app menv subst ty1a [ty1b] co2 [arg2] ty_co_match menv subst (TyConApp tc1 tys) (TyConAppCo _ tc2 cos) _lkco _rkco = ty_co_match_tc menv subst tc1 tys tc2 cos @@ -1178,17 +1181,22 @@ ty_co_match_tc menv subst tc1 tys1 tc2 cos2 = traverse (fmap mkNomReflCo . coercionKind) cos2 ty_co_match_app :: MatchEnv -> LiftCoEnv - -> Type -> Type -> Coercion -> Coercion + -> Type -> [Type] -> Coercion -> [Coercion] -> Maybe LiftCoEnv -ty_co_match_app menv subst ty1a ty1b co2a co2b - = do { -- TODO (RAE): Remove this exponential behavior. - subst1 <- ty_co_match menv subst ki1a ki2a ki_ki_co ki_ki_co - ; let Pair lkco rkco = mkNomReflCo <$> coercionKind ki2a - ; subst2 <- ty_co_match menv subst1 ty1a co2a lkco rkco - ; ty_co_match menv subst2 ty1b co2b (mkNthCo 0 lkco) (mkNthCo 0 rkco) } +ty_co_match_app menv subst ty1 ty1args co2 co2args + | Just (ty1', ty1a) <- repSplitAppTy_maybe ty1 + , Just (co2', co2a) <- splitAppCo_maybe co2 + = ty_co_match_app menv subst ty1' (ty1a : ty1args) co2' (co2a : co2args) + + | otherwise + = do { subst1 <- ty_co_match menv subst ki1 ki2 ki_ki_co ki_ki_co + ; let Pair lkco rkco = mkNomReflCo <$> coercionKind ki2 + ; subst2 <- ty_co_match menv subst1 ty1 co2 lkco rkco + ; let Pair lkcos rkcos = traverse (fmap mkNomReflCo . coercionKind) co2args + ; ty_co_match_args menv subst2 ty1args co2args lkcos rkcos } where - ki1a = typeKind ty1a - ki2a = promoteCoercion co2a + ki1 = typeKind ty1 + ki2 = promoteCoercion co2 ki_ki_co = mkNomReflCo liftedTypeKind ty_co_match_args :: MatchEnv -> LiftCoEnv -> [Type] From git at git.haskell.org Mon Mar 21 20:10:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:16 +0000 (UTC) Subject: [commit: ghc] master: TypeApplications does not imply AllowAmbiguousTypes (01b29eb) Message-ID: <20160321201016.11E793A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/01b29ebd25aceef8c35ea1cc3eabb6dafbb55daa/ghc >--------------------------------------------------------------- commit 01b29ebd25aceef8c35ea1cc3eabb6dafbb55daa Author: Richard Eisenberg Date: Thu Mar 17 17:49:28 2016 -0400 TypeApplications does not imply AllowAmbiguousTypes >--------------------------------------------------------------- 01b29ebd25aceef8c35ea1cc3eabb6dafbb55daa compiler/main/DynFlags.hs | 1 - docs/users_guide/glasgow_exts.rst | 1 - testsuite/tests/dependent/should_compile/RaeJobTalk.hs | 2 +- testsuite/tests/patsyn/should_compile/T11351.hs | 3 ++- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 3c64685..7d7f22f 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -3708,7 +3708,6 @@ impliedXFlags , (LangExt.TemplateHaskell, turnOn, LangExt.TemplateHaskellQuotes) , (LangExt.Strict, turnOn, LangExt.StrictData) - , (LangExt.TypeApplications, turnOn, LangExt.AllowAmbiguousTypes) ] -- Note [Documenting optimisation flags] diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index fe4d40c..25fbb23 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -8640,7 +8640,6 @@ Visible type application .. ghc-flag:: -XTypeApplications - :implies: :ghc-flag:`-XAllowAmbiguousTypes` :since: 8.0.1 Allow the use of type application syntax. diff --git a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs index c03503d..2f0edf8 100644 --- a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs +++ b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs @@ -1,7 +1,7 @@ {- Copyright (c) 2016 Richard Eisenberg -} -{-# LANGUAGE TypeOperators, TypeFamilies, TypeApplications, +{-# LANGUAGE TypeOperators, TypeFamilies, TypeApplications, AllowAmbiguousTypes, ExplicitForAll, ScopedTypeVariables, GADTs, TypeFamilyDependencies, TypeInType, ConstraintKinds, UndecidableInstances, FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, diff --git a/testsuite/tests/patsyn/should_compile/T11351.hs b/testsuite/tests/patsyn/should_compile/T11351.hs index 26f8d2d..0873a88 100644 --- a/testsuite/tests/patsyn/should_compile/T11351.hs +++ b/testsuite/tests/patsyn/should_compile/T11351.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE PatternSynonyms, TypeApplications, ScopedTypeVariables, ViewPatterns #-} +{-# LANGUAGE PatternSynonyms, TypeApplications, ScopedTypeVariables, ViewPatterns, + AllowAmbiguousTypes #-} module T11351 where From git at git.haskell.org Mon Mar 21 20:10:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:18 +0000 (UTC) Subject: [commit: ghc] master: Add two small optimizations. (#11196) (0706a10) Message-ID: <20160321201018.BCA553A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/0706a103ae8c9c61e6bbaadd16b32da76aa5a749/ghc >--------------------------------------------------------------- commit 0706a103ae8c9c61e6bbaadd16b32da76aa5a749 Author: Richard Eisenberg Date: Fri Mar 18 09:40:15 2016 -0400 Add two small optimizations. (#11196) - Optimize zonking * to avoid allocation. - Try to avoid looking at the free variables of a type in the pure unifier. We need look at the variables only in the case of a forall. The performance results updates included in this also include a regression, but the regression is not due to this patch. When validating previous patches, the test case failed, but I was unable to reproduce outside of validation, so I let it go by, thinking the failure was spurious. Upon closer inspection, the perf number was right at the line, and the wibble between a valiation environment and a regular test run was enough to make the difference. >--------------------------------------------------------------- 0706a103ae8c9c61e6bbaadd16b32da76aa5a749 compiler/types/Type.hs | 2 ++ compiler/types/Unify.hs | 20 ++++++++++++-------- testsuite/tests/perf/compiler/all.T | 10 +++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index f7aea67..180624d 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -470,6 +470,8 @@ mapType mapper@(TyCoMapper { tcm_smart = smart, tcm_tyvar = tyvar where go (TyVarTy tv) = tyvar env tv go (AppTy t1 t2) = mkappty <$> go t1 <*> go t2 + go t@(TyConApp _ []) = return t -- avoid allocation in this exceedingly + -- common case (mostly, for *) go (TyConApp tc tys) = mktyconapp tc <$> mapM go tys go (ForAllTy (Anon arg) res) = mkfunty <$> go arg <*> go res go (ForAllTy (Named tv vis) inner) diff --git a/compiler/types/Unify.hs b/compiler/types/Unify.hs index 5edb09d..ed4b224 100644 --- a/compiler/types/Unify.hs +++ b/compiler/types/Unify.hs @@ -977,11 +977,15 @@ umRnBndr2 v1 v2 thing = UM $ \env state -> let rn_env' = rnBndr2 (um_rn_env env) v1 v2 in unUM thing (env { um_rn_env = rn_env' }) state -checkRnEnv :: (RnEnv2 -> Var -> Bool) -> VarSet -> UM () -checkRnEnv inRnEnv varset = UM $ \env state -> - if any (inRnEnv (um_rn_env env)) (varSetElems varset) - then MaybeApart (state, ()) - else Unifiable (state, ()) +checkRnEnv :: (RnEnv2 -> VarSet) -> VarSet -> UM () +checkRnEnv get_set varset = UM $ \env state -> + let env_vars = get_set (um_rn_env env) in + if isEmptyVarSet env_vars || varset `disjointVarSet` env_vars + -- NB: That isEmptyVarSet is a critical optimization; it + -- means we don't have to calculate the free vars of + -- the type, often saving quite a bit of allocation. + then Unifiable (state, ()) + else MaybeApart (state, ()) -- | Converts any SurelyApart to a MaybeApart don'tBeSoSure :: UM () -> UM () @@ -991,13 +995,13 @@ don'tBeSoSure um = UM $ \env state -> other -> other checkRnEnvR :: Type -> UM () -checkRnEnvR ty = checkRnEnv inRnEnvR (tyCoVarsOfType ty) +checkRnEnvR ty = checkRnEnv rnEnvR (tyCoVarsOfType ty) checkRnEnvL :: Type -> UM () -checkRnEnvL ty = checkRnEnv inRnEnvL (tyCoVarsOfType ty) +checkRnEnvL ty = checkRnEnv rnEnvL (tyCoVarsOfType ty) checkRnEnvRCo :: Coercion -> UM () -checkRnEnvRCo co = checkRnEnv inRnEnvR (tyCoVarsOfCo co) +checkRnEnvRCo co = checkRnEnv rnEnvR (tyCoVarsOfCo co) umRnOccL :: TyVar -> UM TyVar umRnOccL v = UM $ \env state -> diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index a1ebe11..ffcc050 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -395,7 +395,7 @@ test('T5631', # expected value: 392904228 (x86/Linux) # 2014-04-04: 346389856 (x86 Windows, 64 bit machine) # 2014-12-01: 390199244 (Windows laptop) - (wordsize(64), 1198327544, 5)]), + (wordsize(64), 1124068664, 5)]), # expected value: 774595008 (amd64/Linux): # expected value: 735486328 (amd64/Linux) 2012/12/12: # expected value: 690742040 (amd64/Linux) Call Arity improvements @@ -404,6 +404,7 @@ test('T5631', # 2015-06-01: 812288344 (amd64/Linux) unknown cause # 2015-12-11: 1128828928 (amd64/Linux) TypeInType (see #11196) # 2015-12-21: 1198327544 (Mac) TypeApplications (will fix with #11196) + # 2015-03-18: 1124068664 (Mac) optimize Unify & zonking only_ways(['normal']) ], compile, @@ -558,7 +559,7 @@ test('T5837', # 2014-12-01: 135914136 (Windows laptop, regression see below) # 2014-12-08 115905208 Constraint solver perf improvements (esp kick-out) - (wordsize(64), 43877520, 10)]) + (wordsize(64), 48507272, 10)]) # sample: 3926235424 (amd64/Linux, 15/2/2012) # 2012-10-02 81879216 # 2012-09-20 87254264 amd64/Linux @@ -575,6 +576,8 @@ test('T5837', # 2015-03-17 53424304 Mac Better depth checking; fails earlier # 2015-06-09 38834096 Better "improvement"; I'm not sure whey it improves things # 2015-12-11 43877520 amd64/Linux, TypeInType (see #11196) + # 2016-03-18 48507272 Mac, accept small regression in exchange + # for other optimisations ], compile_fail,['-freduction-depth=50']) @@ -704,12 +707,13 @@ test('T9872c', test('T9872d', [ only_ways(['normal']), compiler_stats_num_field('bytes allocated', - [(wordsize(64), 534693648, 5), + [(wordsize(64), 506691240, 5), # 2014-12-18 796071864 Initally created # 2014-12-18 739189056 Reduce type families even more eagerly # 2015-01-07 687562440 TrieMap leaf compression # 2015-03-17 726679784 tweak to solver; probably flattens more # 2016-02-08 534693648 Improved a bit by tyConRolesRepresentational + # 2016-03-18 506691240 optimize Unify & zonking (wordsize(32), 59651432, 5) # some date 328810212 # 2015-07-11 350369584 From git at git.haskell.org Mon Mar 21 20:10:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:22 +0000 (UTC) Subject: [commit: ghc] master: Fix #11635 / #11719. (1701255) Message-ID: <20160321201022.378DD3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1701255c06fed2aa2811f7f29f108d88fc4d6f26/ghc >--------------------------------------------------------------- commit 1701255c06fed2aa2811f7f29f108d88fc4d6f26 Author: Richard Eisenberg Date: Fri Mar 18 11:02:38 2016 -0400 Fix #11635 / #11719. Instead of creating a new meta-tyvar and then unifying it with a known kind in a KindedTyVar in a LHsQTyVars, just use the known kind. Sadly, this still doesn't make #11719 usable, because while you can now define a higher-kinded type family, you can't write any equations for it, which is a larger problem. test cases: dependent/should_compile/T{11635,11719} >--------------------------------------------------------------- 1701255c06fed2aa2811f7f29f108d88fc4d6f26 compiler/typecheck/TcHsType.hs | 33 +++++++++++----------- testsuite/tests/dependent/should_compile/T11635.hs | 7 +++++ testsuite/tests/dependent/should_compile/T11719.hs | 18 ++++++++++++ testsuite/tests/dependent/should_compile/all.T | 2 ++ 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index 552c0d0..2b226f2 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -83,7 +83,7 @@ import PrelNames hiding ( wildCardName ) import Pair import qualified GHC.LanguageExtensions as LangExt -import Data.Maybe +import Maybes import Data.List ( partition ) import Control.Monad @@ -1291,7 +1291,7 @@ kcHsTyVarBndrs cusk open_fam all_kind_vars kc_hs_tv :: HsTyVarBndr Name -> TcM (TcTyVar, Bool) kc_hs_tv (UserTyVar (L _ name)) - = do { tv_pair@(tv, scoped) <- tcHsTyVarName name + = do { tv_pair@(tv, scoped) <- tcHsTyVarName Nothing name -- Open type/data families default their variables to kind *. ; when (open_fam && not scoped) $ -- (don't default class tyvars) @@ -1301,13 +1301,8 @@ kcHsTyVarBndrs cusk open_fam all_kind_vars ; return tv_pair } kc_hs_tv (KindedTyVar (L _ name) lhs_kind) - = do { tv_pair@(tv, _) <- tcHsTyVarName name - ; kind <- tcLHsKind lhs_kind - -- for a scoped variable: make sure annotation is consistent - -- for an unscoped variable: unify the meta-tyvar kind - -- either way: we can ignore the resulting coercion - ; discardResult $ unifyKind (Just (mkTyVarTy tv)) kind (tyVarKind tv) - ; return tv_pair } + = do { kind <- tcLHsKind lhs_kind + ; tcHsTyVarName (Just kind) name } report_non_cusk_tvs all_tvs = do { all_tvs <- mapM zonkTyCoVarKind all_tvs @@ -1330,7 +1325,7 @@ tcImplicitTKBndrs :: [Name] -> TcM (a, TyVarSet) -- vars are bound somewhere in the scope -- see Note [Scope-check inferred kinds] -> TcM ([TcTyVar], a) -tcImplicitTKBndrs = tcImplicitTKBndrsX tcHsTyVarName +tcImplicitTKBndrs = tcImplicitTKBndrsX (tcHsTyVarName Nothing) -- | Convenient specialization tcImplicitTKBndrsType :: [Name] @@ -1414,16 +1409,22 @@ tcHsTyVarBndr (KindedTyVar (L _ name) kind) = do { kind <- tcLHsKind kind ; return (mkTcTyVar name kind (SkolemTv False)) } --- | Produce a tyvar of the given name (with a meta-tyvar kind). If --- the name is already in scope, return the scoped variable. The +-- | Produce a tyvar of the given name (with the kind provided, or +-- otherwise a meta-var kind). If +-- the name is already in scope, return the scoped variable, checking +-- to make sure the known kind matches any kind provided. The -- second return value says whether the variable is in scope (True) -- or not (False). (Use this for associated types, for example.) -tcHsTyVarName :: Name -> TcM (TcTyVar, Bool) -tcHsTyVarName name +tcHsTyVarName :: Maybe Kind -> Name -> TcM (TcTyVar, Bool) +tcHsTyVarName m_kind name = do { mb_tv <- tcLookupLcl_maybe name ; case mb_tv of - Just (ATyVar _ tv) -> return (tv, True) - _ -> do { kind <- newMetaKindVar + Just (ATyVar _ tv) + -> do { whenIsJust m_kind $ \ kind -> + discardResult $ + unifyKind (Just (mkTyVarTy tv)) kind (tyVarKind tv) + ; return (tv, True) } + _ -> do { kind <- maybe newMetaKindVar return m_kind ; return (mkTcTyVar name kind vanillaSkolemTv, False) }} -- makes a new skolem tv diff --git a/testsuite/tests/dependent/should_compile/T11635.hs b/testsuite/tests/dependent/should_compile/T11635.hs new file mode 100644 index 0000000..1cbdbaf --- /dev/null +++ b/testsuite/tests/dependent/should_compile/T11635.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeInType, KindSignatures, ExplicitForAll #-} + +module T11635 where + +import Data.Kind + +data X (a :: forall k. k -> * ) b = X diff --git a/testsuite/tests/dependent/should_compile/T11719.hs b/testsuite/tests/dependent/should_compile/T11719.hs new file mode 100644 index 0000000..ba4d7c9 --- /dev/null +++ b/testsuite/tests/dependent/should_compile/T11719.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes, TypeFamilies, TypeInType, TypeOperators, + UndecidableInstances #-} + +module T11719 where + +import Data.Kind + +data TyFun :: * -> * -> * +type a ~> b = TyFun a b -> * + +type family (f :: a ~> b) @@ (x :: a) :: b + +data Null a = Nullable a | NotNullable a + +type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where + (f ? g) x = f @@ (g @@ x) + +type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where -- this fails :( diff --git a/testsuite/tests/dependent/should_compile/all.T b/testsuite/tests/dependent/should_compile/all.T index 2f9d311..5985fd9 100644 --- a/testsuite/tests/dependent/should_compile/all.T +++ b/testsuite/tests/dependent/should_compile/all.T @@ -19,3 +19,5 @@ test('T11405', normal, compile, ['']) test('T11241', normal, compile, ['']) test('T11711', normal, compile, ['']) test('RaeJobTalk', normal, compile, ['']) +test('T11635', normal, compile, ['']) +test('T11719', normal, compile, ['']) From git at git.haskell.org Mon Mar 21 20:10:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:25 +0000 (UTC) Subject: [commit: ghc] master: Prevent eager unification with type families. (3e1b882) Message-ID: <20160321201025.7302D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3e1b8824c849d063c7354dbdf63ae2910cf0fdfc/ghc >--------------------------------------------------------------- commit 3e1b8824c849d063c7354dbdf63ae2910cf0fdfc Author: Richard Eisenberg Date: Fri Mar 18 22:36:34 2016 -0400 Prevent eager unification with type families. See Note [Prevent unification with type families] in TcUnify for the details. >--------------------------------------------------------------- 3e1b8824c849d063c7354dbdf63ae2910cf0fdfc compiler/typecheck/TcType.hs | 16 +++-- compiler/typecheck/TcUnify.hs | 82 +++++++++++++++++++++- testsuite/tests/indexed-types/should_compile/all.T | 1 - .../tests/indexed-types/should_fail/T2693.stderr | 17 ++--- .../tests/indexed-types/should_fail/T4179.stderr | 6 +- .../tests/indexed-types/should_fail/T5439.stderr | 16 ++--- .../tests/indexed-types/should_fail/T7354.stderr | 9 +-- .../tests/indexed-types/should_fail/T7729.stderr | 8 +-- .../tests/indexed-types/should_fail/T7786.stderr | 12 ++-- .../{should_compile => should_fail}/T7788.hs | 0 .../tests/indexed-types/should_fail/T7788.stderr | 10 +++ .../tests/indexed-types/should_fail/T9554.stderr | 13 ++++ .../tests/indexed-types/should_fail/T9662.stderr | 16 +++-- testsuite/tests/indexed-types/should_fail/all.T | 1 + testsuite/tests/perf/compiler/all.T | 3 +- testsuite/tests/typecheck/should_fail/T9260.stderr | 2 +- 16 files changed, 159 insertions(+), 53 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 3e1b8824c849d063c7354dbdf63ae2910cf0fdfc From git at git.haskell.org Mon Mar 21 20:10:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:28 +0000 (UTC) Subject: [commit: ghc] master: Rename test for #11334 to 11334b, fixing conflict (f8ab575) Message-ID: <20160321201028.D68FF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/f8ab575404b726b499e72343b7220e9213880dd4/ghc >--------------------------------------------------------------- commit f8ab575404b726b499e72343b7220e9213880dd4 Author: Richard Eisenberg Date: Fri Mar 18 21:40:04 2016 -0400 Rename test for #11334 to 11334b, fixing conflict >--------------------------------------------------------------- f8ab575404b726b499e72343b7220e9213880dd4 testsuite/tests/dependent/should_fail/{T11334.hs => T11334b.hs} | 2 +- .../tests/dependent/should_fail/{T11334.stderr => T11334b.stderr} | 6 +++--- testsuite/tests/dependent/should_fail/all.T | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/testsuite/tests/dependent/should_fail/T11334.hs b/testsuite/tests/dependent/should_fail/T11334b.hs similarity index 84% rename from testsuite/tests/dependent/should_fail/T11334.hs rename to testsuite/tests/dependent/should_fail/T11334b.hs index 1f9970f..c6f6d20 100644 --- a/testsuite/tests/dependent/should_fail/T11334.hs +++ b/testsuite/tests/dependent/should_fail/T11334b.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DataKinds, NoPolyKinds #-} -module T11334 where +module T11334b where import Data.Functor.Compose import Data.Proxy diff --git a/testsuite/tests/dependent/should_fail/T11334.stderr b/testsuite/tests/dependent/should_fail/T11334b.stderr similarity index 92% rename from testsuite/tests/dependent/should_fail/T11334.stderr rename to testsuite/tests/dependent/should_fail/T11334b.stderr index f7c87a3..8f4251b 100644 --- a/testsuite/tests/dependent/should_fail/T11334.stderr +++ b/testsuite/tests/dependent/should_fail/T11334b.stderr @@ -1,5 +1,5 @@ -T11334.hs:8:14: error: +T11334b.hs:8:14: error: ? Cannot default kind variable ?f0? of kind: k0 -> * Perhaps enable PolyKinds or add a kind signature @@ -7,7 +7,7 @@ T11334.hs:8:14: error: In the expression: Proxy :: Proxy Compose In an equation for ?p?: p = Proxy :: Proxy Compose -T11334.hs:8:14: error: +T11334b.hs:8:14: error: ? Cannot default kind variable ?g0? of kind: k10 -> k0 Perhaps enable PolyKinds or add a kind signature @@ -15,7 +15,7 @@ T11334.hs:8:14: error: In the expression: Proxy :: Proxy Compose In an equation for ?p?: p = Proxy :: Proxy Compose -T11334.hs:8:14: error: +T11334b.hs:8:14: error: ? Cannot default kind variable ?a0? of kind: k10 Perhaps enable PolyKinds or add a kind signature diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index 9565bc0..e2777a4 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -9,7 +9,7 @@ test('SelfDep', normal, compile_fail, ['']) test('BadTelescope4', normal, compile_fail, ['']) test('RenamingStar', normal, compile_fail, ['']) test('T11407', normal, compile_fail, ['']) -test('T11334', normal, compile_fail, ['']) +test('T11334b', normal, compile_fail, ['']) test('InferDependency', normal, compile_fail, ['']) test('KindLevelsB', normal, compile_fail, ['']) test('T11473', normal, compile_fail, ['']) From git at git.haskell.org Mon Mar 21 20:10:31 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:31 +0000 (UTC) Subject: [commit: ghc] master: Make equality print better. (#11712) (0b89064) Message-ID: <20160321201031.AAE913A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/0b89064cc67cb4fbdba0044ab59a17b20bbde1db/ghc >--------------------------------------------------------------- commit 0b89064cc67cb4fbdba0044ab59a17b20bbde1db Author: Richard Eisenberg Date: Fri Mar 18 11:20:31 2016 -0400 Make equality print better. (#11712) >--------------------------------------------------------------- 0b89064cc67cb4fbdba0044ab59a17b20bbde1db compiler/types/TyCoRep.hs | 76 +++++++++++++++++----- .../tests/deSugar/should_compile/T2431.stderr | 6 +- testsuite/tests/gadt/T7558.stderr | 2 +- testsuite/tests/ghci/scripts/Defer02.stderr | 4 +- .../should_compile/PushedInAsGivens.stderr | 2 +- .../indexed-types/should_compile/Simple14.stderr | 4 +- .../indexed-types/should_fail/SimpleFail15.stderr | 2 +- .../tests/indexed-types/should_fail/T4093a.stderr | 4 +- .../should_compile/DataFamilyInstanceLHS.stderr | 4 +- .../NamedWildcardInDataFamilyInstanceLHS.stderr | 4 +- testsuite/tests/polykinds/T10503.stderr | 4 +- testsuite/tests/polykinds/T7230.stderr | 5 +- testsuite/tests/polykinds/T9222.stderr | 4 +- .../tests/roles/should_compile/Roles13.stderr | 2 +- testsuite/tests/roles/should_compile/Roles3.stderr | 2 +- .../typecheck/should_fail/FrozenErrorTests.stderr | 2 +- testsuite/tests/typecheck/should_fail/T5858.stderr | 18 ++--- testsuite/tests/typecheck/should_fail/T7857.stderr | 2 +- .../tests/typecheck/should_fail/T8392a.stderr | 2 +- 19 files changed, 97 insertions(+), 52 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 0b89064cc67cb4fbdba0044ab59a17b20bbde1db From git at git.haskell.org Mon Mar 21 20:10:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:35 +0000 (UTC) Subject: [commit: ghc] master: Track specified/invisible more carefully. (35e9379) Message-ID: <20160321201035.3F91E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/35e937973f61a7e5534ecd0b1c67111cd82d4238/ghc >--------------------------------------------------------------- commit 35e937973f61a7e5534ecd0b1c67111cd82d4238 Author: Richard Eisenberg Date: Sat Mar 19 16:55:50 2016 -0400 Track specified/invisible more carefully. In particular, this allows correct tracking of specified/invisible for variables in Haskell98 data constructors and in pattern synonyms. GADT-syntax constructors are harder, and are left until #11721. This was all inspired by Simon's comments to my fix for #11512, which this subsumes. Test case: ghci/scripts/TypeAppData [skip ci] (The test case fails because of an unrelated problem fixed in the next commit.) >--------------------------------------------------------------- 35e937973f61a7e5534ecd0b1c67111cd82d4238 compiler/basicTypes/DataCon.hs | 96 ++++++++++--- compiler/basicTypes/DataCon.hs-boot | 6 +- compiler/basicTypes/MkId.hs | 14 +- compiler/basicTypes/PatSyn.hs | 25 +++- compiler/iface/BuildTyCl.hs | 48 ++++--- compiler/iface/IfaceSyn.hs | 20 +-- compiler/iface/IfaceType.hs | 6 + compiler/iface/MkIface.hs | 19 +-- compiler/iface/TcIface.hs | 43 +++--- compiler/prelude/TysWiredIn.hs | 6 +- compiler/typecheck/TcHsSyn.hs | 2 +- compiler/typecheck/TcHsType.hs | 4 +- compiler/typecheck/TcInstDcls.hs | 6 +- compiler/typecheck/TcPatSyn.hs | 140 +++++++++++-------- compiler/typecheck/TcRnTypes.hs | 14 +- compiler/typecheck/TcTyClsDecls.hs | 151 ++++++++++++++++----- compiler/typecheck/TcType.hs | 4 +- compiler/types/Coercion.hs | 2 +- compiler/types/TyCoRep.hs | 25 +++- compiler/types/Type.hs | 10 +- compiler/vectorise/Vectorise/Generic/PData.hs | 8 +- compiler/vectorise/Vectorise/Type/TyConDecl.hs | 5 +- docs/users_guide/glasgow_exts.rst | 13 ++ testsuite/tests/ghci/scripts/T11524a.stdout | 28 ++-- testsuite/tests/ghci/scripts/TypeAppData.script | 31 +++++ testsuite/tests/ghci/scripts/TypeAppData.stdout | 14 ++ testsuite/tests/ghci/scripts/all.T | 1 + .../tests/rename/should_fail/rnfail055.stderr | 3 +- testsuite/tests/roles/should_compile/Roles1.stderr | 4 +- 29 files changed, 514 insertions(+), 234 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 35e937973f61a7e5534ecd0b1c67111cd82d4238 From git at git.haskell.org Mon Mar 21 20:10:37 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:37 +0000 (UTC) Subject: [commit: ghc] master: Comment a suspicious zonk in TcFlatten. (9477093) Message-ID: <20160321201037.E0FFB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/947709395015bd6122eedc6da5df356660e76208/ghc >--------------------------------------------------------------- commit 947709395015bd6122eedc6da5df356660e76208 Author: Richard Eisenberg Date: Fri Mar 18 22:37:37 2016 -0400 Comment a suspicious zonk in TcFlatten. >--------------------------------------------------------------- 947709395015bd6122eedc6da5df356660e76208 compiler/typecheck/TcFlatten.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs index 491888e..4971eb1 100644 --- a/compiler/typecheck/TcFlatten.hs +++ b/compiler/typecheck/TcFlatten.hs @@ -1346,6 +1346,9 @@ flatten_tyvar3 tv -- , ppr kind_co <+> dcolon <+> ppr (coercionKind kind_co) ]) ; orig_kind <- liftTcS $ zonkTcType kind -- NB: orig_kind is *not* the kind returned from flatten + -- This zonk is necessary because we might later see the tv's kind + -- in canEqTyVarTyVar (where we use getCastedTyVar_maybe). + -- If you remove it, then e.g. dependent/should_fail/T11407 panics ; return (FTRCasted (setTyVarKind tv orig_kind) kind_co) } {- From git at git.haskell.org Mon Mar 21 20:10:40 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:40 +0000 (UTC) Subject: [commit: ghc] master: Improve panicking output (e19e58c) Message-ID: <20160321201040.87A9B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e19e58ced6fb410c8aa79b2193513258c58a38bd/ghc >--------------------------------------------------------------- commit e19e58ced6fb410c8aa79b2193513258c58a38bd Author: Richard Eisenberg Date: Sun Mar 20 23:15:13 2016 -0400 Improve panicking output >--------------------------------------------------------------- e19e58ced6fb410c8aa79b2193513258c58a38bd compiler/types/Type.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index d78c7f7..e3d3c88 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -854,7 +854,7 @@ piResultTy ty arg empty_subst = mkEmptyTCvSubst $ mkInScopeSet $ tyCoVarsOfTypes [arg,res] | otherwise - = panic "piResultTys" + = pprPanic "piResultTy" (ppr ty $$ ppr arg) -- | (piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn) -- where f :: f_ty @@ -889,7 +889,7 @@ piResultTys ty orig_args@(arg:args) Named tv _ -> go (extendVarEnv emptyTvSubstEnv tv arg) res args | otherwise - = panic "piResultTys" + = pprPanic "piResultTys1" (ppr ty $$ ppr orig_args) where go :: TvSubstEnv -> Type -> [Type] -> Type go tv_env ty [] = substTy (mkTvSubst in_scope tv_env) ty @@ -911,7 +911,7 @@ piResultTys ty orig_args@(arg:args) = piResultTys ty' all_args | otherwise - = panic "piResultTys" + = pprPanic "piResultTys2" (ppr ty $$ ppr orig_args $$ ppr all_args) {- --------------------------------------------------------------------- From git at git.haskell.org Mon Mar 21 20:10:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:43 +0000 (UTC) Subject: [commit: ghc] master: Zonk before calling splitDepVarsOfType. (5c0c751) Message-ID: <20160321201043.404513A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/5c0c751ab2deb4b03b8a2055d4f60d2574cae32f/ghc >--------------------------------------------------------------- commit 5c0c751ab2deb4b03b8a2055d4f60d2574cae32f Author: Richard Eisenberg Date: Mon Mar 21 11:08:10 2016 -0400 Zonk before calling splitDepVarsOfType. It was Utterly Wrong before. Note to self: Never, ever take the free vars of an unzonked type. >--------------------------------------------------------------- 5c0c751ab2deb4b03b8a2055d4f60d2574cae32f compiler/typecheck/TcHsType.hs | 3 ++- compiler/typecheck/TcMType.hs | 38 ++++++++++++++++++++------ compiler/typecheck/TcPatSyn.hs | 13 ++++++--- compiler/typecheck/TcRules.hs | 6 ++--- compiler/typecheck/TcSimplify.hs | 6 +++-- compiler/typecheck/TcTyClsDecls.hs | 45 +++++++++++++++++-------------- compiler/types/Type.hs | 26 ++++++++++++------ testsuite/tests/ghci/scripts/T7873.stdout | 3 +-- 8 files changed, 92 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 5c0c751ab2deb4b03b8a2055d4f60d2574cae32f From git at git.haskell.org Mon Mar 21 20:10:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:10:46 +0000 (UTC) Subject: [commit: ghc] master: Fix #11723 and #11724. (d978c5e) Message-ID: <20160321201046.D8A7B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/d978c5ed93482473b81bbe52bedf37d45d1e1029/ghc >--------------------------------------------------------------- commit d978c5ed93482473b81bbe52bedf37d45d1e1029 Author: Richard Eisenberg Date: Sat Mar 19 17:19:04 2016 -0400 Fix #11723 and #11724. Test cases: typecheck/should_fail/T1172{3,4} >--------------------------------------------------------------- d978c5ed93482473b81bbe52bedf37d45d1e1029 compiler/typecheck/TcHsSyn.hs | 48 +++++++++++++++++----- compiler/typecheck/TcValidity.hs | 13 ++++++ docs/users_guide/glasgow_exts.rst | 2 +- .../tests/dependent/should_fail/T11473.stderr | 9 ++-- testsuite/tests/typecheck/should_fail/T11723.hs | 8 ++++ .../tests/typecheck/should_fail/T11723.stderr | 7 ++++ testsuite/tests/typecheck/should_fail/T11724.hs | 7 ++++ .../tests/typecheck/should_fail/T11724.stderr | 7 ++++ testsuite/tests/typecheck/should_fail/all.T | 2 + 9 files changed, 86 insertions(+), 17 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc d978c5ed93482473b81bbe52bedf37d45d1e1029 From git at git.haskell.org Mon Mar 21 20:43:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:43:03 +0000 (UTC) Subject: [commit: ghc] master: stgMallocBytes: Tolerate malloc(0) returning a NULL ptr (1934f7f) Message-ID: <20160321204303.AADB53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1934f7f1066423a6b35b1f17bf63d40c92681d31/ghc >--------------------------------------------------------------- commit 1934f7f1066423a6b35b1f17bf63d40c92681d31 Author: Herbert Valerio Riedel Date: Mon Mar 21 21:40:23 2016 +0100 stgMallocBytes: Tolerate malloc(0) returning a NULL ptr This is valid behaviour for `malloc()` according to ISO C99 and POSIX, and there's at least one operating system (AIX) which actually does return NULL for 0-sized allocations. The `createAdjustor()` routine is currently the only known use-site of `stgMallocBytes` which may call `stgMallocBytes()` requesting a 0-size allocation. Reviewed By: bgamari, austin Differential Revision: https://phabricator.haskell.org/D2022 >--------------------------------------------------------------- 1934f7f1066423a6b35b1f17bf63d40c92681d31 rts/RtsUtils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c index 72e19a0..a36532c 100644 --- a/rts/RtsUtils.c +++ b/rts/RtsUtils.c @@ -64,6 +64,19 @@ stgMallocBytes (int n, char *msg) n2 = (size_t) n; if ((space = (char *) malloc(n2)) == NULL) { + /* Quoting POSIX.1-2008 (which says more or less the same as ISO C99): + * + * "Upon successful completion with size not equal to 0, malloc() shall + * return a pointer to the allocated space. If size is 0, either a null + * pointer or a unique pointer that can be successfully passed to free() + * shall be returned. Otherwise, it shall return a null pointer and set + * errno to indicate the error." + * + * Consequently, a NULL pointer being returned by `malloc()` for a 0-size + * allocation is *not* to be considered an error. + */ + if (n == 0) return NULL; + /* don't fflush(stdout); WORKAROUND bug in Linux glibc */ rtsConfig.mallocFailHook((W_) n, msg); /*msg*/ stg_exit(EXIT_INTERNAL_ERROR); From git at git.haskell.org Mon Mar 21 20:44:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 20:44:55 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: stgMallocBytes: Tolerate malloc(0) returning a NULL ptr (0560ca6) Message-ID: <20160321204455.6965F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0560ca6d66e69de573ebfd86b43f9cc587147d82/ghc >--------------------------------------------------------------- commit 0560ca6d66e69de573ebfd86b43f9cc587147d82 Author: Herbert Valerio Riedel Date: Mon Mar 21 21:40:23 2016 +0100 stgMallocBytes: Tolerate malloc(0) returning a NULL ptr This is valid behaviour for `malloc()` according to ISO C99 and POSIX, and there's at least one operating system (AIX) which actually does return NULL for 0-sized allocations. The `createAdjustor()` routine is currently the only known use-site of `stgMallocBytes` which may call `stgMallocBytes()` requesting a 0-size allocation. (cherry picked from commit 1934f7f1066423a6b35b1f17bf63d40c92681d31) >--------------------------------------------------------------- 0560ca6d66e69de573ebfd86b43f9cc587147d82 rts/RtsUtils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c index 72e19a0..a36532c 100644 --- a/rts/RtsUtils.c +++ b/rts/RtsUtils.c @@ -64,6 +64,19 @@ stgMallocBytes (int n, char *msg) n2 = (size_t) n; if ((space = (char *) malloc(n2)) == NULL) { + /* Quoting POSIX.1-2008 (which says more or less the same as ISO C99): + * + * "Upon successful completion with size not equal to 0, malloc() shall + * return a pointer to the allocated space. If size is 0, either a null + * pointer or a unique pointer that can be successfully passed to free() + * shall be returned. Otherwise, it shall return a null pointer and set + * errno to indicate the error." + * + * Consequently, a NULL pointer being returned by `malloc()` for a 0-size + * allocation is *not* to be considered an error. + */ + if (n == 0) return NULL; + /* don't fflush(stdout); WORKAROUND bug in Linux glibc */ rtsConfig.mallocFailHook((W_) n, msg); /*msg*/ stg_exit(EXIT_INTERNAL_ERROR); From git at git.haskell.org Mon Mar 21 21:02:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 21:02:54 +0000 (UTC) Subject: [commit: ghc] master: Comments (only) in TcFlatten (2d6d907) Message-ID: <20160321210254.66BE73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2d6d907d8dcc051a7656dafcc0bc827cc651c6c0/ghc >--------------------------------------------------------------- commit 2d6d907d8dcc051a7656dafcc0bc827cc651c6c0 Author: Richard Eisenberg Date: Mon Mar 21 17:03:38 2016 -0400 Comments (only) in TcFlatten >--------------------------------------------------------------- 2d6d907d8dcc051a7656dafcc0bc827cc651c6c0 compiler/typecheck/TcFlatten.hs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs index 4971eb1..89e663f 100644 --- a/compiler/typecheck/TcFlatten.hs +++ b/compiler/typecheck/TcFlatten.hs @@ -797,19 +797,26 @@ flattenManyNom ev tys {- Note [Flattening] ~~~~~~~~~~~~~~~~~~~~ - flatten ty ==> (xi, cc) + flatten ty ==> (xi, co) where xi has no type functions, unless they appear under ForAlls - - cc = Auxiliary given (equality) constraints constraining - the fresh type variables in xi. Evidence for these - is always the identity coercion, because internally the - fresh flattening skolem variables are actually identified - with the types they have been generated to stand in for. + co :: xi ~ ty Note that it is flatten's job to flatten *every type function it sees*. flatten is only called on *arguments* to type functions, by canEqGiven. +Flattening also: + * zonks, removing any metavariables, and + * applies the substitution embodied in the inert set + +Because flattening zonks and the returned coercion ("co" above) is also +zonked, it's possible that (co :: xi ~ ty) isn't quite true, as ty (the +input to the flattener) might not be zonked. After zonking everything, +(co :: xi ~ ty) will be true, however. It is for this reason that we +occasionally have to explicitly zonk, when (co :: xi ~ ty) is important +even before we zonk the whole program. (In particular, this is why the +zonk in flatten_tyvar3 is necessary.) + Flattening a type also means flattening its kind. In the case of a type variable whose kind mentions a type family, this might mean that the result of flattening has a cast in it. @@ -1349,6 +1356,7 @@ flatten_tyvar3 tv -- This zonk is necessary because we might later see the tv's kind -- in canEqTyVarTyVar (where we use getCastedTyVar_maybe). -- If you remove it, then e.g. dependent/should_fail/T11407 panics + -- See also Note [Flattening] ; return (FTRCasted (setTyVarKind tv orig_kind) kind_co) } {- From git at git.haskell.org Mon Mar 21 21:41:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 21:41:59 +0000 (UTC) Subject: [commit: ghc] master: PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...` (6f0e41d) Message-ID: <20160321214159.9BA073A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/6f0e41da96b79cde49ad8761738c281cd190ac65/ghc >--------------------------------------------------------------- commit 6f0e41da96b79cde49ad8761738c281cd190ac65 Author: Herbert Valerio Riedel Date: Mon Mar 21 11:30:03 2016 +0100 PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...` Use `fcmpu 0, ...` rather than `fcmpu cr0, ...` for better portability since some non-GNU assembler (such as IBM's `as`) tend to not support the symbolic register name `cr0`. This matches the syntax that GCC emits for PPC targets. >--------------------------------------------------------------- 6f0e41da96b79cde49ad8761738c281cd190ac65 compiler/nativeGen/PPC/Ppr.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs index 08c02f0..9326813 100644 --- a/compiler/nativeGen/PPC/Ppr.hs +++ b/compiler/nativeGen/PPC/Ppr.hs @@ -764,10 +764,14 @@ pprInstr (FNEG reg1 reg2) = pprUnary (sLit "fneg") reg1 reg2 pprInstr (FCMP reg1 reg2) = hcat [ char '\t', - text "fcmpu\tcr0, ", + text "fcmpu\t0, ", -- Note: we're using fcmpu, not fcmpo -- The difference is with fcmpo, compare with NaN is an invalid operation. - -- We don't handle invalid fp ops, so we don't care + -- We don't handle invalid fp ops, so we don't care. + -- Morever, we use `fcmpu 0, ...` rather than `fcmpu cr0, ...` for + -- better portability since some non-GNU assembler (such as + -- IBM's `as`) tend not to support the symbolic register name cr0. + -- This matches the syntax that GCC seems to emit for PPC targets. pprReg reg1, text ", ", pprReg reg2 From git at git.haskell.org Mon Mar 21 21:43:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 21:43:16 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...` (fd139fc) Message-ID: <20160321214316.4BB133A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/fd139fc1dde482b8363053d4a6a3fd3e0cef3364/ghc >--------------------------------------------------------------- commit fd139fc1dde482b8363053d4a6a3fd3e0cef3364 Author: Herbert Valerio Riedel Date: Mon Mar 21 11:30:03 2016 +0100 PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...` Use `fcmpu 0, ...` rather than `fcmpu cr0, ...` for better portability since some non-GNU assembler (such as IBM's `as`) tend to not support the symbolic register name `cr0`. This matches the syntax that GCC emits for PPC targets. (cherry picked from commit 6f0e41da96b79cde49ad8761738c281cd190ac65) >--------------------------------------------------------------- fd139fc1dde482b8363053d4a6a3fd3e0cef3364 compiler/nativeGen/PPC/Ppr.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs index 08c02f0..9326813 100644 --- a/compiler/nativeGen/PPC/Ppr.hs +++ b/compiler/nativeGen/PPC/Ppr.hs @@ -764,10 +764,14 @@ pprInstr (FNEG reg1 reg2) = pprUnary (sLit "fneg") reg1 reg2 pprInstr (FCMP reg1 reg2) = hcat [ char '\t', - text "fcmpu\tcr0, ", + text "fcmpu\t0, ", -- Note: we're using fcmpu, not fcmpo -- The difference is with fcmpo, compare with NaN is an invalid operation. - -- We don't handle invalid fp ops, so we don't care + -- We don't handle invalid fp ops, so we don't care. + -- Morever, we use `fcmpu 0, ...` rather than `fcmpu cr0, ...` for + -- better portability since some non-GNU assembler (such as + -- IBM's `as`) tend not to support the symbolic register name cr0. + -- This matches the syntax that GCC seems to emit for PPC targets. pprReg reg1, text ", ", pprReg reg2 From git at git.haskell.org Mon Mar 21 22:14:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 21 Mar 2016 22:14:50 +0000 (UTC) Subject: [commit: ghc] master: Use the correct in-scope set in coercionKind (685398e) Message-ID: <20160321221450.881B33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/685398ebc5c8377597714cd8c3e97439d32e3a02/ghc >--------------------------------------------------------------- commit 685398ebc5c8377597714cd8c3e97439d32e3a02 Author: Bartosz Nitka Date: Mon Mar 21 11:11:26 2016 -0700 Use the correct in-scope set in coercionKind The free vars of `ty2` need to be in scope to satisfy the substitution invariant. As far as I can tell we don't have the free vars of `ty2` when substituting, so unfortunately we have to compute them. Test Plan: ./validate Reviewers: austin, bgamari, simonpj, goldfire Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2024 GHC Trac Issues: #11371 >--------------------------------------------------------------- 685398ebc5c8377597714cd8c3e97439d32e3a02 compiler/types/Coercion.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs index e8d1d6c..a2b93bd 100644 --- a/compiler/types/Coercion.hs +++ b/compiler/types/Coercion.hs @@ -1717,7 +1717,12 @@ coercionKind co = go co = let Pair _ k2 = go k_co tv2 = setTyVarKind tv1 k2 Pair ty1 ty2 = go co - ty2' = substTyWithUnchecked [tv1] [TyVarTy tv2 `mk_cast_ty` mkSymCo k_co] ty2 in + subst = zipTvSubst [tv1] [TyVarTy tv2 `mk_cast_ty` mkSymCo k_co] + ty2' = substTyAddInScope subst ty2 in + -- We need free vars of ty2 in scope to satisfy the invariant + -- from Note [The substitution invariant] + -- This is doing repeated substitutions and probably doesn't + -- need to, see #11735 mkNamedForAllTy <$> Pair tv1 tv2 <*> pure Invisible <*> Pair ty1 ty2' go (CoVarCo cv) = toPair $ coVarTypes cv go (AxiomInstCo ax ind cos) @@ -1792,7 +1797,12 @@ coercionKindRole = go = let Pair _ k2 = coercionKind k_co tv2 = setTyVarKind tv1 k2 (Pair ty1 ty2, r) = go co - ty2' = substTyWithUnchecked [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo k_co] ty2 in + subst = zipTvSubst [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo k_co] + ty2' = substTyAddInScope subst ty2 in + -- We need free vars of ty2 in scope to satisfy the invariant + -- from Note [The substitution invariant] + -- This is doing repeated substitutions and probably doesn't + -- need to, see #11735 (mkNamedForAllTy <$> Pair tv1 tv2 <*> pure Invisible <*> Pair ty1 ty2', r) go (CoVarCo cv) = (toPair $ coVarTypes cv, coVarRole cv) go co@(AxiomInstCo ax _ _) = (coercionKind co, coAxiomRole ax) From git at git.haskell.org Tue Mar 22 02:41:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 22 Mar 2016 02:41:06 +0000 (UTC) Subject: [commit: ghc] wip/rae: Avoid running afoul of the zipTvSubst check. (0beb82c) Message-ID: <20160322024106.766C93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/0beb82c171913508dc0de91851ab8e90821d8ba8/ghc >--------------------------------------------------------------- commit 0beb82c171913508dc0de91851ab8e90821d8ba8 Author: Richard Eisenberg Date: Mon Mar 21 22:35:41 2016 -0400 Avoid running afoul of the zipTvSubst check. addDataConStupidTheta includes comments that the types list might be longer than the tvs list. And the check in zipTvSubst doesn't appear to be terribly recent. I am utterly flummoxed as to why this worked before. It was clearly just broken. And now it's fixed. >--------------------------------------------------------------- 0beb82c171913508dc0de91851ab8e90821d8ba8 compiler/typecheck/TcPat.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs index 53b8142..6cc6429 100644 --- a/compiler/typecheck/TcPat.hs +++ b/compiler/typecheck/TcPat.hs @@ -1017,7 +1017,8 @@ addDataConStupidTheta data_con inst_tys -- The origin should always report "occurrence of C" -- even when C occurs in a pattern stupid_theta = dataConStupidTheta data_con - tenv = zipTvSubst (dataConUnivTyVars data_con) inst_tys + univ_tvs = dataConUnivTyVars data_con + tenv = zipTvSubst univ_tvs (takeList univ_tvs inst_tys) -- NB: inst_tys can be longer than the univ tyvars -- because the constructor might have existentials inst_theta = substTheta tenv stupid_theta From git at git.haskell.org Tue Mar 22 02:41:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 22 Mar 2016 02:41:08 +0000 (UTC) Subject: [commit: ghc] wip/rae's head updated: Avoid running afoul of the zipTvSubst check. (0beb82c) Message-ID: <20160322024108.B45CD3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/rae' now includes: 1eefedf Fix #11357. aade111 Fix #11473. f602f4a Fix printing of "kind" vs. "type" 5d98b8b Clean up some pretty-printing in errors. 46f9a47 DriverPipeline: Fix 'unused arguments' warnings from Clang b5565f1 Fix #11711. c5ed41c typechecker: fix trac issue #11708 3fe87aa Fix #11716. f4f315a Fix #11512 by getting visibility right for methods 220a0b9 Add test for #9646 3ddfcc9 PrelRules: Fix constant folding for WordRemOp 2841cca Mark GHC.Real.even and odd as INLINEABLE c095ec5 Ensure T11702 always runs with optasm c0f628d Revert "Add test for #11473" cb7ecda Fix duplicate T11334 test 08d254b Fix T9646 7186a01 Dwarf: Add support for labels in unwind expressions ba95f22 prof: Fix heap census for large ARR_WORDS (#11627) b735e99 DsExpr: Don't build/foldr huge lists 289d57a Add test for incompatible flags (issue #11580) cb3456d base: Rework System.CPUTime e6a44f2 T11145: Fix expected output 286c65f base: Fix CPUTime on Windows 3ade8bc Delete a misleading comment in TyCon 2cb5577 Remove unnecessary Ord instance for ConLike c37a583 Remove unused substTyWithBinders functions af2f7f9 Fix exponential algorithm in pure unifier. 01b29eb TypeApplications does not imply AllowAmbiguousTypes 0706a10 Add two small optimizations. (#11196) 1701255 Fix #11635 / #11719. 0b89064 Make equality print better. (#11712) f8ab575 Rename test for #11334 to 11334b, fixing conflict 3e1b882 Prevent eager unification with type families. 9477093 Comment a suspicious zonk in TcFlatten. 35e9379 Track specified/invisible more carefully. 5c0c751 Zonk before calling splitDepVarsOfType. d978c5e Fix #11723 and #11724. e19e58c Improve panicking output 1934f7f stgMallocBytes: Tolerate malloc(0) returning a NULL ptr 2d6d907 Comments (only) in TcFlatten 6f0e41d PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...` 685398e Use the correct in-scope set in coercionKind 0beb82c Avoid running afoul of the zipTvSubst check. From git at git.haskell.org Tue Mar 22 11:55:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 22 Mar 2016 11:55:36 +0000 (UTC) Subject: [commit: ghc] master's head updated: Avoid running afoul of the zipTvSubst check. (0beb82c) Message-ID: <20160322115536.261453A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'master' now includes: 0beb82c Avoid running afoul of the zipTvSubst check. From git at git.haskell.org Tue Mar 22 14:37:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 22 Mar 2016 14:37:49 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Typo in Note name (c13c918) Message-ID: <20160322143749.A7AE33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/c13c91851f7cfcef58020233c4a76e397cb2fc87/ghc >--------------------------------------------------------------- commit c13c91851f7cfcef58020233c4a76e397cb2fc87 Author: Joachim Breitner Date: Tue Mar 22 11:14:08 2016 +0100 Typo in Note name >--------------------------------------------------------------- c13c91851f7cfcef58020233c4a76e397cb2fc87 compiler/coreSyn/CoreUtils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index d2da53a..1d9b83b 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -753,8 +753,8 @@ Note [exprIsTrivial] applications. Note that primop Ids aren't considered trivial unless -Note [Variable are trivial] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Variables are trivial] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There used to be a gruesome test for (hasNoBinding v) in the Var case: exprIsTrivial (Var v) | hasNoBinding v = idArity v == 0 From git at git.haskell.org Tue Mar 22 14:37:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 22 Mar 2016 14:37:52 +0000 (UTC) Subject: [commit: ghc] wip/T10613: SpecConstr: Transport strictness annotation to specialization’s argument’s binders (8649ac6) Message-ID: <20160322143752.583C53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/8649ac61698c8600f5db64ff7947828bb4715a5d/ghc >--------------------------------------------------------------- commit 8649ac61698c8600f5db64ff7947828bb4715a5d Author: Joachim Breitner Date: Tue Mar 22 15:39:06 2016 +0100 SpecConstr: Transport strictness annotation to specialization?s argument?s binders This is a result of the discussion in ticket:11731#comment:9. >--------------------------------------------------------------- 8649ac61698c8600f5db64ff7947828bb4715a5d compiler/specialise/SpecConstr.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs index 10d5614..46fda8e 100644 --- a/compiler/specialise/SpecConstr.hs +++ b/compiler/specialise/SpecConstr.hs @@ -1648,12 +1648,19 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) `setIdStrictness` spec_str `setIdArity` count isId spec_lam_args spec_str = calcSpecStrictness fn spec_lam_args pats + + -- Conditionally use result of new worker-wrapper transform (spec_lam_args, spec_call_args) = mkWorkerArgs (sc_dflags env) qvars NoOneShotInfo body_ty -- Usual w/w hack to avoid generating -- a spec_rhs of unlifted type and no args - spec_rhs = mkLams spec_lam_args spec_body + spec_lam_args_str = zipWith setIdDemandInfo spec_lam_args $ + fst (splitStrictSig spec_str) ++ repeat topDmd + -- Annotate the variables with the strictness information from + -- the function + + spec_rhs = mkLams spec_lam_args_str spec_body body_ty = exprType spec_body rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn From git at git.haskell.org Tue Mar 22 15:55:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 22 Mar 2016 15:55:49 +0000 (UTC) Subject: [commit: ghc] wip/T10613: SpecConstr: Transport strictness annotation to specialization’s argument’s binders (f168826) Message-ID: <20160322155549.45B103A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/f168826bdee0d65cb560b9b854eb0b9c312d85ae/ghc >--------------------------------------------------------------- commit f168826bdee0d65cb560b9b854eb0b9c312d85ae Author: Joachim Breitner Date: Tue Mar 22 15:39:06 2016 +0100 SpecConstr: Transport strictness annotation to specialization?s argument?s binders This is a result of the discussion in ticket:11731#comment:9. >--------------------------------------------------------------- f168826bdee0d65cb560b9b854eb0b9c312d85ae compiler/specialise/SpecConstr.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs index 10d5614..7e75a4f 100644 --- a/compiler/specialise/SpecConstr.hs +++ b/compiler/specialise/SpecConstr.hs @@ -1648,12 +1648,18 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) `setIdStrictness` spec_str `setIdArity` count isId spec_lam_args spec_str = calcSpecStrictness fn spec_lam_args pats + + -- Conditionally use result of new worker-wrapper transform (spec_lam_args, spec_call_args) = mkWorkerArgs (sc_dflags env) qvars NoOneShotInfo body_ty -- Usual w/w hack to avoid generating -- a spec_rhs of unlifted type and no args - spec_rhs = mkLams spec_lam_args spec_body + spec_lam_args_str = handOutStrictnessInformation (fst (splitStrictSig spec_str)) spec_lam_args + -- ^ Annotate the variables with the strictness information from + -- the function + + spec_rhs = mkLams spec_lam_args_str spec_body body_ty = exprType spec_body rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn @@ -1663,6 +1669,14 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) -- See Note [Transfer activation] ; return (spec_usg, OS call_pat rule spec_id spec_rhs) } +handOutStrictnessInformation :: [Demand] -> [Var] -> [Var] +handOutStrictnessInformation = go + where + go _ [] = [] + go [] vs = vs + go (d:dmds) (v:vs) | isId v = setIdDemandInfo v d : go dmds vs + go dmds (v:vs) = v : go dmds vs + calcSpecStrictness :: Id -- The original function -> [Var] -> [CoreExpr] -- Call pattern -> StrictSig -- Strictness of specialised thing From git at git.haskell.org Tue Mar 22 15:55:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 22 Mar 2016 15:55:46 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Ticky report: Mark single entry functions as such (39977c6) Message-ID: <20160322155546.9C2C23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/39977c6d987db284ca0379ac62214736d76720fe/ghc >--------------------------------------------------------------- commit 39977c6d987db284ca0379ac62214736d76720fe Author: Joachim Breitner Date: Tue Mar 22 16:36:22 2016 +0100 Ticky report: Mark single entry functions as such Based on the idOneShotInfo of their first argument, I hope that?s right. >--------------------------------------------------------------- 39977c6d987db284ca0379ac62214736d76720fe compiler/codeGen/StgCmmBind.hs | 5 +++- compiler/codeGen/StgCmmClosure.hs | 49 +++++++++++++++++++++------------------ compiler/codeGen/StgCmmTicky.hs | 9 ++++--- 3 files changed, 37 insertions(+), 26 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 39977c6d987db284ca0379ac62214736d76720fe From git at git.haskell.org Wed Mar 23 13:47:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:47:46 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Be more explicit about thunk types in ticky-ticky-report (440cd51) Message-ID: <20160323134746.1BE663A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/440cd51b184b3622129394e60a72e5d4563744e3/ghc >--------------------------------------------------------------- commit 440cd51b184b3622129394e60a72e5d4563744e3 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Be more explicit about thunk types in ticky-ticky-report and also, for standard thunks (AP and selector), do not count an entry when they are allocated. It is not possible to count their entries, as their code is shared, but better count nothing than count the wrong thing. (The removed line was added in 11a85cc7ea50d4b7c12ea2cc3c0ce39734dc4217) >--------------------------------------------------------------- 440cd51b184b3622129394e60a72e5d4563744e3 compiler/codeGen/StgCmmBind.hs | 10 ++++--- compiler/codeGen/StgCmmTicky.hs | 62 ++++++++++++++++++++++++++++++----------- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index f34186a..b265153 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -206,7 +206,7 @@ cgRhs :: Id ) cgRhs id (StgRhsCon cc con args) - = withNewTickyCounterThunk False (idName id) $ -- False for "not static" + = withNewTickyCounterCon (idName id) $ buildDynCon id True cc con args {- See Note [GC recovery] in compiler/codeGen/StgCmmClosure.hs -} @@ -386,7 +386,7 @@ cgRhsStdThunk bndr lf_info payload } where gen_code reg -- AHA! A STANDARD-FORM THUNK - = withNewTickyCounterStdThunk False (idName bndr) $ -- False for "not static" + = withNewTickyCounterStdThunk (lfUpdatable lf_info) (idName bndr) $ do { -- LAY OUT THE OBJECT mod_name <- getModuleName @@ -402,7 +402,6 @@ cgRhsStdThunk bndr lf_info payload -- ; (use_cc, blame_cc) <- chooseDynCostCentres cc [{- no args-}] body ; let use_cc = curCCS; blame_cc = curCCS - ; tickyEnterStdThunk closure_info -- BUILD THE OBJECT ; let info_tbl = mkCmmInfo closure_info @@ -453,7 +452,10 @@ closureCodeBody :: Bool -- whether this is a top-level binding closureCodeBody top_lvl bndr cl_info cc _args arity body fv_details | arity == 0 -- No args i.e. thunk - = withNewTickyCounterThunk (isStaticClosure cl_info) (closureName cl_info) $ + = withNewTickyCounterThunk + (isStaticClosure cl_info) + (closureUpdReqd cl_info) + (closureName cl_info) $ emitClosureProcAndInfoTable top_lvl bndr lf_info info_tbl [] $ \(_, node, _) -> thunkCode cl_info fv_details cc node arity body where diff --git a/compiler/codeGen/StgCmmTicky.hs b/compiler/codeGen/StgCmmTicky.hs index 95dfa99..45b88da 100644 --- a/compiler/codeGen/StgCmmTicky.hs +++ b/compiler/codeGen/StgCmmTicky.hs @@ -70,6 +70,7 @@ module StgCmmTicky ( withNewTickyCounterLNE, withNewTickyCounterThunk, withNewTickyCounterStdThunk, + withNewTickyCounterCon, tickyDynAlloc, tickyAllocHeap, @@ -143,7 +144,13 @@ import Control.Monad ( unless, when ) -- ----------------------------------------------------------------------------- -data TickyClosureType = TickyFun | TickyThunk | TickyLNE +data TickyClosureType + = TickyFun + | TickyCon + | TickyThunk + Bool -- ^ True <-> updateable + Bool -- ^ True <-> standard thunk (AP or selector), has no entry counter + | TickyLNE withNewTickyCounterFun, withNewTickyCounterLNE :: Name -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterFun = withNewTickyCounter TickyFun @@ -152,15 +159,38 @@ withNewTickyCounterLNE nm args code = do b <- tickyLNEIsOn if not b then code else withNewTickyCounter TickyLNE nm args code -withNewTickyCounterThunk,withNewTickyCounterStdThunk :: - Bool -> Name -> FCode a -> FCode a -withNewTickyCounterThunk isStatic name code = do +withNewTickyCounterThunk + :: Bool -- ^ static + -> Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterThunk isStatic isUpdatable name code = do b <- tickyDynThunkIsOn if isStatic || not b -- ignore static thunks then code - else withNewTickyCounter TickyThunk name [] code + else withNewTickyCounter (TickyThunk isUpdatable False) name [] code + +withNewTickyCounterStdThunk + :: Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterStdThunk isUpdatable name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter (TickyThunk isUpdatable True) name [] code -withNewTickyCounterStdThunk = withNewTickyCounterThunk +withNewTickyCounterCon + :: Name + -> FCode a + -> FCode a +withNewTickyCounterCon name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter TickyCon name [] code -- args does not include the void arguments withNewTickyCounter :: TickyClosureType -> Name -> [NonVoid Id] -> FCode a -> FCode a @@ -184,21 +214,21 @@ emitTickyCounter cloType name args ; let ppr_for_ticky_name :: SDoc ppr_for_ticky_name = let n = ppr name + ext = case cloType of + TickyFun -> empty + TickyCon -> parens (text "con") + TickyThunk upd std -> parens $ hcat $ punctuate comma $ + [text "thk"] ++ [text "se"|not upd] ++ [text "std"|std] + TickyLNE | isInternalName name -> parens (text "LNE") + | otherwise -> panic "emitTickyCounter: how is this an external LNE?" p = case hasHaskellName parent of -- NB the default "top" ticky ctr does not -- have a Haskell name Just pname -> text "in" <+> ppr (nameUnique pname) _ -> empty - in (<+> p) $ if isInternalName name - then let s = n <+> (parens (ppr mod_name)) - in case cloType of - TickyFun -> s - TickyThunk -> s <+> parens (text "thk") - TickyLNE -> s <+> parens (text "LNE") - else case cloType of - TickyFun -> n - TickyThunk -> n <+> parens (text "thk") - TickyLNE -> panic "emitTickyCounter: how is this an external LNE?" + in if isInternalName name + then n <+> parens (ppr mod_name) <+> ext <+> p + else n <+> ext <+> p ; fun_descr_lit <- newStringCLit $ showSDocDebug dflags ppr_for_ticky_name ; arg_descr_lit <- newStringCLit $ map (showTypeCategory . idType . unsafe_stripNV) args From git at git.haskell.org Wed Mar 23 13:47:48 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:47:48 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Evac: Do not evaluate selector thunks pointing to counting indirections (2e0ccaf) Message-ID: <20160323134748.E5D263A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/2e0ccafe3d03758f506c7f1738c6bdbd71f62f22/ghc >--------------------------------------------------------------- commit 2e0ccafe3d03758f506c7f1738c6bdbd71f62f22 Author: Joachim Breitner Date: Wed Mar 23 13:50:00 2016 +0100 Evac: Do not evaluate selector thunks pointing to counting indirections >--------------------------------------------------------------- 2e0ccafe3d03758f506c7f1738c6bdbd71f62f22 rts/sm/Evac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 3b4314b..9369543 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -998,12 +998,17 @@ selector_loop: } case IND: - case COUNTING_IND: case IND_STATIC: // Again, we might need to untag a constructor. selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); goto selector_loop; + case COUNTING_IND: + // do not short cut a COUNTING_IND, as we would miss a the count + // Can we simply tick the counter here? Not really: If this selector + // thunk is not going to be used, we counted more than we wanted! + goto bale_out; + case BLACKHOLE: { StgClosure *r; From git at git.haskell.org Wed Mar 23 13:47:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:47:51 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Do not print DmdType in Core output (b108342) Message-ID: <20160323134751.AF4B73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/b10834204d78d22a3e3db7fb0131a3acadcae1cd/ghc >--------------------------------------------------------------- commit b10834204d78d22a3e3db7fb0131a3acadcae1cd Author: Joachim Breitner Date: Wed Mar 23 13:38:34 2016 +0100 Do not print DmdType in Core output too verbose, and usualy preceded by Str= anyways. >--------------------------------------------------------------- b10834204d78d22a3e3db7fb0131a3acadcae1cd compiler/basicTypes/Demand.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/basicTypes/Demand.hs b/compiler/basicTypes/Demand.hs index 3ce9228..5359c2f 100644 --- a/compiler/basicTypes/Demand.hs +++ b/compiler/basicTypes/Demand.hs @@ -1239,8 +1239,7 @@ bothDmdType (DmdType fv1 ds1 r1) (fv2, t2) instance Outputable DmdType where ppr (DmdType fv ds res) - = hsep [text "DmdType", - hcat (map ppr ds) <> ppr res, + = hsep [hcat (map ppr ds) <> ppr res, if null fv_elts then empty else braces (fsep (map pp_elt fv_elts))] where From git at git.haskell.org Wed Mar 23 13:47:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:47:54 +0000 (UTC) Subject: [commit: ghc] wip/T10613: SpecConstr: Transport strictness annotation to specialization’s argument’s binders (25577ef) Message-ID: <20160323134754.66A223A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/25577effced37a165a09b82405b0463258e5881b/ghc >--------------------------------------------------------------- commit 25577effced37a165a09b82405b0463258e5881b Author: Joachim Breitner Date: Tue Mar 22 15:39:06 2016 +0100 SpecConstr: Transport strictness annotation to specialization?s argument?s binders This is a result of the discussion in ticket:11731#comment:9. >--------------------------------------------------------------- 25577effced37a165a09b82405b0463258e5881b compiler/specialise/SpecConstr.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs index 10d5614..7e75a4f 100644 --- a/compiler/specialise/SpecConstr.hs +++ b/compiler/specialise/SpecConstr.hs @@ -1648,12 +1648,18 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) `setIdStrictness` spec_str `setIdArity` count isId spec_lam_args spec_str = calcSpecStrictness fn spec_lam_args pats + + -- Conditionally use result of new worker-wrapper transform (spec_lam_args, spec_call_args) = mkWorkerArgs (sc_dflags env) qvars NoOneShotInfo body_ty -- Usual w/w hack to avoid generating -- a spec_rhs of unlifted type and no args - spec_rhs = mkLams spec_lam_args spec_body + spec_lam_args_str = handOutStrictnessInformation (fst (splitStrictSig spec_str)) spec_lam_args + -- ^ Annotate the variables with the strictness information from + -- the function + + spec_rhs = mkLams spec_lam_args_str spec_body body_ty = exprType spec_body rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn @@ -1663,6 +1669,14 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) -- See Note [Transfer activation] ; return (spec_usg, OS call_pat rule spec_id spec_rhs) } +handOutStrictnessInformation :: [Demand] -> [Var] -> [Var] +handOutStrictnessInformation = go + where + go _ [] = [] + go [] vs = vs + go (d:dmds) (v:vs) | isId v = setIdDemandInfo v d : go dmds vs + go dmds (v:vs) = v : go dmds vs + calcSpecStrictness :: Id -- The original function -> [Var] -> [CoreExpr] -- Call pattern -> StrictSig -- Strictness of specialised thing From git at git.haskell.org Wed Mar 23 13:47:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:47:57 +0000 (UTC) Subject: [commit: ghc] wip/T10613: State hack hack in ticky report (4ee615d) Message-ID: <20160323134757.29F3A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/4ee615d7a7345c7d3b6a6c627adf5c9a7d7f5bc8/ghc >--------------------------------------------------------------- commit 4ee615d7a7345c7d3b6a6c627adf5c9a7d7f5bc8 Author: Joachim Breitner Date: Wed Mar 23 11:10:25 2016 +0100 State hack hack in ticky report In the ticky report, do not mark a function with a State# argument as its first argument as single-entry. >--------------------------------------------------------------- 4ee615d7a7345c7d3b6a6c627adf5c9a7d7f5bc8 compiler/codeGen/StgCmmClosure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index b467048..3b83b8e 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -234,7 +234,10 @@ mkLFReEntrant _ _ [] _ = pprPanic "mkLFReEntrant" empty mkLFReEntrant top fvs args arg_descr = LFReEntrant top os_info (length args) (null fvs) arg_descr - where os_info = idOneShotInfo (head args) + where + state_hack_hack = isStateHackType (idType (head args)) + os_info | state_hack_hack = noOneShotInfo + | otherwise = idOneShotInfo (head args) ------------- mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo From git at git.haskell.org Wed Mar 23 13:47:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:47:59 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rename isNopSig to isTopSig (d589cfa) Message-ID: <20160323134759.D41883A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/d589cfae846e475686f50de6974e41a7e3295a74/ghc >--------------------------------------------------------------- commit d589cfae846e475686f50de6974e41a7e3295a74 Author: Joachim Breitner Date: Wed Mar 23 10:41:16 2016 +0100 Rename isNopSig to isTopSig to be consistent with the other uses of nop vs. top in Demand.hs. Also, stop prettyprinting top strictness signatures in Core dumps. >--------------------------------------------------------------- d589cfae846e475686f50de6974e41a7e3295a74 compiler/basicTypes/Demand.hs | 12 ++++++------ compiler/coreSyn/CoreArity.hs | 2 +- compiler/coreSyn/PprCore.hs | 3 ++- compiler/iface/MkIface.hs | 2 +- compiler/main/TidyPgm.hs | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/compiler/basicTypes/Demand.hs b/compiler/basicTypes/Demand.hs index 96e02b2..3ce9228 100644 --- a/compiler/basicTypes/Demand.hs +++ b/compiler/basicTypes/Demand.hs @@ -37,7 +37,7 @@ module Demand ( appIsBottom, isBottomingSig, pprIfaceStrictSig, trimCPRInfo, returnsCPR_maybe, StrictSig(..), mkStrictSig, mkClosedStrictSig, nopSig, botSig, cprProdSig, - isNopSig, splitStrictSig, increaseStrictSigArity, + isTopSig, splitStrictSig, increaseStrictSigArity, seqDemand, seqDemandList, seqDmdType, seqStrictSig, @@ -1262,10 +1262,10 @@ cprProdDmdType :: Arity -> DmdType cprProdDmdType arity = DmdType emptyDmdEnv [] (vanillaCprProdRes arity) -isNopDmdType :: DmdType -> Bool -isNopDmdType (DmdType env [] res) +isTopDmdType :: DmdType -> Bool +isTopDmdType (DmdType env [] res) | isTopRes res && isEmptyVarEnv env = True -isNopDmdType _ = False +isTopDmdType _ = False mkDmdType :: DmdEnv -> [Demand] -> DmdResult -> DmdType mkDmdType fv ds res = DmdType fv ds res @@ -1669,8 +1669,8 @@ increaseStrictSigArity :: Int -> StrictSig -> StrictSig increaseStrictSigArity arity_increase (StrictSig (DmdType env dmds res)) = StrictSig (DmdType env (replicate arity_increase topDmd ++ dmds) res) -isNopSig :: StrictSig -> Bool -isNopSig (StrictSig ty) = isNopDmdType ty +isTopSig :: StrictSig -> Bool +isTopSig (StrictSig ty) = isTopDmdType ty isBottomingSig :: StrictSig -> Bool -- True if the signature diverges or throws an exception diff --git a/compiler/coreSyn/CoreArity.hs b/compiler/coreSyn/CoreArity.hs index 8086299..cf6cd98 100644 --- a/compiler/coreSyn/CoreArity.hs +++ b/compiler/coreSyn/CoreArity.hs @@ -711,7 +711,7 @@ arityType env (Cast e co) arityType _ (Var v) | strict_sig <- idStrictness v - , not $ isNopSig strict_sig + , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds = if isBotRes res then ABot arity diff --git a/compiler/coreSyn/PprCore.hs b/compiler/coreSyn/PprCore.hs index d5e3660..60e9a6a 100644 --- a/compiler/coreSyn/PprCore.hs +++ b/compiler/coreSyn/PprCore.hs @@ -400,7 +400,7 @@ ppIdInfo id info , (has_arity, text "Arity=" <> int arity) , (has_called_arity, text "CallArity=" <> int called_arity) , (has_caf_info, text "Caf=" <> ppr caf_info) - , (True, text "Str=" <> pprStrictness str_info) + , (has_str_info, text "Str=" <> pprStrictness str_info) , (has_unf, text "Unf=" <> ppr unf_info) , (not (null rules), text "RULES:" <+> vcat (map pprRule rules)) ] -- Inline pragma, occ, demand, one-shot info @@ -421,6 +421,7 @@ ppIdInfo id info has_caf_info = not (mayHaveCafRefs caf_info) str_info = strictnessInfo info + has_str_info = not (isTopSig str_info) unf_info = unfoldingInfo info has_unf = hasSomeUnfolding unf_info diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 196dd19..7f8397b 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -1684,7 +1684,7 @@ toIfaceIdInfo id_info ------------ Strictness -------------- -- No point in explicitly exporting TopSig sig_info = strictnessInfo id_info - strict_hsinfo | not (isNopSig sig_info) = Just (HsStrictness sig_info) + strict_hsinfo | not (isTopSig sig_info) = Just (HsStrictness sig_info) | otherwise = Nothing ------------ Unfolding -------------- diff --git a/compiler/main/TidyPgm.hs b/compiler/main/TidyPgm.hs index 5bbbdb5..4f379e9 100644 --- a/compiler/main/TidyPgm.hs +++ b/compiler/main/TidyPgm.hs @@ -37,7 +37,7 @@ import IdInfo import InstEnv import FamInstEnv import Type ( tidyTopType ) -import Demand ( appIsBottom, isNopSig, isBottomingSig ) +import Demand ( appIsBottom, isTopSig, isBottomingSig ) import BasicTypes import Name hiding (varName) import NameSet @@ -1235,7 +1235,7 @@ tidyTopIdInfo dflags rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold caf_ mb_bot_str = exprBotStrictness_maybe orig_rhs sig = strictnessInfo idinfo - final_sig | not $ isNopSig sig + final_sig | not $ isTopSig sig = WARN( _bottom_hidden sig , ppr name ) sig -- try a cheap-and-cheerful bottom analyser | Just (_, nsig) <- mb_bot_str = nsig From git at git.haskell.org Wed Mar 23 13:48:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:48:02 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Typo in Note name (34f7388) Message-ID: <20160323134802.8C44C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/34f73888ae9bf1542843f285f6a1c517b4470a3e/ghc >--------------------------------------------------------------- commit 34f73888ae9bf1542843f285f6a1c517b4470a3e Author: Joachim Breitner Date: Tue Mar 22 11:14:08 2016 +0100 Typo in Note name >--------------------------------------------------------------- 34f73888ae9bf1542843f285f6a1c517b4470a3e compiler/coreSyn/CoreUtils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index d2da53a..1d9b83b 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -753,8 +753,8 @@ Note [exprIsTrivial] applications. Note that primop Ids aren't considered trivial unless -Note [Variable are trivial] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Variables are trivial] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There used to be a gruesome test for (hasNoBinding v) in the Var case: exprIsTrivial (Var v) | hasNoBinding v = idArity v == 0 From git at git.haskell.org Wed Mar 23 13:48:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:48:05 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Ticky: Do not count every entry twice (af90af1) Message-ID: <20160323134805.3989E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/af90af1edd45158b02ca092c6fe0d0c9d5860f58/ghc >--------------------------------------------------------------- commit af90af1edd45158b02ca092c6fe0d0c9d5860f58 Author: Joachim Breitner Date: Thu Mar 17 17:25:36 2016 +0100 Ticky: Do not count every entry twice (likely introduced by 99d4e5b4a0bd32813ff8c74e91d2dcf6b3555176, possibly due to a merge mistake). >--------------------------------------------------------------- af90af1edd45158b02ca092c6fe0d0c9d5860f58 compiler/codeGen/StgCmmBind.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index b265153..eae599c 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -578,8 +578,7 @@ thunkCode cl_info fv_details _cc node arity body -- that cc of enclosing scope will be recorded -- in update frame CAF/DICT functions will be -- subsumed by this enclosing cc - do { tickyEnterThunk cl_info - ; enterCostCentreThunk (CmmReg nodeReg) + do { enterCostCentreThunk (CmmReg nodeReg) ; let lf_info = closureLFInfo cl_info ; fv_bindings <- mapM bind_fv fv_details ; load_fvs node lf_info fv_bindings From git at git.haskell.org Wed Mar 23 13:48:07 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:48:07 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Ticky report: Mark single entry functions as such (3c183f7) Message-ID: <20160323134807.E9C123A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/3c183f761b11e6855f03c8a11c711512916e0877/ghc >--------------------------------------------------------------- commit 3c183f761b11e6855f03c8a11c711512916e0877 Author: Joachim Breitner Date: Tue Mar 22 16:36:22 2016 +0100 Ticky report: Mark single entry functions as such Based on the idOneShotInfo of their first argument, I hope that?s right. >--------------------------------------------------------------- 3c183f761b11e6855f03c8a11c711512916e0877 compiler/codeGen/StgCmmBind.hs | 5 +++- compiler/codeGen/StgCmmClosure.hs | 49 +++++++++++++++++++++------------------ compiler/codeGen/StgCmmTicky.hs | 9 ++++--- 3 files changed, 37 insertions(+), 26 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 3c183f761b11e6855f03c8a11c711512916e0877 From git at git.haskell.org Wed Mar 23 13:48:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:48:13 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (395c1c1) Message-ID: <20160323134813.599B83A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/395c1c1725c6fa8d982b74df078c1218588b3925/ghc >--------------------------------------------------------------- commit 395c1c1725c6fa8d982b74df078c1218588b3925 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- 395c1c1725c6fa8d982b74df078c1218588b3925 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 395c1c1725c6fa8d982b74df078c1218588b3925 From git at git.haskell.org Wed Mar 23 13:48:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:48:10 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Temporarily move regular entry counting to the COUNTING_IND (31b3de7) Message-ID: <20160323134810.995D43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/31b3de72aaadbe088ef12a65ff12172ea3464ee8/ghc >--------------------------------------------------------------- commit 31b3de72aaadbe088ef12a65ff12172ea3464ee8 Author: Joachim Breitner Date: Wed Mar 23 14:28:34 2016 +0100 Temporarily move regular entry counting to the COUNTING_IND >--------------------------------------------------------------- 31b3de72aaadbe088ef12a65ff12172ea3464ee8 compiler/codeGen/StgCmmBind.hs | 8 ++++++-- rts/StgMiscClosures.cmm | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 5951175..8672273 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -609,9 +609,13 @@ thunkCode cl_info fv_details _cc node arity body -- Heap overflow check ; entryHeapCheck cl_info node' arity [] $ do - { -- Overwrite with black hole if necessary + { + -- Disabled for now, as we (temporarily unconditionally) move the + -- counting to the counting indirection + -- tickyEnterThunk cl_info + + -- Overwrite with black hole if necessary -- but *after* the heap-overflow check - ; tickyEnterThunk cl_info ; when (blackHoleOnEntry cl_info && node_points) (blackHoleIt node) diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 96b95aa..0f27fdb 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -283,6 +283,7 @@ INFO_TABLE(stg_COUNTING_IND,1,2,COUNTING_IND,"COUNTING_IND","COUNTING_IND") StgEntCounter_multi_entry_count(ent_ctr) = StgEntCounter_multi_entry_count(ent_ctr) + 1; } StgCountingInd_entries(clos) = entries + 1; + StgEntCounter_entry_count(ent_ctr) = StgEntCounter_entry_count(ent_ctr) + 1; #if defined(TICKY_TICKY) && !defined(PROFILING) /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than From git at git.haskell.org Wed Mar 23 13:48:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:48:16 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Remove all mentions of IND_OLDGEN outside of docs/rts (5d7c67c) Message-ID: <20160323134816.195033A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/5d7c67ca2d4fe9c21ef9b029f7ba5e458181c175/ghc >--------------------------------------------------------------- commit 5d7c67ca2d4fe9c21ef9b029f7ba5e458181c175 Author: Joachim Breitner Date: Fri Jan 22 10:31:25 2016 +0100 Remove all mentions of IND_OLDGEN outside of docs/rts >--------------------------------------------------------------- 5d7c67ca2d4fe9c21ef9b029f7ba5e458181c175 compiler/codeGen/StgCmmProf.hs | 3 +-- rts/sm/Scav.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs index c1b149d..434d7b5 100644 --- a/compiler/codeGen/StgCmmProf.hs +++ b/compiler/codeGen/StgCmmProf.hs @@ -328,8 +328,7 @@ ldvRecordCreate closure = do -- -- | Called when a closure is entered, marks the closure as having -- been "used". The closure is not an "inherently used" one. The --- closure is not @IND@ or @IND_OLDGEN@ because neither is considered --- for LDV profiling. +-- closure is not @IND@ because that is not considered for LDV profiling. -- ldvEnterClosure :: ClosureInfo -> CmmReg -> FCode () ldvEnterClosure closure_info node_reg = do diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index 953f055..abb7726 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -1533,7 +1533,7 @@ scavenge_one(StgPtr p) } else { size = gen->scan - start; } - debugBelch("evac IND_OLDGEN: %ld bytes", size * sizeof(W_)); + debugBelch("evac IND: %ld bytes", size * sizeof(W_)); } #endif break; From git at git.haskell.org Wed Mar 23 13:48:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 13:48:18 +0000 (UTC) Subject: [commit: ghc] wip/T10613's head updated: Temporarily move regular entry counting to the COUNTING_IND (31b3de7) Message-ID: <20160323134818.7A50F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T10613' now includes: 220a0b9 Add test for #9646 3ddfcc9 PrelRules: Fix constant folding for WordRemOp 2841cca Mark GHC.Real.even and odd as INLINEABLE c095ec5 Ensure T11702 always runs with optasm c0f628d Revert "Add test for #11473" cb7ecda Fix duplicate T11334 test 08d254b Fix T9646 7186a01 Dwarf: Add support for labels in unwind expressions ba95f22 prof: Fix heap census for large ARR_WORDS (#11627) b735e99 DsExpr: Don't build/foldr huge lists 289d57a Add test for incompatible flags (issue #11580) cb3456d base: Rework System.CPUTime e6a44f2 T11145: Fix expected output 286c65f base: Fix CPUTime on Windows 3ade8bc Delete a misleading comment in TyCon 2cb5577 Remove unnecessary Ord instance for ConLike c37a583 Remove unused substTyWithBinders functions af2f7f9 Fix exponential algorithm in pure unifier. 01b29eb TypeApplications does not imply AllowAmbiguousTypes 0706a10 Add two small optimizations. (#11196) 1701255 Fix #11635 / #11719. 0b89064 Make equality print better. (#11712) f8ab575 Rename test for #11334 to 11334b, fixing conflict 3e1b882 Prevent eager unification with type families. 9477093 Comment a suspicious zonk in TcFlatten. 35e9379 Track specified/invisible more carefully. 5c0c751 Zonk before calling splitDepVarsOfType. d978c5e Fix #11723 and #11724. e19e58c Improve panicking output 1934f7f stgMallocBytes: Tolerate malloc(0) returning a NULL ptr 2d6d907 Comments (only) in TcFlatten 6f0e41d PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...` 685398e Use the correct in-scope set in coercionKind 0beb82c Avoid running afoul of the zipTvSubst check. 5d7c67c Remove all mentions of IND_OLDGEN outside of docs/rts 440cd51 Be more explicit about thunk types in ticky-ticky-report af90af1 Ticky: Do not count every entry twice 395c1c1 Rough working implementation of #10613 34f7388 Typo in Note name 25577ef SpecConstr: Transport strictness annotation to specialization?s argument?s binders 3c183f7 Ticky report: Mark single entry functions as such d589cfa Rename isNopSig to isTopSig 4ee615d State hack hack in ticky report b108342 Do not print DmdType in Core output 2e0ccaf Evac: Do not evaluate selector thunks pointing to counting indirections 31b3de7 Temporarily move regular entry counting to the COUNTING_IND From git at git.haskell.org Wed Mar 23 14:58:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 14:58:06 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Adjust test output to removed "DmdType" (084d635) Message-ID: <20160323145806.2DC3B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/084d635d300b1292e0417857ffd4423be3877e5d/ghc >--------------------------------------------------------------- commit 084d635d300b1292e0417857ffd4423be3877e5d Author: Joachim Breitner Date: Wed Mar 23 16:00:23 2016 +0100 Adjust test output to removed "DmdType" >--------------------------------------------------------------- 084d635d300b1292e0417857ffd4423be3877e5d .../tests/deSugar/should_compile/T2431.stderr | 18 ++++++------- .../tests/determinism/should_compile/determ004.hs | 2 +- .../simplCore/should_compile/spec-inline-determ.hs | 4 +-- .../tests/numeric/should_compile/T7116.stdout | 14 +++++----- testsuite/tests/perf/should_run/T4267.hs | 4 +-- testsuite/tests/perf/should_run/T5949.hs | 4 +-- .../tests/roles/should_compile/Roles13.stderr | 26 +++++++++--------- testsuite/tests/roles/should_compile/T8958.stderr | 4 +-- .../tests/simplCore/should_compile/T3717.stderr | 10 +++---- .../tests/simplCore/should_compile/T3772.stdout | 10 +++---- .../tests/simplCore/should_compile/T4398.stderr | 6 ++--- .../tests/simplCore/should_compile/T4908.stderr | 12 ++++----- .../tests/simplCore/should_compile/T4930.stderr | 10 +++---- .../tests/simplCore/should_compile/T7360.stderr | 31 +++++++++++----------- .../tests/simplCore/should_compile/T9400.stderr | 8 +++--- .../tests/simplCore/should_compile/simpl016.stderr | 2 +- .../simplCore/should_compile/spec-inline.stderr | 24 ++++++++--------- .../tests/stranal/should_compile/T10694.stdout | 10 +++---- 18 files changed, 99 insertions(+), 100 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 084d635d300b1292e0417857ffd4423be3877e5d From git at git.haskell.org Wed Mar 23 16:37:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:13 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix printing of "kind" vs. "type" (6247d27) Message-ID: <20160323163713.EC6603A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6247d27fdaebd3a92647884ee1e86232fc9e54d1/ghc >--------------------------------------------------------------- commit 6247d27fdaebd3a92647884ee1e86232fc9e54d1 Author: Richard Eisenberg Date: Tue Mar 15 14:54:48 2016 -0400 Fix printing of "kind" vs. "type" This is as reported in #11471, though it's not the focus of that ticket. test case: polykinds/KindVType (cherry picked from commit f602f4a6fbf40d1a3c3c02294e90fcb2d5866d04) >--------------------------------------------------------------- 6247d27fdaebd3a92647884ee1e86232fc9e54d1 compiler/typecheck/TcUnify.hs | 10 +--------- testsuite/tests/polykinds/KindVType.hs | 8 ++++++++ testsuite/tests/polykinds/KindVType.stderr | 7 +++++++ testsuite/tests/polykinds/all.T | 1 + 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/compiler/typecheck/TcUnify.hs b/compiler/typecheck/TcUnify.hs index affdd59..8eeef4e 100644 --- a/compiler/typecheck/TcUnify.hs +++ b/compiler/typecheck/TcUnify.hs @@ -1170,16 +1170,8 @@ uType origin t_or_k orig_ty1 orig_ty2 -- See Note [Mismatched type lists and application decomposition] | tc1 == tc2, length tys1 == length tys2 = ASSERT2( isGenerativeTyCon tc1 Nominal, ppr tc1 ) - do { cos <- zipWith3M (uType origin) t_or_ks tys1 tys2 + do { cos <- zipWithM (uType origin t_or_k) tys1 tys2 ; return $ mkTyConAppCo Nominal tc1 cos } - where - bndrs = tyConBinders tc1 - t_or_ks = case t_or_k of - KindLevel -> repeat KindLevel - TypeLevel -> map (\bndr -> if isNamedBinder bndr - then KindLevel - else TypeLevel) bndrs ++ - repeat TypeLevel go (LitTy m) ty@(LitTy n) | m == n diff --git a/testsuite/tests/polykinds/KindVType.hs b/testsuite/tests/polykinds/KindVType.hs new file mode 100644 index 0000000..16815c8 --- /dev/null +++ b/testsuite/tests/polykinds/KindVType.hs @@ -0,0 +1,8 @@ +module KindVType where + +-- test printing of "type" in output, not "kind" + +import Data.Proxy + +foo :: Proxy Maybe +foo = (Proxy :: Proxy Int) diff --git a/testsuite/tests/polykinds/KindVType.stderr b/testsuite/tests/polykinds/KindVType.stderr new file mode 100644 index 0000000..7ce3404 --- /dev/null +++ b/testsuite/tests/polykinds/KindVType.stderr @@ -0,0 +1,7 @@ + +KindVType.hs:8:8: error: + ? Couldn't match type ?*? with ?* -> *? + Expected type: Proxy Maybe + Actual type: Proxy Int + ? In the expression: (Proxy :: Proxy Int) + In an equation for ?foo?: foo = (Proxy :: Proxy Int) diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index a5612f8..522ae43 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -144,3 +144,4 @@ test('T11399', normal, compile_fail, ['']) test('T11611', normal, compile_fail, ['']) test('T11648', normal, compile, ['']) test('T11648b', normal, compile_fail, ['']) +test('KindVType', normal, compile_fail, ['']) From git at git.haskell.org Wed Mar 23 16:37:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:16 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Remove redundant anonymiseTyBinders (#11648) (ad5ee57) Message-ID: <20160323163716.A6FB33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/ad5ee57b0f91239b3142d4b5260eadfef0b3af52/ghc >--------------------------------------------------------------- commit ad5ee57b0f91239b3142d4b5260eadfef0b3af52 Author: Richard Eisenberg Date: Tue Mar 15 11:37:00 2016 -0400 Remove redundant anonymiseTyBinders (#11648) This was necessary in an earlier version of the patch for #11648, but not in the final version. I forgot to remove it. (cherry picked from commit 19be5385e2875578c3a7d1154238580f0ef3c754) >--------------------------------------------------------------- ad5ee57b0f91239b3142d4b5260eadfef0b3af52 compiler/typecheck/TcTyClsDecls.hs | 5 ++--- compiler/typecheck/TcType.hs | 27 --------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/compiler/typecheck/TcTyClsDecls.hs b/compiler/typecheck/TcTyClsDecls.hs index ef393a8..e138727 100644 --- a/compiler/typecheck/TcTyClsDecls.hs +++ b/compiler/typecheck/TcTyClsDecls.hs @@ -320,15 +320,14 @@ kcTyClGroup (TyClGroup { group_tyclds = decls }) kc_res_kind = tyConResKind tc ; kvs <- kindGeneralize (mkForAllTys kc_binders kc_res_kind) ; (kc_binders', kc_res_kind') <- zonkTcKindToKind kc_binders kc_res_kind - ; let kc_binders'' = anonymiseTyBinders kc_binders' kc_res_kind' -- Make sure kc_kind' has the final, zonked kind variables ; traceTc "Generalise kind" $ vcat [ ppr name, ppr kc_binders, ppr kc_res_kind - , ppr kvs, ppr kc_binders'', ppr kc_res_kind' ] + , ppr kvs, ppr kc_binders', ppr kc_res_kind' ] ; return (mkTcTyCon name - (map (mkNamedBinder Invisible) kvs ++ kc_binders'') + (map (mkNamedBinder Invisible) kvs ++ kc_binders') kc_res_kind' (mightBeUnsaturatedTyCon tc)) } diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs index 3791169..d4363f8 100644 --- a/compiler/typecheck/TcType.hs +++ b/compiler/typecheck/TcType.hs @@ -87,7 +87,6 @@ module TcType ( orphNamesOfTypes, orphNamesOfCoCon, getDFunTyKey, evVarPred_maybe, evVarPred, - anonymiseTyBinders, --------------------------------- -- Predicate types @@ -226,7 +225,6 @@ import Control.Monad (liftM, ap) import Control.Applicative (Applicative(..), (<$>) ) #endif import Data.Functor.Identity -import Data.List ( mapAccumR ) {- ************************************************************************ @@ -2347,28 +2345,3 @@ sizeType = go sizeTypes :: [Type] -> TypeSize sizeTypes tys = sum (map sizeType tys) - -{- -************************************************************************ -* * - Binders -* * -************************************************************************ --} - --- | Given a list of binders and a type they bind in, turn any --- superfluous Named binders into Anon ones. -anonymiseTyBinders :: [TyBinder] -> Type -> [TyBinder] -anonymiseTyBinders binders res_ty = binders' - where - (_, binders') = mapAccumR go (tyCoVarsOfTypeAcc res_ty) binders - - go :: FV -> TyBinder -> (FV, TyBinder) - go fv (Named tv Visible) - | not (tv `elemVarSet` runFVSet fv) - = ( (tv `FV.delFV` fv) `unionFV` tyCoVarsOfTypeAcc kind - , Anon kind ) - where - kind = tyVarKind tv - - go fv binder = (tyCoVarsBndrAcc binder fv, binder) From git at git.haskell.org Wed Mar 23 16:37:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:19 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11512 by getting visibility right for methods (4c64da0) Message-ID: <20160323163719.D1FB73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/4c64da079d6009f8da7877c86c12ac5212c15d3e/ghc >--------------------------------------------------------------- commit 4c64da079d6009f8da7877c86c12ac5212c15d3e Author: Richard Eisenberg Date: Wed Mar 16 23:37:30 2016 -0400 Fix #11512 by getting visibility right for methods Test case: typecheck/should_compile/T11512 (cherry picked from commit f4f315a37470ce86e3eadeb328d0d3a9242f3097) >--------------------------------------------------------------- 4c64da079d6009f8da7877c86c12ac5212c15d3e compiler/basicTypes/MkId.hs | 19 ++++++++++++++----- compiler/typecheck/TcExpr.hs | 5 ++++- .../tests/dependent/should_compile/RaeJobTalk.hs | 4 ++-- testsuite/tests/typecheck/should_compile/T11512.hs | 11 +++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/compiler/basicTypes/MkId.hs b/compiler/basicTypes/MkId.hs index 92d6b5e..5bab875 100644 --- a/compiler/basicTypes/MkId.hs +++ b/compiler/basicTypes/MkId.hs @@ -262,9 +262,6 @@ Then the top-level type for op is forall b. Ord b => a -> b -> b -This is unlike ordinary record selectors, which have all the for-alls -at the outside. When dealing with classes it's very convenient to -recover the original type signature from the class op selector. -} mkDictSelId :: Name -- Name of one of the *value* selectors @@ -278,11 +275,23 @@ mkDictSelId name clas new_tycon = isNewTyCon tycon [data_con] = tyConDataCons tycon tyvars = dataConUnivTyVars data_con + tc_binders = tyConBinders tycon arg_tys = dataConRepArgTys data_con -- Includes the dictionary superclasses val_index = assoc "MkId.mkDictSelId" (sel_names `zip` [0..]) name - sel_ty = mkSpecForAllTys tyvars (mkFunTy (mkClassPred clas (mkTyVarTys tyvars)) - (getNth arg_tys val_index)) + sel_ty = mkForAllTys (zipWith mk_binder tc_binders tyvars) $ + mkFunTy (mkClassPred clas (mkTyVarTys tyvars)) $ + getNth arg_tys val_index + + -- copy the visibility from the tycon binders. Consider: + -- class C a where foo :: Proxy a + -- In the type of foo, `a` must be Specified but `k` must be Invisible + mk_binder tc_binder tyvar + | Invisible <- binderVisibility tc_binder + = mkNamedBinder Invisible tyvar + | otherwise + = mkNamedBinder Specified tyvar -- don't just copy from tc_binder, because + -- tc_binders can be Visible base_info = noCafIdInfo `setArityInfo` 1 diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs index 23d0de9..4d6a109 100644 --- a/compiler/typecheck/TcExpr.hs +++ b/compiler/typecheck/TcExpr.hs @@ -1175,7 +1175,10 @@ tcArgs fun orig_fun_ty fun_orig orig_args herald ; case tcSplitForAllTy_maybe upsilon_ty of Just (binder, inner_ty) | Just tv <- binderVar_maybe binder -> - ASSERT( binderVisibility binder == Specified ) + ASSERT2( binderVisibility binder == Specified + , (vcat [ ppr fun_ty, ppr upsilon_ty, ppr binder + , ppr inner_ty, pprTvBndr tv + , ppr (binderVisibility binder) ]) ) do { let kind = tyVarKind tv ; ty_arg <- tcHsTypeApp hs_ty_arg kind ; let insted_ty = substTyWithUnchecked [tv] [ty_arg] inner_ty diff --git a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs index 705c0ef..c03503d 100644 --- a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs +++ b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs @@ -217,7 +217,7 @@ instance TyConAble RuntimeRep where tyCon = RuntimeRep -- Can't just define Typeable the way we want, because the instances -- overlap. So we have to mock up instance chains via closed type families. -class Typeable' (a :: k) (b :: Bool) where +class Typeable' a (b :: Bool) where typeRep' :: TypeRep a type family CheckPrim a where @@ -236,7 +236,7 @@ instance (Typeable a, Typeable b) => Typeable' (a b) 'False where typeRep' = TyApp typeRep typeRep typeRep :: forall a. Typeable a => TypeRep a -typeRep = typeRep' @_ @_ @(CheckPrim a) -- RAE: #11512 says we need the extra @_. +typeRep = typeRep' @_ @(CheckPrim a) ----------------------------- -- Useful instances diff --git a/testsuite/tests/typecheck/should_compile/T11512.hs b/testsuite/tests/typecheck/should_compile/T11512.hs new file mode 100644 index 0000000..49100e0 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11512.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds, TypeApplications, ScopedTypeVariables #-} + +module Bug where + +import Data.Proxy + +class C a where + foo :: Proxy a + +bar :: forall a. C a => Proxy a +bar = foo @a diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 98f6ef0..f1403da 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -507,3 +507,4 @@ test('T11246', normal, compile, ['']) test('T11608', normal, compile, ['']) test('T11401', normal, compile, ['']) test('T11699', normal, compile, ['']) +test('T11512', normal, compile, ['']) From git at git.haskell.org Wed Mar 23 16:37:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:23 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Clean up some pretty-printing in errors. (496c210) Message-ID: <20160323163723.81CD63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/496c210b48d9779414fbf23354cad43534f41d72/ghc >--------------------------------------------------------------- commit 496c210b48d9779414fbf23354cad43534f41d72 Author: Richard Eisenberg Date: Tue Mar 15 16:56:51 2016 -0400 Clean up some pretty-printing in errors. It turns out that there were some pretty egregious mistakes in the code that suggested -fprint-explicit-kinds, which are fixed. This commit also reorders a bunch of error messages, which I think is an improvement. This also adds the test case for #11471, which is what triggered the cleanup in TcErrors. Now that #11473 is done, there is nothing more outstanding for #11471. test case: dependent/should_fail/T11471 (cherry picked from commit 5d98b8bf249fab9bb0be6c5d4e8ddd4578994abb) >--------------------------------------------------------------- 496c210b48d9779414fbf23354cad43534f41d72 compiler/typecheck/TcErrors.hs | 15 +++++++++++---- compiler/typecheck/TcType.hs | 14 ++++++++++---- testsuite/tests/dependent/should_fail/T11471.hs | 15 +++++++++++++++ testsuite/tests/dependent/should_fail/T11471.stderr | 18 ++++++++++++++++++ testsuite/tests/dependent/should_fail/all.T | 1 + .../tests/indexed-types/should_fail/NoMatchErr.stderr | 4 ++-- .../tests/indexed-types/should_fail/T1897b.stderr | 4 ++-- testsuite/tests/indexed-types/should_fail/T1900.stderr | 4 ++-- testsuite/tests/indexed-types/should_fail/T2544.stderr | 8 ++++---- testsuite/tests/indexed-types/should_fail/T2693.stderr | 2 +- testsuite/tests/indexed-types/should_fail/T4179.stderr | 2 +- testsuite/tests/indexed-types/should_fail/T7729.stderr | 2 +- .../tests/indexed-types/should_fail/T7729a.stderr | 2 +- testsuite/tests/indexed-types/should_fail/T9036.stderr | 4 ++-- testsuite/tests/indexed-types/should_fail/T9171.stderr | 1 + testsuite/tests/polykinds/T9144.stderr | 1 + testsuite/tests/typecheck/should_fail/T8030.stderr | 4 ++-- testsuite/tests/typecheck/should_fail/T8034.stderr | 4 ++-- testsuite/tests/typecheck/should_fail/T8142.stderr | 4 ++-- 19 files changed, 79 insertions(+), 30 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 496c210b48d9779414fbf23354cad43534f41d72 From git at git.haskell.org Wed Mar 23 16:37:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:26 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11716. (6a670e2) Message-ID: <20160323163726.CFADB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6a670e2c64ba43f9ce65b52f39ea0c0971328c9e/ghc >--------------------------------------------------------------- commit 6a670e2c64ba43f9ce65b52f39ea0c0971328c9e Author: Richard Eisenberg Date: Wed Mar 16 15:20:32 2016 -0400 Fix #11716. There were several smallish bugs here: - We had too small an InScopeSet when rejigging GADT return types. - When adding the extra_tvs with a datatype kind signature, we were sometimes changing Uniques of an explicitly bound kind var. - Using coercionKind in the flattener got the wrong visibility for a binder. Now we just zonk to get what we need. Test case: dependent/should_compile/RaeJobTalk (cherry picked from commit 3fe87aa00ac05f1abea22ea58d51ecc1e3073d19) >--------------------------------------------------------------- 6a670e2c64ba43f9ce65b52f39ea0c0971328c9e compiler/typecheck/TcCanonical.hs | 4 +- compiler/typecheck/TcFlatten.hs | 4 +- compiler/typecheck/TcHsType.hs | 12 +- compiler/typecheck/TcPat.hs | 9 +- compiler/typecheck/TcTyClsDecls.hs | 7 +- compiler/typecheck/TcType.hs | 1 + .../tests/dependent/should_compile/RaeJobTalk.hs | 697 +++++++++++++++++++++ testsuite/tests/dependent/should_compile/all.T | 6 +- 8 files changed, 727 insertions(+), 13 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 6a670e2c64ba43f9ce65b52f39ea0c0971328c9e From git at git.haskell.org Wed Mar 23 16:37:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:29 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: typechecker: fix trac issue #11708 (fefbd6c) Message-ID: <20160323163729.9984E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/fefbd6cc0d381ad81a80a8a5ed24f0dc1b011c95/ghc >--------------------------------------------------------------- commit fefbd6cc0d381ad81a80a8a5ed24f0dc1b011c95 Author: Csongor Kiss Date: Wed Mar 16 15:26:59 2016 -0400 typechecker: fix trac issue #11708 Summary: Fixes T11708 Reviewers: austin, bgamari, goldfire, simonpj Reviewed By: goldfire, simonpj Subscribers: simonpj, goldfire, thomie Differential Revision: https://phabricator.haskell.org/D2006 GHC Trac Issues: #11708 (cherry picked from commit c5ed41cbcaa40068763c8bd01badcada38cdbd03) >--------------------------------------------------------------- fefbd6cc0d381ad81a80a8a5ed24f0dc1b011c95 compiler/typecheck/TcHsType.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index 58c0ca1..552c0d0 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -933,10 +933,17 @@ tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon -> TcM (TcType, TcKind) handle_tyfams tc tc_tc | mightBeUnsaturatedTyCon tc_tc - = return (ty, tc_kind) + = do { traceTc "tcTyVar2a" (ppr tc_tc $$ ppr tc_kind) + ; return (ty, tc_kind) } | otherwise - = instantiateTyN 0 ty tc_kind + = do { (tc_ty, kind) <- instantiateTyN 0 ty tc_kind + -- tc and tc_ty must not be traced here, because that would + -- force the evaluation of a potentially knot-tied variable (tc), + -- and the typechecker would hang, as per #11708 + ; traceTc "tcTyVar2b" (vcat [ ppr tc_tc <+> dcolon <+> ppr tc_kind + , ppr kind ]) + ; return (tc_ty, kind) } where ty = mkNakedTyConApp tc [] tc_kind = tyConKind tc_tc From git at git.haskell.org Wed Mar 23 16:37:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:32 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11473. (6e99d03) Message-ID: <20160323163733.001943A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6e99d03bf44658c3c65a495fce2f413bf784a145/ghc >--------------------------------------------------------------- commit 6e99d03bf44658c3c65a495fce2f413bf784a145 Author: Richard Eisenberg Date: Tue Mar 15 14:27:22 2016 -0400 Fix #11473. I've added a check in the zonker for representation polymorphism. I don't like having this be in the zonker, but I don't know where else to put it. It can't go in TcValidity, because a clever enough user could convince the solver to do bogus representation polymorphism even though there's nothing obviously wrong in what they wrote. Note that TcValidity doesn't run over *expressions*, which is where this problem arises. In any case, the check is simple and it works. test case: dependent/should_fail/T11473 (cherry picked from commit aade111248dce0834ed83dc4f18c234967b32024) >--------------------------------------------------------------- 6e99d03bf44658c3c65a495fce2f413bf784a145 compiler/typecheck/TcHsSyn.hs | 64 +++++++++++++++++++--- .../{typecheck => dependent}/should_fail/T11473.hs | 13 ++++- .../tests/dependent/should_fail/T11473.stderr | 7 +++ testsuite/tests/dependent/should_fail/all.T | 1 + 4 files changed, 75 insertions(+), 10 deletions(-) diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs index d84e527..9094533 100644 --- a/compiler/typecheck/TcHsSyn.hs +++ b/compiler/typecheck/TcHsSyn.hs @@ -276,6 +276,7 @@ zonkIdOccs env ids = map (zonkIdOcc env) ids zonkIdBndr :: ZonkEnv -> TcId -> TcM Id zonkIdBndr env id = do ty' <- zonkTcTypeToType env (idType id) + ensureNotRepresentationPolymorphic id ty' return (setIdType id ty') zonkIdBndrs :: ZonkEnv -> [TcId] -> TcM [Id] @@ -456,19 +457,34 @@ zonk_bind env (AbsBinds { abs_tvs = tyvars, abs_ev_vars = evs , abe_mono = zonkIdOcc env mono_id , abe_prags = new_prags }) -zonk_bind env (AbsBindsSig { abs_tvs = tyvars - , abs_ev_vars = evs - , abs_sig_export = poly - , abs_sig_prags = prags - , abs_sig_ev_bind = ev_bind - , abs_sig_bind = bind }) +zonk_bind env outer_bind@(AbsBindsSig { abs_tvs = tyvars + , abs_ev_vars = evs + , abs_sig_export = poly + , abs_sig_prags = prags + , abs_sig_ev_bind = ev_bind + , abs_sig_bind = lbind }) + | L bind_loc bind@(FunBind { fun_id = L loc local + , fun_matches = ms + , fun_co_fn = co_fn }) <- lbind = ASSERT( all isImmutableTyVar tyvars ) do { (env0, new_tyvars) <- zonkTyBndrsX env tyvars ; (env1, new_evs) <- zonkEvBndrsX env0 evs ; (env2, new_ev_bind) <- zonkTcEvBinds env1 ev_bind - ; new_val_bind <- zonk_lbind env2 bind + -- Inline zonk_bind (FunBind ...) because we wish to skip + -- the check for representation-polymorphic binders. The + -- local binder in the FunBind in an AbsBindsSig is never actually + -- bound in Core -- indeed, that's the whole point of AbsBindsSig. + -- just calling zonk_bind causes #11405. + ; new_local <- updateVarTypeM (zonkTcTypeToType env2) local + ; (env3, new_co_fn) <- zonkCoFn env2 co_fn + ; new_ms <- zonkMatchGroup env3 zonkLExpr ms + -- If there is a representation polymorphism problem, it will + -- be caught here: ; new_poly_id <- zonkIdBndr env2 poly ; new_prags <- zonkSpecPrags env2 prags + ; let new_val_bind = L bind_loc (bind { fun_id = L loc new_local + , fun_matches = new_ms + , fun_co_fn = new_co_fn }) ; return (AbsBindsSig { abs_tvs = new_tyvars , abs_ev_vars = new_evs , abs_sig_export = new_poly_id @@ -476,6 +492,9 @@ zonk_bind env (AbsBindsSig { abs_tvs = tyvars , abs_sig_ev_bind = new_ev_bind , abs_sig_bind = new_val_bind }) } + | otherwise + = pprPanic "zonk_bind" (ppr outer_bind) + zonk_bind env (PatSynBind bind@(PSB { psb_id = L loc id , psb_args = details , psb_def = lpat @@ -1624,3 +1643,34 @@ zonkTypeZapping tv | otherwise = anyTypeOfKind (tyVarKind tv) ; writeMetaTyVar tv ty ; return ty } + +--------------------------------------- +-- | According to the rules around representation polymorphism +-- (see https://ghc.haskell.org/trac/ghc/wiki/NoSubKinds), no binder +-- can have a representation-polymorphic type. This check ensures +-- that we respect this rule. It is a bit regrettable that this error +-- occurs in zonking, after which we should have reported all errors. +-- But it's hard to see where else to do it, because this can be discovered +-- only after all solving is done. And, perhaps most importantly, this +-- isn't really a compositional property of a type system, so it's +-- not a terrible surprise that the check has to go in an awkward spot. +ensureNotRepresentationPolymorphic + :: TcId -- the id we're checking (for errors only) + -> Type -- its zonked type + -> TcM () +ensureNotRepresentationPolymorphic id ty + = whenNoErrs $ -- sometimes we end up zonking bogus definitions of type + -- forall a. a. See, for example, test ghci/scripts/T9140 + unless (isEmptyVarSet (tyCoVarsOfType ki)) $ + addErrAt (nameSrcSpan $ idName id) $ + vcat [ text "The following variable has an unknown runtime representation:" + , text " Var name:" <+> ppr id + , text " Var type:" <+> ppr tidy_ty + , text " Type's kind:" <+> ppr tidy_ki + , text "Perhaps add a type or kind signature to fix the representation." + ] + where + ki = typeKind ty + + (tidy_env, tidy_ty) = tidyOpenType emptyTidyEnv ty + tidy_ki = tidyType tidy_env ki diff --git a/testsuite/tests/typecheck/should_fail/T11473.hs b/testsuite/tests/dependent/should_fail/T11473.hs similarity index 67% copy from testsuite/tests/typecheck/should_fail/T11473.hs copy to testsuite/tests/dependent/should_fail/T11473.hs index cb9f791..12d95ca 100644 --- a/testsuite/tests/typecheck/should_fail/T11473.hs +++ b/testsuite/tests/dependent/should_fail/T11473.hs @@ -1,6 +1,7 @@ {-# LANGUAGE PolyKinds, TypeFamilies, MagicHash, DataKinds, TypeInType, RankNTypes #-} module T11473 where + import GHC.Exts import GHC.Types @@ -14,7 +15,13 @@ class BoxIt (a :: TYPE lev) where instance BoxIt Char# where boxed x = C# x instance BoxIt Char where boxed = id --- This should be an error: there is no way we can produce code for both Lifted --- and Unlifted levities -hello :: forall (lev :: Levity). forall (a :: TYPE lev). BoxIt a => a -> Boxed a +hello :: forall (r :: RuntimeRep). forall (a :: TYPE r). BoxIt a => a -> Boxed a hello x = boxed x +{-# NOINLINE hello #-} + +main :: IO () +main = do + print $ boxed 'c'# + print $ boxed 'c' + print $ hello 'c' + print $ hello 'c'# diff --git a/testsuite/tests/dependent/should_fail/T11473.stderr b/testsuite/tests/dependent/should_fail/T11473.stderr new file mode 100644 index 0000000..7a7cc32 --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T11473.stderr @@ -0,0 +1,7 @@ + +T11473.hs:19:7: error: + The following variable has an unknown runtime representation: + Var name: x + Var type: a + Type's kind: TYPE r + Perhaps add a type or kind signature to fix the representation. diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index fc22a2a..b830121 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -13,3 +13,4 @@ test('T11334', normal, compile_fail, ['']) test('InferDependency', normal, compile_fail, ['']) test('KindLevelsB', normal, compile_fail, ['']) test('T11471', normal, compile_fail, ['']) +test('T11473', normal, compile_fail, ['']) From git at git.haskell.org Wed Mar 23 16:37:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:36 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11357. (b1f26af) Message-ID: <20160323163736.2FD903A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/b1f26af9f894eb4c7f237c6c34b23f97d0203f24/ghc >--------------------------------------------------------------- commit b1f26af9f894eb4c7f237c6c34b23f97d0203f24 Author: Richard Eisenberg Date: Tue Mar 15 13:49:15 2016 -0400 Fix #11357. We were looking at a data instance tycon for visibility info, which is the wrong place to look. Look at the data family tycon instead. Also improved the pretty-printing near there to suppress kind arguments when appropriate. (cherry picked from commit 1eefedf7371778d1721d9af9247c2eff12ae7417) >--------------------------------------------------------------- b1f26af9f894eb4c7f237c6c34b23f97d0203f24 compiler/typecheck/TcDeriv.hs | 4 ++-- compiler/typecheck/TcGenGenerics.hs | 29 ++++++++++++++++------- testsuite/tests/deriving/should_compile/T11357.hs | 10 ++++++++ testsuite/tests/deriving/should_compile/all.T | 1 + 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs index 800d2a5..eb6e13c 100644 --- a/compiler/typecheck/TcDeriv.hs +++ b/compiler/typecheck/TcDeriv.hs @@ -1240,10 +1240,10 @@ no_cons_why rep_tc = quotes (pprSourceTyCon rep_tc) <+> text "must have at least one data constructor" cond_RepresentableOk :: Condition -cond_RepresentableOk (_, tc, tc_args) = canDoGenerics tc tc_args +cond_RepresentableOk (dflags, tc, tc_args) = canDoGenerics dflags tc tc_args cond_Representable1Ok :: Condition -cond_Representable1Ok (_, tc, tc_args) = canDoGenerics1 tc tc_args +cond_Representable1Ok (dflags, tc, tc_args) = canDoGenerics1 dflags tc tc_args cond_enumOrProduct :: Class -> Condition cond_enumOrProduct cls = cond_isEnumeration `orCond` diff --git a/compiler/typecheck/TcGenGenerics.hs b/compiler/typecheck/TcGenGenerics.hs index 08b3c9a..0477767 100644 --- a/compiler/typecheck/TcGenGenerics.hs +++ b/compiler/typecheck/TcGenGenerics.hs @@ -18,6 +18,7 @@ import Type import TcType import TcGenDeriv import DataCon +import DynFlags ( DynFlags, GeneralFlag(Opt_PrintExplicitKinds), gopt ) import TyCon import FamInstEnv ( FamInst, FamFlavor(..), mkSingleCoAxiom ) import FamInst @@ -128,7 +129,7 @@ following constraints are satisfied. -} -canDoGenerics :: TyCon -> [Type] -> Validity +canDoGenerics :: DynFlags -> TyCon -> [Type] -> Validity -- canDoGenerics rep_tc tc_args determines if Generic/Rep can be derived for a -- type expression (rep_tc tc_arg0 tc_arg1 ... tc_argn). -- @@ -136,7 +137,7 @@ canDoGenerics :: TyCon -> [Type] -> Validity -- care of because canDoGenerics is applied to rep tycons. -- -- It returns Nothing if deriving is possible. It returns (Just reason) if not. -canDoGenerics tc tc_args +canDoGenerics dflags tc tc_args = mergeErrors ( -- Check (c) from Note [Requirements for deriving Generic and Rep]. (if (not (null (tyConStupidTheta tc))) @@ -146,7 +147,12 @@ canDoGenerics tc tc_args -- -- Data family indices can be instantiated; the `tc_args` here are -- the representation tycon args - (if (all isTyVarTy (filterOutInvisibleTypes tc tc_args)) + -- + -- NB: Use user_tc here. In the case of a data *instance*, the + -- user_tc is the family tc, which has the right visibility settings. + -- (For a normal datatype, user_tc == tc.) Getting this wrong + -- led to #11357. + (if (all isTyVarTy (filterOutInvisibleTypes user_tc tc_args)) then IsValid else NotValid (tc_name <+> text "must not be instantiated;" <+> text "try deriving `" <> tc_name <+> tc_tys <> @@ -156,9 +162,14 @@ canDoGenerics tc tc_args where -- The tc can be a representation tycon. When we want to display it to the -- user (in an error message) we should print its parent - (tc_name, tc_tys) = case tyConFamInst_maybe tc of - Just (ptc, tys) -> (ppr ptc, hsep (map ppr (tys ++ drop (length tys) tc_args))) - _ -> (ppr tc, hsep (map ppr (tyConTyVars tc))) + (user_tc, tc_name, tc_tys) = case tyConFamInst_maybe tc of + Just (ptc, tys) -> (ptc, ppr ptc, hsep (map ppr (filter_kinds $ tys ++ drop (length tys) tc_args))) + _ -> (tc, ppr tc, hsep (map ppr (filter_kinds $ mkTyVarTys $ tyConTyVars tc))) + + filter_kinds | gopt Opt_PrintExplicitKinds dflags + = id + | otherwise + = filterOutInvisibleTypes user_tc -- Check (d) from Note [Requirements for deriving Generic and Rep]. -- @@ -228,9 +239,9 @@ explicitly, even though foldDataConArgs is also doing this internally. -- are taken care of by the call to canDoGenerics. -- -- It returns Nothing if deriving is possible. It returns (Just reason) if not. -canDoGenerics1 :: TyCon -> [Type] -> Validity -canDoGenerics1 rep_tc tc_args = - canDoGenerics rep_tc tc_args `andValid` additionalChecks +canDoGenerics1 :: DynFlags -> TyCon -> [Type] -> Validity +canDoGenerics1 dflags rep_tc tc_args = + canDoGenerics dflags rep_tc tc_args `andValid` additionalChecks where additionalChecks -- check (f) from Note [Requirements for deriving Generic and Rep] diff --git a/testsuite/tests/deriving/should_compile/T11357.hs b/testsuite/tests/deriving/should_compile/T11357.hs new file mode 100644 index 0000000..f3dc715 --- /dev/null +++ b/testsuite/tests/deriving/should_compile/T11357.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeFamilies #-} +module T11357 where + +import GHC.Generics (Generic1) + +data family ProxyFam (a :: k) +data instance ProxyFam (a :: k) = ProxyCon deriving Generic1 diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T index ad235d6..e62c50c 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -64,3 +64,4 @@ test('T9968', normal, compile, ['']) test('T11174', normal, compile, ['']) test('T11416', normal, compile, ['']) test('T11396', normal, compile, ['']) +test('T11357', normal, compile, ['']) From git at git.haskell.org Wed Mar 23 16:37:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:38 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Revert "Add test for #11473" (a31bc44) Message-ID: <20160323163738.D889A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/a31bc446f0a72b3f81074979d9c19c6437ca84e7/ghc >--------------------------------------------------------------- commit a31bc446f0a72b3f81074979d9c19c6437ca84e7 Author: Ben Gamari Date: Fri Mar 18 16:49:13 2016 +0100 Revert "Add test for #11473" This reverts commit 89bdac7635e6ed08927d760aa885d3e7ef3edb81 as this test is duplicated with dependent/should_fail/T11473, added by aade111248dce0834ed83dc4f18c234967b3202. (cherry picked from commit c0f628dc6f604028acc665e5b37019750a30c852) >--------------------------------------------------------------- a31bc446f0a72b3f81074979d9c19c6437ca84e7 testsuite/tests/typecheck/should_fail/T11473.hs | 20 -------------------- testsuite/tests/typecheck/should_fail/all.T | 1 - 2 files changed, 21 deletions(-) diff --git a/testsuite/tests/typecheck/should_fail/T11473.hs b/testsuite/tests/typecheck/should_fail/T11473.hs deleted file mode 100644 index cb9f791..0000000 --- a/testsuite/tests/typecheck/should_fail/T11473.hs +++ /dev/null @@ -1,20 +0,0 @@ -{-# LANGUAGE PolyKinds, TypeFamilies, MagicHash, DataKinds, TypeInType, RankNTypes #-} - -module T11473 where -import GHC.Exts -import GHC.Types - -type family Boxed (a :: k) :: * -type instance Boxed Char# = Char -type instance Boxed Char = Char - -class BoxIt (a :: TYPE lev) where - boxed :: a -> Boxed a - -instance BoxIt Char# where boxed x = C# x -instance BoxIt Char where boxed = id - --- This should be an error: there is no way we can produce code for both Lifted --- and Unlifted levities -hello :: forall (lev :: Levity). forall (a :: TYPE lev). BoxIt a => a -> Boxed a -hello x = boxed x diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 1dcc2fb..b58b175 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -405,6 +405,5 @@ test('T11347', normal, compile_fail, ['']) test('T11356', normal, compile_fail, ['']) test('T11355', normal, compile_fail, ['']) test('T11464', normal, compile_fail, ['']) -test('T11473', expect_broken(11473), compile_fail, ['']) test('T11563', normal, compile_fail, ['']) test('T11313', normal, compile_fail, ['']) From git at git.haskell.org Wed Mar 23 16:37:41 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:41 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11711. (e3cf12a) Message-ID: <20160323163741.D22CF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/e3cf12ab4b6ea2ddbc8b23fd2856b575c30948f9/ghc >--------------------------------------------------------------- commit e3cf12ab4b6ea2ddbc8b23fd2856b575c30948f9 Author: Richard Eisenberg Date: Wed Mar 16 14:30:00 2016 -0400 Fix #11711. There were two bugs here, both simple: we need to filter out covars before calling isMetaTyVar in the solver, and TcPat had a tcSubType the wrong way round. test case: dependent/should_compile/T11711 (cherry picked from commit b5565f1a79fd24fc45a6f1a58821a317852d4b89) >--------------------------------------------------------------- e3cf12ab4b6ea2ddbc8b23fd2856b575c30948f9 compiler/hsSyn/HsPat.hs | 8 +-- compiler/typecheck/TcPat.hs | 2 +- compiler/typecheck/TcSimplify.hs | 4 +- testsuite/tests/dependent/should_compile/T11711.hs | 58 ++++++++++++++++++++++ testsuite/tests/dependent/should_compile/all.T | 1 + testsuite/tests/patsyn/should_fail/mono.stderr | 20 ++++---- 6 files changed, 78 insertions(+), 15 deletions(-) diff --git a/compiler/hsSyn/HsPat.hs b/compiler/hsSyn/HsPat.hs index 82aeb69..09a38a9 100644 --- a/compiler/hsSyn/HsPat.hs +++ b/compiler/hsSyn/HsPat.hs @@ -421,9 +421,11 @@ pprPat (TuplePat pats bx _) = tupleParens (boxityTupleSort bx) (pprWithCommas pprPat (ConPatIn con details) = pprUserCon (unLoc con) details pprPat (ConPatOut { pat_con = con, pat_tvs = tvs, pat_dicts = dicts, pat_binds = binds, pat_args = details }) - = getPprStyle $ \ sty -> -- Tiresome; in TcBinds.tcRhs we print out a - if debugStyle sty then -- typechecked Pat in an error message, - -- and we want to make sure it prints nicely + = sdocWithDynFlags $ \dflags -> + -- Tiresome; in TcBinds.tcRhs we print out a + -- typechecked Pat in an error message, + -- and we want to make sure it prints nicely + if gopt Opt_PrintTypecheckerElaboration dflags then ppr con <> braces (sep [ hsep (map pprPatBndr (tvs ++ dicts)) , ppr binds]) diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs index adad0ed..e56bb20 100644 --- a/compiler/typecheck/TcPat.hs +++ b/compiler/typecheck/TcPat.hs @@ -821,7 +821,7 @@ tcPatSynPat penv (L con_span _) pat_syn pat_ty arg_pats thing_inside prov_theta' = substTheta tenv prov_theta req_theta' = substTheta tenv req_theta - ; wrap <- tcSubTypeO (pe_orig penv) GenSigCtxt ty' pat_ty + ; wrap <- tcSubTypeET (pe_orig penv) pat_ty ty' ; traceTc "tcPatSynPat" (ppr pat_syn $$ ppr pat_ty $$ ppr ty' $$ diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs index 6ac8ab3..cc5031a 100644 --- a/compiler/typecheck/TcSimplify.hs +++ b/compiler/typecheck/TcSimplify.hs @@ -133,10 +133,12 @@ simpl_top wanteds = return wc | otherwise = do { free_tvs <- TcS.zonkTyCoVarsAndFV (tyCoVarsOfWC wc) - ; let meta_tvs = varSetElems (filterVarSet isMetaTyVar free_tvs) + ; let meta_tvs = varSetElems $ + filterVarSet (isTyVar <&&> isMetaTyVar) free_tvs -- zonkTyCoVarsAndFV: the wc_first_go is not yet zonked -- filter isMetaTyVar: we might have runtime-skolems in GHCi, -- and we definitely don't want to try to assign to those! + -- the isTyVar needs to weed out coercion variables ; defaulted <- mapM defaultTyVarTcS meta_tvs -- Has unification side effects ; if or defaulted diff --git a/testsuite/tests/dependent/should_compile/T11711.hs b/testsuite/tests/dependent/should_compile/T11711.hs new file mode 100644 index 0000000..633ae35 --- /dev/null +++ b/testsuite/tests/dependent/should_compile/T11711.hs @@ -0,0 +1,58 @@ +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE TypeInType #-} +{-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE FlexibleInstances #-} + +module T11711 where + +import Data.Kind (Type) + +data (:~~:) (a :: k1) (b :: k2) where + HRefl :: a :~~: a + +data TypeRep (a :: k) where + TrTyCon :: String -> TypeRep k -> TypeRep (a :: k) + TrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). + TypeRep (a :: k1 -> k2) + -> TypeRep (b :: k1) + -> TypeRep (a b) + +class Typeable (a :: k) where + typeRep :: TypeRep a + +data TypeRepX where + TypeRepX :: forall k (a :: k). TypeRep a -> TypeRepX + +eqTypeRep :: TypeRep a -> TypeRep b -> Maybe (a :~~: b) +eqTypeRep = undefined + +typeRepKind :: forall k (a :: k). TypeRep a -> TypeRep k +typeRepKind = undefined + +instance Typeable Type where + typeRep = TrTyCon "Type" typeRep + +funResultTy :: TypeRepX -> TypeRepX -> Maybe TypeRepX +funResultTy (TypeRepX f) (TypeRepX x) + | Just HRefl <- (typeRep :: TypeRep Type) `eqTypeRep` typeRepKind f + , TRFun arg res <- f + , Just HRefl <- arg `eqTypeRep` x + = Just (TypeRepX res) + | otherwise + = Nothing + +trArrow :: TypeRep (->) +trArrow = undefined + +pattern TRFun :: forall fun. () + => forall arg res. (fun ~ (arg -> res)) + => TypeRep arg + -> TypeRep res + -> TypeRep fun +pattern TRFun arg res <- TrApp (TrApp (eqTypeRep trArrow -> Just HRefl) arg) res diff --git a/testsuite/tests/dependent/should_compile/all.T b/testsuite/tests/dependent/should_compile/all.T index 9da91ce..2f9d311 100644 --- a/testsuite/tests/dependent/should_compile/all.T +++ b/testsuite/tests/dependent/should_compile/all.T @@ -17,4 +17,5 @@ test('dynamic-paper', expect_fail_for(['optasm', 'optllvm']), compile, ['']) test('T11311', normal, compile, ['']) test('T11405', normal, compile, ['']) test('T11241', normal, compile, ['']) +test('T11711', normal, compile, ['']) test('RaeJobTalk', normal, compile, ['']) diff --git a/testsuite/tests/patsyn/should_fail/mono.stderr b/testsuite/tests/patsyn/should_fail/mono.stderr index 2bed60e..20714e7 100644 --- a/testsuite/tests/patsyn/should_fail/mono.stderr +++ b/testsuite/tests/patsyn/should_fail/mono.stderr @@ -1,12 +1,12 @@ -mono.hs:7:4: - Couldn't match type ?Int? with ?Bool? - Expected type: [Bool] - Actual type: [Int] - In the pattern: Single x - In an equation for ?f?: f (Single x) = x +mono.hs:7:4: error: + ? Couldn't match type ?Bool? with ?Int? + Expected type: [Int] + Actual type: [Bool] + ? In the pattern: Single x + In an equation for ?f?: f (Single x) = x -mono.hs:7:16: - Couldn't match expected type ?Bool? with actual type ?Int? - In the expression: x - In an equation for ?f?: f (Single x) = x +mono.hs:7:16: error: + ? Couldn't match expected type ?Bool? with actual type ?Int? + ? In the expression: x + In an equation for ?f?: f (Single x) = x From git at git.haskell.org Wed Mar 23 16:37:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:44 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: DsExpr: Don't build/foldr huge lists (19ab525) Message-ID: <20160323163744.81D4C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/19ab5256a1a0a4e7d4ed0d36973fb43eeeda447f/ghc >--------------------------------------------------------------- commit 19ab5256a1a0a4e7d4ed0d36973fb43eeeda447f Author: Ben Gamari Date: Sun Mar 20 17:49:58 2016 +0100 DsExpr: Don't build/foldr huge lists Desugaring long lists with build trades large static data for large code, which is likely a poor trade-off. See #11707. Test Plan: Validate, nofib Reviewers: simonpj, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2007 GHC Trac Issues: #11707 (cherry picked from commit b735e99d79448bd7f416b35d8b0473d8eb5271f1) >--------------------------------------------------------------- 19ab5256a1a0a4e7d4ed0d36973fb43eeeda447f compiler/deSugar/DsExpr.hs | 29 ++++++++++++++++++++++++++++- testsuite/tests/perf/compiler/all.T | 3 ++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/compiler/deSugar/DsExpr.hs b/compiler/deSugar/DsExpr.hs index e720d6e..6116578 100644 --- a/compiler/deSugar/DsExpr.hs +++ b/compiler/deSugar/DsExpr.hs @@ -788,6 +788,12 @@ allocation in some nofib programs. Specifically Of course, if rules aren't turned on then there is pretty much no point doing this fancy stuff, and it may even be harmful. +Moreover, for large lists (with a dynamic prefix longer than maxBuildLength) we +choose not to perform this optimization as it will trade large static data for +large code, which is generally a poor trade-off. See #11707 and the +documentation for maxBuildLength. + + =======> Note by SLPJ Dec 08. I'm unconvinced that we should *ever* generate a build for an explicit @@ -803,10 +809,29 @@ We do not want to generate a build invocation on the LHS of this RULE! We fix this by disabling rules in rule LHSs, and testing that flag here; see Note [Desugaring RULE left hand sides] in Desugar -To test this I've added a (static) flag -fsimple-list-literals, which +To test this I've added a flag -fsimple-list-literals, which makes all list literals be generated via the simple route. -} +{- | The longest list length which we will desugar using @build at . + +This is essentially a magic number and its setting is unfortunate rather +arbitrary. The idea here, as mentioned in Note [Desugaring explicit lists], +is to avoid deforesting large static data into large(r) code. Ideally we'd +want a smaller threshold with larger consumers and vice-versa, but we have no +way of knowing what will be consuming our list in the desugaring impossible to +set generally correctly. + +The effect of reducing this number will be that 'build' fusion is applied +less often. From a runtime performance perspective, applying 'build' more +liberally on "moderately" sized lists should rarely hurt and will often it can +only expose further optimization opportunities; if no fusion is possible it will +eventually get rule-rewritten back to a list). We do, however, pay in compile +time. +-} +maxBuildLength :: Int +maxBuildLength = 32 + dsExplicitList :: Type -> Maybe (SyntaxExpr Id) -> [LHsExpr Id] -> DsM CoreExpr -- See Note [Desugaring explicit lists] @@ -815,6 +840,8 @@ dsExplicitList elt_ty Nothing xs ; xs' <- mapM dsLExpr xs ; let (dynamic_prefix, static_suffix) = spanTail is_static xs' ; if gopt Opt_SimpleListLiterals dflags -- -fsimple-list-literals + || length dynamic_prefix > maxBuildLength + -- Don't generate builds if the list is very long. || not (gopt Opt_EnableRewriteRules dflags) -- Rewrite rules off -- Don't generate a build if there are no rules to eliminate it! -- See Note [Desugaring RULE left hand sides] in Desugar diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index 5c7a6c7..77fde50 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -719,12 +719,13 @@ test('T9872d', test('T9961', [ only_ways(['normal']), compiler_stats_num_field('bytes allocated', - [(wordsize(64), 745044392, 5), + [(wordsize(64), 519436672, 5), # 2015-01-12 807117816 Initally created # 2015-spring 772510192 Got better # 2015-05-22 663978160 Fix for #10370 improves it more # 2015-10-28 708680480 x86_64/Linux Emit Typeable at definition site # 2015-12-17 745044392 x86_64/Darwin Creep upwards + # 2016-03-20 519436672 x64_64/Linux Don't use build desugaring for large lists (D2007) (wordsize(32), 375647160, 5) ]), ], From git at git.haskell.org Wed Mar 23 16:37:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:47 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: PrelRules: Fix constant folding for WordRemOp (630d079) Message-ID: <20160323163747.462963A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/630d07995a814f665531eaecf07dffe1298c6fd5/ghc >--------------------------------------------------------------- commit 630d07995a814f665531eaecf07dffe1298c6fd5 Author: Ben Gamari Date: Wed Mar 16 10:00:12 2016 +0100 PrelRules: Fix constant folding for WordRemOp Test Plan: Validate with testcase in D2002 Reviewers: austin, simonpj Reviewed By: simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D2004 GHC Trac Issues: #11702 (cherry picked from commit 3ddfcc95cd41dac19c8f4d55e8fc03128b77b738 and commit c095ec5d970ec3a3a00a1920c01f67df52d07060) >--------------------------------------------------------------- 630d07995a814f665531eaecf07dffe1298c6fd5 compiler/prelude/PrelRules.hs | 7 ++++++- testsuite/tests/numeric/should_run/all.T | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs index 440b3c1..4df3418 100644 --- a/compiler/prelude/PrelRules.hs +++ b/compiler/prelude/PrelRules.hs @@ -138,7 +138,12 @@ primOpRules nm WordMulOp = mkPrimOpRule nm 2 [ binaryLit (wordOp2 (*)) primOpRules nm WordQuotOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 quot) , rightIdentityDynFlags onew ] primOpRules nm WordRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 rem) - , rightIdentityDynFlags onew ] + , leftZero zerow + , do l <- getLiteral 1 + dflags <- getDynFlags + guard (l == onew dflags) + retLit zerow + , equalArgs >> retLit zerow ] primOpRules nm AndOp = mkPrimOpRule nm 2 [ binaryLit (wordOp2 (.&.)) , idempotent , zeroElem zerow ] diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T index 050de91..d6b7197 100644 --- a/testsuite/tests/numeric/should_run/all.T +++ b/testsuite/tests/numeric/should_run/all.T @@ -65,4 +65,4 @@ test('CarryOverflow', omit_ways(['ghci']), compile_and_run, ['']) test('T9810', normal, compile_and_run, ['']) test('T10011', normal, compile_and_run, ['']) test('T10962', omit_ways(['ghci']), compile_and_run, ['']) -test('T11702', expect_broken(11702), compile_and_run, ['']) +test('T11702', extra_ways(['optasm']), compile_and_run, ['']) From git at git.haskell.org Wed Mar 23 16:37:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:49 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Remove the check_lifted check in TcValidity (eaa07ba) Message-ID: <20160323163749.EABB03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/eaa07bae849afd22c7c29253e61a188f80c5e495/ghc >--------------------------------------------------------------- commit eaa07bae849afd22c7c29253e61a188f80c5e495 Author: Simon Peyton Jones Date: Wed Jan 20 16:02:22 2016 +0000 Remove the check_lifted check in TcValidity This patch fixes Trac #11465. The check_unlifted check really isn't necessary, as discussed in Trac #11120 comment:19. Removing it made just one test-suite change, in indexed-types/should_fail/T9357, by allowing type family F (a :: k1) :: k2 type instance F Int# = Int to be accepted. And indeed that seems entirely reasonable. (cherry picked from commit 07afe448c3a83d7239054baf9d54681ca19766b0) >--------------------------------------------------------------- eaa07bae849afd22c7c29253e61a188f80c5e495 compiler/typecheck/TcValidity.hs | 17 ++++++++++++++--- testsuite/tests/indexed-types/should_fail/T9357.hs | 5 +++++ testsuite/tests/indexed-types/should_fail/T9357.stderr | 8 ++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs index a51ceb3..859b0ec 100644 --- a/compiler/typecheck/TcValidity.hs +++ b/compiler/typecheck/TcValidity.hs @@ -448,9 +448,21 @@ forAllAllowed _ = False ---------------------------------------- -- | Fail with error message if the type is unlifted check_lifted :: TidyEnv -> Type -> TcM () +check_lifted _ _ = return () + +{- ------ Legacy comment --------- +The check_unlifted function seems entirely redundant. The +kind system should check for uses of unlifted types. So I've +removed the check. See Trac #11120 comment:19. + check_lifted env ty = checkTcM (not (isUnliftedType ty)) (unliftedArgErr env ty) +unliftedArgErr :: TidyEnv -> Type -> (TidyEnv, SDoc) +unliftedArgErr env ty = (env, sep [text "Illegal unlifted type:", ppr_tidy env ty]) +------ End of legacy comment --------- -} + + check_type :: TidyEnv -> UserTypeCtxt -> Rank -> Type -> TcM () -- The args say what the *type context* requires, independent -- of *flag* settings. You test the flag settings at usage sites. @@ -619,9 +631,8 @@ forAllEscapeErr env ty tau_kind 2 (vcat [ text " type:" <+> ppr_tidy env ty , text "of kind:" <+> ppr_tidy env tau_kind ]) ) -unliftedArgErr, ubxArgTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc) -unliftedArgErr env ty = (env, sep [text "Illegal unlifted type:", ppr_tidy env ty]) -ubxArgTyErr env ty = (env, sep [text "Illegal unboxed tuple type as function argument:", ppr_tidy env ty]) +ubxArgTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc) +ubxArgTyErr env ty = (env, sep [text "Illegal unboxed tuple type as function argument:", ppr_tidy env ty]) kindErr :: TidyEnv -> Kind -> (TidyEnv, SDoc) kindErr env kind = (env, sep [text "Expecting an ordinary type, but found a type of kind", ppr_tidy env kind]) diff --git a/testsuite/tests/indexed-types/should_fail/T9357.hs b/testsuite/tests/indexed-types/should_fail/T9357.hs index 29c57f4..9365663 100644 --- a/testsuite/tests/indexed-types/should_fail/T9357.hs +++ b/testsuite/tests/indexed-types/should_fail/T9357.hs @@ -4,5 +4,10 @@ module T9357 where import GHC.Exts type family F (a :: k1) :: k2 + type instance F Int# = Int + -- This one is actually OK (F is poly-kinded; + -- c.f. Trac #11120 comment:19 + type instance F (forall a. a->a) = Int + -- But this one is not (impredicative) diff --git a/testsuite/tests/indexed-types/should_fail/T9357.stderr b/testsuite/tests/indexed-types/should_fail/T9357.stderr index f625ed2..32331e5 100644 --- a/testsuite/tests/indexed-types/should_fail/T9357.stderr +++ b/testsuite/tests/indexed-types/should_fail/T9357.stderr @@ -1,8 +1,4 @@ -T9357.hs:7:15: error: - ? Illegal unlifted type: Int# - ? In the type instance declaration for ?F? - -T9357.hs:8:15: error: - ? Illegal polymorphic type: forall a. a -> a +T9357.hs:12:15: error: + ? Illegal polymorphic or qualified type: forall a1. a1 -> a1 ? In the type instance declaration for ?F? From git at git.haskell.org Wed Mar 23 16:37:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:52 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: T9357: Fix expected output (9a2c0d8) Message-ID: <20160323163752.A7DBA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/9a2c0d8a13b668dee8eadbc8ad87bb036ffca4f9/ghc >--------------------------------------------------------------- commit 9a2c0d8a13b668dee8eadbc8ad87bb036ffca4f9 Author: Ben Gamari Date: Mon Mar 21 13:04:40 2016 +0100 T9357: Fix expected output >--------------------------------------------------------------- 9a2c0d8a13b668dee8eadbc8ad87bb036ffca4f9 testsuite/tests/indexed-types/should_fail/T9357.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tests/indexed-types/should_fail/T9357.stderr b/testsuite/tests/indexed-types/should_fail/T9357.stderr index 32331e5..daa735d 100644 --- a/testsuite/tests/indexed-types/should_fail/T9357.stderr +++ b/testsuite/tests/indexed-types/should_fail/T9357.stderr @@ -1,4 +1,4 @@ T9357.hs:12:15: error: - ? Illegal polymorphic or qualified type: forall a1. a1 -> a1 + ? Illegal polymorphic type: forall a. a -> a ? In the type instance declaration for ?F? From git at git.haskell.org Wed Mar 23 16:37:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:55 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Mark GHC.Real.even and odd as INLINEABLE (9246525) Message-ID: <20160323163755.578EA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/92465259ae875a2fece5ab37a45e358ba1819d83/ghc >--------------------------------------------------------------- commit 92465259ae875a2fece5ab37a45e358ba1819d83 Author: Ben Gamari Date: Mon Mar 14 13:27:23 2016 +0100 Mark GHC.Real.even and odd as INLINEABLE Previously they were merely specialised at Int and Integer. It seems to me that these are cheap enough to be worth inlining. See #11701 for motivation. Test Plan: Validate Reviewers: austin, hvr, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1997 GHC Trac Issues: #11701 (cherry picked from commit 2841ccab595ce38fb86b789574f057c3abe3d630) >--------------------------------------------------------------- 92465259ae875a2fece5ab37a45e358ba1819d83 libraries/base/GHC/Real.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/base/GHC/Real.hs b/libraries/base/GHC/Real.hs index 186be27..3a97f1f 100644 --- a/libraries/base/GHC/Real.hs +++ b/libraries/base/GHC/Real.hs @@ -463,10 +463,8 @@ showSigned showPos p x even, odd :: (Integral a) => a -> Bool even n = n `rem` 2 == 0 odd = not . even -{-# SPECIALISE even :: Int -> Bool #-} -{-# SPECIALISE odd :: Int -> Bool #-} -{-# SPECIALISE even :: Integer -> Bool #-} -{-# SPECIALISE odd :: Integer -> Bool #-} +{-# INLINEABLE even #-} +{-# INLINEABLE odd #-} ------------------------------------------------------- -- | raise a number to a non-negative integral power From git at git.haskell.org Wed Mar 23 16:37:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:37:58 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: DriverPipeline: Fix 'unused arguments' warnings from Clang (6babb89) Message-ID: <20160323163758.0F7773A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6babb89baac43058bcb4a86edbba0560f01f4670/ghc >--------------------------------------------------------------- commit 6babb89baac43058bcb4a86edbba0560f01f4670 Author: Erik de Castro Lopo Date: Sun Mar 13 15:28:11 2016 +1100 DriverPipeline: Fix 'unused arguments' warnings from Clang When using Clang as the C compiler, over 100 tests were failing due to Clang reporting that some command line arguments were not being used. These warnings only occur when Clang is compiling assembler files which happens in two places, one of which already conditionally adding `-Qunused-arguments` to the command line when the compiler was Clang. This fixes the other. Test Plan: validate with clang as the C compiler Reviewers: bgamari, hvr, austin, rwbarton Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1998 GHC Trac Issues: #11684 (cherry picked from commit 46f9a476e17714e27d893b491cc0dcf68c745249) >--------------------------------------------------------------- 6babb89baac43058bcb4a86edbba0560f01f4670 compiler/main/DriverPipeline.hs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 455f613..c9174f4 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1576,16 +1576,32 @@ mkExtraObj dflags extn xs = do cFile <- newTempName dflags extn oFile <- newTempName dflags "o" writeFile cFile xs - let rtsDetails = getPackageDetails dflags rtsUnitId - pic_c_flags = picCCOpts dflags + ccInfo <- liftIO $ getCompilerInfo dflags SysTools.runCc dflags - ([Option "-c", - FileOption "" cFile, - Option "-o", - FileOption "" oFile] - ++ map (FileOption "-I") (includeDirs rtsDetails) - ++ map Option pic_c_flags) + ([Option "-c", + FileOption "" cFile, + Option "-o", + FileOption "" oFile] + ++ if extn /= "s" + then cOpts + else asmOpts ccInfo) return oFile + where + -- Pass a different set of options to the C compiler depending one whether + -- we're compiling C or assembler. When compiling C, we pass the usual + -- set of include directories and PIC flags. + cOpts = map Option (picCCOpts dflags) + ++ map (FileOption "-I") + (includeDirs $ getPackageDetails dflags rtsUnitId) + + -- When compiling assembler code, we drop the usual C options, and if the + -- compiler is Clang, we add an extra argument to tell Clang to ignore + -- unused command line options. See trac #11684. + asmOpts ccInfo = + if any (ccInfo ==) [Clang, AppleClang, AppleClang51] + then [Option "-Qunused-arguments"] + else [] + -- When linking a binary, we need to create a C main() function that -- starts everything off. This used to be compiled statically as part From git at git.haskell.org Wed Mar 23 16:38:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:05 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add test for #9646 (8dff211) Message-ID: <20160323163805.17A3B3A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/8dff21104b6a56e458943f25f3013fb2b0be0a0f/ghc >--------------------------------------------------------------- commit 8dff21104b6a56e458943f25f3013fb2b0be0a0f Author: Erik de Castro Lopo Date: Wed Mar 16 20:19:28 2016 +1100 Add test for #9646 Test Plan: Test that it passes git HEAD and fails with GHC 7.8. Reviewers: bgamari, hvr, austin, goldfire, thomie Differential Revision: https://phabricator.haskell.org/D2009 GHC Trac Issues: #9646 (cherry picked from commit 220a0b934c71a8844a14dd8cd67fa0e23f807182) >--------------------------------------------------------------- 8dff21104b6a56e458943f25f3013fb2b0be0a0f testsuite/tests/simplCore/T9646/Main.hs | 47 +++++++++ testsuite/tests/simplCore/T9646/Makefile | 9 ++ testsuite/tests/simplCore/T9646/Natural.hs | 84 ++++++++++++++++ testsuite/tests/simplCore/T9646/StrictPrim.hs | 70 +++++++++++++ testsuite/tests/simplCore/T9646/T9646.stdout | 5 + testsuite/tests/simplCore/T9646/Type.hs | 79 +++++++++++++++ .../tests/simplCore/T9646/cbits/primitive-memops.c | 25 +++++ .../tests/simplCore/T9646/cbits/primitive-memops.h | 10 ++ testsuite/tests/simplCore/T9646/readme.txt | 112 +++++++++++++++++++++ .../tests/{programs/lex => simplCore/T9646}/test.T | 2 +- 10 files changed, 442 insertions(+), 1 deletion(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 8dff21104b6a56e458943f25f3013fb2b0be0a0f From git at git.haskell.org Wed Mar 23 16:38:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:00 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix duplicate T11334 test (4bc13dd) Message-ID: <20160323163800.B56173A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/4bc13dd05de130c3ee424b3280f3886b4b7e8984/ghc >--------------------------------------------------------------- commit 4bc13dd05de130c3ee424b3280f3886b4b7e8984 Author: Ben Gamari Date: Sun Mar 20 16:02:32 2016 +0100 Fix duplicate T11334 test (cherry picked from commit cb7ecdad9b56be1e2cbdf249664521d6261ccd71) >--------------------------------------------------------------- 4bc13dd05de130c3ee424b3280f3886b4b7e8984 libraries/base/tests/{T11334.hs => T11334a.hs} | 0 libraries/base/tests/{T11334.stdout => T11334a.stdout} | 0 libraries/base/tests/all.T | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/base/tests/T11334.hs b/libraries/base/tests/T11334a.hs similarity index 100% rename from libraries/base/tests/T11334.hs rename to libraries/base/tests/T11334a.hs diff --git a/libraries/base/tests/T11334.stdout b/libraries/base/tests/T11334a.stdout similarity index 100% rename from libraries/base/tests/T11334.stdout rename to libraries/base/tests/T11334a.stdout diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T index 574aba6..4ca3cda 100644 --- a/libraries/base/tests/all.T +++ b/libraries/base/tests/all.T @@ -211,5 +211,5 @@ test('T9848', compile_and_run, ['-O']) test('T10149', normal, compile_and_run, ['']) -test('T11334', normal, compile_and_run, ['']) +test('T11334a', normal, compile_and_run, ['']) test('T11555', normal, compile_and_run, ['']) \ No newline at end of file From git at git.haskell.org Wed Mar 23 16:38:07 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:07 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix T9646 (573716f) Message-ID: <20160323163807.C1C913A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/573716f57f5be7bb7c82a0c6065f1f0ea1e09dfd/ghc >--------------------------------------------------------------- commit 573716f57f5be7bb7c82a0c6065f1f0ea1e09dfd Author: Ben Gamari Date: Sun Mar 20 16:47:31 2016 +0100 Fix T9646 For #9646. (cherry picked from commit 08d254bc8452cdb12f852805f20d346ad4181ed8) >--------------------------------------------------------------- 573716f57f5be7bb7c82a0c6065f1f0ea1e09dfd testsuite/tests/simplCore/T9646/test.T | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tests/simplCore/T9646/test.T b/testsuite/tests/simplCore/T9646/test.T index 2baae52..1456217 100644 --- a/testsuite/tests/simplCore/T9646/test.T +++ b/testsuite/tests/simplCore/T9646/test.T @@ -2,5 +2,5 @@ test('T9646', [when(fast(), skip), extra_clean(['Main.hi', 'Main.o'])], multimod_compile_and_run, - ['Main', '']) + ['Main -ddump-simpl -ddump-to-file', '']) From git at git.haskell.org Wed Mar 23 16:38:11 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:11 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: prof: Fix heap census for large ARR_WORDS (#11627) (8c61f12) Message-ID: <20160323163811.2D8213A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/8c61f1256192ca02ee59206c377a5be4cf98c099/ghc >--------------------------------------------------------------- commit 8c61f1256192ca02ee59206c377a5be4cf98c099 Author: Jason Eisenberg Date: Sun Mar 20 17:49:24 2016 +0100 prof: Fix heap census for large ARR_WORDS (#11627) The heap census now handles large ARR_WORDS objects which have been shrunk by shrinkMutableByteArray# or resizeMutableByteArray#. Test Plan: ./validate && make test WAY=profasm Reviewers: hvr, bgamari, austin, thomie Reviewed By: thomie Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2005 GHC Trac Issues: #11627 (cherry picked from commit ba95f22eb98cc2ee2d8d76e56df80769c379413d) >--------------------------------------------------------------- 8c61f1256192ca02ee59206c377a5be4cf98c099 rts/ProfHeap.c | 14 ++++++++ .../should_run/T11627a.hs} | 1 + .../should_run/T11627a.stdout} | 0 testsuite/tests/profiling/should_run/T11627b.hs | 42 ++++++++++++++++++++++ testsuite/tests/profiling/should_run/all.T | 8 +++++ 5 files changed, 65 insertions(+) diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c index 8eea62f..1b82b36 100644 --- a/rts/ProfHeap.c +++ b/rts/ProfHeap.c @@ -937,6 +937,20 @@ heapCensusChain( Census *census, bdescr *bd ) } p = bd->start; + + // When we shrink a large ARR_WORDS, we do not adjust the free pointer + // of the associated block descriptor, thus introducing slop at the end + // of the object. This slop remains after GC, violating the assumption + // of the loop below that all slop has been eliminated (#11627). + // Consequently, we handle large ARR_WORDS objects as a special case. + if (bd->flags & BF_LARGE + && get_itbl((StgClosure *)p)->type == ARR_WORDS) { + size = arr_words_sizeW((StgArrBytes *)p); + prim = rtsTrue; + heapProfObject(census, (StgClosure *)p, size, prim); + continue; + } + while (p < bd->free) { info = get_itbl((StgClosure *)p); prim = rtsFalse; diff --git a/testsuite/tests/perf/space_leaks/space_leak_001.hs b/testsuite/tests/profiling/should_run/T11627a.hs similarity index 65% copy from testsuite/tests/perf/space_leaks/space_leak_001.hs copy to testsuite/tests/profiling/should_run/T11627a.hs index cabde0a..3e1ce3c 100644 --- a/testsuite/tests/perf/space_leaks/space_leak_001.hs +++ b/testsuite/tests/profiling/should_run/T11627a.hs @@ -1,3 +1,4 @@ +-- Original test case for #11627 (space_leak_001.hs) import Data.List diff --git a/testsuite/tests/perf/space_leaks/space_leak_001.stdout b/testsuite/tests/profiling/should_run/T11627a.stdout similarity index 100% copy from testsuite/tests/perf/space_leaks/space_leak_001.stdout copy to testsuite/tests/profiling/should_run/T11627a.stdout diff --git a/testsuite/tests/profiling/should_run/T11627b.hs b/testsuite/tests/profiling/should_run/T11627b.hs new file mode 100644 index 0000000..5e5545a --- /dev/null +++ b/testsuite/tests/profiling/should_run/T11627b.hs @@ -0,0 +1,42 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + + +-- A reduced test case for #11627 + + +import GHC.Prim +import GHC.Types (Int(..),IO(..)) +import System.Mem + + +main :: IO () +main = do + -- Allocate a large object (size >= 8/10 of one block = 8/10 * 4096 B) + let nBytes = 123 * 4096 + b <- newBlob nBytes + + -- Shrink it by at least one word + let delta = 100 + shrinkBlob b $ nBytes - delta + + -- Perform a heap census (assumes we are running with -i0, so a census is + -- run after every GC) + performGC + + -- Hold on to b so it is not GCed before the census + shrinkBlob b $ nBytes - delta + +------------------------------------------------------------------------------ + +data Blob = Blob# !(MutableByteArray# RealWorld) + +newBlob :: Int -> IO Blob +newBlob (I# n#) = + IO $ \s -> case newByteArray# n# s of + (# s', mba# #) -> (# s', Blob# mba# #) + +shrinkBlob :: Blob -> Int -> IO () +shrinkBlob (Blob# mba#) (I# n#) = + IO $ \s -> case shrinkMutableByteArray# mba# n# s of + s' -> (# s', () #) diff --git a/testsuite/tests/profiling/should_run/all.T b/testsuite/tests/profiling/should_run/all.T index 707ade3..ec4949b 100644 --- a/testsuite/tests/profiling/should_run/all.T +++ b/testsuite/tests/profiling/should_run/all.T @@ -95,3 +95,11 @@ test('callstack002', [], compile_and_run, test('T5363', [], compile_and_run, ['']) test('profinline001', [], compile_and_run, ['']) + +test('T11627a', [extra_ways(extra_prof_ways)], compile_and_run, ['']) + +test('T11627b', [ extra_run_opts('+RTS -i0 -RTS') # census after each GC + , extra_ways(extra_prof_ways) + ] + , compile_and_run + , ['']) From git at git.haskell.org Wed Mar 23 16:38:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:13 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Delete a misleading comment in TyCon (c948a30) Message-ID: <20160323163813.CE9403A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/c948a300225db11edaffda1cdcc2e7653e80f021/ghc >--------------------------------------------------------------- commit c948a300225db11edaffda1cdcc2e7653e80f021 Author: Bartosz Nitka Date: Mon Mar 21 03:30:59 2016 -0700 Delete a misleading comment in TyCon `Ord` for `TyCon` uses `Uniques` and it's not lexicographic. I did some archeology and in rGHC6c381e873e222417d9a67aeec77b9555eca7b7a8 the comment was introduced, where there was something like `Ord3 Tycon` which *was* lexicographic. In rGHC9dd6e1c216993624a2cd74b62ca0f0569c02c26b `Ord3 TyCon` was already not lexicographic and `Ord3` got removed. Test Plan: make someone take a look Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2017 (cherry picked from commit 3ade8bc790c74c676f75001373247835d3b23ff5) >--------------------------------------------------------------- c948a300225db11edaffda1cdcc2e7653e80f021 compiler/types/TyCon.hs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs index 5d01732..69a9360 100644 --- a/compiler/types/TyCon.hs +++ b/compiler/types/TyCon.hs @@ -2027,9 +2027,6 @@ tyConRuntimeRepInfo _ = NoRRI ************************************************************************ @TyCon at s are compared by comparing their @Unique at s. - -The strictness analyser needs @Ord at . It is a lexicographic order with -the property @(a<=b) || (b<=a)@. -} instance Eq TyCon where From git at git.haskell.org Wed Mar 23 16:38:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:16 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix exponential algorithm in pure unifier. (919e5c1) Message-ID: <20160323163816.7D2543A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/919e5c16a449a2cd6ed5c4017477294435a1b1a2/ghc >--------------------------------------------------------------- commit 919e5c16a449a2cd6ed5c4017477294435a1b1a2 Author: Richard Eisenberg Date: Thu Mar 17 15:40:58 2016 -0400 Fix exponential algorithm in pure unifier. (cherry picked from commit af2f7f90dd0aaae0e33d1f8064377d1657f180a6) >--------------------------------------------------------------- 919e5c16a449a2cd6ed5c4017477294435a1b1a2 compiler/types/Unify.hs | 52 ++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/compiler/types/Unify.hs b/compiler/types/Unify.hs index 1cc1513..75b65df 100644 --- a/compiler/types/Unify.hs +++ b/compiler/types/Unify.hs @@ -710,11 +710,11 @@ unify_ty ty1 ty2 _kco -- so if one type is an App the other one jolly well better be too unify_ty (AppTy ty1a ty1b) ty2 _kco | Just (ty2a, ty2b) <- tcRepSplitAppTy_maybe ty2 - = unify_ty_app ty1a ty1b ty2a ty2b + = unify_ty_app ty1a [ty1b] ty2a [ty2b] unify_ty ty1 (AppTy ty2a ty2b) _kco | Just (ty1a, ty1b) <- tcRepSplitAppTy_maybe ty1 - = unify_ty_app ty1a ty1b ty2a ty2b + = unify_ty_app ty1a [ty1b] ty2a [ty2b] unify_ty (LitTy x) (LitTy y) _kco | x == y = return () @@ -757,15 +757,18 @@ unify_ty _ ty2 _ unify_ty _ _ _ = surelyApart -unify_ty_app :: Type -> Type -> Type -> Type -> UM () -unify_ty_app ty1a ty1b ty2a ty2b - = do { -- TODO (RAE): Remove this exponential behavior. - let ki1a = typeKind ty1a - ki2a = typeKind ty2a - ; unify_ty ki1a ki2a (mkNomReflCo liftedTypeKind) - ; let kind_co = mkNomReflCo ki1a - ; unify_ty ty1a ty2a kind_co - ; unify_ty ty1b ty2b (mkNthCo 0 kind_co) } +unify_ty_app :: Type -> [Type] -> Type -> [Type] -> UM () +unify_ty_app ty1 ty1args ty2 ty2args + | Just (ty1', ty1a) <- repSplitAppTy_maybe ty1 + , Just (ty2', ty2a) <- repSplitAppTy_maybe ty2 + = unify_ty_app ty1' (ty1a : ty1args) ty2' (ty2a : ty2args) + + | otherwise + = do { let ki1 = typeKind ty1 + ki2 = typeKind ty2 + ; unify_ty ki1 ki2 (mkNomReflCo liftedTypeKind) + ; unify_ty ty1 ty2 (mkNomReflCo ki1) + ; unify_tys ty1args ty2args } unify_tys :: [Type] -> [Type] -> UM () unify_tys orig_xs orig_ys @@ -1145,11 +1148,11 @@ ty_co_match menv subst ty (SubCo co) lkco rkco ty_co_match menv subst (AppTy ty1a ty1b) co _lkco _rkco | Just (co2, arg2) <- splitAppCo_maybe co -- c.f. Unify.match on AppTy - = ty_co_match_app menv subst ty1a ty1b co2 arg2 + = ty_co_match_app menv subst ty1a [ty1b] co2 [arg2] ty_co_match menv subst ty1 (AppCo co2 arg2) _lkco _rkco | Just (ty1a, ty1b) <- repSplitAppTy_maybe ty1 -- yes, the one from Type, not TcType; this is for coercion optimization - = ty_co_match_app menv subst ty1a ty1b co2 arg2 + = ty_co_match_app menv subst ty1a [ty1b] co2 [arg2] ty_co_match menv subst (TyConApp tc1 tys) (TyConAppCo _ tc2 cos) _lkco _rkco = ty_co_match_tc menv subst tc1 tys tc2 cos @@ -1187,17 +1190,22 @@ ty_co_match_tc menv subst tc1 tys1 tc2 cos2 = traverse (fmap mkNomReflCo . coercionKind) cos2 ty_co_match_app :: MatchEnv -> LiftCoEnv - -> Type -> Type -> Coercion -> Coercion + -> Type -> [Type] -> Coercion -> [Coercion] -> Maybe LiftCoEnv -ty_co_match_app menv subst ty1a ty1b co2a co2b - = do { -- TODO (RAE): Remove this exponential behavior. - subst1 <- ty_co_match menv subst ki1a ki2a ki_ki_co ki_ki_co - ; let Pair lkco rkco = mkNomReflCo <$> coercionKind ki2a - ; subst2 <- ty_co_match menv subst1 ty1a co2a lkco rkco - ; ty_co_match menv subst2 ty1b co2b (mkNthCo 0 lkco) (mkNthCo 0 rkco) } +ty_co_match_app menv subst ty1 ty1args co2 co2args + | Just (ty1', ty1a) <- repSplitAppTy_maybe ty1 + , Just (co2', co2a) <- splitAppCo_maybe co2 + = ty_co_match_app menv subst ty1' (ty1a : ty1args) co2' (co2a : co2args) + + | otherwise + = do { subst1 <- ty_co_match menv subst ki1 ki2 ki_ki_co ki_ki_co + ; let Pair lkco rkco = mkNomReflCo <$> coercionKind ki2 + ; subst2 <- ty_co_match menv subst1 ty1 co2 lkco rkco + ; let Pair lkcos rkcos = traverse (fmap mkNomReflCo . coercionKind) co2args + ; ty_co_match_args menv subst2 ty1args co2args lkcos rkcos } where - ki1a = typeKind ty1a - ki2a = promoteCoercion co2a + ki1 = typeKind ty1 + ki2 = promoteCoercion co2 ki_ki_co = mkNomReflCo liftedTypeKind ty_co_match_args :: MatchEnv -> LiftCoEnv -> [Type] From git at git.haskell.org Wed Mar 23 16:38:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:19 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: TypeApplications does not imply AllowAmbiguousTypes (fcf36a9) Message-ID: <20160323163819.35A293A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/fcf36a9c64f2cc80cd8d6a062a6993eb00f44a11/ghc >--------------------------------------------------------------- commit fcf36a9c64f2cc80cd8d6a062a6993eb00f44a11 Author: Richard Eisenberg Date: Thu Mar 17 17:49:28 2016 -0400 TypeApplications does not imply AllowAmbiguousTypes (cherry picked from commit 01b29ebd25aceef8c35ea1cc3eabb6dafbb55daa) >--------------------------------------------------------------- fcf36a9c64f2cc80cd8d6a062a6993eb00f44a11 compiler/main/DynFlags.hs | 1 - docs/users_guide/glasgow_exts.rst | 1 - testsuite/tests/dependent/should_compile/RaeJobTalk.hs | 2 +- testsuite/tests/patsyn/should_compile/T11351.hs | 3 ++- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index fa1141e..361c51e 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -3701,7 +3701,6 @@ impliedXFlags , (LangExt.TemplateHaskell, turnOn, LangExt.TemplateHaskellQuotes) , (LangExt.Strict, turnOn, LangExt.StrictData) - , (LangExt.TypeApplications, turnOn, LangExt.AllowAmbiguousTypes) ] -- Note [Documenting optimisation flags] diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index be8de73..b002109 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -8623,7 +8623,6 @@ Visible type application .. ghc-flag:: -XTypeApplications - :implies: :ghc-flag:`-XAllowAmbiguousTypes` :since: 8.0.1 Allow the use of type application syntax. diff --git a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs index c03503d..2f0edf8 100644 --- a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs +++ b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs @@ -1,7 +1,7 @@ {- Copyright (c) 2016 Richard Eisenberg -} -{-# LANGUAGE TypeOperators, TypeFamilies, TypeApplications, +{-# LANGUAGE TypeOperators, TypeFamilies, TypeApplications, AllowAmbiguousTypes, ExplicitForAll, ScopedTypeVariables, GADTs, TypeFamilyDependencies, TypeInType, ConstraintKinds, UndecidableInstances, FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, diff --git a/testsuite/tests/patsyn/should_compile/T11351.hs b/testsuite/tests/patsyn/should_compile/T11351.hs index 26f8d2d..0873a88 100644 --- a/testsuite/tests/patsyn/should_compile/T11351.hs +++ b/testsuite/tests/patsyn/should_compile/T11351.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE PatternSynonyms, TypeApplications, ScopedTypeVariables, ViewPatterns #-} +{-# LANGUAGE PatternSynonyms, TypeApplications, ScopedTypeVariables, ViewPatterns, + AllowAmbiguousTypes #-} module T11351 where From git at git.haskell.org Wed Mar 23 16:38:21 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:21 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add two small optimizations. (#11196) (4183976) Message-ID: <20160323163821.D8E9A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/4183976003ab9da51583d78debec798cd53789cc/ghc >--------------------------------------------------------------- commit 4183976003ab9da51583d78debec798cd53789cc Author: Richard Eisenberg Date: Fri Mar 18 09:40:15 2016 -0400 Add two small optimizations. (#11196) - Optimize zonking * to avoid allocation. - Try to avoid looking at the free variables of a type in the pure unifier. We need look at the variables only in the case of a forall. The performance results updates included in this also include a regression, but the regression is not due to this patch. When validating previous patches, the test case failed, but I was unable to reproduce outside of validation, so I let it go by, thinking the failure was spurious. Upon closer inspection, the perf number was right at the line, and the wibble between a valiation environment and a regular test run was enough to make the difference. (cherry picked from commit 0706a103ae8c9c61e6bbaadd16b32da76aa5a749) >--------------------------------------------------------------- 4183976003ab9da51583d78debec798cd53789cc compiler/types/Type.hs | 2 ++ compiler/types/Unify.hs | 20 ++++++++++++-------- testsuite/tests/perf/compiler/all.T | 17 ++++++++++++----- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index dd142c0..726c77b 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -477,6 +477,8 @@ mapType mapper@(TyCoMapper { tcm_smart = smart, tcm_tyvar = tyvar where go (TyVarTy tv) = tyvar env tv go (AppTy t1 t2) = mkappty <$> go t1 <*> go t2 + go t@(TyConApp _ []) = return t -- avoid allocation in this exceedingly + -- common case (mostly, for *) go (TyConApp tc tys) = mktyconapp tc <$> mapM go tys go (ForAllTy (Anon arg) res) = mkfunty <$> go arg <*> go res go (ForAllTy (Named tv vis) inner) diff --git a/compiler/types/Unify.hs b/compiler/types/Unify.hs index 75b65df..bc53cac 100644 --- a/compiler/types/Unify.hs +++ b/compiler/types/Unify.hs @@ -986,11 +986,15 @@ umRnBndr2 v1 v2 thing = UM $ \env state -> let rn_env' = rnBndr2 (um_rn_env env) v1 v2 in unUM thing (env { um_rn_env = rn_env' }) state -checkRnEnv :: (RnEnv2 -> Var -> Bool) -> VarSet -> UM () -checkRnEnv inRnEnv varset = UM $ \env state -> - if any (inRnEnv (um_rn_env env)) (varSetElems varset) - then MaybeApart (state, ()) - else Unifiable (state, ()) +checkRnEnv :: (RnEnv2 -> VarSet) -> VarSet -> UM () +checkRnEnv get_set varset = UM $ \env state -> + let env_vars = get_set (um_rn_env env) in + if isEmptyVarSet env_vars || varset `disjointVarSet` env_vars + -- NB: That isEmptyVarSet is a critical optimization; it + -- means we don't have to calculate the free vars of + -- the type, often saving quite a bit of allocation. + then Unifiable (state, ()) + else MaybeApart (state, ()) -- | Converts any SurelyApart to a MaybeApart don'tBeSoSure :: UM () -> UM () @@ -1000,13 +1004,13 @@ don'tBeSoSure um = UM $ \env state -> other -> other checkRnEnvR :: Type -> UM () -checkRnEnvR ty = checkRnEnv inRnEnvR (tyCoVarsOfType ty) +checkRnEnvR ty = checkRnEnv rnEnvR (tyCoVarsOfType ty) checkRnEnvL :: Type -> UM () -checkRnEnvL ty = checkRnEnv inRnEnvL (tyCoVarsOfType ty) +checkRnEnvL ty = checkRnEnv rnEnvL (tyCoVarsOfType ty) checkRnEnvRCo :: Coercion -> UM () -checkRnEnvRCo co = checkRnEnv inRnEnvR (tyCoVarsOfCo co) +checkRnEnvRCo co = checkRnEnv rnEnvR (tyCoVarsOfCo co) umRnOccL :: TyVar -> UM TyVar umRnOccL v = UM $ \env state -> diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index 77fde50..ffcc050 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -395,7 +395,7 @@ test('T5631', # expected value: 392904228 (x86/Linux) # 2014-04-04: 346389856 (x86 Windows, 64 bit machine) # 2014-12-01: 390199244 (Windows laptop) - (wordsize(64), 1198327544, 5)]), + (wordsize(64), 1124068664, 5)]), # expected value: 774595008 (amd64/Linux): # expected value: 735486328 (amd64/Linux) 2012/12/12: # expected value: 690742040 (amd64/Linux) Call Arity improvements @@ -404,6 +404,7 @@ test('T5631', # 2015-06-01: 812288344 (amd64/Linux) unknown cause # 2015-12-11: 1128828928 (amd64/Linux) TypeInType (see #11196) # 2015-12-21: 1198327544 (Mac) TypeApplications (will fix with #11196) + # 2015-03-18: 1124068664 (Mac) optimize Unify & zonking only_ways(['normal']) ], compile, @@ -558,7 +559,7 @@ test('T5837', # 2014-12-01: 135914136 (Windows laptop, regression see below) # 2014-12-08 115905208 Constraint solver perf improvements (esp kick-out) - (wordsize(64), 43877520, 10)]) + (wordsize(64), 48507272, 10)]) # sample: 3926235424 (amd64/Linux, 15/2/2012) # 2012-10-02 81879216 # 2012-09-20 87254264 amd64/Linux @@ -575,6 +576,8 @@ test('T5837', # 2015-03-17 53424304 Mac Better depth checking; fails earlier # 2015-06-09 38834096 Better "improvement"; I'm not sure whey it improves things # 2015-12-11 43877520 amd64/Linux, TypeInType (see #11196) + # 2016-03-18 48507272 Mac, accept small regression in exchange + # for other optimisations ], compile_fail,['-freduction-depth=50']) @@ -676,11 +679,12 @@ test('T9872a', test('T9872b', [ only_ways(['normal']), compiler_stats_num_field('bytes allocated', - [(wordsize(64), 5199926080, 5), + [(wordsize(64), 4918990352, 5), # 2014-12-10 6483306280 Initally created # 2014-12-16 6892251912 Flattener parameterized over roles # 2014-12-18 3480212048 Reduce type families even more eagerly # 2015-12-11 5199926080 TypeInType (see #11196) + # 2016-02-08 4918990352 Improved a bit by tyConRolesRepresentational (wordsize(32), 1700000000, 5) ]), ], @@ -689,11 +693,12 @@ test('T9872b', test('T9872c', [ only_ways(['normal']), compiler_stats_num_field('bytes allocated', - [(wordsize(64), 4723613784, 5), + [(wordsize(64), 4454071184, 5), # 2014-12-10 5495850096 Initally created # 2014-12-16 5842024784 Flattener parameterized over roles # 2014-12-18 2963554096 Reduce type families even more eagerly # 2015-12-11 4723613784 TypeInType (see #11196) + # 2016-02-08 4454071184 Improved a bit by tyConRolesRepresentational (wordsize(32), 1500000000, 5) ]), ], @@ -702,11 +707,13 @@ test('T9872c', test('T9872d', [ only_ways(['normal']), compiler_stats_num_field('bytes allocated', - [(wordsize(64), 566134504, 5), + [(wordsize(64), 506691240, 5), # 2014-12-18 796071864 Initally created # 2014-12-18 739189056 Reduce type families even more eagerly # 2015-01-07 687562440 TrieMap leaf compression # 2015-03-17 726679784 tweak to solver; probably flattens more + # 2016-02-08 534693648 Improved a bit by tyConRolesRepresentational + # 2016-03-18 506691240 optimize Unify & zonking (wordsize(32), 59651432, 5) # some date 328810212 # 2015-07-11 350369584 From git at git.haskell.org Wed Mar 23 16:38:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:25 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11635 / #11719. (74f760a) Message-ID: <20160323163825.59F703A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/74f760a3dc614ef1354c70e3619130455fb0bdf9/ghc >--------------------------------------------------------------- commit 74f760a3dc614ef1354c70e3619130455fb0bdf9 Author: Richard Eisenberg Date: Fri Mar 18 11:02:38 2016 -0400 Fix #11635 / #11719. Instead of creating a new meta-tyvar and then unifying it with a known kind in a KindedTyVar in a LHsQTyVars, just use the known kind. Sadly, this still doesn't make #11719 usable, because while you can now define a higher-kinded type family, you can't write any equations for it, which is a larger problem. test cases: dependent/should_compile/T{11635,11719} (cherry picked from commit 1701255c06fed2aa2811f7f29f108d88fc4d6f26) >--------------------------------------------------------------- 74f760a3dc614ef1354c70e3619130455fb0bdf9 compiler/typecheck/TcHsType.hs | 33 +++++++++++----------- testsuite/tests/dependent/should_compile/T11635.hs | 7 +++++ testsuite/tests/dependent/should_compile/T11719.hs | 18 ++++++++++++ testsuite/tests/dependent/should_compile/all.T | 2 ++ 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index 552c0d0..2b226f2 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -83,7 +83,7 @@ import PrelNames hiding ( wildCardName ) import Pair import qualified GHC.LanguageExtensions as LangExt -import Data.Maybe +import Maybes import Data.List ( partition ) import Control.Monad @@ -1291,7 +1291,7 @@ kcHsTyVarBndrs cusk open_fam all_kind_vars kc_hs_tv :: HsTyVarBndr Name -> TcM (TcTyVar, Bool) kc_hs_tv (UserTyVar (L _ name)) - = do { tv_pair@(tv, scoped) <- tcHsTyVarName name + = do { tv_pair@(tv, scoped) <- tcHsTyVarName Nothing name -- Open type/data families default their variables to kind *. ; when (open_fam && not scoped) $ -- (don't default class tyvars) @@ -1301,13 +1301,8 @@ kcHsTyVarBndrs cusk open_fam all_kind_vars ; return tv_pair } kc_hs_tv (KindedTyVar (L _ name) lhs_kind) - = do { tv_pair@(tv, _) <- tcHsTyVarName name - ; kind <- tcLHsKind lhs_kind - -- for a scoped variable: make sure annotation is consistent - -- for an unscoped variable: unify the meta-tyvar kind - -- either way: we can ignore the resulting coercion - ; discardResult $ unifyKind (Just (mkTyVarTy tv)) kind (tyVarKind tv) - ; return tv_pair } + = do { kind <- tcLHsKind lhs_kind + ; tcHsTyVarName (Just kind) name } report_non_cusk_tvs all_tvs = do { all_tvs <- mapM zonkTyCoVarKind all_tvs @@ -1330,7 +1325,7 @@ tcImplicitTKBndrs :: [Name] -> TcM (a, TyVarSet) -- vars are bound somewhere in the scope -- see Note [Scope-check inferred kinds] -> TcM ([TcTyVar], a) -tcImplicitTKBndrs = tcImplicitTKBndrsX tcHsTyVarName +tcImplicitTKBndrs = tcImplicitTKBndrsX (tcHsTyVarName Nothing) -- | Convenient specialization tcImplicitTKBndrsType :: [Name] @@ -1414,16 +1409,22 @@ tcHsTyVarBndr (KindedTyVar (L _ name) kind) = do { kind <- tcLHsKind kind ; return (mkTcTyVar name kind (SkolemTv False)) } --- | Produce a tyvar of the given name (with a meta-tyvar kind). If --- the name is already in scope, return the scoped variable. The +-- | Produce a tyvar of the given name (with the kind provided, or +-- otherwise a meta-var kind). If +-- the name is already in scope, return the scoped variable, checking +-- to make sure the known kind matches any kind provided. The -- second return value says whether the variable is in scope (True) -- or not (False). (Use this for associated types, for example.) -tcHsTyVarName :: Name -> TcM (TcTyVar, Bool) -tcHsTyVarName name +tcHsTyVarName :: Maybe Kind -> Name -> TcM (TcTyVar, Bool) +tcHsTyVarName m_kind name = do { mb_tv <- tcLookupLcl_maybe name ; case mb_tv of - Just (ATyVar _ tv) -> return (tv, True) - _ -> do { kind <- newMetaKindVar + Just (ATyVar _ tv) + -> do { whenIsJust m_kind $ \ kind -> + discardResult $ + unifyKind (Just (mkTyVarTy tv)) kind (tyVarKind tv) + ; return (tv, True) } + _ -> do { kind <- maybe newMetaKindVar return m_kind ; return (mkTcTyVar name kind vanillaSkolemTv, False) }} -- makes a new skolem tv diff --git a/testsuite/tests/dependent/should_compile/T11635.hs b/testsuite/tests/dependent/should_compile/T11635.hs new file mode 100644 index 0000000..1cbdbaf --- /dev/null +++ b/testsuite/tests/dependent/should_compile/T11635.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE TypeInType, KindSignatures, ExplicitForAll #-} + +module T11635 where + +import Data.Kind + +data X (a :: forall k. k -> * ) b = X diff --git a/testsuite/tests/dependent/should_compile/T11719.hs b/testsuite/tests/dependent/should_compile/T11719.hs new file mode 100644 index 0000000..ba4d7c9 --- /dev/null +++ b/testsuite/tests/dependent/should_compile/T11719.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes, TypeFamilies, TypeInType, TypeOperators, + UndecidableInstances #-} + +module T11719 where + +import Data.Kind + +data TyFun :: * -> * -> * +type a ~> b = TyFun a b -> * + +type family (f :: a ~> b) @@ (x :: a) :: b + +data Null a = Nullable a | NotNullable a + +type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where + (f ? g) x = f @@ (g @@ x) + +type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where -- this fails :( diff --git a/testsuite/tests/dependent/should_compile/all.T b/testsuite/tests/dependent/should_compile/all.T index 2f9d311..5985fd9 100644 --- a/testsuite/tests/dependent/should_compile/all.T +++ b/testsuite/tests/dependent/should_compile/all.T @@ -19,3 +19,5 @@ test('T11405', normal, compile, ['']) test('T11241', normal, compile, ['']) test('T11711', normal, compile, ['']) test('RaeJobTalk', normal, compile, ['']) +test('T11635', normal, compile, ['']) +test('T11719', normal, compile, ['']) From git at git.haskell.org Wed Mar 23 16:38:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:29 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Improve pattern synonym error messages (add `PatSynOrigin`) (1d74e4d) Message-ID: <20160323163829.23ADA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1d74e4d7970ccc6e8ef431bbd42a4a29d870f823/ghc >--------------------------------------------------------------- commit 1d74e4d7970ccc6e8ef431bbd42a4a29d870f823 Author: Rik Steenkamp Date: Thu Feb 25 19:27:54 2016 +0100 Improve pattern synonym error messages (add `PatSynOrigin`) Adds a new data constructor `PatSynOrigin Bool Name` to the `CtOrigin` data type. This allows for better error messages when the origin of a wanted constraint is a pattern synonym declaration. Fixes T10873. Reviewers: mpickering, simonpj, austin, thomie, bgamari Reviewed By: simonpj, thomie, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1866 GHC Trac Issues: #10873 >--------------------------------------------------------------- 1d74e4d7970ccc6e8ef431bbd42a4a29d870f823 compiler/typecheck/TcErrors.hs | 37 +++++++++++++++++++----- compiler/typecheck/TcPatSyn.hs | 6 ++-- compiler/typecheck/TcRnTypes.hs | 7 +++++ testsuite/tests/patsyn/should_fail/T10873.hs | 10 +++++++ testsuite/tests/patsyn/should_fail/T10873.stderr | 24 +++++++++++++++ testsuite/tests/patsyn/should_fail/all.T | 1 + 6 files changed, 75 insertions(+), 10 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 1d74e4d7970ccc6e8ef431bbd42a4a29d870f823 From git at git.haskell.org Wed Mar 23 16:38:31 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:31 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Comment a suspicious zonk in TcFlatten. (1938568) Message-ID: <20160323163831.C75793A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/193856869cfb10cbb6b76dff66a58895da289486/ghc >--------------------------------------------------------------- commit 193856869cfb10cbb6b76dff66a58895da289486 Author: Richard Eisenberg Date: Fri Mar 18 22:37:37 2016 -0400 Comment a suspicious zonk in TcFlatten. (cherry picked from commit 947709395015bd6122eedc6da5df356660e76208) >--------------------------------------------------------------- 193856869cfb10cbb6b76dff66a58895da289486 compiler/typecheck/TcFlatten.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs index c306479..e340b5a 100644 --- a/compiler/typecheck/TcFlatten.hs +++ b/compiler/typecheck/TcFlatten.hs @@ -1350,6 +1350,9 @@ flatten_tyvar3 tv , ppr kind_co <+> dcolon <+> ppr (coercionKind kind_co) ]) ; orig_kind <- liftTcS $ zonkTcType kind -- NB: orig_kind is *not* the kind returned from flatten + -- This zonk is necessary because we might later see the tv's kind + -- in canEqTyVarTyVar (where we use getCastedTyVar_maybe). + -- If you remove it, then e.g. dependent/should_fail/T11407 panics ; return (FTRCasted (setTyVarKind tv orig_kind) kind_co) } {- From git at git.haskell.org Wed Mar 23 16:38:34 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:34 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Refactoring around TcPatSyn.tcPatToExpr (9bb204a) Message-ID: <20160323163834.7EDBA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/9bb204a9884a206a930e127aee7bc44c520fa28d/ghc >--------------------------------------------------------------- commit 9bb204a9884a206a930e127aee7bc44c520fa28d Author: Simon Peyton Jones Date: Wed Mar 9 13:14:09 2016 +0000 Refactoring around TcPatSyn.tcPatToExpr Just comments, a bit of refactoring, and a better error-reporting infrastructure (cherry picked from commit 5a494d8ec688e42601262913172f24cee7a36c9b) >--------------------------------------------------------------- 9bb204a9884a206a930e127aee7bc44c520fa28d compiler/typecheck/TcPatSyn.hs | 182 +++++++++++++---------- testsuite/tests/patsyn/should_fail/unidir.stderr | 7 +- 2 files changed, 111 insertions(+), 78 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 9bb204a9884a206a930e127aee7bc44c520fa28d From git at git.haskell.org Wed Mar 23 16:38:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:38 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Track specified/invisible more carefully. (fefaba9) Message-ID: <20160323163838.087793A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/fefaba919f4fcfe4eb71198d91a8718b72d7b6a1/ghc >--------------------------------------------------------------- commit fefaba919f4fcfe4eb71198d91a8718b72d7b6a1 Author: Richard Eisenberg Date: Sat Mar 19 16:55:50 2016 -0400 Track specified/invisible more carefully. In particular, this allows correct tracking of specified/invisible for variables in Haskell98 data constructors and in pattern synonyms. GADT-syntax constructors are harder, and are left until #11721. This was all inspired by Simon's comments to my fix for #11512, which this subsumes. Test case: ghci/scripts/TypeAppData [skip ci] (The test case fails because of an unrelated problem fixed in the next commit.) (cherry picked from commit 35e937973f61a7e5534ecd0b1c67111cd82d4238) >--------------------------------------------------------------- fefaba919f4fcfe4eb71198d91a8718b72d7b6a1 compiler/basicTypes/DataCon.hs | 94 +++++++++++-- compiler/basicTypes/DataCon.hs-boot | 6 +- compiler/basicTypes/MkId.hs | 14 +- compiler/basicTypes/PatSyn.hs | 25 +++- compiler/iface/BuildTyCl.hs | 48 ++++--- compiler/iface/IfaceSyn.hs | 20 +-- compiler/iface/IfaceType.hs | 6 + compiler/iface/MkIface.hs | 19 +-- compiler/iface/TcIface.hs | 43 +++--- compiler/prelude/TysWiredIn.hs | 6 +- compiler/typecheck/TcHsSyn.hs | 2 +- compiler/typecheck/TcHsType.hs | 4 +- compiler/typecheck/TcInstDcls.hs | 6 +- compiler/typecheck/TcPatSyn.hs | 140 +++++++++++-------- compiler/typecheck/TcRnTypes.hs | 14 +- compiler/typecheck/TcTyClsDecls.hs | 151 ++++++++++++++++----- compiler/typecheck/TcType.hs | 4 +- compiler/types/Coercion.hs | 2 +- compiler/types/TyCoRep.hs | 25 +++- compiler/types/Type.hs | 10 +- compiler/vectorise/Vectorise/Generic/PData.hs | 8 +- compiler/vectorise/Vectorise/Type/TyConDecl.hs | 5 +- docs/users_guide/glasgow_exts.rst | 13 ++ testsuite/tests/ghci/scripts/T11524a.stdout | 28 ++-- testsuite/tests/ghci/scripts/TypeAppData.script | 31 +++++ testsuite/tests/ghci/scripts/TypeAppData.stdout | 14 ++ testsuite/tests/ghci/scripts/all.T | 1 + .../tests/rename/should_fail/rnfail055.stderr | 3 +- testsuite/tests/roles/should_compile/Roles1.stderr | 4 +- 29 files changed, 514 insertions(+), 232 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc fefaba919f4fcfe4eb71198d91a8718b72d7b6a1 From git at git.haskell.org Wed Mar 23 16:38:40 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:40 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Zonk before calling splitDepVarsOfType. (f840006) Message-ID: <20160323163840.C92A53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/f840006b3e05c426951605f96ac5791afff10540/ghc >--------------------------------------------------------------- commit f840006b3e05c426951605f96ac5791afff10540 Author: Richard Eisenberg Date: Mon Mar 21 11:08:10 2016 -0400 Zonk before calling splitDepVarsOfType. It was Utterly Wrong before. Note to self: Never, ever take the free vars of an unzonked type. (cherry picked from commit 5c0c751ab2deb4b03b8a2055d4f60d2574cae32f) >--------------------------------------------------------------- f840006b3e05c426951605f96ac5791afff10540 compiler/typecheck/TcHsType.hs | 3 ++- compiler/typecheck/TcMType.hs | 38 ++++++++++++++++++++------ compiler/typecheck/TcPatSyn.hs | 13 ++++++--- compiler/typecheck/TcRules.hs | 6 ++--- compiler/typecheck/TcSimplify.hs | 6 +++-- compiler/typecheck/TcTyClsDecls.hs | 45 +++++++++++++++++-------------- compiler/types/Type.hs | 26 ++++++++++++------ testsuite/tests/ghci/scripts/T7873.stdout | 3 +-- 8 files changed, 92 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc f840006b3e05c426951605f96ac5791afff10540 From git at git.haskell.org Wed Mar 23 16:38:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:43 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Improve panicking output (c60141f) Message-ID: <20160323163843.9EEE63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/c60141f5856af785c1c1d20d95d4f354a29daccf/ghc >--------------------------------------------------------------- commit c60141f5856af785c1c1d20d95d4f354a29daccf Author: Richard Eisenberg Date: Sun Mar 20 23:15:13 2016 -0400 Improve panicking output (cherry picked from commit e19e58ced6fb410c8aa79b2193513258c58a38bd) >--------------------------------------------------------------- c60141f5856af785c1c1d20d95d4f354a29daccf compiler/types/Type.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 5752058..7b5922f 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -861,7 +861,7 @@ piResultTy ty arg empty_subst = mkEmptyTCvSubst $ mkInScopeSet $ tyCoVarsOfTypes [arg,res] | otherwise - = panic "piResultTys" + = pprPanic "piResultTy" (ppr ty $$ ppr arg) -- | (piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn) -- where f :: f_ty @@ -896,7 +896,7 @@ piResultTys ty orig_args@(arg:args) Named tv _ -> go (extendVarEnv emptyTvSubstEnv tv arg) res args | otherwise - = panic "piResultTys" + = pprPanic "piResultTys1" (ppr ty $$ ppr orig_args) where go :: TvSubstEnv -> Type -> [Type] -> Type go tv_env ty [] = substTy (mkTvSubst in_scope tv_env) ty @@ -918,7 +918,7 @@ piResultTys ty orig_args@(arg:args) = piResultTys ty' all_args | otherwise - = panic "piResultTys" + = pprPanic "piResultTys2" (ppr ty $$ ppr orig_args $$ ppr all_args) {- --------------------------------------------------------------------- From git at git.haskell.org Wed Mar 23 16:38:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:47 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11723 and #11724. (54bacdd) Message-ID: <20160323163847.4A7993A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/54bacddfc6d8df60d11b91b74e3e788d5c667bc4/ghc >--------------------------------------------------------------- commit 54bacddfc6d8df60d11b91b74e3e788d5c667bc4 Author: Richard Eisenberg Date: Sat Mar 19 17:19:04 2016 -0400 Fix #11723 and #11724. Test cases: typecheck/should_fail/T1172{3,4} (cherry picked from commit d978c5ed93482473b81bbe52bedf37d45d1e1029) >--------------------------------------------------------------- 54bacddfc6d8df60d11b91b74e3e788d5c667bc4 compiler/typecheck/TcHsSyn.hs | 48 +++++++++++++++++----- compiler/typecheck/TcValidity.hs | 13 ++++++ docs/users_guide/glasgow_exts.rst | 2 +- .../tests/dependent/should_fail/T11473.stderr | 9 ++-- testsuite/tests/typecheck/should_fail/T11723.hs | 8 ++++ .../tests/typecheck/should_fail/T11723.stderr | 7 ++++ testsuite/tests/typecheck/should_fail/T11724.hs | 7 ++++ .../tests/typecheck/should_fail/T11724.stderr | 7 ++++ testsuite/tests/typecheck/should_fail/all.T | 2 + 9 files changed, 86 insertions(+), 17 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 54bacddfc6d8df60d11b91b74e3e788d5c667bc4 From git at git.haskell.org Wed Mar 23 16:38:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:49 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Make equality print better. (#11712) (09b872d) Message-ID: <20160323163849.EDFDB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/09b872dc61590a71c28feb37c37bf864664efaf7/ghc >--------------------------------------------------------------- commit 09b872dc61590a71c28feb37c37bf864664efaf7 Author: Richard Eisenberg Date: Fri Mar 18 11:20:31 2016 -0400 Make equality print better. (#11712) (cherry picked from commit 0b89064cc67cb4fbdba0044ab59a17b20bbde1db) >--------------------------------------------------------------- 09b872dc61590a71c28feb37c37bf864664efaf7 compiler/types/TyCoRep.hs | 76 +++++++++++++++++----- .../tests/deSugar/should_compile/T2431.stderr | 6 +- testsuite/tests/gadt/T7558.stderr | 2 +- testsuite/tests/ghci/scripts/Defer02.stderr | 4 +- .../should_compile/PushedInAsGivens.stderr | 2 +- .../indexed-types/should_compile/Simple14.stderr | 4 +- .../indexed-types/should_fail/SimpleFail15.stderr | 2 +- .../tests/indexed-types/should_fail/T4093a.stderr | 4 +- .../should_compile/DataFamilyInstanceLHS.stderr | 4 +- .../NamedWildcardInDataFamilyInstanceLHS.stderr | 4 +- testsuite/tests/polykinds/T10503.stderr | 4 +- testsuite/tests/polykinds/T7230.stderr | 5 +- testsuite/tests/polykinds/T9222.stderr | 4 +- .../tests/roles/should_compile/Roles13.stderr | 2 +- testsuite/tests/roles/should_compile/Roles3.stderr | 2 +- .../typecheck/should_fail/FrozenErrorTests.stderr | 2 +- testsuite/tests/typecheck/should_fail/T5858.stderr | 18 ++--- testsuite/tests/typecheck/should_fail/T7857.stderr | 2 +- .../tests/typecheck/should_fail/T8392a.stderr | 2 +- 19 files changed, 97 insertions(+), 52 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 09b872dc61590a71c28feb37c37bf864664efaf7 From git at git.haskell.org Wed Mar 23 16:38:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:52 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Use the correct in-scope set in coercionKind (65dc975) Message-ID: <20160323163852.996A53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/65dc9756968701d81baa884a1a3619ff40ea1e66/ghc >--------------------------------------------------------------- commit 65dc9756968701d81baa884a1a3619ff40ea1e66 Author: Bartosz Nitka Date: Mon Mar 21 11:11:26 2016 -0700 Use the correct in-scope set in coercionKind The free vars of `ty2` need to be in scope to satisfy the substitution invariant. As far as I can tell we don't have the free vars of `ty2` when substituting, so unfortunately we have to compute them. Test Plan: ./validate Reviewers: austin, bgamari, simonpj, goldfire Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2024 GHC Trac Issues: #11371 (cherry picked from commit 685398ebc5c8377597714cd8c3e97439d32e3a02) >--------------------------------------------------------------- 65dc9756968701d81baa884a1a3619ff40ea1e66 compiler/types/Coercion.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs index beee39b..471ce45 100644 --- a/compiler/types/Coercion.hs +++ b/compiler/types/Coercion.hs @@ -1720,7 +1720,12 @@ coercionKind co = go co = let Pair _ k2 = go k_co tv2 = setTyVarKind tv1 k2 Pair ty1 ty2 = go co - ty2' = substTyWithUnchecked [tv1] [TyVarTy tv2 `mk_cast_ty` mkSymCo k_co] ty2 in + subst = zipTvSubst [tv1] [TyVarTy tv2 `mk_cast_ty` mkSymCo k_co] + ty2' = substTyAddInScope subst ty2 in + -- We need free vars of ty2 in scope to satisfy the invariant + -- from Note [The substitution invariant] + -- This is doing repeated substitutions and probably doesn't + -- need to, see #11735 mkNamedForAllTy <$> Pair tv1 tv2 <*> pure Invisible <*> Pair ty1 ty2' go (CoVarCo cv) = toPair $ coVarTypes cv go (AxiomInstCo ax ind cos) @@ -1795,7 +1800,12 @@ coercionKindRole = go = let Pair _ k2 = coercionKind k_co tv2 = setTyVarKind tv1 k2 (Pair ty1 ty2, r) = go co - ty2' = substTyWithUnchecked [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo k_co] ty2 in + subst = zipTvSubst [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo k_co] + ty2' = substTyAddInScope subst ty2 in + -- We need free vars of ty2 in scope to satisfy the invariant + -- from Note [The substitution invariant] + -- This is doing repeated substitutions and probably doesn't + -- need to, see #11735 (mkNamedForAllTy <$> Pair tv1 tv2 <*> pure Invisible <*> Pair ty1 ty2', r) go (CoVarCo cv) = (toPair $ coVarTypes cv, coVarRole cv) go co@(AxiomInstCo ax _ _) = (coercionKind co, coAxiomRole ax) From git at git.haskell.org Wed Mar 23 16:38:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 23 Mar 2016 16:38:55 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Comments (only) in TcFlatten (1c586cf) Message-ID: <20160323163855.5A0AE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1c586cf49546393df4ea0e66324af320898d8c86/ghc >--------------------------------------------------------------- commit 1c586cf49546393df4ea0e66324af320898d8c86 Author: Richard Eisenberg Date: Mon Mar 21 17:03:38 2016 -0400 Comments (only) in TcFlatten (cherry picked from commit 2d6d907d8dcc051a7656dafcc0bc827cc651c6c0) >--------------------------------------------------------------- 1c586cf49546393df4ea0e66324af320898d8c86 compiler/typecheck/TcFlatten.hs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs index e340b5a..6af8660 100644 --- a/compiler/typecheck/TcFlatten.hs +++ b/compiler/typecheck/TcFlatten.hs @@ -801,19 +801,26 @@ flattenManyNom ev tys {- Note [Flattening] ~~~~~~~~~~~~~~~~~~~~ - flatten ty ==> (xi, cc) + flatten ty ==> (xi, co) where xi has no type functions, unless they appear under ForAlls - - cc = Auxiliary given (equality) constraints constraining - the fresh type variables in xi. Evidence for these - is always the identity coercion, because internally the - fresh flattening skolem variables are actually identified - with the types they have been generated to stand in for. + co :: xi ~ ty Note that it is flatten's job to flatten *every type function it sees*. flatten is only called on *arguments* to type functions, by canEqGiven. +Flattening also: + * zonks, removing any metavariables, and + * applies the substitution embodied in the inert set + +Because flattening zonks and the returned coercion ("co" above) is also +zonked, it's possible that (co :: xi ~ ty) isn't quite true, as ty (the +input to the flattener) might not be zonked. After zonking everything, +(co :: xi ~ ty) will be true, however. It is for this reason that we +occasionally have to explicitly zonk, when (co :: xi ~ ty) is important +even before we zonk the whole program. (In particular, this is why the +zonk in flatten_tyvar3 is necessary.) + Flattening a type also means flattening its kind. In the case of a type variable whose kind mentions a type family, this might mean that the result of flattening has a cast in it. @@ -1353,6 +1360,7 @@ flatten_tyvar3 tv -- This zonk is necessary because we might later see the tv's kind -- in canEqTyVarTyVar (where we use getCastedTyVar_maybe). -- If you remove it, then e.g. dependent/should_fail/T11407 panics + -- See also Note [Flattening] ; return (FTRCasted (setTyVarKind tv orig_kind) kind_co) } {- From git at git.haskell.org Thu Mar 24 00:52:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 00:52:29 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Rename test for #11334 to 11334b, fixing conflict (f6d2748) Message-ID: <20160324005229.426803A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/f6d27485df643b2924cc27769b985ccdf1ffc443/ghc >--------------------------------------------------------------- commit f6d27485df643b2924cc27769b985ccdf1ffc443 Author: Richard Eisenberg Date: Fri Mar 18 21:40:04 2016 -0400 Rename test for #11334 to 11334b, fixing conflict (cherry picked from commit f8ab575404b726b499e72343b7220e9213880dd4) >--------------------------------------------------------------- f6d27485df643b2924cc27769b985ccdf1ffc443 testsuite/tests/dependent/should_fail/{T11334.hs => T11334b.hs} | 2 +- .../tests/dependent/should_fail/{T11334.stderr => T11334b.stderr} | 6 +++--- testsuite/tests/dependent/should_fail/all.T | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/testsuite/tests/dependent/should_fail/T11334.hs b/testsuite/tests/dependent/should_fail/T11334b.hs similarity index 84% rename from testsuite/tests/dependent/should_fail/T11334.hs rename to testsuite/tests/dependent/should_fail/T11334b.hs index 1f9970f..c6f6d20 100644 --- a/testsuite/tests/dependent/should_fail/T11334.hs +++ b/testsuite/tests/dependent/should_fail/T11334b.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DataKinds, NoPolyKinds #-} -module T11334 where +module T11334b where import Data.Functor.Compose import Data.Proxy diff --git a/testsuite/tests/dependent/should_fail/T11334.stderr b/testsuite/tests/dependent/should_fail/T11334b.stderr similarity index 92% rename from testsuite/tests/dependent/should_fail/T11334.stderr rename to testsuite/tests/dependent/should_fail/T11334b.stderr index f7c87a3..8f4251b 100644 --- a/testsuite/tests/dependent/should_fail/T11334.stderr +++ b/testsuite/tests/dependent/should_fail/T11334b.stderr @@ -1,5 +1,5 @@ -T11334.hs:8:14: error: +T11334b.hs:8:14: error: ? Cannot default kind variable ?f0? of kind: k0 -> * Perhaps enable PolyKinds or add a kind signature @@ -7,7 +7,7 @@ T11334.hs:8:14: error: In the expression: Proxy :: Proxy Compose In an equation for ?p?: p = Proxy :: Proxy Compose -T11334.hs:8:14: error: +T11334b.hs:8:14: error: ? Cannot default kind variable ?g0? of kind: k10 -> k0 Perhaps enable PolyKinds or add a kind signature @@ -15,7 +15,7 @@ T11334.hs:8:14: error: In the expression: Proxy :: Proxy Compose In an equation for ?p?: p = Proxy :: Proxy Compose -T11334.hs:8:14: error: +T11334b.hs:8:14: error: ? Cannot default kind variable ?a0? of kind: k10 Perhaps enable PolyKinds or add a kind signature diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index b830121..a601d60 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -9,7 +9,7 @@ test('SelfDep', normal, compile_fail, ['']) test('BadTelescope4', normal, compile_fail, ['']) test('RenamingStar', normal, compile_fail, ['']) test('T11407', normal, compile_fail, ['']) -test('T11334', normal, compile_fail, ['']) +test('T11334b', normal, compile_fail, ['']) test('InferDependency', normal, compile_fail, ['']) test('KindLevelsB', normal, compile_fail, ['']) test('T11471', normal, compile_fail, ['']) From git at git.haskell.org Thu Mar 24 00:52:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 00:52:32 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Prevent eager unification with type families. (84ca17f) Message-ID: <20160324005232.7A92F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/84ca17fcab570b8f01a419bdbf2587e688eca302/ghc >--------------------------------------------------------------- commit 84ca17fcab570b8f01a419bdbf2587e688eca302 Author: Richard Eisenberg Date: Fri Mar 18 22:36:34 2016 -0400 Prevent eager unification with type families. See Note [Prevent unification with type families] in TcUnify for the details. (cherry picked from commit 3e1b8824c849d063c7354dbdf63ae2910cf0fdfc) >--------------------------------------------------------------- 84ca17fcab570b8f01a419bdbf2587e688eca302 compiler/typecheck/TcType.hs | 7 +- compiler/typecheck/TcUnify.hs | 82 +++++++++++++++++++++- testsuite/tests/indexed-types/should_compile/all.T | 2 +- .../tests/indexed-types/should_fail/T2693.stderr | 17 ++--- .../tests/indexed-types/should_fail/T4179.stderr | 6 +- .../tests/indexed-types/should_fail/T5439.stderr | 16 ++--- .../tests/indexed-types/should_fail/T7354.stderr | 9 +-- .../tests/indexed-types/should_fail/T7729.stderr | 8 +-- .../tests/indexed-types/should_fail/T7786.stderr | 12 ++-- .../{should_compile => should_fail}/T7788.hs | 0 .../tests/indexed-types/should_fail/T7788.stderr | 10 +++ .../tests/indexed-types/should_fail/T9554.stderr | 13 ++++ .../tests/indexed-types/should_fail/T9662.stderr | 16 +++-- testsuite/tests/indexed-types/should_fail/all.T | 1 + testsuite/tests/perf/compiler/all.T | 3 +- testsuite/tests/typecheck/should_fail/T9260.stderr | 2 +- 16 files changed, 156 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 84ca17fcab570b8f01a419bdbf2587e688eca302 From git at git.haskell.org Thu Mar 24 00:52:37 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 00:52:37 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Avoid running afoul of the zipTvSubst check. (4bcec82) Message-ID: <20160324005237.CEF573A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/4bcec82c560acddde024575842efe82736f4ed3b/ghc >--------------------------------------------------------------- commit 4bcec82c560acddde024575842efe82736f4ed3b Author: Richard Eisenberg Date: Mon Mar 21 22:35:41 2016 -0400 Avoid running afoul of the zipTvSubst check. addDataConStupidTheta includes comments that the types list might be longer than the tvs list. And the check in zipTvSubst doesn't appear to be terribly recent. I am utterly flummoxed as to why this worked before. It was clearly just broken. And now it's fixed. (cherry picked from commit 0beb82c171913508dc0de91851ab8e90821d8ba8) >--------------------------------------------------------------- 4bcec82c560acddde024575842efe82736f4ed3b compiler/typecheck/TcPat.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs index 53b8142..6cc6429 100644 --- a/compiler/typecheck/TcPat.hs +++ b/compiler/typecheck/TcPat.hs @@ -1017,7 +1017,8 @@ addDataConStupidTheta data_con inst_tys -- The origin should always report "occurrence of C" -- even when C occurs in a pattern stupid_theta = dataConStupidTheta data_con - tenv = zipTvSubst (dataConUnivTyVars data_con) inst_tys + univ_tvs = dataConUnivTyVars data_con + tenv = zipTvSubst univ_tvs (takeList univ_tvs inst_tys) -- NB: inst_tys can be longer than the univ tyvars -- because the constructor might have existentials inst_theta = substTheta tenv stupid_theta From git at git.haskell.org Thu Mar 24 00:52:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 00:52:35 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Replace mkTvSubstPrs (a `zip` b) with zipTvSubst a b (aeafaf6) Message-ID: <20160324005235.24C653A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/aeafaf65b9f3d7763ebc1c595119b94553e4b4b0/ghc >--------------------------------------------------------------- commit aeafaf65b9f3d7763ebc1c595119b94553e4b4b0 Author: Bartosz Nitka Date: Wed Feb 10 08:12:44 2016 -0800 Replace mkTvSubstPrs (a `zip` b) with zipTvSubst a b It's just a small cleanup. There should be no change in behaviour. Test Plan: ./validate --slow Reviewers: austin, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D1901 (cherry picked from commit d27da53652a6ba01c91856859a4be674fe3c835d) >--------------------------------------------------------------- aeafaf65b9f3d7763ebc1c595119b94553e4b4b0 compiler/deSugar/DsExpr.hs | 2 +- compiler/typecheck/TcPat.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/deSugar/DsExpr.hs b/compiler/deSugar/DsExpr.hs index 6116578..8a64a68 100644 --- a/compiler/deSugar/DsExpr.hs +++ b/compiler/deSugar/DsExpr.hs @@ -624,7 +624,7 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields mk_alt upd_fld_env con = do { let (univ_tvs, ex_tvs, eq_spec, prov_theta, _req_theta, arg_tys, _) = conLikeFullSig con - subst = mkTvSubstPrs (univ_tvs `zip` in_inst_tys) + subst = zipTvSubst univ_tvs in_inst_tys -- I'm not bothering to clone the ex_tvs ; eqs_vars <- mapM newPredVarDs (substTheta subst (eqSpecPreds eq_spec)) diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs index e56bb20..53b8142 100644 --- a/compiler/typecheck/TcPat.hs +++ b/compiler/typecheck/TcPat.hs @@ -1017,7 +1017,7 @@ addDataConStupidTheta data_con inst_tys -- The origin should always report "occurrence of C" -- even when C occurs in a pattern stupid_theta = dataConStupidTheta data_con - tenv = mkTvSubstPrs (dataConUnivTyVars data_con `zip` inst_tys) + tenv = zipTvSubst (dataConUnivTyVars data_con) inst_tys -- NB: inst_tys can be longer than the univ tyvars -- because the constructor might have existentials inst_theta = substTheta tenv stupid_theta From git at git.haskell.org Thu Mar 24 09:47:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:47:56 +0000 (UTC) Subject: [commit: ghc] master: Comment fix (7e74079) Message-ID: <20160324094756.7942E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/7e74079772431d00cc8d1e6b3826ce35e46b9bdd/ghc >--------------------------------------------------------------- commit 7e74079772431d00cc8d1e6b3826ce35e46b9bdd Author: Simon Peyton Jones Date: Thu Mar 17 08:50:23 2016 +0000 Comment fix >--------------------------------------------------------------- 7e74079772431d00cc8d1e6b3826ce35e46b9bdd compiler/types/Kind.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/types/Kind.hs b/compiler/types/Kind.hs index ac7fc58..e3cebcd 100644 --- a/compiler/types/Kind.hs +++ b/compiler/types/Kind.hs @@ -50,7 +50,7 @@ Constraint and *. Indeed we can have coercions between the two. Consider op :: a -> a For this single-method class we may generate a newtype, which in turn generates an axiom witnessing - Ord a ~ (a -> a) + C a ~ (a -> a) so on the left we have Constraint, and on the right we have *. See Trac #7451. From git at git.haskell.org Thu Mar 24 09:47:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:47:59 +0000 (UTC) Subject: [commit: ghc] master: Move applyTysX near piResultTys (7d5ff3d) Message-ID: <20160324094759.23DFA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/7d5ff3d36946d99ba4691344e04dd0328b2c1ef2/ghc >--------------------------------------------------------------- commit 7d5ff3d36946d99ba4691344e04dd0328b2c1ef2 Author: Simon Peyton Jones Date: Mon Mar 21 12:51:40 2016 +0000 Move applyTysX near piResultTys >--------------------------------------------------------------- 7d5ff3d36946d99ba4691344e04dd0328b2c1ef2 compiler/types/Type.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index e3d3c88..c5561a3 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -913,6 +913,18 @@ piResultTys ty orig_args@(arg:args) | otherwise = pprPanic "piResultTys2" (ppr ty $$ ppr orig_args $$ ppr all_args) +applyTysX :: [TyVar] -> Type -> [Type] -> Type +-- applyTyxX beta-reduces (/\tvs. body_ty) arg_tys +-- Assumes that (/\tvs. body_ty) is closed +applyTysX tvs body_ty arg_tys + = ASSERT2( length arg_tys >= n_tvs, pp_stuff ) + ASSERT2( tyCoVarsOfType body_ty `subVarSet` mkVarSet tvs, pp_stuff ) + mkAppTys (substTyWith tvs (take n_tvs arg_tys) body_ty) + (drop n_tvs arg_tys) + where + pp_stuff = vcat [ppr tvs, ppr body_ty, ppr arg_tys] + n_tvs = length tvs + {- --------------------------------------------------------------------- TyConApp @@ -1484,18 +1496,6 @@ splitPiTysInvisible ty = split ty ty [] split orig_ty _ bndrs = (reverse bndrs, orig_ty) -applyTysX :: [TyVar] -> Type -> [Type] -> Type --- applyTyxX beta-reduces (/\tvs. body_ty) arg_tys --- Assumes that (/\tvs. body_ty) is closed -applyTysX tvs body_ty arg_tys - = ASSERT2( length arg_tys >= n_tvs, pp_stuff ) - ASSERT2( tyCoVarsOfType body_ty `subVarSet` mkVarSet tvs, pp_stuff ) - mkAppTys (substTyWith tvs (take n_tvs arg_tys) body_ty) - (drop n_tvs arg_tys) - where - pp_stuff = vcat [ppr tvs, ppr body_ty, ppr arg_tys] - n_tvs = length tvs - {- %************************************************************************ %* * From git at git.haskell.org Thu Mar 24 09:48:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:48:02 +0000 (UTC) Subject: [commit: ghc] master: Move DFunUnfolding generation to TcInstDcls (db9e4eb) Message-ID: <20160324094802.51C7C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/db9e4eb4e3fe916df7a69da1b211083ad6068aff/ghc >--------------------------------------------------------------- commit db9e4eb4e3fe916df7a69da1b211083ad6068aff Author: Simon Peyton Jones Date: Wed Mar 23 15:37:50 2016 +0000 Move DFunUnfolding generation to TcInstDcls The desugarer had a fragile case to generate the Unfolding for a DFun. This patch moves the unfolding generation to TcInstDcls, where all the pieces are to hand. Fixes Trac #11742 >--------------------------------------------------------------- db9e4eb4e3fe916df7a69da1b211083ad6068aff compiler/deSugar/DsBinds.hs | 21 ----------- compiler/typecheck/TcInstDcls.hs | 42 +++++++++++++++++----- testsuite/tests/roles/should_compile/T8958.stderr | 13 ++++--- testsuite/tests/simplCore/should_compile/T11742.hs | 8 +++++ testsuite/tests/simplCore/should_compile/all.T | 1 + 5 files changed, 52 insertions(+), 33 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc db9e4eb4e3fe916df7a69da1b211083ad6068aff From git at git.haskell.org Thu Mar 24 09:51:12 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:12 +0000 (UTC) Subject: [commit: ghc] master: ErrUtils: Add timings to compiler phases (8048d51) Message-ID: <20160324095112.C0EA93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/8048d51be0676627b417c128af0b0c352b75c537/ghc >--------------------------------------------------------------- commit 8048d51be0676627b417c128af0b0c352b75c537 Author: Ben Gamari Date: Wed Mar 23 16:11:45 2016 +0100 ErrUtils: Add timings to compiler phases This adds timings and allocation figures to the compiler's output when run with `-v2` in an effort to ease performance analysis. Todo: * Documentation * Where else should we add these? * Perhaps we should remove some of the now-arguably-redundant `showPass` occurrences where they are * Must we force more? * Perhaps we should place this behind a `-ftimings` instead of `-v2` Test Plan: `ghc -v2 Test.hs`, look at the output Reviewers: hvr, goldfire, simonmar, austin Reviewed By: simonmar Subscribers: angerman, michalt, niteria, ezyang, thomie Differential Revision: https://phabricator.haskell.org/D1959 >--------------------------------------------------------------- 8048d51be0676627b417c128af0b0c352b75c537 compiler/cmm/CmmParse.y | 3 +- compiler/coreSyn/CoreLint.hs | 9 +----- compiler/coreSyn/CorePrep.hs | 16 ++++++---- compiler/deSugar/Desugar.hs | 9 +++--- compiler/ghci/ByteCodeGen.hs | 15 +++++----- compiler/llvmGen/LlvmCodeGen.hs | 3 +- compiler/llvmGen/LlvmMangler.hs | 7 +++-- compiler/main/CodeOutput.hs | 7 +++-- compiler/main/ErrUtils.hs | 58 +++++++++++++++++++++++++++++++++++- compiler/main/GhcMake.hs | 19 ++++++------ compiler/main/HscMain.hs | 63 +++++++++++++++++++++------------------- compiler/main/TidyPgm.hs | 23 ++++++++++----- compiler/simplCore/SimplCore.hs | 39 ++++++++++++++----------- compiler/typecheck/TcRnDriver.hs | 12 ++++---- compiler/utils/Outputable.hs | 8 ++++- docs/users_guide/debugging.rst | 10 ++++++- docs/users_guide/using.rst | 4 +-- 17 files changed, 197 insertions(+), 108 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 8048d51be0676627b417c128af0b0c352b75c537 From git at git.haskell.org Thu Mar 24 09:51:15 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:15 +0000 (UTC) Subject: [commit: ghc] master: base: Fix ClockGetTime on OS X (2ddfb75) Message-ID: <20160324095115.666263A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2ddfb7573793c2a288d0979868f876af75733426/ghc >--------------------------------------------------------------- commit 2ddfb7573793c2a288d0979868f876af75733426 Author: Ben Gamari Date: Wed Mar 23 17:25:26 2016 +0100 base: Fix ClockGetTime on OS X Apparently _POSIX_CPUTIME may be defined as -1 if CLOCK_PROCESS_CPUTIME_ID isn't defined. Test Plan: Validate Reviewers: austin, hvr, erikd, goldfire Reviewed By: erikd, goldfire Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2028 GHC Trac Issues: #11733 >--------------------------------------------------------------- 2ddfb7573793c2a288d0979868f876af75733426 libraries/base/System/CPUTime.hsc | 2 +- libraries/base/System/CPUTime/Posix/ClockGetTime.hsc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/base/System/CPUTime.hsc b/libraries/base/System/CPUTime.hsc index a6d934f..0475975 100644 --- a/libraries/base/System/CPUTime.hsc +++ b/libraries/base/System/CPUTime.hsc @@ -34,7 +34,7 @@ import System.IO.Unsafe (unsafePerformIO) #if defined(mingw32_HOST_OS) import qualified System.CPUTime.Windows as I -#elif _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) +#elif _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) && _POSIX_CPUTIME >= 0 import qualified System.CPUTime.Posix.ClockGetTime as I #elif defined(HAVE_GETRUSAGE) && ! irix_HOST_OS && ! solaris2_HOST_OS diff --git a/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc b/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc index f4d224a..d7f2444 100644 --- a/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc +++ b/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc @@ -12,7 +12,7 @@ module System.CPUTime.Posix.ClockGetTime , getCpuTimePrecision ) where -#if defined(_POSIX_CPUTIME) +#if _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) && _POSIX_CPUTIME >= 0 import Foreign import Foreign.C From git at git.haskell.org Thu Mar 24 09:51:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:18 +0000 (UTC) Subject: [commit: ghc] master: Add `PatSynSigSkol` and modify `PatSynCtxt` (997312b) Message-ID: <20160324095118.9F6433A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/997312b04c56017197250096d61f3e8fab502319/ghc >--------------------------------------------------------------- commit 997312b04c56017197250096d61f3e8fab502319 Author: Rik Steenkamp Date: Wed Mar 23 16:17:27 2016 +0100 Add `PatSynSigSkol` and modify `PatSynCtxt` As the type of a pattern synonym cannot in general be represented by a value of type Type, we cannot use a value `SigSkol (PatSynCtxt n) (Check ty)` to represent the signature of a pattern synonym (this causes incorrect signatures to be printed in error messages). Therefore we now represent it by a value `PatSynSigSkol n` (instead of incorrect signatures we simply print no explicit signature). Furthermore, we rename `PatSynCtxt` to `PatSynBuilderCtxt`, and use `SigSkol (PatSynBuilderCtxt n) (Check ty)` to represent the type of a bidirectional pattern synonym when used in an expression context. Before, this type was represented by a value `SigSkol (PatSynCtxt n) (Check ty)`, which caused incorrect error messages. Also, in `mk_dict_err` of `typecheck\TcErrors.hs` we now distinguish between all enclosing implications and "useful" enclosing implications, for better error messages concerning pattern synonyms. See `Note [Useful implications]`. See the Phabricator page for examples. Reviewers: mpickering, goldfire, simonpj, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1967 GHC Trac Issues: #11667 >--------------------------------------------------------------- 997312b04c56017197250096d61f3e8fab502319 compiler/basicTypes/PatSyn.hs | 15 ++++ compiler/typecheck/TcErrors.hs | 88 ++++++++++++++++-------- compiler/typecheck/TcPatSyn.hs | 5 +- compiler/typecheck/TcRnTypes.hs | 7 ++ compiler/typecheck/TcSimplify.hs | 4 +- compiler/typecheck/TcType.hs | 17 ++--- compiler/typecheck/TcValidity.hs | 38 +++++----- testsuite/tests/patsyn/should_fail/T10873.stderr | 9 ++- testsuite/tests/patsyn/should_fail/T11039.stderr | 4 +- testsuite/tests/patsyn/should_fail/T11667.hs | 31 +++++++++ testsuite/tests/patsyn/should_fail/T11667.stderr | 43 ++++++++++++ testsuite/tests/patsyn/should_fail/all.T | 1 + 12 files changed, 194 insertions(+), 68 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 997312b04c56017197250096d61f3e8fab502319 From git at git.haskell.org Thu Mar 24 09:51:21 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:21 +0000 (UTC) Subject: [commit: ghc] master: Ensure T9646 dump-simpl output is cleaned (da3b29b) Message-ID: <20160324095121.4783B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/da3b29bd1768d717753b7d1642e0e4e97750ae7b/ghc >--------------------------------------------------------------- commit da3b29bd1768d717753b7d1642e0e4e97750ae7b Author: Ben Gamari Date: Mon Mar 21 00:49:24 2016 +0100 Ensure T9646 dump-simpl output is cleaned >--------------------------------------------------------------- da3b29bd1768d717753b7d1642e0e4e97750ae7b testsuite/tests/simplCore/T9646/test.T | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/simplCore/T9646/test.T b/testsuite/tests/simplCore/T9646/test.T index 1456217..d31f8fe 100644 --- a/testsuite/tests/simplCore/T9646/test.T +++ b/testsuite/tests/simplCore/T9646/test.T @@ -1,6 +1,9 @@ test('T9646', - [when(fast(), skip), extra_clean(['Main.hi', 'Main.o'])], + [when(fast(), skip), + extra_clean(['Main.hi', 'Main.o', 'Main.dump-simpl', + 'Natural.dump-simpl', 'StrictPrim.dump-simpl', + 'Type.dump-simpl'])], multimod_compile_and_run, ['Main -ddump-simpl -ddump-to-file', '']) From git at git.haskell.org Thu Mar 24 09:51:24 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:24 +0000 (UTC) Subject: [commit: ghc] master: Add unicode syntax for banana brackets (03a1bb4) Message-ID: <20160324095124.48F413A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/03a1bb4d010f94bed233ca261bf44e00c7bd9878/ghc >--------------------------------------------------------------- commit 03a1bb4d010f94bed233ca261bf44e00c7bd9878 Author: Josh Price Date: Wed Mar 23 16:19:01 2016 +0100 Add unicode syntax for banana brackets Summary: Add "?" and "?" as unicode alternatives for "(|" and "|)" respectively. This must be implemented differently than other unicode additions because ?" and "?" are interpretted as a $unigraphic rather than a $unisymbol. Test Plan: validate Reviewers: goldfire, bgamari, austin Reviewed By: bgamari, austin Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2012 GHC Trac Issues: #10162 >--------------------------------------------------------------- 03a1bb4d010f94bed233ca261bf44e00c7bd9878 compiler/parser/Lexer.x | 21 ++++++++++--- compiler/parser/Parser.y | 4 +-- docs/users_guide/glasgow_exts.rst | 4 +++ .../tests/arrows/should_compile/arrowform1.hs | 26 ++++++++--------- testsuite/tests/parser/unicode/all.T | 2 ++ testsuite/tests/parser/unicode/arrowsyntax.hs | 34 ++++++++++++++++++++++ 6 files changed, 72 insertions(+), 19 deletions(-) diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 650b302..4eb8fd3 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -395,8 +395,17 @@ $tab { warnTab } <0> { "(|" / { ifExtension arrowsEnabled `alexAndPred` notFollowedBySymbol } - { special IToparenbar } - "|)" / { ifExtension arrowsEnabled } { special ITcparenbar } + { special (IToparenbar NormalSyntax) } + "|)" / { ifExtension arrowsEnabled } { special (ITcparenbar NormalSyntax) } + + $unigraphic -- ? + / { ifCurrentChar '?' `alexAndPred` + ifExtension (\i -> unicodeSyntaxEnabled i && arrowsEnabled i) } + { special (IToparenbar UnicodeSyntax) } + $unigraphic -- ? + / { ifCurrentChar '?' `alexAndPred` + ifExtension (\i -> unicodeSyntaxEnabled i && arrowsEnabled i) } + { special (ITcparenbar UnicodeSyntax) } } <0> { @@ -704,8 +713,8 @@ data Token -- Arrow notation extension | ITproc | ITrec - | IToparenbar -- (| - | ITcparenbar -- |) + | IToparenbar IsUnicodeSyntax -- (| + | ITcparenbar IsUnicodeSyntax -- |) | ITlarrowtail IsUnicodeSyntax -- -< | ITrarrowtail IsUnicodeSyntax -- >- | ITLarrowtail IsUnicodeSyntax -- -<< @@ -942,6 +951,10 @@ followedByDigit :: AlexAccPred ExtsBitmap followedByDigit _ _ _ (AI _ buf) = afterOptionalSpace buf (\b -> nextCharIs b (`elem` ['0'..'9'])) +ifCurrentChar :: Char -> AlexAccPred ExtsBitmap +ifCurrentChar char _ (AI _ buf) _ _ + = nextCharIs buf (== char) + -- We must reject doc comments as being ordinary comments everywhere. -- In some cases the doc comment will be selected as the lexeme due to -- maximal munch, but not always, because the nested comment rule is diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index a640bcb..0b11b04 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -427,8 +427,8 @@ output it generates. ')' { L _ ITcparen } '(#' { L _ IToubxparen } '#)' { L _ ITcubxparen } - '(|' { L _ IToparenbar } - '|)' { L _ ITcparenbar } + '(|' { L _ (IToparenbar _) } + '|)' { L _ (ITcparenbar _) } ';' { L _ ITsemi } ',' { L _ ITcomma } '`' { L _ ITbackquote } diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index a4a0830..978fe8b 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -302,6 +302,10 @@ sequences. The following alternatives are provided: +--------------+---------------+-------------+--------------------------------+ | ``forall`` | ? | 0x2200 | FOR ALL | +--------------+---------------+-------------+--------------------------------+ +| ``(|`` | ? | 0x2987 | Z NOTATION LEFT IMAGE BRACKET | ++--------------+---------------+-------------+--------------------------------+ +| ``|)`` | ? | 0x2988 | Z NOTATION RIGHT IMAGE BRACKET | ++--------------+---------------+-------------+--------------------------------+ .. _magic-hash: diff --git a/testsuite/tests/arrows/should_compile/arrowform1.hs b/testsuite/tests/arrows/should_compile/arrowform1.hs index 70b9669..c41e6c7 100644 --- a/testsuite/tests/arrows/should_compile/arrowform1.hs +++ b/testsuite/tests/arrows/should_compile/arrowform1.hs @@ -9,22 +9,22 @@ handle f h = proc (b,s) -> (f -< (b,s)) <+> (h -< (b,("FAIL",s))) f :: ArrowPlus a => a (Int,Int) String f = proc (x,y) -> - (|handle - (returnA -< show y) - (\s -> returnA -< s ++ show x) - |) + (|handle + (returnA -< show y) + (\s -> returnA -< s ++ show x) + |) g :: ArrowPlus a => a (Int,Int) String g = proc (x,y) -> - (|handle - (\msg -> returnA -< msg ++ show y) - (\s msg -> returnA -< s ++ show x) - |) ("hello " ++ show x) + (|handle + (\msg -> returnA -< msg ++ show y) + (\s msg -> returnA -< s ++ show x) + |) ("hello " ++ show x) h :: ArrowPlus a => a (Int,Int) Int h = proc (x,y) -> - ( - (\z -> returnA -< x + z) - <+> - (\z -> returnA -< y + z) - ) (x*y) + ( + (\z -> returnA -< x + z) + <+> + (\z -> returnA -< y + z) + ) (x*y) diff --git a/testsuite/tests/parser/unicode/all.T b/testsuite/tests/parser/unicode/all.T index 36554cc..6876fe7 100644 --- a/testsuite/tests/parser/unicode/all.T +++ b/testsuite/tests/parser/unicode/all.T @@ -26,3 +26,5 @@ test('T7671', normal, compile, ['']) # supported by the test suite (see 10907) test('T10907', normal, compile, ['']) test('T7650', normal, compile, ['']) + +test('arrowsyntax', normal, compile, ['']) \ No newline at end of file diff --git a/testsuite/tests/parser/unicode/arrowsyntax.hs b/testsuite/tests/parser/unicode/arrowsyntax.hs new file mode 100644 index 0000000..05a8495 --- /dev/null +++ b/testsuite/tests/parser/unicode/arrowsyntax.hs @@ -0,0 +1,34 @@ +{-# LANGUAGE Arrows #-} +{-# LANGUAGE UnicodeSyntax #-} + +-- See Trac #2978 and #10162 for details +-- This test is a unicode version of tests/arrows/should_compile/arrowform1.hs + +module ShouldCompile where + +import Control.Arrow + +handle :: ArrowPlus a => a (b,s) c -> a (b,(String,s)) c -> a (b,s) c +handle f h = proc (b,s) -> (f ? (b,s)) <+> (h ? (b,("FAIL",s))) + +f :: ArrowPlus a => a (Int,Int) String +f = proc (x,y) -> + ?handle + (returnA ? show y) + (\s -> returnA ? s ++ show x) + ? + +g :: ArrowPlus a => a (Int,Int) String +g = proc (x,y) -> + ?handle + (\msg -> returnA ? msg ++ show y) + (\s msg -> returnA ? s ++ show x) + ? ("hello " ++ show x) + +h :: ArrowPlus a => a (Int,Int) Int +h = proc (x,y) -> + ( + (\z -> returnA ? x + z) + <+> + (\z -> returnA ? y + z) + ) (x*y) From git at git.haskell.org Thu Mar 24 09:51:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:26 +0000 (UTC) Subject: [commit: ghc] master: Fix regression test for #11145. (e57b9ff) Message-ID: <20160324095126.EBB373A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e57b9ffee858278bf1ef8ed0754346685334b9ba/ghc >--------------------------------------------------------------- commit e57b9ffee858278bf1ef8ed0754346685334b9ba Author: Dominik Bollmann Date: Thu Mar 24 10:11:46 2016 +0100 Fix regression test for #11145. Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2032 GHC Trac Issues: #11145 >--------------------------------------------------------------- e57b9ffee858278bf1ef8ed0754346685334b9ba testsuite/tests/th/T11145.stderr | 2 +- testsuite/tests/th/all.T | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/tests/th/T11145.stderr b/testsuite/tests/th/T11145.stderr index 98e518c..731349d 100644 --- a/testsuite/tests/th/T11145.stderr +++ b/testsuite/tests/th/T11145.stderr @@ -3,6 +3,6 @@ T11145.hs:8:1: error: ? Data constructor ?MkFuggle? returns type ?Fuggle Int (Maybe Bool)? instead of an instance of its parent type ?Fuggle - Int (Maybe (a_a4MU, b_a4MV))? + Int (Maybe (a, b))? ? In the definition of data constructor ?MkFuggle? In the data instance declaration for ?Fuggle? diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 7e9f25d..3939880 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -396,4 +396,4 @@ test('TH_finalizer', normal, compile, ['-v0']) test('T10603', normal, compile, ['-ddump-splices -dsuppress-uniques']) test('T11452', normal, compile_fail, ['-v0']) test('T9022', normal, compile_and_run, ['-v0']) -test('T11145', normal, compile_fail, ['-v0']) \ No newline at end of file +test('T11145', normal, compile_fail, ['-v0 -dsuppress-uniques']) From git at git.haskell.org Thu Mar 24 09:51:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:29 +0000 (UTC) Subject: [commit: ghc] master: Close ticky profiling file stream after printing (#9405) (2708c22) Message-ID: <20160324095129.CC3683A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2708c22b8c8a415446d963575c0396a038b43a93/ghc >--------------------------------------------------------------- commit 2708c22b8c8a415446d963575c0396a038b43a93 Author: Flaviu Andrei Csernik Date: Wed Mar 23 16:18:11 2016 +0100 Close ticky profiling file stream after printing (#9405) Test Plan: T9405 Reviewers: simonmar, austin, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2008 GHC Trac Issues: #9405 >--------------------------------------------------------------- 2708c22b8c8a415446d963575c0396a038b43a93 rts/RtsFlags.c | 4 +++- rts/RtsStartup.c | 3 +++ testsuite/tests/rts/Makefile | 9 +++++++++ testsuite/tests/rts/T9405.hs | 3 +++ testsuite/tests/rts/all.T | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 3d0d7a4..cce799e 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -590,9 +590,11 @@ void setupRtsFlags (int *argc, char *argv[], RtsConfig rts_config) if (RtsFlags.GcFlags.statsFile != NULL) { initStatsFile (RtsFlags.GcFlags.statsFile); } +#ifdef TICKY_TICKY if (RtsFlags.TickyFlags.tickyFile != NULL) { - initStatsFile (RtsFlags.GcFlags.statsFile); + initStatsFile (RtsFlags.TickyFlags.tickyFile); } +#endif } /* ----------------------------------------------------------------------------- diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index bd6a6ae..4b9d947 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -408,6 +408,9 @@ hs_exit_(rtsBool wait_foreign) #if defined(TICKY_TICKY) if (RtsFlags.TickyFlags.showTickyStats) PrintTickyInfo(); + + FILE *tf = RtsFlags.TickyFlags.tickyFile; + if (tf != NULL) fclose(tf); #endif #if defined(mingw32_HOST_OS) && !defined(THREADED_RTS) diff --git a/testsuite/tests/rts/Makefile b/testsuite/tests/rts/Makefile index 094506d..6181f87 100644 --- a/testsuite/tests/rts/Makefile +++ b/testsuite/tests/rts/Makefile @@ -45,6 +45,15 @@ T5423: "$(TEST_HC)" $(TEST_HC_OPTS) -v0 T5423.o T5423_cmm.o -o T5423$(exeext) ./T5423 +.PHONY: T9405 +T9405: + @'$(TEST_HC)' $(TEST_HC_OPTS) -ticky -rtsopts T9405.hs; \ + ./T9405 +RTS -rT9405.ticky & \ + sleep 0.2; \ + kill -2 $$!; \ + wait $$!; \ + [ -s T9405.ticky ] && echo Ticky-Ticky + # Naming convention: 'T5423_' obj-way '_' obj-src # obj-way ::= v | dyn # obj-src ::= gcc // using __attribute__(constructor) diff --git a/testsuite/tests/rts/T9405.hs b/testsuite/tests/rts/T9405.hs new file mode 100644 index 0000000..ca68e10 --- /dev/null +++ b/testsuite/tests/rts/T9405.hs @@ -0,0 +1,3 @@ +import Control.Concurrent + +main = threadDelay 2000000 diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index 60513ca..269bc55 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -330,3 +330,6 @@ test('T10904', [ omit_ways(['ghci']), extra_run_opts('20000') ], test('T10728', [extra_run_opts('+RTS -maxN3 -RTS'), only_ways(['threaded2'])], compile_and_run, ['']) + +test('T9405', [extra_clean(['T9405.ticky'])], + run_command, ['$MAKE -s --no-print-directory T9405']) From git at git.haskell.org Thu Mar 24 09:51:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:32 +0000 (UTC) Subject: [commit: ghc] master: Create empty dump files (fixes #10320) (9f9345e) Message-ID: <20160324095132.F14723A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/9f9345e5ad55e4a02e6de9afac814ac58c852ff2/ghc >--------------------------------------------------------------- commit 9f9345e5ad55e4a02e6de9afac814ac58c852ff2 Author: Kai Harries Date: Wed Mar 23 16:21:52 2016 +0100 Create empty dump files (fixes #10320) Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2015 GHC Trac Issues: #10320 >--------------------------------------------------------------- 9f9345e5ad55e4a02e6de9afac814ac58c852ff2 compiler/simplCore/Simplify.hs | 14 +++++++++++++- testsuite/tests/driver/Makefile | 8 ++++++++ testsuite/tests/driver/T10320.hs | 8 ++++++++ testsuite/tests/driver/all.T | 5 +++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs index e905300..debc7d8 100644 --- a/compiler/simplCore/Simplify.hs +++ b/compiler/simplCore/Simplify.hs @@ -1581,7 +1581,9 @@ tryRules env rules fn args call_cont = do { dflags <- getDynFlags ; case lookupRule dflags (getUnfoldingInRuleMatch env) (activeRule env) fn (argInfoAppArgs args) rules of { - Nothing -> return Nothing ; -- No rule matches + Nothing -> + do { nodump dflags -- This ensures that an empty file is written + ; return Nothing } ; -- No rule matches Just (rule, rule_rhs) -> do { checkedTick (RuleFired (ru_name rule)) ; let cont' = pushSimplifiedArgs env @@ -1606,6 +1608,16 @@ tryRules env rules fn args call_cont | otherwise = return () + nodump dflags + | dopt Opt_D_dump_rule_rewrites dflags + = liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_rewrites "" empty + + | dopt Opt_D_dump_rule_firings dflags + = liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_firings "" empty + + | otherwise + = return () + log_rule dflags flag hdr details = liftIO . dumpSDoc dflags alwaysQualify flag "" $ sep [text hdr, nest 4 details] diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile index 50696a7..8c98681 100644 --- a/testsuite/tests/driver/Makefile +++ b/testsuite/tests/driver/Makefile @@ -609,3 +609,11 @@ T10182: "$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs-boot "$(TEST_HC)" $(TEST_HC_OPTS) -c T10182a.hs "$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs + +.PHONY: T10320 +T10320: + $(RM) -rf T10320 T10320.dump-rule-rewrites T10320.hi T10320.o + "$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites -fenable-rewrite-rules T10320.hs + [ -s T10320.dump-rule-rewrites ] + "$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites T10320.hs + [ -f T10320.dump-rule-rewrites ] && [ ! -s T10320.dump-rule-rewrites ] diff --git a/testsuite/tests/driver/T10320.hs b/testsuite/tests/driver/T10320.hs new file mode 100644 index 0000000..f2f613c --- /dev/null +++ b/testsuite/tests/driver/T10320.hs @@ -0,0 +1,8 @@ +-- | Test file for issue #10320. + +module Main (main) where + +main :: IO () +main = print $ map (+1) (map (+1) [1, 2, 3]) + +{-# RULES "map/map" forall f g xs. map f (map g xs) = map (f.g) xs #-} diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index e52eae3..ae75823 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -472,3 +472,8 @@ test('T11429a', normal, compile, ['-Wunrecognised-warning-flags -Wfoobar']) test('T11429b', normal, compile, ['-Wno-unrecognised-warning-flags -Wfoobar']) test('T11429c', normal, compile_fail, ['-Wunrecognised-warning-flags -Werror -Wfoobar']) +test('T10320', + [ ignore_output + , extra_clean(['T10320', 'T10320.o', 'T10320.hi'])], + run_command, + ['$MAKE -s --no-print-directory T10320']) From git at git.haskell.org Thu Mar 24 09:51:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:35 +0000 (UTC) Subject: [commit: ghc] master: DsExpr: Rip out static/dynamic check in list desugaring (0db0594) Message-ID: <20160324095135.A70263A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/0db05941668814094c2b18b3d35e1deaed36c210/ghc >--------------------------------------------------------------- commit 0db05941668814094c2b18b3d35e1deaed36c210 Author: Ben Gamari Date: Wed Mar 23 17:24:45 2016 +0100 DsExpr: Rip out static/dynamic check in list desugaring Previously we would try to break explicit lists into a dynamic prefix and static tail and desugar the former into a `build` expression. Unfortunately, this heuristic resulted in surprising behavior (see #11710) and wasn't pulling its weight. Here we drop it (along with the `-fsimple-list-literals` flag), leaving only the list length heuristic to determine whether `build` or cons list desugaring should be used. Test Plan: Validate Reviewers: simonpj, austin Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2023 GHC Trac Issues: #11710 >--------------------------------------------------------------- 0db05941668814094c2b18b3d35e1deaed36c210 compiler/deSugar/DsExpr.hs | 95 +++++++--------------- compiler/main/DynFlags.hs | 2 - .../tests/simplCore/should_compile/T3234.stderr | 21 +++-- .../tests/simplCore/should_compile/T6056.stderr | 1 - 4 files changed, 41 insertions(+), 78 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 0db05941668814094c2b18b3d35e1deaed36c210 From git at git.haskell.org Thu Mar 24 09:51:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:38 +0000 (UTC) Subject: [commit: ghc] master: Various ticky-related work (6c2c853) Message-ID: <20160324095138.4A3603A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/6c2c853b11fe25c106469da7b105e2be596c17de/ghc >--------------------------------------------------------------- commit 6c2c853b11fe25c106469da7b105e2be596c17de Author: Joachim Breitner Date: Wed Mar 23 16:20:36 2016 +0100 Various ticky-related work this Diff contains small, self-contained changes as I work towards fixing #10613. It is mostly created to let harbormaster do its job, but feedback is welcome as well. Please do not merge this via arc; I?d like to push the individual patches as layed out here. I might push mostly trivial ones even without review, as long as the build passes. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2014 >--------------------------------------------------------------- 6c2c853b11fe25c106469da7b105e2be596c17de compiler/codeGen/StgCmmBind.hs | 13 +++++---- compiler/codeGen/StgCmmProf.hs | 3 +- compiler/codeGen/StgCmmTicky.hs | 62 ++++++++++++++++++++++++++++++----------- rts/sm/Scav.c | 2 +- 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index f34186a..eae599c 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -206,7 +206,7 @@ cgRhs :: Id ) cgRhs id (StgRhsCon cc con args) - = withNewTickyCounterThunk False (idName id) $ -- False for "not static" + = withNewTickyCounterCon (idName id) $ buildDynCon id True cc con args {- See Note [GC recovery] in compiler/codeGen/StgCmmClosure.hs -} @@ -386,7 +386,7 @@ cgRhsStdThunk bndr lf_info payload } where gen_code reg -- AHA! A STANDARD-FORM THUNK - = withNewTickyCounterStdThunk False (idName bndr) $ -- False for "not static" + = withNewTickyCounterStdThunk (lfUpdatable lf_info) (idName bndr) $ do { -- LAY OUT THE OBJECT mod_name <- getModuleName @@ -402,7 +402,6 @@ cgRhsStdThunk bndr lf_info payload -- ; (use_cc, blame_cc) <- chooseDynCostCentres cc [{- no args-}] body ; let use_cc = curCCS; blame_cc = curCCS - ; tickyEnterStdThunk closure_info -- BUILD THE OBJECT ; let info_tbl = mkCmmInfo closure_info @@ -453,7 +452,10 @@ closureCodeBody :: Bool -- whether this is a top-level binding closureCodeBody top_lvl bndr cl_info cc _args arity body fv_details | arity == 0 -- No args i.e. thunk - = withNewTickyCounterThunk (isStaticClosure cl_info) (closureName cl_info) $ + = withNewTickyCounterThunk + (isStaticClosure cl_info) + (closureUpdReqd cl_info) + (closureName cl_info) $ emitClosureProcAndInfoTable top_lvl bndr lf_info info_tbl [] $ \(_, node, _) -> thunkCode cl_info fv_details cc node arity body where @@ -576,8 +578,7 @@ thunkCode cl_info fv_details _cc node arity body -- that cc of enclosing scope will be recorded -- in update frame CAF/DICT functions will be -- subsumed by this enclosing cc - do { tickyEnterThunk cl_info - ; enterCostCentreThunk (CmmReg nodeReg) + do { enterCostCentreThunk (CmmReg nodeReg) ; let lf_info = closureLFInfo cl_info ; fv_bindings <- mapM bind_fv fv_details ; load_fvs node lf_info fv_bindings diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs index c1b149d..434d7b5 100644 --- a/compiler/codeGen/StgCmmProf.hs +++ b/compiler/codeGen/StgCmmProf.hs @@ -328,8 +328,7 @@ ldvRecordCreate closure = do -- -- | Called when a closure is entered, marks the closure as having -- been "used". The closure is not an "inherently used" one. The --- closure is not @IND@ or @IND_OLDGEN@ because neither is considered --- for LDV profiling. +-- closure is not @IND@ because that is not considered for LDV profiling. -- ldvEnterClosure :: ClosureInfo -> CmmReg -> FCode () ldvEnterClosure closure_info node_reg = do diff --git a/compiler/codeGen/StgCmmTicky.hs b/compiler/codeGen/StgCmmTicky.hs index 95dfa99..0ffe6a3 100644 --- a/compiler/codeGen/StgCmmTicky.hs +++ b/compiler/codeGen/StgCmmTicky.hs @@ -70,6 +70,7 @@ module StgCmmTicky ( withNewTickyCounterLNE, withNewTickyCounterThunk, withNewTickyCounterStdThunk, + withNewTickyCounterCon, tickyDynAlloc, tickyAllocHeap, @@ -143,7 +144,13 @@ import Control.Monad ( unless, when ) -- ----------------------------------------------------------------------------- -data TickyClosureType = TickyFun | TickyThunk | TickyLNE +data TickyClosureType + = TickyFun + | TickyCon + | TickyThunk + Bool -- True <-> updateable + Bool -- True <-> standard thunk (AP or selector), has no entry counter + | TickyLNE withNewTickyCounterFun, withNewTickyCounterLNE :: Name -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterFun = withNewTickyCounter TickyFun @@ -152,15 +159,38 @@ withNewTickyCounterLNE nm args code = do b <- tickyLNEIsOn if not b then code else withNewTickyCounter TickyLNE nm args code -withNewTickyCounterThunk,withNewTickyCounterStdThunk :: - Bool -> Name -> FCode a -> FCode a -withNewTickyCounterThunk isStatic name code = do +withNewTickyCounterThunk + :: Bool -- ^ static + -> Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterThunk isStatic isUpdatable name code = do b <- tickyDynThunkIsOn if isStatic || not b -- ignore static thunks then code - else withNewTickyCounter TickyThunk name [] code + else withNewTickyCounter (TickyThunk isUpdatable False) name [] code + +withNewTickyCounterStdThunk + :: Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterStdThunk isUpdatable name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter (TickyThunk isUpdatable True) name [] code -withNewTickyCounterStdThunk = withNewTickyCounterThunk +withNewTickyCounterCon + :: Name + -> FCode a + -> FCode a +withNewTickyCounterCon name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter TickyCon name [] code -- args does not include the void arguments withNewTickyCounter :: TickyClosureType -> Name -> [NonVoid Id] -> FCode a -> FCode a @@ -184,21 +214,21 @@ emitTickyCounter cloType name args ; let ppr_for_ticky_name :: SDoc ppr_for_ticky_name = let n = ppr name + ext = case cloType of + TickyFun -> empty + TickyCon -> parens (text "con") + TickyThunk upd std -> parens $ hcat $ punctuate comma $ + [text "thk"] ++ [text "se"|not upd] ++ [text "std"|std] + TickyLNE | isInternalName name -> parens (text "LNE") + | otherwise -> panic "emitTickyCounter: how is this an external LNE?" p = case hasHaskellName parent of -- NB the default "top" ticky ctr does not -- have a Haskell name Just pname -> text "in" <+> ppr (nameUnique pname) _ -> empty - in (<+> p) $ if isInternalName name - then let s = n <+> (parens (ppr mod_name)) - in case cloType of - TickyFun -> s - TickyThunk -> s <+> parens (text "thk") - TickyLNE -> s <+> parens (text "LNE") - else case cloType of - TickyFun -> n - TickyThunk -> n <+> parens (text "thk") - TickyLNE -> panic "emitTickyCounter: how is this an external LNE?" + in if isInternalName name + then n <+> parens (ppr mod_name) <+> ext <+> p + else n <+> ext <+> p ; fun_descr_lit <- newStringCLit $ showSDocDebug dflags ppr_for_ticky_name ; arg_descr_lit <- newStringCLit $ map (showTypeCategory . idType . unsafe_stripNV) args diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index 953f055..abb7726 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -1533,7 +1533,7 @@ scavenge_one(StgPtr p) } else { size = gen->scan - start; } - debugBelch("evac IND_OLDGEN: %ld bytes", size * sizeof(W_)); + debugBelch("evac IND: %ld bytes", size * sizeof(W_)); } #endif break; From git at git.haskell.org Thu Mar 24 09:51:41 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 09:51:41 +0000 (UTC) Subject: [commit: ghc] master: Add expected output for T9405 (8335cc7) Message-ID: <20160324095141.485EB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/8335cc7350cc5e49ee42a2413461a7fa69ebad6c/ghc >--------------------------------------------------------------- commit 8335cc7350cc5e49ee42a2413461a7fa69ebad6c Author: Ben Gamari Date: Thu Mar 24 05:52:56 2016 -0400 Add expected output for T9405 >--------------------------------------------------------------- 8335cc7350cc5e49ee42a2413461a7fa69ebad6c testsuite/tests/rts/T9405.stdout | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testsuite/tests/rts/T9405.stdout b/testsuite/tests/rts/T9405.stdout new file mode 100644 index 0000000..a62f1c2 --- /dev/null +++ b/testsuite/tests/rts/T9405.stdout @@ -0,0 +1,3 @@ +[1 of 1] Compiling Main ( T9405.hs, T9405.o ) +Linking T9405 ... +Ticky-Ticky From git at git.haskell.org Thu Mar 24 15:12:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 15:12:38 +0000 (UTC) Subject: [commit: ghc] master: Revert "Various ticky-related work" (ef653f1) Message-ID: <20160324151238.0CBB23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/ef653f1f819e5213f7a2a7ea1b78e3fa76c66c8e/ghc >--------------------------------------------------------------- commit ef653f1f819e5213f7a2a7ea1b78e3fa76c66c8e Author: Ben Gamari Date: Thu Mar 24 11:23:31 2016 +0100 Revert "Various ticky-related work" This reverts commit 6c2c853b11fe25c106469da7b105e2be596c17de which was supposed to be merged as individual commits. >--------------------------------------------------------------- ef653f1f819e5213f7a2a7ea1b78e3fa76c66c8e compiler/codeGen/StgCmmBind.hs | 13 ++++----- compiler/codeGen/StgCmmProf.hs | 3 +- compiler/codeGen/StgCmmTicky.hs | 62 +++++++++++------------------------------ rts/sm/Scav.c | 2 +- 4 files changed, 25 insertions(+), 55 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index eae599c..f34186a 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -206,7 +206,7 @@ cgRhs :: Id ) cgRhs id (StgRhsCon cc con args) - = withNewTickyCounterCon (idName id) $ + = withNewTickyCounterThunk False (idName id) $ -- False for "not static" buildDynCon id True cc con args {- See Note [GC recovery] in compiler/codeGen/StgCmmClosure.hs -} @@ -386,7 +386,7 @@ cgRhsStdThunk bndr lf_info payload } where gen_code reg -- AHA! A STANDARD-FORM THUNK - = withNewTickyCounterStdThunk (lfUpdatable lf_info) (idName bndr) $ + = withNewTickyCounterStdThunk False (idName bndr) $ -- False for "not static" do { -- LAY OUT THE OBJECT mod_name <- getModuleName @@ -402,6 +402,7 @@ cgRhsStdThunk bndr lf_info payload -- ; (use_cc, blame_cc) <- chooseDynCostCentres cc [{- no args-}] body ; let use_cc = curCCS; blame_cc = curCCS + ; tickyEnterStdThunk closure_info -- BUILD THE OBJECT ; let info_tbl = mkCmmInfo closure_info @@ -452,10 +453,7 @@ closureCodeBody :: Bool -- whether this is a top-level binding closureCodeBody top_lvl bndr cl_info cc _args arity body fv_details | arity == 0 -- No args i.e. thunk - = withNewTickyCounterThunk - (isStaticClosure cl_info) - (closureUpdReqd cl_info) - (closureName cl_info) $ + = withNewTickyCounterThunk (isStaticClosure cl_info) (closureName cl_info) $ emitClosureProcAndInfoTable top_lvl bndr lf_info info_tbl [] $ \(_, node, _) -> thunkCode cl_info fv_details cc node arity body where @@ -578,7 +576,8 @@ thunkCode cl_info fv_details _cc node arity body -- that cc of enclosing scope will be recorded -- in update frame CAF/DICT functions will be -- subsumed by this enclosing cc - do { enterCostCentreThunk (CmmReg nodeReg) + do { tickyEnterThunk cl_info + ; enterCostCentreThunk (CmmReg nodeReg) ; let lf_info = closureLFInfo cl_info ; fv_bindings <- mapM bind_fv fv_details ; load_fvs node lf_info fv_bindings diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs index 434d7b5..c1b149d 100644 --- a/compiler/codeGen/StgCmmProf.hs +++ b/compiler/codeGen/StgCmmProf.hs @@ -328,7 +328,8 @@ ldvRecordCreate closure = do -- -- | Called when a closure is entered, marks the closure as having -- been "used". The closure is not an "inherently used" one. The --- closure is not @IND@ because that is not considered for LDV profiling. +-- closure is not @IND@ or @IND_OLDGEN@ because neither is considered +-- for LDV profiling. -- ldvEnterClosure :: ClosureInfo -> CmmReg -> FCode () ldvEnterClosure closure_info node_reg = do diff --git a/compiler/codeGen/StgCmmTicky.hs b/compiler/codeGen/StgCmmTicky.hs index 0ffe6a3..95dfa99 100644 --- a/compiler/codeGen/StgCmmTicky.hs +++ b/compiler/codeGen/StgCmmTicky.hs @@ -70,7 +70,6 @@ module StgCmmTicky ( withNewTickyCounterLNE, withNewTickyCounterThunk, withNewTickyCounterStdThunk, - withNewTickyCounterCon, tickyDynAlloc, tickyAllocHeap, @@ -144,13 +143,7 @@ import Control.Monad ( unless, when ) -- ----------------------------------------------------------------------------- -data TickyClosureType - = TickyFun - | TickyCon - | TickyThunk - Bool -- True <-> updateable - Bool -- True <-> standard thunk (AP or selector), has no entry counter - | TickyLNE +data TickyClosureType = TickyFun | TickyThunk | TickyLNE withNewTickyCounterFun, withNewTickyCounterLNE :: Name -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterFun = withNewTickyCounter TickyFun @@ -159,38 +152,15 @@ withNewTickyCounterLNE nm args code = do b <- tickyLNEIsOn if not b then code else withNewTickyCounter TickyLNE nm args code -withNewTickyCounterThunk - :: Bool -- ^ static - -> Bool -- ^ updateable - -> Name - -> FCode a - -> FCode a -withNewTickyCounterThunk isStatic isUpdatable name code = do +withNewTickyCounterThunk,withNewTickyCounterStdThunk :: + Bool -> Name -> FCode a -> FCode a +withNewTickyCounterThunk isStatic name code = do b <- tickyDynThunkIsOn if isStatic || not b -- ignore static thunks then code - else withNewTickyCounter (TickyThunk isUpdatable False) name [] code - -withNewTickyCounterStdThunk - :: Bool -- ^ updateable - -> Name - -> FCode a - -> FCode a -withNewTickyCounterStdThunk isUpdatable name code = do - b <- tickyDynThunkIsOn - if not b - then code - else withNewTickyCounter (TickyThunk isUpdatable True) name [] code + else withNewTickyCounter TickyThunk name [] code -withNewTickyCounterCon - :: Name - -> FCode a - -> FCode a -withNewTickyCounterCon name code = do - b <- tickyDynThunkIsOn - if not b - then code - else withNewTickyCounter TickyCon name [] code +withNewTickyCounterStdThunk = withNewTickyCounterThunk -- args does not include the void arguments withNewTickyCounter :: TickyClosureType -> Name -> [NonVoid Id] -> FCode a -> FCode a @@ -214,21 +184,21 @@ emitTickyCounter cloType name args ; let ppr_for_ticky_name :: SDoc ppr_for_ticky_name = let n = ppr name - ext = case cloType of - TickyFun -> empty - TickyCon -> parens (text "con") - TickyThunk upd std -> parens $ hcat $ punctuate comma $ - [text "thk"] ++ [text "se"|not upd] ++ [text "std"|std] - TickyLNE | isInternalName name -> parens (text "LNE") - | otherwise -> panic "emitTickyCounter: how is this an external LNE?" p = case hasHaskellName parent of -- NB the default "top" ticky ctr does not -- have a Haskell name Just pname -> text "in" <+> ppr (nameUnique pname) _ -> empty - in if isInternalName name - then n <+> parens (ppr mod_name) <+> ext <+> p - else n <+> ext <+> p + in (<+> p) $ if isInternalName name + then let s = n <+> (parens (ppr mod_name)) + in case cloType of + TickyFun -> s + TickyThunk -> s <+> parens (text "thk") + TickyLNE -> s <+> parens (text "LNE") + else case cloType of + TickyFun -> n + TickyThunk -> n <+> parens (text "thk") + TickyLNE -> panic "emitTickyCounter: how is this an external LNE?" ; fun_descr_lit <- newStringCLit $ showSDocDebug dflags ppr_for_ticky_name ; arg_descr_lit <- newStringCLit $ map (showTypeCategory . idType . unsafe_stripNV) args diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index abb7726..953f055 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -1533,7 +1533,7 @@ scavenge_one(StgPtr p) } else { size = gen->scan - start; } - debugBelch("evac IND: %ld bytes", size * sizeof(W_)); + debugBelch("evac IND_OLDGEN: %ld bytes", size * sizeof(W_)); } #endif break; From git at git.haskell.org Thu Mar 24 15:12:40 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 15:12:40 +0000 (UTC) Subject: [commit: ghc] master: Show: Restore redundant parentheses around records (1448f8a) Message-ID: <20160324151240.B76623A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1448f8ab2379452312f1f74f6d5ba4de8ad3d47e/ghc >--------------------------------------------------------------- commit 1448f8ab2379452312f1f74f6d5ba4de8ad3d47e Author: Ben Gamari Date: Thu Mar 24 10:54:11 2016 +0100 Show: Restore redundant parentheses around records As discussed in #2530 we are going to continue to produce parentheses here in order to preserve compatibility with previous GHC releases. It was found that dropped parentheses would break some testsuites which compared against output from Show. This has been documented in the users guide. This reverts commit 5692643c9d17e746327588cd6157a923642b7975. Test Plan: Validate Reviewers: hvr, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2027 GHC Trac Issues: #2350 >--------------------------------------------------------------- 1448f8ab2379452312f1f74f6d5ba4de8ad3d47e compiler/hsSyn/HsExpr.hs | 6 ++---- compiler/typecheck/TcGenDeriv.hs | 2 -- docs/users_guide/bugs.rst | 15 +++++++++++++++ testsuite/tests/codeGen/should_run/T7953.stdout | 4 ++-- testsuite/tests/deriving/should_run/drvrun020.stdout | 2 +- .../tests/ghc-api/annotations-literals/literals.stdout | 6 +++--- 6 files changed, 23 insertions(+), 12 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 1448f8ab2379452312f1f74f6d5ba4de8ad3d47e From git at git.haskell.org Thu Mar 24 15:12:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 15:12:44 +0000 (UTC) Subject: [commit: ghc] master: Default RuntimeRep variables unless -fprint-explicit-runtime-reps (371608f) Message-ID: <20160324151244.7DB5C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/371608f1cdaf20c49eb6c5ec165b9eb08b745a89/ghc >--------------------------------------------------------------- commit 371608f1cdaf20c49eb6c5ec165b9eb08b745a89 Author: Ben Gamari Date: Thu Mar 24 11:39:59 2016 +0100 Default RuntimeRep variables unless -fprint-explicit-runtime-reps Summary: Addresses #11549 by defaulting `RuntimeRep` variables to `PtrRepLifted` and adding a new compiler flag `-fprint-explicit-runtime-reps` to disable this behavior. This is just a guess at the right way to go about this. If it's wrong-beyond-any-hope just say so. Test Plan: Working on a testcase Reviewers: goldfire, austin Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1961 GHC Trac Issues: #11549 >--------------------------------------------------------------- 371608f1cdaf20c49eb6c5ec165b9eb08b745a89 compiler/main/DynFlags.hs | 2 + compiler/prelude/TysWiredIn.hs-boot | 1 + compiler/types/TyCoRep.hs | 89 +++++++++++++++++++++- docs/users_guide/using.rst | 16 ++++ testsuite/tests/dependent/ghci/T11549.script | 14 ++++ testsuite/tests/dependent/ghci/T11549.stdout | 12 +++ testsuite/tests/dependent/ghci/all.T | 3 + .../dependent/should_fail/TypeSkolEscape.stderr | 2 +- testsuite/tests/ghci/scripts/T7627.stdout | 10 +-- utils/mkUserGuidePart/Options/Verbosity.hs | 7 ++ 10 files changed, 144 insertions(+), 12 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 371608f1cdaf20c49eb6c5ec165b9eb08b745a89 From git at git.haskell.org Thu Mar 24 15:12:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 15:12:47 +0000 (UTC) Subject: [commit: ghc] master: Defer inlining of Eq for primitive types (0bd0c31) Message-ID: <20160324151247.341353A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/0bd0c31e833055eb3e86177f70c4b4d93d5a1c11/ghc >--------------------------------------------------------------- commit 0bd0c31e833055eb3e86177f70c4b4d93d5a1c11 Author: Ben Gamari Date: Thu Mar 24 11:24:32 2016 +0100 Defer inlining of Eq for primitive types Summary: This is one solution to #11688, wherein (==) was inlined to soon defeating a rewrite rule provided by bytestring. Since the RHSs of Eq's methods are simple, there is little to be gained and much to be lost by inlining them early. For instance, the bytestring library provides, ```lang=haskell break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString) breakByte :: Word8 -> ByteString -> (ByteString, ByteString) ``` and a rule ``` forall x. break ((==) x) = breakByte x ``` since `breakByte` implments an optimized version of `break (== x)` for known `x :: Word8`. If we allow `(==)` to be inlined too early, we will prevent this rule from firing. This was the cause of #11688. This patch just defers the `Eq` methods, although it's likely worthwhile giving `Ord` this same treatment. This regresses compiler allocations for T9661 by about 8% due to the additional inlining that we now require the simplifier to perform. Updates the `bytestring` submodule to include updated rewrite rules which match on `eqWord8` instead of `(==)`. Test Plan: * Validate, examine performance impact Reviewers: simonpj, hvr, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1980 GHC Trac Issues: #11688 >--------------------------------------------------------------- 0bd0c31e833055eb3e86177f70c4b4d93d5a1c11 libraries/base/GHC/Char.hs | 9 +++- libraries/base/GHC/Float.hs | 20 +++++---- libraries/base/GHC/Int.hs | 74 +++++++++++++++++++++++++++---- libraries/base/GHC/Word.hs | 77 +++++++++++++++++++++++++++++--- libraries/ghc-prim/GHC/Classes.hs | 87 +++++++++++++++++++++++++++++++++---- testsuite/tests/perf/compiler/all.T | 5 ++- 6 files changed, 236 insertions(+), 36 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 0bd0c31e833055eb3e86177f70c4b4d93d5a1c11 From git at git.haskell.org Thu Mar 24 17:29:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 17:29:35 +0000 (UTC) Subject: [commit: ghc] master: Tidy up handling of coercion variables (cb08f8d) Message-ID: <20160324172935.4091E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/cb08f8da37ff5fb99e1d02b8afdcb802d23e9a8d/ghc >--------------------------------------------------------------- commit cb08f8da37ff5fb99e1d02b8afdcb802d23e9a8d Author: Simon Peyton Jones Date: Thu Mar 24 17:31:12 2016 +0000 Tidy up handling of coercion variables * Comments to explain that a CoVar, whose IdInfo is CoVarId, is always unlifted (but may be nominal or representational role) And TyCoRep.isCoercionType picks out only those unlifted types, NOT the lifted versions * Introduce Var.NcId for non-co-var Ids with predicate isNonCoVarId * Add assertions in CoreSubst that the Id env is only used for NcIds * Fix lurking bug in CSE which extended the CoreSubst Id env with a CoVar * Fix two bugs in Specialise.spec_call, which wrongly treated CoVars like NcIds - needed a varToCoreExpr in one place - needed extendSubst not extendIdSubst in another This was the root cause of Trac #11644 Minor refactoring * Eliminate unused mkDerivedLocalCoVarM, mkUserLocalCoVar * Small refactor in mkSysLocalOrCoVar >--------------------------------------------------------------- cb08f8da37ff5fb99e1d02b8afdcb802d23e9a8d compiler/basicTypes/Id.hs | 20 ++---------- compiler/basicTypes/IdInfo.hs | 4 ++- compiler/basicTypes/Var.hs | 37 +++++++++++++++------- compiler/coreSyn/CoreLint.hs | 2 +- compiler/coreSyn/CoreSubst.hs | 12 ++++--- compiler/simplCore/CSE.hs | 16 ++++++---- compiler/specialise/Specialise.hs | 14 +++++--- compiler/types/TyCoRep.hs | 4 ++- .../should_compile/T11644.hs} | 2 +- testsuite/tests/simplCore/should_compile/all.T | 1 + 10 files changed, 64 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc cb08f8da37ff5fb99e1d02b8afdcb802d23e9a8d From git at git.haskell.org Thu Mar 24 17:29:37 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 17:29:37 +0000 (UTC) Subject: [commit: ghc] master: Comments only (2b5929c) Message-ID: <20160324172937.E41AE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2b5929cc4390d03de2c4ae950d7e2a69b5065f2a/ghc >--------------------------------------------------------------- commit 2b5929cc4390d03de2c4ae950d7e2a69b5065f2a Author: Simon Peyton Jones Date: Thu Mar 24 17:21:56 2016 +0000 Comments only >--------------------------------------------------------------- 2b5929cc4390d03de2c4ae950d7e2a69b5065f2a compiler/types/Coercion.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs index a2b93bd..64e2c5b 100644 --- a/compiler/types/Coercion.hs +++ b/compiler/types/Coercion.hs @@ -133,7 +133,7 @@ import Data.Function ( on ) -- The coercion arguments always *precisely* saturate -- arity of (that branch of) the CoAxiom. If there are -- any left over, we use AppCo. See - -- See [Coercion axioms applied to coercions] + -- See [Coercion axioms applied to coercions] in TyCoRep \subsection{Coercion variables} %* * From git at git.haskell.org Thu Mar 24 19:41:52 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 19:41:52 +0000 (UTC) Subject: [commit: ghc] master: Avoid local label syntax for assembler on AIX (343349d) Message-ID: <20160324194152.ACD5D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/343349df1f19f21899818d647bf570e489d0cf8f/ghc >--------------------------------------------------------------- commit 343349df1f19f21899818d647bf570e489d0cf8f Author: Herbert Valerio Riedel Date: Thu Mar 24 20:35:42 2016 +0100 Avoid local label syntax for assembler on AIX Unfortunately (for inline `__asm__()` uses), IBM's `as` doesn't seem to support local labels[1] like GNU `as` does so we need to workaround this when on AIX. [1]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Symbol-Names Turns out this also addresses the long-standing bug #485 Reviewed By: bgamari, trommler Differential Revision: https://phabricator.haskell.org/D2029 >--------------------------------------------------------------- 343349df1f19f21899818d647bf570e489d0cf8f includes/stg/SMP.h | 20 ++++++++++++++++++++ rts/AdjustorAsm.S | 14 +++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h index 756f040..21f05ed 100644 --- a/includes/stg/SMP.h +++ b/includes/stg/SMP.h @@ -121,9 +121,18 @@ xchg(StgPtr p, StgWord w) ); #elif powerpc_HOST_ARCH __asm__ __volatile__ ( +# if aix_HOST_OS + /* IBM's assembler doesn't seem to support local labels so we use + * explicit relative numeric offsets to workaround this limitation + */ + " lwarx %0, 0, %2\n" + " stwcx. %1, 0, %2\n" + " bne- $-8" +# else // aix_HOST_OS "1: lwarx %0, 0, %2\n" " stwcx. %1, 0, %2\n" " bne- 1b" +# endif :"=&r" (result) :"r" (w), "r" (p) ); @@ -205,12 +214,23 @@ cas(StgVolatilePtr p, StgWord o, StgWord n) #elif powerpc_HOST_ARCH StgWord result; __asm__ __volatile__ ( +# if aix_HOST_OS + /* IBM's assembler doesn't seem to support local labels so we use + * explicit relative numeric offsets to workaround this limitation + */ + " lwarx %0, 0, %3\n" + " cmpw %0, %1\n" + " bne $+12\n" + " stwcx. %2, 0, %3\n" + " bne- $-16\n" +# else // aix_HOST_OS "1: lwarx %0, 0, %3\n" " cmpw %0, %1\n" " bne 2f\n" " stwcx. %2, 0, %3\n" " bne- 1b\n" "2:" +# endif // !aix_HOST_OS :"=&r" (result) :"r" (o), "r" (n), "r" (p) :"cc", "memory" diff --git a/rts/AdjustorAsm.S b/rts/AdjustorAsm.S index ca7ae36..1713acb 100644 --- a/rts/AdjustorAsm.S +++ b/rts/AdjustorAsm.S @@ -63,8 +63,12 @@ #define r31 31 #endif - +#if defined(aix_HOST_OS) +/* IBM's assembler needs a different pseudo-op to declare a .text section */ +.csect .text[PR] +#else .text +#endif #if LEADING_UNDERSCORE .globl _adjustorCode _adjustorCode: @@ -101,14 +105,14 @@ adjustorCode: LOAD r12, EXTRA_WORDS_OFF(r2) mtctr r12 - b 2f -1: + b L2 +L1: LOAD r0, LINKAGE_AREA_SIZE + 8*WS(r30) STORE r0, LINKAGE_AREA_SIZE + 10*WS(r31) addi r30, r30, WS addi r31, r31, WS -2: - bdnz 1b +L2: + bdnz L1 /* Restore r30 and r31 now. */ From git at git.haskell.org Thu Mar 24 19:52:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 19:52:38 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Avoid local label syntax for assembler on AIX (ade015c) Message-ID: <20160324195238.BDA473A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/ade015c7ff269a3947dd414143048f638be0ff46/ghc >--------------------------------------------------------------- commit ade015c7ff269a3947dd414143048f638be0ff46 Author: Herbert Valerio Riedel Date: Thu Mar 24 20:35:42 2016 +0100 Avoid local label syntax for assembler on AIX Unfortunately (for inline `__asm__()` uses), IBM's `as` doesn't seem to support local labels[1] like GNU `as` does so we need to workaround this when on AIX. [1]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Symbol-Names Turns out this also addresses the long-standing bug #485 (cherry picked from commit 343349df1f19f21899818d647bf570e489d0cf8f) >--------------------------------------------------------------- ade015c7ff269a3947dd414143048f638be0ff46 includes/stg/SMP.h | 20 ++++++++++++++++++++ rts/AdjustorAsm.S | 14 +++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h index 756f040..21f05ed 100644 --- a/includes/stg/SMP.h +++ b/includes/stg/SMP.h @@ -121,9 +121,18 @@ xchg(StgPtr p, StgWord w) ); #elif powerpc_HOST_ARCH __asm__ __volatile__ ( +# if aix_HOST_OS + /* IBM's assembler doesn't seem to support local labels so we use + * explicit relative numeric offsets to workaround this limitation + */ + " lwarx %0, 0, %2\n" + " stwcx. %1, 0, %2\n" + " bne- $-8" +# else // aix_HOST_OS "1: lwarx %0, 0, %2\n" " stwcx. %1, 0, %2\n" " bne- 1b" +# endif :"=&r" (result) :"r" (w), "r" (p) ); @@ -205,12 +214,23 @@ cas(StgVolatilePtr p, StgWord o, StgWord n) #elif powerpc_HOST_ARCH StgWord result; __asm__ __volatile__ ( +# if aix_HOST_OS + /* IBM's assembler doesn't seem to support local labels so we use + * explicit relative numeric offsets to workaround this limitation + */ + " lwarx %0, 0, %3\n" + " cmpw %0, %1\n" + " bne $+12\n" + " stwcx. %2, 0, %3\n" + " bne- $-16\n" +# else // aix_HOST_OS "1: lwarx %0, 0, %3\n" " cmpw %0, %1\n" " bne 2f\n" " stwcx. %2, 0, %3\n" " bne- 1b\n" "2:" +# endif // !aix_HOST_OS :"=&r" (result) :"r" (o), "r" (n), "r" (p) :"cc", "memory" diff --git a/rts/AdjustorAsm.S b/rts/AdjustorAsm.S index ca7ae36..1713acb 100644 --- a/rts/AdjustorAsm.S +++ b/rts/AdjustorAsm.S @@ -63,8 +63,12 @@ #define r31 31 #endif - +#if defined(aix_HOST_OS) +/* IBM's assembler needs a different pseudo-op to declare a .text section */ +.csect .text[PR] +#else .text +#endif #if LEADING_UNDERSCORE .globl _adjustorCode _adjustorCode: @@ -101,14 +105,14 @@ adjustorCode: LOAD r12, EXTRA_WORDS_OFF(r2) mtctr r12 - b 2f -1: + b L2 +L1: LOAD r0, LINKAGE_AREA_SIZE + 8*WS(r30) STORE r0, LINKAGE_AREA_SIZE + 10*WS(r31) addi r30, r30, WS addi r31, r31, WS -2: - bdnz 1b +L2: + bdnz L1 /* Restore r30 and r31 now. */ From git at git.haskell.org Thu Mar 24 21:59:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 21:59:55 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Close ticky profiling file stream after printing (#9405) (803cbd8) Message-ID: <20160324215955.DD75F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/803cbd8b02b7f33f0c464321cde0e3a810562ba0/ghc >--------------------------------------------------------------- commit 803cbd8b02b7f33f0c464321cde0e3a810562ba0 Author: Flaviu Andrei Csernik Date: Wed Mar 23 16:18:11 2016 +0100 Close ticky profiling file stream after printing (#9405) Test Plan: T9405 Reviewers: simonmar, austin, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2008 GHC Trac Issues: #9405 (cherry picked from commit 2708c22b8c8a415446d963575c0396a038b43a93) >--------------------------------------------------------------- 803cbd8b02b7f33f0c464321cde0e3a810562ba0 rts/RtsFlags.c | 4 +++- rts/RtsStartup.c | 3 +++ testsuite/tests/rts/Makefile | 9 +++++++++ testsuite/tests/rts/T9405.hs | 3 +++ testsuite/tests/rts/T9405.stdout | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 46d1409..b497429 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -589,9 +589,11 @@ void setupRtsFlags (int *argc, char *argv[], RtsConfig rts_config) if (RtsFlags.GcFlags.statsFile != NULL) { initStatsFile (RtsFlags.GcFlags.statsFile); } +#ifdef TICKY_TICKY if (RtsFlags.TickyFlags.tickyFile != NULL) { - initStatsFile (RtsFlags.GcFlags.statsFile); + initStatsFile (RtsFlags.TickyFlags.tickyFile); } +#endif } /* ----------------------------------------------------------------------------- diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index bd6a6ae..4b9d947 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -408,6 +408,9 @@ hs_exit_(rtsBool wait_foreign) #if defined(TICKY_TICKY) if (RtsFlags.TickyFlags.showTickyStats) PrintTickyInfo(); + + FILE *tf = RtsFlags.TickyFlags.tickyFile; + if (tf != NULL) fclose(tf); #endif #if defined(mingw32_HOST_OS) && !defined(THREADED_RTS) diff --git a/testsuite/tests/rts/Makefile b/testsuite/tests/rts/Makefile index 52de19c..02255a6 100644 --- a/testsuite/tests/rts/Makefile +++ b/testsuite/tests/rts/Makefile @@ -45,6 +45,15 @@ T5423: "$(TEST_HC)" $(TEST_HC_OPTS) -v0 T5423.o T5423_cmm.o -o T5423$(exeext) ./T5423 +.PHONY: T9405 +T9405: + @'$(TEST_HC)' $(TEST_HC_OPTS) -ticky -rtsopts T9405.hs; \ + ./T9405 +RTS -rT9405.ticky & \ + sleep 0.2; \ + kill -2 $$!; \ + wait $$!; \ + [ -s T9405.ticky ] && echo Ticky-Ticky + # Naming convention: 'T5423_' obj-way '_' obj-src # obj-way ::= v | dyn # obj-src ::= gcc // using __attribute__(constructor) diff --git a/testsuite/tests/rts/T9405.hs b/testsuite/tests/rts/T9405.hs new file mode 100644 index 0000000..ca68e10 --- /dev/null +++ b/testsuite/tests/rts/T9405.hs @@ -0,0 +1,3 @@ +import Control.Concurrent + +main = threadDelay 2000000 diff --git a/testsuite/tests/rts/T9405.stdout b/testsuite/tests/rts/T9405.stdout new file mode 100644 index 0000000..a62f1c2 --- /dev/null +++ b/testsuite/tests/rts/T9405.stdout @@ -0,0 +1,3 @@ +[1 of 1] Compiling Main ( T9405.hs, T9405.o ) +Linking T9405 ... +Ticky-Ticky From git at git.haskell.org Thu Mar 24 21:59:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 21:59:58 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: DsExpr: Rip out static/dynamic check in list desugaring (f733608) Message-ID: <20160324215958.935053A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/f733608e5e303ebcd0002c329f44fa056cb99b88/ghc >--------------------------------------------------------------- commit f733608e5e303ebcd0002c329f44fa056cb99b88 Author: Ben Gamari Date: Wed Mar 23 17:24:45 2016 +0100 DsExpr: Rip out static/dynamic check in list desugaring Previously we would try to break explicit lists into a dynamic prefix and static tail and desugar the former into a `build` expression. Unfortunately, this heuristic resulted in surprising behavior (see #11710) and wasn't pulling its weight. Here we drop it (along with the `-fsimple-list-literals` flag), leaving only the list length heuristic to determine whether `build` or cons list desugaring should be used. Test Plan: Validate Reviewers: simonpj, austin Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2023 GHC Trac Issues: #11710 (cherry picked from commit 0db05941668814094c2b18b3d35e1deaed36c210) >--------------------------------------------------------------- f733608e5e303ebcd0002c329f44fa056cb99b88 compiler/deSugar/DsExpr.hs | 95 +++++++--------------- compiler/main/DynFlags.hs | 2 - .../tests/simplCore/should_compile/T3234.stderr | 21 +++-- .../tests/simplCore/should_compile/T6056.stderr | 1 - 4 files changed, 41 insertions(+), 78 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc f733608e5e303ebcd0002c329f44fa056cb99b88 From git at git.haskell.org Thu Mar 24 22:00:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:01 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: add regression test for #11145. (1d87402) Message-ID: <20160324220001.EE8103A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1d874025de87e9e987c84de4e6926bf199245545/ghc >--------------------------------------------------------------- commit 1d874025de87e9e987c84de4e6926bf199245545 Author: Dominik Bollmann Date: Fri Mar 11 10:38:28 2016 +0100 add regression test for #11145. The original TH failure observed by the ticket, namely that Template Haskell quotes of data instance GADTs are broken, is not observable anymore in HEAD. I therefore just added the corresponding regression test. Test Plan: ./validate Reviewers: goldfire, austin, thomie, jstolarek, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1978 GHC Trac Issues: #11145 (cherry picked from commit f3def7643d390db54d18b8c3d385c490fba58a41) >--------------------------------------------------------------- 1d874025de87e9e987c84de4e6926bf199245545 testsuite/tests/th/T11145.hs | 9 +++++++++ testsuite/tests/th/T11145.stderr | 8 ++++++++ testsuite/tests/th/all.T | 1 + 3 files changed, 18 insertions(+) diff --git a/testsuite/tests/th/T11145.hs b/testsuite/tests/th/T11145.hs new file mode 100644 index 0000000..f3968e9 --- /dev/null +++ b/testsuite/tests/th/T11145.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TemplateHaskell #-} +module T11145 where + +data family Fuggle x y + +[d| data instance Fuggle Int (Maybe (a,b)) where + MkFuggle :: Fuggle Int (Maybe Bool) |] diff --git a/testsuite/tests/th/T11145.stderr b/testsuite/tests/th/T11145.stderr new file mode 100644 index 0000000..98e518c --- /dev/null +++ b/testsuite/tests/th/T11145.stderr @@ -0,0 +1,8 @@ + +T11145.hs:8:1: error: + ? Data constructor ?MkFuggle? returns type ?Fuggle + Int (Maybe Bool)? + instead of an instance of its parent type ?Fuggle + Int (Maybe (a_a4MU, b_a4MV))? + ? In the definition of data constructor ?MkFuggle? + In the data instance declaration for ?Fuggle? diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index db84c607..2116606 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -399,3 +399,4 @@ test('T11345', normal, compile_and_run, ['-v0 -dsuppress-uniques']) test('TH_finalizer', normal, compile, ['-v0']) test('T10603', normal, compile, ['-ddump-splices -dsuppress-uniques']) test('T11452', normal, compile_fail, ['-v0']) +test('T11145', normal, compile_fail, ['-v0']) From git at git.haskell.org Thu Mar 24 22:00:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:05 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add test for incompatible flags (issue #11580) (9f8e1d9) Message-ID: <20160324220005.31DBF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/9f8e1d93460b7f8cb4137cab743d52e97b69f76a/ghc >--------------------------------------------------------------- commit 9f8e1d93460b7f8cb4137cab743d52e97b69f76a Author: Kai Harries Date: Sun Mar 20 17:51:39 2016 +0100 Add test for incompatible flags (issue #11580) Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2013 GHC Trac Issues: #11580 (cherry picked from commit 289d57a6894b5d3eb5daf696a75275a8146f0092) >--------------------------------------------------------------- 9f8e1d93460b7f8cb4137cab743d52e97b69f76a testsuite/tests/safeHaskell/flags/SafeFlags30.hs | 7 +++++++ testsuite/tests/safeHaskell/flags/SafeFlags30.stderr | 3 +++ testsuite/tests/safeHaskell/flags/all.T | 1 + 3 files changed, 11 insertions(+) diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags30.hs b/testsuite/tests/safeHaskell/flags/SafeFlags30.hs new file mode 100644 index 0000000..27790a4 --- /dev/null +++ b/testsuite/tests/safeHaskell/flags/SafeFlags30.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE Safe, Unsafe, Trustworthy #-} +-- | Basic test to see that incompatible flags give a nice error +-- message and ghc do not panic (see issue #11580). +module SafeFlags30 where + +f :: Int +f = 1 diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags30.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags30.stderr new file mode 100644 index 0000000..11ff3a6 --- /dev/null +++ b/testsuite/tests/safeHaskell/flags/SafeFlags30.stderr @@ -0,0 +1,3 @@ +ghc: SafeFlags30.hs:1:20-25: Incompatible Safe Haskell flags! (Safe, Unsafe) +SafeFlags30.hs:1:28-38: Incompatible Safe Haskell flags! (Safe, Trustworthy) +Usage: For basic information, try the `--help' option. diff --git a/testsuite/tests/safeHaskell/flags/all.T b/testsuite/tests/safeHaskell/flags/all.T index fff8841..0fa30e5 100644 --- a/testsuite/tests/safeHaskell/flags/all.T +++ b/testsuite/tests/safeHaskell/flags/all.T @@ -62,3 +62,4 @@ test('SafeFlags29', normal, compile_fail, ['']) test('Flags01', normal, compile, ['-XSafe']) test('Flags02', normal, compile, ['-XSafe']) +test('SafeFlags30', normal, compile_fail, ['']) From git at git.haskell.org Thu Mar 24 22:00:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:08 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: ErrUtils: Add timings to compiler phases (11d5727) Message-ID: <20160324220008.22E323A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/11d572729693b08215a0b3606b274b625d87f2a2/ghc >--------------------------------------------------------------- commit 11d572729693b08215a0b3606b274b625d87f2a2 Author: Ben Gamari Date: Wed Mar 23 16:11:45 2016 +0100 ErrUtils: Add timings to compiler phases This adds timings and allocation figures to the compiler's output when run with `-v2` in an effort to ease performance analysis. Todo: * Documentation * Where else should we add these? * Perhaps we should remove some of the now-arguably-redundant `showPass` occurrences where they are * Must we force more? * Perhaps we should place this behind a `-ftimings` instead of `-v2` Test Plan: `ghc -v2 Test.hs`, look at the output Reviewers: hvr, goldfire, simonmar, austin Reviewed By: simonmar Subscribers: angerman, michalt, niteria, ezyang, thomie Differential Revision: https://phabricator.haskell.org/D1959 (cherry picked from commit 8048d51be0676627b417c128af0b0c352b75c537) >--------------------------------------------------------------- 11d572729693b08215a0b3606b274b625d87f2a2 compiler/cmm/CmmParse.y | 3 +- compiler/coreSyn/CoreLint.hs | 9 +----- compiler/coreSyn/CorePrep.hs | 16 ++++++---- compiler/deSugar/Desugar.hs | 9 +++--- compiler/ghci/ByteCodeGen.hs | 15 +++++----- compiler/llvmGen/LlvmCodeGen.hs | 3 +- compiler/llvmGen/LlvmMangler.hs | 7 +++-- compiler/main/CodeOutput.hs | 7 +++-- compiler/main/ErrUtils.hs | 58 +++++++++++++++++++++++++++++++++++- compiler/main/GhcMake.hs | 19 ++++++------ compiler/main/HscMain.hs | 63 +++++++++++++++++++++------------------- compiler/main/TidyPgm.hs | 23 ++++++++++----- compiler/simplCore/SimplCore.hs | 39 ++++++++++++++----------- compiler/typecheck/TcRnDriver.hs | 12 ++++---- compiler/utils/Outputable.hs | 8 ++++- docs/users_guide/debugging.rst | 10 ++++++- docs/users_guide/using.rst | 4 +-- 17 files changed, 197 insertions(+), 108 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 11d572729693b08215a0b3606b274b625d87f2a2 From git at git.haskell.org Thu Mar 24 22:00:11 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:11 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Create empty dump files (fixes #10320) (1624fd9) Message-ID: <20160324220011.64D053A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1624fd9c108ff51fbb75eebaf7ead1786d99437c/ghc >--------------------------------------------------------------- commit 1624fd9c108ff51fbb75eebaf7ead1786d99437c Author: Kai Harries Date: Wed Mar 23 16:21:52 2016 +0100 Create empty dump files (fixes #10320) Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2015 GHC Trac Issues: #10320 (cherry picked from commit 9f9345e5ad55e4a02e6de9afac814ac58c852ff2) >--------------------------------------------------------------- 1624fd9c108ff51fbb75eebaf7ead1786d99437c compiler/simplCore/Simplify.hs | 14 +++++++++++++- testsuite/tests/driver/Makefile | 8 ++++++++ testsuite/tests/driver/T10320.hs | 8 ++++++++ testsuite/tests/driver/all.T | 5 +++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs index 5aa5881..ae44ee2 100644 --- a/compiler/simplCore/Simplify.hs +++ b/compiler/simplCore/Simplify.hs @@ -1581,7 +1581,9 @@ tryRules env rules fn args call_cont = do { dflags <- getDynFlags ; case lookupRule dflags (getUnfoldingInRuleMatch env) (activeRule env) fn (argInfoAppArgs args) rules of { - Nothing -> return Nothing ; -- No rule matches + Nothing -> + do { nodump dflags -- This ensures that an empty file is written + ; return Nothing } ; -- No rule matches Just (rule, rule_rhs) -> do { checkedTick (RuleFired (ru_name rule)) ; let cont' = pushSimplifiedArgs env @@ -1606,6 +1608,16 @@ tryRules env rules fn args call_cont | otherwise = return () + nodump dflags + | dopt Opt_D_dump_rule_rewrites dflags + = liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_rewrites "" empty + + | dopt Opt_D_dump_rule_firings dflags + = liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_firings "" empty + + | otherwise + = return () + log_rule dflags flag hdr details = liftIO . dumpSDoc dflags alwaysQualify flag "" $ sep [text hdr, nest 4 details] diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile index 50696a7..8c98681 100644 --- a/testsuite/tests/driver/Makefile +++ b/testsuite/tests/driver/Makefile @@ -609,3 +609,11 @@ T10182: "$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs-boot "$(TEST_HC)" $(TEST_HC_OPTS) -c T10182a.hs "$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs + +.PHONY: T10320 +T10320: + $(RM) -rf T10320 T10320.dump-rule-rewrites T10320.hi T10320.o + "$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites -fenable-rewrite-rules T10320.hs + [ -s T10320.dump-rule-rewrites ] + "$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites T10320.hs + [ -f T10320.dump-rule-rewrites ] && [ ! -s T10320.dump-rule-rewrites ] diff --git a/testsuite/tests/driver/T10320.hs b/testsuite/tests/driver/T10320.hs new file mode 100644 index 0000000..f2f613c --- /dev/null +++ b/testsuite/tests/driver/T10320.hs @@ -0,0 +1,8 @@ +-- | Test file for issue #10320. + +module Main (main) where + +main :: IO () +main = print $ map (+1) (map (+1) [1, 2, 3]) + +{-# RULES "map/map" forall f g xs. map f (map g xs) = map (f.g) xs #-} diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 5a19366..a50476a 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -471,3 +471,8 @@ test('T11429a', normal, compile, ['-Wunrecognised-warning-flags -Wfoobar']) test('T11429b', normal, compile, ['-Wno-unrecognised-warning-flags -Wfoobar']) test('T11429c', normal, compile_fail, ['-Wunrecognised-warning-flags -Werror -Wfoobar']) +test('T10320', + [ ignore_output + , extra_clean(['T10320', 'T10320.o', 'T10320.hi'])], + run_command, + ['$MAKE -s --no-print-directory T10320']) From git at git.haskell.org Thu Mar 24 22:00:14 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:14 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Move getOccFS to Name (0d87eb5) Message-ID: <20160324220014.2C5433A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0d87eb5ee849fd434910ca20c06edaaf61e9db07/ghc >--------------------------------------------------------------- commit 0d87eb5ee849fd434910ca20c06edaaf61e9db07 Author: Ben Gamari Date: Fri Mar 11 11:42:01 2016 +0100 Move getOccFS to Name (cherry picked from commit 3ea11eb1c367a15e5b7dac83d31937ac7d44b3b2) >--------------------------------------------------------------- 0d87eb5ee849fd434910ca20c06edaaf61e9db07 compiler/basicTypes/Name.hs | 4 +++- compiler/iface/MkIface.hs | 17 +++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler/basicTypes/Name.hs b/compiler/basicTypes/Name.hs index 74eec8a..eb820d4 100644 --- a/compiler/basicTypes/Name.hs +++ b/compiler/basicTypes/Name.hs @@ -68,7 +68,7 @@ module Name ( -- * Class 'NamedThing' and overloaded friends NamedThing(..), - getSrcLoc, getSrcSpan, getOccString, + getSrcLoc, getSrcSpan, getOccString, getOccFS, pprInfixName, pprPrefixName, pprModulePrefix, nameStableString, @@ -633,10 +633,12 @@ class NamedThing a where getSrcLoc :: NamedThing a => a -> SrcLoc getSrcSpan :: NamedThing a => a -> SrcSpan getOccString :: NamedThing a => a -> String +getOccFS :: NamedThing a => a -> FastString getSrcLoc = nameSrcLoc . getName getSrcSpan = nameSrcSpan . getName getOccString = occNameString . getOccName +getOccFS = occNameFS . getOccName pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc -- See Outputable.pprPrefixVar, pprInfixVar; diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 3d15f28..1a31afd 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -1428,7 +1428,7 @@ tyConToIfaceDecl env tycon if_binders = zipIfaceBinders tc_tyvars (tyConBinders tycon) if_res_kind = tidyToIfaceType tc_env1 (tyConResKind tycon) if_syn_type ty = tidyToIfaceType tc_env1 ty - if_res_var = getFS `fmap` tyConFamilyResVar_maybe tycon + if_res_var = getOccFS `fmap` tyConFamilyResVar_maybe tycon -- use these when you don't have tyConTyVars (degenerate_binders, degenerate_res_kind) @@ -1530,7 +1530,7 @@ classToIfaceDecl env clas ifFDs = map toIfaceFD clas_fds, ifATs = map toIfaceAT clas_ats, ifSigs = map toIfaceClassOp op_stuff, - ifMinDef = fmap getFS (classMinimalDef clas), + ifMinDef = fmap getOccFS (classMinimalDef clas), ifRec = boolToRecFlag (isRecursiveTyCon tycon) }) where (clas_tyvars, clas_fds, sc_theta, _, clas_ats, op_stuff) @@ -1564,8 +1564,8 @@ classToIfaceDecl env clas toDmSpec (_, VanillaDM) = VanillaDM toDmSpec (_, GenericDM dm_ty) = GenericDM (tidyToIfaceType env1 dm_ty) - toIfaceFD (tvs1, tvs2) = (map (getFS . tidyTyVar env1) tvs1, - map (getFS . tidyTyVar env1) tvs2) + toIfaceFD (tvs1, tvs2) = (map (getOccFS . tidyTyVar env1) tvs1, + map (getOccFS . tidyTyVar env1) tvs2) -------------------------- tidyToIfaceType :: TidyEnv -> Type -> IfaceType @@ -1592,9 +1592,6 @@ tidyTyVar :: TidyEnv -> TyVar -> TyVar tidyTyVar (_, subst) tv = lookupVarEnv subst tv `orElse` tv -- TcType.tidyTyVarOcc messes around with FlatSkols -getFS :: NamedThing a => a -> FastString -getFS x = occNameFS (getOccName x) - -------------------------- instanceToIfaceInst :: ClsInst -> IfaceClsInst instanceToIfaceInst (ClsInst { is_dfun = dfun_id, is_flag = oflag @@ -1770,7 +1767,7 @@ toIfaceExpr (Lam x b) = IfaceLam (toIfaceBndr x, toIfaceOneShot x) (toIfac toIfaceExpr (App f a) = toIfaceApp f [a] toIfaceExpr (Case s x ty as) | null as = IfaceECase (toIfaceExpr s) (toIfaceType ty) - | otherwise = IfaceCase (toIfaceExpr s) (getFS x) (map toIfaceAlt as) + | otherwise = IfaceCase (toIfaceExpr s) (getOccFS x) (map toIfaceAlt as) toIfaceExpr (Let b e) = IfaceLet (toIfaceBind b) (toIfaceExpr e) toIfaceExpr (Cast e co) = IfaceCast (toIfaceExpr e) (toIfaceCoercion co) toIfaceExpr (Tick t e) @@ -1801,7 +1798,7 @@ toIfaceBind (Rec prs) = IfaceRec [(toIfaceLetBndr b, toIfaceExpr r) | (b,r) < --------------------- toIfaceAlt :: (AltCon, [Var], CoreExpr) -> (IfaceConAlt, [FastString], IfaceExpr) -toIfaceAlt (c,bs,r) = (toIfaceCon c, map getFS bs, toIfaceExpr r) +toIfaceAlt (c,bs,r) = (toIfaceCon c, map getOccFS bs, toIfaceExpr r) --------------------- toIfaceCon :: AltCon -> IfaceConAlt @@ -1837,5 +1834,5 @@ toIfaceVar v | Just fcall <- isFCallId_maybe v = IfaceFCall fcall (toIfaceType (idType v)) -- Foreign calls have special syntax | isExternalName name = IfaceExt name - | otherwise = IfaceLcl (getFS name) + | otherwise = IfaceLcl (getOccFS name) where name = idName v From git at git.haskell.org Thu Mar 24 22:00:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:16 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix regression test for #11145. (cf38cec) Message-ID: <20160324220016.D68B33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/cf38cec25a963bf2faff7e0d51dbece040f80ee3/ghc >--------------------------------------------------------------- commit cf38cec25a963bf2faff7e0d51dbece040f80ee3 Author: Dominik Bollmann Date: Thu Mar 24 10:11:46 2016 +0100 Fix regression test for #11145. Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2032 GHC Trac Issues: #11145 (cherry picked from commit e57b9ffee858278bf1ef8ed0754346685334b9ba) >--------------------------------------------------------------- cf38cec25a963bf2faff7e0d51dbece040f80ee3 testsuite/tests/th/T11145.stderr | 2 +- testsuite/tests/th/all.T | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/tests/th/T11145.stderr b/testsuite/tests/th/T11145.stderr index 98e518c..731349d 100644 --- a/testsuite/tests/th/T11145.stderr +++ b/testsuite/tests/th/T11145.stderr @@ -3,6 +3,6 @@ T11145.hs:8:1: error: ? Data constructor ?MkFuggle? returns type ?Fuggle Int (Maybe Bool)? instead of an instance of its parent type ?Fuggle - Int (Maybe (a_a4MU, b_a4MV))? + Int (Maybe (a, b))? ? In the definition of data constructor ?MkFuggle? In the data instance declaration for ?Fuggle? diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 2116606..d5124fe 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -399,4 +399,4 @@ test('T11345', normal, compile_and_run, ['-v0 -dsuppress-uniques']) test('TH_finalizer', normal, compile, ['-v0']) test('T10603', normal, compile, ['-ddump-splices -dsuppress-uniques']) test('T11452', normal, compile_fail, ['-v0']) -test('T11145', normal, compile_fail, ['-v0']) +test('T11145', normal, compile_fail, ['-v0 -dsuppress-uniques']) From git at git.haskell.org Thu Mar 24 22:00:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:20 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add `PatSynSigSkol` and modify `PatSynCtxt` (13a54bc) Message-ID: <20160324220020.2F4B03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/13a54bc3526df1f13c717ec80456743d9bbe6656/ghc >--------------------------------------------------------------- commit 13a54bc3526df1f13c717ec80456743d9bbe6656 Author: Rik Steenkamp Date: Wed Mar 23 16:17:27 2016 +0100 Add `PatSynSigSkol` and modify `PatSynCtxt` As the type of a pattern synonym cannot in general be represented by a value of type Type, we cannot use a value `SigSkol (PatSynCtxt n) (Check ty)` to represent the signature of a pattern synonym (this causes incorrect signatures to be printed in error messages). Therefore we now represent it by a value `PatSynSigSkol n` (instead of incorrect signatures we simply print no explicit signature). Furthermore, we rename `PatSynCtxt` to `PatSynBuilderCtxt`, and use `SigSkol (PatSynBuilderCtxt n) (Check ty)` to represent the type of a bidirectional pattern synonym when used in an expression context. Before, this type was represented by a value `SigSkol (PatSynCtxt n) (Check ty)`, which caused incorrect error messages. Also, in `mk_dict_err` of `typecheck\TcErrors.hs` we now distinguish between all enclosing implications and "useful" enclosing implications, for better error messages concerning pattern synonyms. See `Note [Useful implications]`. See the Phabricator page for examples. Reviewers: mpickering, goldfire, simonpj, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1967 GHC Trac Issues: #11667 (cherry picked from commit 997312b04c56017197250096d61f3e8fab502319) >--------------------------------------------------------------- 13a54bc3526df1f13c717ec80456743d9bbe6656 compiler/basicTypes/PatSyn.hs | 15 ++++ compiler/typecheck/TcErrors.hs | 88 ++++++++++++++++-------- compiler/typecheck/TcPatSyn.hs | 5 +- compiler/typecheck/TcRnTypes.hs | 7 ++ compiler/typecheck/TcSimplify.hs | 4 +- compiler/typecheck/TcType.hs | 17 ++--- compiler/typecheck/TcValidity.hs | 38 +++++----- testsuite/tests/patsyn/should_fail/T10873.stderr | 9 ++- testsuite/tests/patsyn/should_fail/T11039.stderr | 4 +- testsuite/tests/patsyn/should_fail/T11667.hs | 31 +++++++++ testsuite/tests/patsyn/should_fail/T11667.stderr | 43 ++++++++++++ testsuite/tests/patsyn/should_fail/all.T | 1 + 12 files changed, 194 insertions(+), 68 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 13a54bc3526df1f13c717ec80456743d9bbe6656 From git at git.haskell.org Thu Mar 24 22:00:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:22 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Defer inlining of Eq for primitive types (ed3398d) Message-ID: <20160324220022.E3B5C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/ed3398d176fc777dff8f5ae5315425e40c705c2d/ghc >--------------------------------------------------------------- commit ed3398d176fc777dff8f5ae5315425e40c705c2d Author: Ben Gamari Date: Thu Mar 24 11:24:32 2016 +0100 Defer inlining of Eq for primitive types Summary: This is one solution to #11688, wherein (==) was inlined to soon defeating a rewrite rule provided by bytestring. Since the RHSs of Eq's methods are simple, there is little to be gained and much to be lost by inlining them early. For instance, the bytestring library provides, ```lang=haskell break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString) breakByte :: Word8 -> ByteString -> (ByteString, ByteString) ``` and a rule ``` forall x. break ((==) x) = breakByte x ``` since `breakByte` implments an optimized version of `break (== x)` for known `x :: Word8`. If we allow `(==)` to be inlined too early, we will prevent this rule from firing. This was the cause of #11688. This patch just defers the `Eq` methods, although it's likely worthwhile giving `Ord` this same treatment. This regresses compiler allocations for T9661 by about 8% due to the additional inlining that we now require the simplifier to perform. Updates the `bytestring` submodule to include updated rewrite rules which match on `eqWord8` instead of `(==)`. Test Plan: * Validate, examine performance impact Reviewers: simonpj, hvr, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1980 GHC Trac Issues: #11688 (cherry picked from commit 0bd0c31e833055eb3e86177f70c4b4d93d5a1c11) >--------------------------------------------------------------- ed3398d176fc777dff8f5ae5315425e40c705c2d libraries/base/GHC/Char.hs | 9 +++- libraries/base/GHC/Float.hs | 20 +++++---- libraries/base/GHC/Int.hs | 74 +++++++++++++++++++++++++++---- libraries/base/GHC/Word.hs | 77 +++++++++++++++++++++++++++++--- libraries/ghc-prim/GHC/Classes.hs | 87 +++++++++++++++++++++++++++++++++---- testsuite/tests/perf/compiler/all.T | 5 ++- 6 files changed, 236 insertions(+), 36 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc ed3398d176fc777dff8f5ae5315425e40c705c2d From git at git.haskell.org Thu Mar 24 22:00:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:25 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Define tyConRolesRepresentational and use it (1b75e1d) Message-ID: <20160324220025.97E713A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1b75e1d713635a86ea21b1e98689ab3330c92cac/ghc >--------------------------------------------------------------- commit 1b75e1d713635a86ea21b1e98689ab3330c92cac Author: Simon Peyton Jones Date: Mon Feb 8 17:41:58 2016 +0000 Define tyConRolesRepresentational and use it tyConRolesRepresentational is just a version of tyConRolesX, but specialised for a Representational argument. Saves a bit of extra argument passing and pattern matching, and tyConRolesX was often called when we knew the argument role was Representational. Rather to my surprise this made the compiler allocate 5% less for tests T9872{b,c,d}. At least I think it's this commit. Good thing, regardless. >--------------------------------------------------------------- 1b75e1d713635a86ea21b1e98689ab3330c92cac compiler/typecheck/TcFlatten.hs | 2 +- compiler/types/Coercion.hs | 17 ++++++++++------- compiler/types/OptCoercion.hs | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs index 6af8660..76eda37 100644 --- a/compiler/typecheck/TcFlatten.hs +++ b/compiler/typecheck/TcFlatten.hs @@ -1046,7 +1046,7 @@ flatten_ty_con_app tc tys ; let role = eqRelRole eq_rel ; (xis, cos) <- case eq_rel of NomEq -> flatten_many_nom tys - ReprEq -> flatten_many (tyConRolesX role tc) tys + ReprEq -> flatten_many (tyConRolesRepresentational tc) tys ; return (mkTyConApp tc xis, mkTyConAppCo role tc cos) } {- diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs index 471ce45..fe9cc41 100644 --- a/compiler/types/Coercion.hs +++ b/compiler/types/Coercion.hs @@ -53,7 +53,7 @@ module Coercion ( splitAppCo_maybe, splitForAllCo_maybe, - nthRole, tyConRolesX, setNominalRole_maybe, + nthRole, tyConRolesX, tyConRolesRepresentational, setNominalRole_maybe, pickLR, @@ -608,7 +608,7 @@ mkAppCo (TyConAppCo r tc args) arg = case r of Nominal -> TyConAppCo Nominal tc (args ++ [arg]) Representational -> TyConAppCo Representational tc (args ++ [arg']) - where new_role = (tyConRolesX Representational tc) !! (length args) + where new_role = (tyConRolesRepresentational tc) !! (length args) arg' = downgradeRole new_role Nominal arg Phantom -> TyConAppCo Phantom tc (args ++ [toPhantomCo arg]) mkAppCo co arg = AppCo co arg @@ -669,13 +669,13 @@ mkTransAppCo r1 co1 ty1a ty1b r2 co2 ty2a ty2b r3 , nextRole ty1b == r2 = (mkAppCo co1_repr (mkNomReflCo ty2a)) `mkTransCo` (mkTyConAppCo Representational tc1b - (zipWith mkReflCo (tyConRolesX Representational tc1b) tys1b + (zipWith mkReflCo (tyConRolesRepresentational tc1b) tys1b ++ [co2])) | Just (tc1a, tys1a) <- splitTyConApp_maybe ty1a , nextRole ty1a == r2 = (mkTyConAppCo Representational tc1a - (zipWith mkReflCo (tyConRolesX Representational tc1a) tys1a + (zipWith mkReflCo (tyConRolesRepresentational tc1a) tys1a ++ [co2])) `mkTransCo` (mkAppCo co1_repr (mkNomReflCo ty2b)) @@ -1052,20 +1052,23 @@ toPhantomCo co -- Convert args to a TyConAppCo Nominal to the same TyConAppCo Representational applyRoles :: TyCon -> [Coercion] -> [Coercion] applyRoles tc cos - = zipWith (\r -> downgradeRole r Nominal) (tyConRolesX Representational tc) cos + = zipWith (\r -> downgradeRole r Nominal) (tyConRolesRepresentational tc) cos -- the Role parameter is the Role of the TyConAppCo -- defined here because this is intimiately concerned with the implementation -- of TyConAppCo tyConRolesX :: Role -> TyCon -> [Role] -tyConRolesX Representational tc = tyConRoles tc ++ repeat Nominal +tyConRolesX Representational tc = tyConRolesRepresentational tc tyConRolesX role _ = repeat role +tyConRolesRepresentational :: TyCon -> [Role] +tyConRolesRepresentational tc = tyConRoles tc ++ repeat Nominal + nthRole :: Role -> TyCon -> Int -> Role nthRole Nominal _ _ = Nominal nthRole Phantom _ _ = Phantom nthRole Representational tc n - = (tyConRolesX Representational tc) `getNth` n + = (tyConRolesRepresentational tc) `getNth` n ltRole :: Role -> Role -> Bool -- Is one role "less" than another? diff --git a/compiler/types/OptCoercion.hs b/compiler/types/OptCoercion.hs index 2ae67d2..fb6c68e 100644 --- a/compiler/types/OptCoercion.hs +++ b/compiler/types/OptCoercion.hs @@ -180,7 +180,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) (True, Nominal) -> mkTyConAppCo Representational tc (zipWith3 (opt_co3 env sym) - (map Just (tyConRolesX Representational tc)) + (map Just (tyConRolesRepresentational tc)) (repeat Nominal) cos) (False, Nominal) -> @@ -189,7 +189,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) -- must use opt_co2 here, because some roles may be P -- See Note [Optimising coercion optimisation] mkTyConAppCo r tc (zipWith (opt_co2 env sym) - (tyConRolesX r tc) -- the current roles + (tyConRolesRepresentational tc) -- the current roles cos) (_, Phantom) -> pprPanic "opt_co4 sees a phantom!" (ppr g) From git at git.haskell.org Thu Mar 24 22:00:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:28 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Simplify: Make generated names more useful (17f8814) Message-ID: <20160324220028.57D693A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/17f88142bce386ff99b5130c621f09ade4c909d2/ghc >--------------------------------------------------------------- commit 17f88142bce386ff99b5130c621f09ade4c909d2 Author: Ben Gamari Date: Fri Mar 11 15:24:49 2016 +0100 Simplify: Make generated names more useful makeTrivial is responsible for concocting names during simplification. Previously, however, it would make no attempt to generate a name that might be useful to later readers of the resulting Core. Here we add a bit of state to SimplEnv: a finite depth stack of binders within which we are currently simplifying. We then derive generated binders from this context. See #11676. Open questions: * Is there a better way to accomplish this? * Is `maxContextDepth` too large/small? Test Plan: Validate, look at Core. Reviewers: austin, simonpj Reviewed By: simonpj Subscribers: thomie, simonpj Differential Revision: https://phabricator.haskell.org/D1970 GHC Trac Issues: #11676 (cherry picked from commit 4d791b4f77975422df38f6b43084008edd097f1b) >--------------------------------------------------------------- 17f88142bce386ff99b5130c621f09ade4c909d2 compiler/simplCore/Simplify.hs | 32 +++++++------ .../tests/deSugar/should_compile/T2431.stderr | 30 ++++++++----- .../tests/ghci.debugger/scripts/break009.stdout | 2 +- .../tests/ghci.debugger/scripts/break010.stdout | 4 +- .../tests/ghci.debugger/scripts/break011.stdout | 22 ++++----- .../tests/ghci.debugger/scripts/break012.stdout | 14 +++--- .../tests/ghci.debugger/scripts/break028.stdout | 4 +- .../tests/ghci.debugger/scripts/print018.stdout | 6 +-- .../tests/ghci.debugger/scripts/print031.stdout | 2 +- .../tests/roles/should_compile/Roles13.stderr | 52 +++++++++++++--------- .../tests/simplCore/should_compile/EvalTest.stdout | 2 +- .../tests/simplCore/should_compile/T9400.stderr | 10 ++--- .../simplCore/should_compile/spec-inline.stderr | 18 ++++---- 13 files changed, 111 insertions(+), 87 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 17f88142bce386ff99b5130c621f09ade4c909d2 From git at git.haskell.org Thu Mar 24 22:00:31 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:31 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: ErrUtils: Emulate getAllocationCounter on GHC 7.8 (457d15f) Message-ID: <20160324220031.0962F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/457d15f1d212c9d29ee942ec3771bacaeba87d74/ghc >--------------------------------------------------------------- commit 457d15f1d212c9d29ee942ec3771bacaeba87d74 Author: Ben Gamari Date: Thu Mar 24 13:08:34 2016 +0100 ErrUtils: Emulate getAllocationCounter on GHC 7.8 >--------------------------------------------------------------- 457d15f1d212c9d29ee942ec3771bacaeba87d74 compiler/main/ErrUtils.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs index 21fd7e8..9b98b5e 100644 --- a/compiler/main/ErrUtils.hs +++ b/compiler/main/ErrUtils.hs @@ -462,6 +462,14 @@ showPass dflags what = ifVerbose dflags 2 $ logInfo dflags defaultUserStyle (text "***" <+> text what <> colon) +#if ! MIN_VERSION_base(4,8,0) +-- This is a hack to allow us to build stage1 with 7.8 compilers, which +-- did not support getAllocationCounter. This means that the allocation numbers +-- produced by stage1 are bogus, but stage2 will be fine. +getAllocationCounter :: IO Int64 +getAllocationCounter = return 0 +#endif + -- | Time a compilation phase. -- -- When timings are enabled (e.g. with the @-v2@ flag), the allocations From git at git.haskell.org Thu Mar 24 22:00:34 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:34 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Default RuntimeRep variables unless -fprint-explicit-runtime-reps (f0dcd55) Message-ID: <20160324220034.C3B443A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/f0dcd551de3b883516fef37a6f762f2d799d7bf8/ghc >--------------------------------------------------------------- commit f0dcd551de3b883516fef37a6f762f2d799d7bf8 Author: Ben Gamari Date: Thu Mar 24 11:39:59 2016 +0100 Default RuntimeRep variables unless -fprint-explicit-runtime-reps Summary: Addresses #11549 by defaulting `RuntimeRep` variables to `PtrRepLifted` and adding a new compiler flag `-fprint-explicit-runtime-reps` to disable this behavior. This is just a guess at the right way to go about this. If it's wrong-beyond-any-hope just say so. Test Plan: Working on a testcase Reviewers: goldfire, austin Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1961 GHC Trac Issues: #11549 (cherry picked from commit 371608f1cdaf20c49eb6c5ec165b9eb08b745a89) >--------------------------------------------------------------- f0dcd551de3b883516fef37a6f762f2d799d7bf8 compiler/main/DynFlags.hs | 2 + compiler/prelude/TysWiredIn.hs-boot | 1 + compiler/types/TyCoRep.hs | 89 +++++++++++++++++++++- docs/users_guide/using.rst | 16 ++++ testsuite/tests/dependent/ghci/T11549.script | 14 ++++ testsuite/tests/dependent/ghci/T11549.stdout | 12 +++ testsuite/tests/dependent/ghci/all.T | 3 + .../dependent/should_fail/TypeSkolEscape.stderr | 2 +- testsuite/tests/ghci/scripts/T7627.stdout | 10 +-- utils/mkUserGuidePart/Options/Verbosity.hs | 7 ++ 10 files changed, 144 insertions(+), 12 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc f0dcd551de3b883516fef37a6f762f2d799d7bf8 From git at git.haskell.org Thu Mar 24 22:00:37 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:37 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Ensure T9646 dump-simpl output is cleaned (4e5a0b0) Message-ID: <20160324220037.754533A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/4e5a0b0f70d22cdd701e363a680a1fd68fc853e2/ghc >--------------------------------------------------------------- commit 4e5a0b0f70d22cdd701e363a680a1fd68fc853e2 Author: Ben Gamari Date: Mon Mar 21 00:49:24 2016 +0100 Ensure T9646 dump-simpl output is cleaned (cherry picked from commit da3b29bd1768d717753b7d1642e0e4e97750ae7b) >--------------------------------------------------------------- 4e5a0b0f70d22cdd701e363a680a1fd68fc853e2 testsuite/tests/simplCore/T9646/test.T | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/simplCore/T9646/test.T b/testsuite/tests/simplCore/T9646/test.T index 1456217..d31f8fe 100644 --- a/testsuite/tests/simplCore/T9646/test.T +++ b/testsuite/tests/simplCore/T9646/test.T @@ -1,6 +1,9 @@ test('T9646', - [when(fast(), skip), extra_clean(['Main.hi', 'Main.o'])], + [when(fast(), skip), + extra_clean(['Main.hi', 'Main.o', 'Main.dump-simpl', + 'Natural.dump-simpl', 'StrictPrim.dump-simpl', + 'Type.dump-simpl'])], multimod_compile_and_run, ['Main -ddump-simpl -ddump-to-file', '']) From git at git.haskell.org Thu Mar 24 22:00:40 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:00:40 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Show: Restore redundant parentheses around records (0616691) Message-ID: <20160324220040.362973A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/061669156c0e24a550dc968e5d6c7f1e5e518505/ghc >--------------------------------------------------------------- commit 061669156c0e24a550dc968e5d6c7f1e5e518505 Author: Ben Gamari Date: Thu Mar 24 10:54:11 2016 +0100 Show: Restore redundant parentheses around records As discussed in #2530 we are going to continue to produce parentheses here in order to preserve compatibility with previous GHC releases. It was found that dropped parentheses would break some testsuites which compared against output from Show. This has been documented in the users guide. This reverts commit 5692643c9d17e746327588cd6157a923642b7975. Test Plan: Validate Reviewers: hvr, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2027 GHC Trac Issues: #2350 (cherry picked from commit 1448f8ab2379452312f1f74f6d5ba4de8ad3d47e) >--------------------------------------------------------------- 061669156c0e24a550dc968e5d6c7f1e5e518505 compiler/hsSyn/HsExpr.hs | 6 ++---- compiler/typecheck/TcGenDeriv.hs | 2 -- docs/users_guide/bugs.rst | 15 +++++++++++++++ testsuite/tests/codeGen/should_run/T7953.stdout | 4 ++-- testsuite/tests/deriving/should_run/drvrun020.stdout | 2 +- .../tests/ghc-api/annotations-literals/literals.stdout | 6 +++--- 6 files changed, 23 insertions(+), 12 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 061669156c0e24a550dc968e5d6c7f1e5e518505 From git at git.haskell.org Thu Mar 24 22:13:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:13:00 +0000 (UTC) Subject: [commit: ghc] master: users_guide: Fix various issues (2cebbe6) Message-ID: <20160324221300.2411E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2cebbe657afd6a3c31dd1d2b7d04978525c27a56/ghc >--------------------------------------------------------------- commit 2cebbe657afd6a3c31dd1d2b7d04978525c27a56 Author: Ben Gamari Date: Thu Mar 24 22:32:04 2016 +0100 users_guide: Fix various issues Sphinx apparently expects references to anchors that don't accompany a header to have a caption. Test Plan: validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2033 >--------------------------------------------------------------- 2cebbe657afd6a3c31dd1d2b7d04978525c27a56 docs/users_guide/glasgow_exts.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 978fe8b..3aa9f23 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1861,8 +1861,9 @@ The following syntax is stolen: single: Quasi-quotes Stolen by: :ghc-flag:`-XQuasiQuotes`. Moreover, this introduces an ambiguity - with list comprehension syntax. See - :ref:`quasi-quotes-list-comprehension-ambiguity` for details. + with list comprehension syntax. See the + :ref:`discussion on quasi-quoting ` + for details. ``$(``, ``$$(``, ``$varid``, ``$$varid`` .. index:: @@ -7635,10 +7636,10 @@ Pretty-printing in the presence of kind polymorphism With kind polymorphism, there is quite a bit going on behind the scenes that may be invisible to a Haskell programmer. GHC supports several flags that control how types are printed in error messages and at the GHCi prompt. -See :ref:`pretty-printing-types` for the details. If you are using -kind polymorphism and are confused as to why GHC is rejecting (or accepting) -your program, we encourage you to turn on these flags, especially -:ghc-flag:`-fprint-explicit-kinds`. +See the :ref:`discussion of type pretty-printing options ` +for further details. If you are using kind polymorphism and are confused as to +why GHC is rejecting (or accepting) your program, we encourage you to turn on +these flags, especially :ghc-flag:`-fprint-explicit-kinds`. .. index:: single: TYPE @@ -8717,11 +8718,14 @@ Here are the details: for the time being; it is expected that these will be brought in line with other declarations in the future. The rules for GADT data constructors are as follows: + * All kind and type variables are considered specified and available for visible type application. + * Universal variables always come first, in precisely the order they appear in the type delcaration. Universal variables that are constrained by a GADT return type are not included in the data constructor. + * Existential variables come next. Their order is determined by a user- written `forall`; or, if there is none, by taking the left-to-right order in the data constructor's type and doing a stable topological sort. From git at git.haskell.org Thu Mar 24 22:13:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:13:02 +0000 (UTC) Subject: [commit: ghc] master: users-guide: Add -Wredundant-constraints to flags reference (8ff6518) Message-ID: <20160324221302.C77B33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/8ff6518b5af1b357eb043ac46f9209bd0019a193/ghc >--------------------------------------------------------------- commit 8ff6518b5af1b357eb043ac46f9209bd0019a193 Author: Ben Gamari Date: Thu Mar 24 22:32:20 2016 +0100 users-guide: Add -Wredundant-constraints to flags reference Test Plan: Validate and read Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2035 GHC Trac Issues: #11741 >--------------------------------------------------------------- 8ff6518b5af1b357eb043ac46f9209bd0019a193 docs/users_guide/using-warnings.rst | 2 ++ utils/mkUserGuidePart/Options/Warnings.hs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index ffe5a41..16c6585 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -398,6 +398,8 @@ of ``-W(no-)*``. .. ghc-flag:: -Wredundant-constraints + :since: 8.0 + .. index:: single: redundant constraints, warning diff --git a/utils/mkUserGuidePart/Options/Warnings.hs b/utils/mkUserGuidePart/Options/Warnings.hs index b194bf2..3552172 100644 --- a/utils/mkUserGuidePart/Options/Warnings.hs +++ b/utils/mkUserGuidePart/Options/Warnings.hs @@ -370,6 +370,13 @@ warningsOptions = , flagType = DynamicFlag , flagReverse = "-Wno-amp" } + , flag { flagName = "-Wredundant-constraints" + , flagDescription = + "Have the compiler warn about redundant constraints in type"++ + "signatures." + , flagType = DynamicFlag + , flagReverse = "-Wno-redundant-constraints" + } , flag { flagName = "-Wdeferred-type-errors" , flagDescription = "Report warnings when :ref:`deferred type errors "++ From git at git.haskell.org Thu Mar 24 22:13:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:13:05 +0000 (UTC) Subject: [commit: ghc] master: users_guide: small improvements on pattern synonyms. (173a5d8) Message-ID: <20160324221305.7AF003A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/173a5d8ee4d3d8b7ddd2e8b81c957d03441c4f2b/ghc >--------------------------------------------------------------- commit 173a5d8ee4d3d8b7ddd2e8b81c957d03441c4f2b Author: Dominik Bollmann Date: Thu Mar 24 22:32:56 2016 +0100 users_guide: small improvements on pattern synonyms. Since the order of required and provided constraint contexts of pattern synonyms has been switched recently, I updated a couple places in the users guide's pattern synonym section to accommodate for this. Test Plan: read it :-) Reviewers: goldfire, thomie, mpickering, simonpj, austin, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D2034 >--------------------------------------------------------------- 173a5d8ee4d3d8b7ddd2e8b81c957d03441c4f2b docs/users_guide/glasgow_exts.rst | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 3aa9f23..0128f33 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -4032,9 +4032,8 @@ Pattern synonyms Allow the definition of pattern synonyms. Pattern synonyms are enabled by the flag :ghc-flag:`-XPatternSynonyms`, which is -required for defining them, but *not* for using them. More information -and examples of view patterns can be found on the -`Wiki page `. +required for defining them, but *not* for using them. More information and +examples of view patterns can be found on the `Wiki page `. Pattern synonyms enable giving names to parametrized pattern schemes. They can also be thought of as abstract constructors that don't have a @@ -4301,21 +4300,21 @@ it is assigned a *pattern type* of the form :: pattern P :: CReq => CProv => t1 -> t2 -> ... -> tN -> t -where ?CProv? and ?CReq? are type contexts, and ?t1?, ?t2?, ..., ?tN? +where ?CReq? and ?CProv? are type contexts, and ?t1?, ?t2?, ..., ?tN? and ?t? are types. Notice the unusual form of the type, with two -contexts ?CProv? and ?CReq?: +contexts ?CReq? and ?CProv?: + +- ?CReq? are the constraints *required* to match the pattern. - ?CProv? are the constraints *made available (provided)* by a successful pattern match. -- ?CReq? are the constraints *required* to match the pattern. - For example, consider :: data T a where MkT :: (Show b) => a -> b -> T a - f1 :: (Eq a, Num a) => T a -> String + f1 :: (Num a, Eq a) => T a -> String f1 (MkT 42 x) = show x pattern ExNumPat :: (Num a, Eq a) => (Show b) => b -> T a @@ -4338,8 +4337,13 @@ Exactly the same reasoning applies to ``ExNumPat``: matching against Note also the following points -- In the common case where ``Prov`` is empty, ``()``, it can be omitted - altogether. +- In the common case where ``CProv`` is empty, (i.e., ``()``), it can be + omitted altogether in the above pattern type signature for ``P``. + +- However, if ``CProv`` is non-empty, while ``CReq`` is, the above pattern type + signature for ``P`` must be specified as :: + + P :: () => CProv => t1 -> t2 -> .. -> tN -> t - You may specify an explicit *pattern signature*, as we did for ``ExNumPat`` above, to specify the type of a pattern, just as you can @@ -4400,7 +4404,7 @@ Note also the following points then be rejected. In short, if you want GADT-like behaviour for pattern synonyms, then - (unlike unlike concrete data constructors like ``S1``) you must write + (unlike concrete data constructors like ``S1``) you must write its type with explicit provided equalities. For a concrete data constructor like ``S1`` you can write its type signature as either ``S1 :: Bool -> S Bool`` or ``S1 :: (b~Bool) => Bool -> S b``; the From git at git.haskell.org Thu Mar 24 22:13:09 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:13:09 +0000 (UTC) Subject: [commit: ghc] master: Add option `no-keep-hi-files` and `no-keep-o-files` (fixes #4114) (2414952) Message-ID: <20160324221309.1408A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/24149528a0a2d17ff9b5b087e0a8249c8c9cef98/ghc >--------------------------------------------------------------- commit 24149528a0a2d17ff9b5b087e0a8249c8c9cef98 Author: Kai Harries Date: Thu Mar 24 22:33:27 2016 +0100 Add option `no-keep-hi-files` and `no-keep-o-files` (fixes #4114) Summary: Remove `.hi` and `.o` files if the flags `no-keep-hi-files` and `no-keep-o-files` are given. Test Plan: ./validate Reviewers: austin, thomie, bgamari Reviewed By: thomie, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2021 GHC Trac Issues: #4114 >--------------------------------------------------------------- 24149528a0a2d17ff9b5b087e0a8249c8c9cef98 compiler/main/DriverPipeline.hs | 6 ++++++ compiler/main/DynFlags.hs | 20 ++++++++++++++++++++ docs/users_guide/separate_compilation.rst | 21 +++++++++++++++++++-- testsuite/tests/driver/T4114a.hs | 14 ++++++++++++++ testsuite/tests/driver/T4114aSub.hs | 20 ++++++++++++++++++++ testsuite/tests/driver/T4114b.hs | 13 +++++++++++++ testsuite/tests/driver/T4114bSub.hs | 20 ++++++++++++++++++++ testsuite/tests/driver/T4114c.hs | 14 ++++++++++++++ testsuite/tests/driver/T4114cSub.hs | 20 ++++++++++++++++++++ testsuite/tests/driver/T4114d.hs | 14 ++++++++++++++ testsuite/tests/driver/T4114dSub.hs | 20 ++++++++++++++++++++ testsuite/tests/driver/all.T | 5 +++++ .../mkUserGuidePart/Options/KeepingIntermediates.hs | 12 ++++++++++++ 13 files changed, 197 insertions(+), 2 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 24149528a0a2d17ff9b5b087e0a8249c8c9cef98 From git at git.haskell.org Thu Mar 24 22:24:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:24:03 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users_guide: Fix various issues (4aadd5f) Message-ID: <20160324222403.655BE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/4aadd5f9f1df1922a963fc14d5d335b9ba6d544f/ghc >--------------------------------------------------------------- commit 4aadd5f9f1df1922a963fc14d5d335b9ba6d544f Author: Ben Gamari Date: Thu Mar 24 22:32:04 2016 +0100 users_guide: Fix various issues Sphinx apparently expects references to anchors that don't accompany a header to have a caption. Test Plan: validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2033 (cherry picked from commit 2cebbe657afd6a3c31dd1d2b7d04978525c27a56) >--------------------------------------------------------------- 4aadd5f9f1df1922a963fc14d5d335b9ba6d544f docs/users_guide/glasgow_exts.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index c1cd56f..c05db45 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -1840,8 +1840,9 @@ The following syntax is stolen: single: Quasi-quotes Stolen by: :ghc-flag:`-XQuasiQuotes`. Moreover, this introduces an ambiguity - with list comprehension syntax. See - :ref:`quasi-quotes-list-comprehension-ambiguity` for details. + with list comprehension syntax. See the + :ref:`discussion on quasi-quoting ` + for details. ``$(``, ``$$(``, ``$varid``, ``$$varid`` .. index:: @@ -7614,10 +7615,10 @@ Pretty-printing in the presence of kind polymorphism With kind polymorphism, there is quite a bit going on behind the scenes that may be invisible to a Haskell programmer. GHC supports several flags that control how types are printed in error messages and at the GHCi prompt. -See :ref:`pretty-printing-types` for the details. If you are using -kind polymorphism and are confused as to why GHC is rejecting (or accepting) -your program, we encourage you to turn on these flags, especially -:ghc-flag:`-fprint-explicit-kinds`. +See the :ref:`discussion of type pretty-printing options ` +for further details. If you are using kind polymorphism and are confused as to +why GHC is rejecting (or accepting) your program, we encourage you to turn on +these flags, especially :ghc-flag:`-fprint-explicit-kinds`. .. index:: single: TYPE @@ -8696,11 +8697,14 @@ Here are the details: for the time being; it is expected that these will be brought in line with other declarations in the future. The rules for GADT data constructors are as follows: + * All kind and type variables are considered specified and available for visible type application. + * Universal variables always come first, in precisely the order they appear in the type delcaration. Universal variables that are constrained by a GADT return type are not included in the data constructor. + * Existential variables come next. Their order is determined by a user- written `forall`; or, if there is none, by taking the left-to-right order in the data constructor's type and doing a stable topological sort. From git at git.haskell.org Thu Mar 24 22:24:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:24:06 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users-guide: Add -Wredundant-constraints to flags reference (abca151) Message-ID: <20160324222406.1D3EC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/abca1519926aa1a2c62d929a95a723037ebfe517/ghc >--------------------------------------------------------------- commit abca1519926aa1a2c62d929a95a723037ebfe517 Author: Ben Gamari Date: Thu Mar 24 22:32:20 2016 +0100 users-guide: Add -Wredundant-constraints to flags reference Test Plan: Validate and read Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2035 GHC Trac Issues: #11741 (cherry picked from commit 8ff6518b5af1b357eb043ac46f9209bd0019a193) >--------------------------------------------------------------- abca1519926aa1a2c62d929a95a723037ebfe517 docs/users_guide/using-warnings.rst | 2 ++ utils/mkUserGuidePart/Options/Warnings.hs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index ffe5a41..16c6585 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -398,6 +398,8 @@ of ``-W(no-)*``. .. ghc-flag:: -Wredundant-constraints + :since: 8.0 + .. index:: single: redundant constraints, warning diff --git a/utils/mkUserGuidePart/Options/Warnings.hs b/utils/mkUserGuidePart/Options/Warnings.hs index b194bf2..3552172 100644 --- a/utils/mkUserGuidePart/Options/Warnings.hs +++ b/utils/mkUserGuidePart/Options/Warnings.hs @@ -370,6 +370,13 @@ warningsOptions = , flagType = DynamicFlag , flagReverse = "-Wno-amp" } + , flag { flagName = "-Wredundant-constraints" + , flagDescription = + "Have the compiler warn about redundant constraints in type"++ + "signatures." + , flagType = DynamicFlag + , flagReverse = "-Wno-redundant-constraints" + } , flag { flagName = "-Wdeferred-type-errors" , flagDescription = "Report warnings when :ref:`deferred type errors "++ From git at git.haskell.org Thu Mar 24 22:24:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:24:08 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users_guide: small improvements on pattern synonyms. (86d63d6) Message-ID: <20160324222408.EBC153A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/86d63d610cad79d2600dbab44447445afb36795e/ghc >--------------------------------------------------------------- commit 86d63d610cad79d2600dbab44447445afb36795e Author: Dominik Bollmann Date: Thu Mar 24 22:32:56 2016 +0100 users_guide: small improvements on pattern synonyms. Since the order of required and provided constraint contexts of pattern synonyms has been switched recently, I updated a couple places in the users guide's pattern synonym section to accommodate for this. Test Plan: read it :-) Reviewers: goldfire, thomie, mpickering, simonpj, austin, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D2034 (cherry picked from commit 173a5d8ee4d3d8b7ddd2e8b81c957d03441c4f2b) >--------------------------------------------------------------- 86d63d610cad79d2600dbab44447445afb36795e docs/users_guide/glasgow_exts.rst | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index c05db45..603ab95 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -4011,9 +4011,8 @@ Pattern synonyms Allow the definition of pattern synonyms. Pattern synonyms are enabled by the flag :ghc-flag:`-XPatternSynonyms`, which is -required for defining them, but *not* for using them. More information -and examples of view patterns can be found on the -`Wiki page `. +required for defining them, but *not* for using them. More information and +examples of view patterns can be found on the `Wiki page `. Pattern synonyms enable giving names to parametrized pattern schemes. They can also be thought of as abstract constructors that don't have a @@ -4280,21 +4279,21 @@ it is assigned a *pattern type* of the form :: pattern P :: CReq => CProv => t1 -> t2 -> ... -> tN -> t -where ?CProv? and ?CReq? are type contexts, and ?t1?, ?t2?, ..., ?tN? +where ?CReq? and ?CProv? are type contexts, and ?t1?, ?t2?, ..., ?tN? and ?t? are types. Notice the unusual form of the type, with two -contexts ?CProv? and ?CReq?: +contexts ?CReq? and ?CProv?: + +- ?CReq? are the constraints *required* to match the pattern. - ?CProv? are the constraints *made available (provided)* by a successful pattern match. -- ?CReq? are the constraints *required* to match the pattern. - For example, consider :: data T a where MkT :: (Show b) => a -> b -> T a - f1 :: (Eq a, Num a) => T a -> String + f1 :: (Num a, Eq a) => T a -> String f1 (MkT 42 x) = show x pattern ExNumPat :: (Num a, Eq a) => (Show b) => b -> T a @@ -4317,8 +4316,13 @@ Exactly the same reasoning applies to ``ExNumPat``: matching against Note also the following points -- In the common case where ``Prov`` is empty, ``()``, it can be omitted - altogether. +- In the common case where ``CProv`` is empty, (i.e., ``()``), it can be + omitted altogether in the above pattern type signature for ``P``. + +- However, if ``CProv`` is non-empty, while ``CReq`` is, the above pattern type + signature for ``P`` must be specified as :: + + P :: () => CProv => t1 -> t2 -> .. -> tN -> t - You may specify an explicit *pattern signature*, as we did for ``ExNumPat`` above, to specify the type of a pattern, just as you can @@ -4379,7 +4383,7 @@ Note also the following points then be rejected. In short, if you want GADT-like behaviour for pattern synonyms, then - (unlike unlike concrete data constructors like ``S1``) you must write + (unlike concrete data constructors like ``S1``) you must write its type with explicit provided equalities. For a concrete data constructor like ``S1`` you can write its type signature as either ``S1 :: Bool -> S Bool`` or ``S1 :: (b~Bool) => Bool -> S b``; the From git at git.haskell.org Thu Mar 24 22:25:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:25:50 +0000 (UTC) Subject: [commit: ghc] master: Add NCG support for AIX/ppc32 (df26b95) Message-ID: <20160324222550.9332F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/df26b95559fd467abc0a3a4151127c95cb5011b9/ghc >--------------------------------------------------------------- commit df26b95559fd467abc0a3a4151127c95cb5011b9 Author: Herbert Valerio Riedel Date: Thu Mar 24 21:00:17 2016 +0100 Add NCG support for AIX/ppc32 This extends the previous work to revive the unregisterised GHC build for AIX/ppc32. Strictly speaking, AIX runs on POWER4 (and later) hardware, but the PPC32 instructions implemented in the PPC NCG represent a compatible subset of the POWER4 ISA. IBM AIX follows the PowerOpen ABI (and shares many similiarites with the Linux PPC64 ELF V1 NCG backend) but uses the rather limited XCOFF format (compared to ELF). This doesn't support dynamic libraries yet. A major limiting factor is that the AIX assembler does not support the `@ha`/`@l` relocation types nor the ha16()/lo16() functions Darwin's assembler supports. Therefore we need to avoid emitting those. In case of numeric literals we simply compute the functions ourselves, while for labels we have to use local TOCs and hope everything fits into a 16bit offset (for ppc32 this gives us at most 16384 entries per TOC section, which is enough to compile GHC). Another issue is that XCOFF doesn't seem to have a relocation type for label-differences, and therefore the label-differences placed into tables-next-to-code can't be relocated, but the linker may rearrange different sections, so we need to place all read-only sections into the same `.text[PR]` section to workaround this. Finally, the PowerOpen ABI distinguishes between function-descriptors and actualy entry-point addresses. For AIX we need to be specific when emitting assembler code whether we want the address of the function descriptor `printf`) or for the entry-point (`.printf`). So we let the asm pretty-printer prefix a dot to all emitted subroutine calls (i.e. `BL`) on AIX only. For now, STG routines' entry-point labels are not prefixed by a label and don't have any associated function-descriptor. Reviewers: austin, trommler, erikd, bgamari Reviewed By: trommler, erikd, bgamari Differential Revision: https://phabricator.haskell.org/D2019 >--------------------------------------------------------------- df26b95559fd467abc0a3a4151127c95cb5011b9 aclocal.m4 | 13 ++--- compiler/cmm/CLabel.hs | 13 +++-- compiler/ghc.mk | 14 ----- compiler/nativeGen/PIC.hs | 56 ++++++++++++++++++++ compiler/nativeGen/PPC/CodeGen.hs | 104 ++++++++++++++++++++++++++++++++++++-- compiler/nativeGen/PPC/Ppr.hs | 39 ++++++++++++-- compiler/nativeGen/PPC/Regs.hs | 2 + compiler/nativeGen/PprBase.hs | 14 +++++ mk/config.mk.in | 5 +- rts/StgCRun.c | 6 ++- rts/StgCRunAsm.S | 81 ++++++++++++++++++++++++++--- rts/ghc.mk | 1 + 12 files changed, 302 insertions(+), 46 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc df26b95559fd467abc0a3a4151127c95cb5011b9 From git at git.haskell.org Thu Mar 24 22:25:53 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 22:25:53 +0000 (UTC) Subject: [commit: ghc] master: Remove code-duplication in the PPC NCG (4dc8835) Message-ID: <20160324222553.4129A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/4dc883562b6adaba36e79a4fd3e46ec92ad78f4f/ghc >--------------------------------------------------------------- commit 4dc883562b6adaba36e79a4fd3e46ec92ad78f4f Author: Herbert Valerio Riedel Date: Thu Mar 24 23:24:08 2016 +0100 Remove code-duplication in the PPC NCG Reviewed By: bgamari, trommler Differential Revision: https://phabricator.haskell.org/D2020 >--------------------------------------------------------------- 4dc883562b6adaba36e79a4fd3e46ec92ad78f4f compiler/nativeGen/PPC/CodeGen.hs | 45 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs index d8e3286..7b2f79b 100644 --- a/compiler/nativeGen/PPC/CodeGen.hs +++ b/compiler/nativeGen/PPC/CodeGen.hs @@ -1005,17 +1005,7 @@ genJump (CmmLit (CmmLabel lbl)) genJump tree = do dflags <- getDynFlags - let platform = targetPlatform dflags - case platformOS platform of - OSLinux -> case platformArch platform of - ArchPPC -> genJump' tree GCPLinux - ArchPPC_64 ELF_V1 -> genJump' tree (GCPLinux64ELF 1) - ArchPPC_64 ELF_V2 -> genJump' tree (GCPLinux64ELF 2) - _ -> panic "PPC.CodeGen.genJump: Unknown Linux" - OSAIX -> genJump' tree GCPAIX - OSDarwin -> genJump' tree GCPDarwin - _ -> panic "PPC.CodeGen.genJump: not defined for this os" - + genJump' tree (platformToGCP (targetPlatform dflags)) genJump' :: CmmExpr -> GenCCallPlatform -> NatM InstrBlock @@ -1085,21 +1075,24 @@ genCCall :: ForeignTarget -- function to call -> NatM InstrBlock genCCall target dest_regs argsAndHints = do dflags <- getDynFlags - let platform = targetPlatform dflags - case platformOS platform of - OSLinux -> case platformArch platform of - ArchPPC -> genCCall' dflags GCPLinux - target dest_regs argsAndHints - ArchPPC_64 ELF_V1 -> genCCall' dflags (GCPLinux64ELF 1) - target dest_regs argsAndHints - ArchPPC_64 ELF_V2 -> genCCall' dflags (GCPLinux64ELF 2) - target dest_regs argsAndHints - _ -> panic "PPC.CodeGen.genCCall: Unknown Linux" - OSAIX -> genCCall' dflags GCPAIX target dest_regs argsAndHints - OSDarwin -> genCCall' dflags GCPDarwin target dest_regs argsAndHints - _ -> panic "PPC.CodeGen.genCCall: not defined for this os" - -data GenCCallPlatform = GCPLinux | GCPDarwin | GCPLinux64ELF Int | GCPAIX + genCCall' dflags (platformToGCP (targetPlatform dflags)) + target dest_regs argsAndHints + +-- TODO: replace 'Int' by an enum such as 'PPC_64ABI' +data GenCCallPlatform = GCPLinux | GCPDarwin | GCPLinux64ELF !Int | GCPAIX + deriving Eq + +platformToGCP :: Platform -> GenCCallPlatform +platformToGCP platform = case platformOS platform of + OSLinux -> case platformArch platform of + ArchPPC -> GCPLinux + ArchPPC_64 ELF_V1 -> GCPLinux64ELF 1 + ArchPPC_64 ELF_V2 -> GCPLinux64ELF 2 + _ -> panic "PPC.CodeGen.platformToGCP: Unknown Linux" + OSAIX -> GCPAIX + OSDarwin -> GCPDarwin + _ -> panic "PPC.CodeGen.platformToGCP: not defined for this OS" + genCCall' :: DynFlags From git at git.haskell.org Thu Mar 24 23:43:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 23:43:13 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Tidy up handling of coercion variables (c12ae2f) Message-ID: <20160324234313.7A69B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/c12ae2f986d4cd59e38752da7fd7b597d6ba903e/ghc >--------------------------------------------------------------- commit c12ae2f986d4cd59e38752da7fd7b597d6ba903e Author: Simon Peyton Jones Date: Thu Mar 24 17:31:12 2016 +0000 Tidy up handling of coercion variables * Comments to explain that a CoVar, whose IdInfo is CoVarId, is always unlifted (but may be nominal or representational role) And TyCoRep.isCoercionType picks out only those unlifted types, NOT the lifted versions * Introduce Var.NcId for non-co-var Ids with predicate isNonCoVarId * Add assertions in CoreSubst that the Id env is only used for NcIds * Fix lurking bug in CSE which extended the CoreSubst Id env with a CoVar * Fix two bugs in Specialise.spec_call, which wrongly treated CoVars like NcIds - needed a varToCoreExpr in one place - needed extendSubst not extendIdSubst in another This was the root cause of Trac #11644 Minor refactoring * Eliminate unused mkDerivedLocalCoVarM, mkUserLocalCoVar * Small refactor in mkSysLocalOrCoVar (cherry picked from commit cb08f8da37ff5fb99e1d02b8afdcb802d23e9a8d) >--------------------------------------------------------------- c12ae2f986d4cd59e38752da7fd7b597d6ba903e compiler/basicTypes/Id.hs | 20 ++---------- compiler/basicTypes/IdInfo.hs | 4 ++- compiler/basicTypes/Var.hs | 37 +++++++++++++++------- compiler/coreSyn/CoreLint.hs | 2 +- compiler/coreSyn/CoreSubst.hs | 12 ++++--- compiler/simplCore/CSE.hs | 16 ++++++---- compiler/specialise/Specialise.hs | 14 +++++--- compiler/types/TyCoRep.hs | 4 ++- .../should_compile/T11644.hs} | 2 +- testsuite/tests/simplCore/should_compile/all.T | 1 + 10 files changed, 64 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc c12ae2f986d4cd59e38752da7fd7b597d6ba903e From git at git.haskell.org Thu Mar 24 23:43:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 24 Mar 2016 23:43:16 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add NCG support for AIX/ppc32 (b200051) Message-ID: <20160324234316.314AC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/b2000510ae756318c542f874ec7e6c47d6744b3c/ghc >--------------------------------------------------------------- commit b2000510ae756318c542f874ec7e6c47d6744b3c Author: Herbert Valerio Riedel Date: Thu Mar 24 21:00:17 2016 +0100 Add NCG support for AIX/ppc32 This extends the previous work to revive the unregisterised GHC build for AIX/ppc32. Strictly speaking, AIX runs on POWER4 (and later) hardware, but the PPC32 instructions implemented in the PPC NCG represent a compatible subset of the POWER4 ISA. IBM AIX follows the PowerOpen ABI (and shares many similiarites with the Linux PPC64 ELF V1 NCG backend) but uses the rather limited XCOFF format (compared to ELF). This doesn't support dynamic libraries yet. A major limiting factor is that the AIX assembler does not support the `@ha`/`@l` relocation types nor the ha16()/lo16() functions Darwin's assembler supports. Therefore we need to avoid emitting those. In case of numeric literals we simply compute the functions ourselves, while for labels we have to use local TOCs and hope everything fits into a 16bit offset (for ppc32 this gives us at most 16384 entries per TOC section, which is enough to compile GHC). Another issue is that XCOFF doesn't seem to have a relocation type for label-differences, and therefore the label-differences placed into tables-next-to-code can't be relocated, but the linker may rearrange different sections, so we need to place all read-only sections into the same `.text[PR]` section to workaround this. Finally, the PowerOpen ABI distinguishes between function-descriptors and actualy entry-point addresses. For AIX we need to be specific when emitting assembler code whether we want the address of the function descriptor `printf`) or for the entry-point (`.printf`). So we let the asm pretty-printer prefix a dot to all emitted subroutine calls (i.e. `BL`) on AIX only. For now, STG routines' entry-point labels are not prefixed by a label and don't have any associated function-descriptor. Reviewers: austin, trommler, erikd, bgamari Reviewed By: trommler, erikd, bgamari Differential Revision: https://phabricator.haskell.org/D2019 (cherry picked from commit df26b95559fd467abc0a3a4151127c95cb5011b9) >--------------------------------------------------------------- b2000510ae756318c542f874ec7e6c47d6744b3c aclocal.m4 | 13 ++--- compiler/cmm/CLabel.hs | 13 +++-- compiler/ghc.mk | 14 ----- compiler/nativeGen/PIC.hs | 56 ++++++++++++++++++++ compiler/nativeGen/PPC/CodeGen.hs | 104 ++++++++++++++++++++++++++++++++++++-- compiler/nativeGen/PPC/Ppr.hs | 39 ++++++++++++-- compiler/nativeGen/PPC/Regs.hs | 2 + compiler/nativeGen/PprBase.hs | 14 +++++ mk/config.mk.in | 5 +- rts/StgCRun.c | 6 ++- rts/StgCRunAsm.S | 81 ++++++++++++++++++++++++++--- rts/ghc.mk | 1 + 12 files changed, 302 insertions(+), 46 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc b2000510ae756318c542f874ec7e6c47d6744b3c From git at git.haskell.org Fri Mar 25 00:28:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 00:28:44 +0000 (UTC) Subject: [commit: ghc] master: base: Fix GHC.Word and GHC.Int on 32-bit platforms (26f86f3) Message-ID: <20160325002844.51DB43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/26f86f3d397159f9c0db0b59766138f553ba5a86/ghc >--------------------------------------------------------------- commit 26f86f3d397159f9c0db0b59766138f553ba5a86 Author: Ben Gamari Date: Fri Mar 25 00:48:22 2016 +0100 base: Fix GHC.Word and GHC.Int on 32-bit platforms Due to a cut-and-paste error D1980 (#11688) broke 32-bit platforms. This should fix it. See #11750. >--------------------------------------------------------------- 26f86f3d397159f9c0db0b59766138f553ba5a86 libraries/base/GHC/Int.hs | 4 ++-- libraries/base/GHC/Word.hs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/base/GHC/Int.hs b/libraries/base/GHC/Int.hs index 558d30d..62a5a68 100644 --- a/libraries/base/GHC/Int.hs +++ b/libraries/base/GHC/Int.hs @@ -600,8 +600,8 @@ instance Eq Int64 where (/=) = neInt64 eqInt64, neInt64 :: Int64 -> Int64 -> Bool -eqInt64 (I64# x) (I64# y) = isTrue# (x ==# y) -neInt64 (I64# x) (I64# y) = isTrue# (x /=# y) +eqInt64 (I64# x) (I64# y) = isTrue# (x `eqInt64#` y) +neInt64 (I64# x) (I64# y) = isTrue# (x `neInt64#` y) {-# INLINE [1] eqInt64 #-} {-# INLINE [1] neInt64 #-} diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs index 5022ffd..384cf38 100644 --- a/libraries/base/GHC/Word.hs +++ b/libraries/base/GHC/Word.hs @@ -602,8 +602,8 @@ instance Eq Word64 where (/=) = neWord64 eqWord64, neWord64 :: Word64 -> Word64 -> Bool -eqWord64 (W64# x) (W64# y) = isTrue# (x `eqWord#` y) -neWord64 (W64# x) (W64# y) = isTrue# (x `neWord#` y) +eqWord64 (W64# x) (W64# y) = isTrue# (x `eqWord64#` y) +neWord64 (W64# x) (W64# y) = isTrue# (x `neWord64#` y) {-# INLINE [1] eqWord64 #-} {-# INLINE [1] neWord64 #-} From git at git.haskell.org Fri Mar 25 01:00:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 01:00:03 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: TysPrim: Generalize kind of (->) (6129750) Message-ID: <20160325010003.C2EDB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/6129750a414af87fcf5e4dec48e6470539053f73/ghc >--------------------------------------------------------------- commit 6129750a414af87fcf5e4dec48e6470539053f73 Author: Ben Gamari Date: Wed Mar 16 23:28:59 2016 +0100 TysPrim: Generalize kind of (->) >--------------------------------------------------------------- 6129750a414af87fcf5e4dec48e6470539053f73 compiler/prelude/TysPrim.hs | 22 ++++++++++------------ compiler/types/TyCon.hs | 6 +++--- compiler/types/Type.hs | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/compiler/prelude/TysPrim.hs b/compiler/prelude/TysPrim.hs index ce25c30..d61892c 100644 --- a/compiler/prelude/TysPrim.hs +++ b/compiler/prelude/TysPrim.hs @@ -20,7 +20,7 @@ module TysPrim( kKiVar, -- Kind constructors... - tYPETyConName, unliftedTypeKindTyConName, + tYPETyCon, tYPETyConName, unliftedTypeKindTyConName, -- Kinds tYPE, @@ -269,20 +269,18 @@ kKiVar = (mkTemplateTyVars $ repeat liftedTypeKind) !! 10 funTyConName :: Name funTyConName = mkPrimTyConName (fsLit "(->)") funTyConKey funTyCon +-- | The @(->)@ type constructor. +-- +-- @ +-- (->) :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). +-- TYPE rep1 -> TYPE rep2 -> * +-- @ funTyCon :: TyCon -funTyCon = mkFunTyCon funTyConName (map Anon [liftedTypeKind, liftedTypeKind]) - tc_rep_nm +funTyCon = mkFunTyCon funTyConName tyvars kind tc_rep_nm where - -- You might think that (->) should have type (?? -> ? -> *), and you'd be right - -- But if we do that we get kind errors when saying - -- instance Control.Arrow (->) - -- because the expected kind is (*->*->*). The trouble is that the - -- expected/actual stuff in the unifier does not go contra-variant, whereas - -- the kind sub-typing does. Sigh. It really only matters if you use (->) in - -- a prefix way, thus: (->) Int# Int#. And this is unusual. - -- because they are never in scope in the source - + tyvars = map (\tv -> Named tv Invisible) [runtimeRep1TyVar, runtimeRep2TyVar] tc_rep_nm = mkPrelTyConRepName funTyConName + kind = mkFunTys [tYPE runtimeRep1Ty, tYPE runtimeRep2Ty] liftedTypeKind {- ************************************************************************ diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs index b980c9b..3a700f4 100644 --- a/compiler/types/TyCon.hs +++ b/compiler/types/TyCon.hs @@ -1194,14 +1194,14 @@ So we compromise, and move their Kind calculation to the call site. -- | Given the name of the function type constructor and it's kind, create the -- corresponding 'TyCon'. It is reccomended to use 'TyCoRep.funTyCon' if you want -- this functionality -mkFunTyCon :: Name -> [TyBinder] -> Name -> TyCon -mkFunTyCon name binders rep_nm +mkFunTyCon :: Name -> [TyBinder] -> Kind -> Name -> TyCon +mkFunTyCon name binders kind rep_nm = FunTyCon { tyConUnique = nameUnique name, tyConName = name, tyConBinders = binders, tyConResKind = liftedTypeKind, - tyConKind = mkForAllTys binders liftedTypeKind, + tyConKind = mkForAllTys binders kind, tyConArity = 2, tcRepName = rep_nm } diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index c5561a3..6ea6a82 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -211,7 +211,7 @@ import Class import TyCon import TysPrim import {-# SOURCE #-} TysWiredIn ( listTyCon, typeNatKind - , typeSymbolKind, liftedTypeKind ) + , typeSymbolKind, runtimeRepTy, liftedTypeKind ) import PrelNames import CoAxiom import {-# SOURCE #-} Coercion @@ -980,6 +980,14 @@ tyConAppArgN n ty Just tys -> ASSERT2( n < length tys, ppr n <+> ppr tys ) tys `getNth` n Nothing -> pprPanic "tyConAppArgN" (ppr n <+> ppr ty) +-- | If given a type @TYPE (rr :: RuntimeRep)@ then returns @Just rr@ +-- otherwise @Nothing at . +tyRuntimeRep :: Type -> Maybe Type +tyRuntimeRep (TyConApp tc [rr]) + | tc == tYPETyCon = ASSERT(typeKind rr `eqType` runtimeRepTy) + Just rr +tyRuntimeRep _ = Nothing + -- | Attempts to tease a type apart into a type constructor and the application -- of a number of arguments to that constructor. Panics if that is not possible. -- See also 'splitTyConApp_maybe' @@ -998,7 +1006,9 @@ splitTyConApp_maybe ty = repSplitTyConApp_maybe ty -- assumes the synonyms have already been dealt with. repSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type]) repSplitTyConApp_maybe (TyConApp tc tys) = Just (tc, tys) -repSplitTyConApp_maybe (ForAllTy (Anon arg) res) = Just (funTyCon, [arg,res]) +repSplitTyConApp_maybe (ForAllTy (Anon arg) res) + | Just rep1 <- tyRuntimeRep arg + , Just rep2 <- tyRuntimeRep res = Just (funTyCon, [rep1, rep2, arg, res]) repSplitTyConApp_maybe _ = Nothing -- | Attempts to tease a list type apart and gives the type of the elements if From git at git.haskell.org Fri Mar 25 01:00:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 01:00:06 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow's head updated: TysPrim: Generalize kind of (->) (6129750) Message-ID: <20160325010006.8078E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/generalized-arrow' now includes: 46f9a47 DriverPipeline: Fix 'unused arguments' warnings from Clang b5565f1 Fix #11711. c5ed41c typechecker: fix trac issue #11708 3fe87aa Fix #11716. f4f315a Fix #11512 by getting visibility right for methods 220a0b9 Add test for #9646 3ddfcc9 PrelRules: Fix constant folding for WordRemOp 2841cca Mark GHC.Real.even and odd as INLINEABLE c095ec5 Ensure T11702 always runs with optasm c0f628d Revert "Add test for #11473" cb7ecda Fix duplicate T11334 test 08d254b Fix T9646 7186a01 Dwarf: Add support for labels in unwind expressions ba95f22 prof: Fix heap census for large ARR_WORDS (#11627) b735e99 DsExpr: Don't build/foldr huge lists 289d57a Add test for incompatible flags (issue #11580) cb3456d base: Rework System.CPUTime e6a44f2 T11145: Fix expected output 286c65f base: Fix CPUTime on Windows 3ade8bc Delete a misleading comment in TyCon 2cb5577 Remove unnecessary Ord instance for ConLike c37a583 Remove unused substTyWithBinders functions af2f7f9 Fix exponential algorithm in pure unifier. 01b29eb TypeApplications does not imply AllowAmbiguousTypes 0706a10 Add two small optimizations. (#11196) 1701255 Fix #11635 / #11719. 0b89064 Make equality print better. (#11712) f8ab575 Rename test for #11334 to 11334b, fixing conflict 3e1b882 Prevent eager unification with type families. 9477093 Comment a suspicious zonk in TcFlatten. 35e9379 Track specified/invisible more carefully. 5c0c751 Zonk before calling splitDepVarsOfType. d978c5e Fix #11723 and #11724. e19e58c Improve panicking output 1934f7f stgMallocBytes: Tolerate malloc(0) returning a NULL ptr 2d6d907 Comments (only) in TcFlatten 6f0e41d PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...` 685398e Use the correct in-scope set in coercionKind 0beb82c Avoid running afoul of the zipTvSubst check. 7e74079 Comment fix 7d5ff3d Move applyTysX near piResultTys db9e4eb Move DFunUnfolding generation to TcInstDcls e57b9ff Fix regression test for #11145. 2ddfb75 base: Fix ClockGetTime on OS X da3b29b Ensure T9646 dump-simpl output is cleaned 8048d51 ErrUtils: Add timings to compiler phases 997312b Add `PatSynSigSkol` and modify `PatSynCtxt` 2708c22 Close ticky profiling file stream after printing (#9405) 03a1bb4 Add unicode syntax for banana brackets 6c2c853 Various ticky-related work 9f9345e Create empty dump files (fixes #10320) 0db0594 DsExpr: Rip out static/dynamic check in list desugaring 8335cc7 Add expected output for T9405 ef653f1 Revert "Various ticky-related work" 1448f8a Show: Restore redundant parentheses around records 371608f Default RuntimeRep variables unless -fprint-explicit-runtime-reps 0bd0c31 Defer inlining of Eq for primitive types 2b5929c Comments only cb08f8d Tidy up handling of coercion variables 343349d Avoid local label syntax for assembler on AIX 2cebbe6 users_guide: Fix various issues 8ff6518 users-guide: Add -Wredundant-constraints to flags reference 173a5d8 users_guide: small improvements on pattern synonyms. 2414952 Add option `no-keep-hi-files` and `no-keep-o-files` (fixes #4114) df26b95 Add NCG support for AIX/ppc32 4dc8835 Remove code-duplication in the PPC NCG 26f86f3 base: Fix GHC.Word and GHC.Int on 32-bit platforms 6129750 TysPrim: Generalize kind of (->) From git at git.haskell.org Fri Mar 25 09:27:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 09:27:55 +0000 (UTC) Subject: [commit: ghc] master: An extra traceTc in tcExpr for ExprWithSig (84dd9d0) Message-ID: <20160325092755.E9A553A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/84dd9d0d4ccc904d64410b7f2c27ef79a5edd262/ghc >--------------------------------------------------------------- commit 84dd9d0d4ccc904d64410b7f2c27ef79a5edd262 Author: Simon Peyton Jones Date: Thu Mar 24 20:53:14 2016 +0000 An extra traceTc in tcExpr for ExprWithSig >--------------------------------------------------------------- 84dd9d0d4ccc904d64410b7f2c27ef79a5edd262 compiler/typecheck/TcExpr.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs index 4d6a109..3a8e829 100644 --- a/compiler/typecheck/TcExpr.hs +++ b/compiler/typecheck/TcExpr.hs @@ -1470,6 +1470,7 @@ tcExprSig expr sig@(TISI { sig_bndr = s_bndr else tcSubType_NC ExprSigCtxt inferred_sigma (mkCheckExpType my_sigma) + ; traceTc "tcExpSig" (ppr qtvs $$ ppr givens $$ ppr inferred_sigma $$ ppr my_sigma) ; let poly_wrap = wrap <.> mkWpTyLams qtvs <.> mkWpLams givens From git at git.haskell.org Fri Mar 25 09:27:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 09:27:58 +0000 (UTC) Subject: [commit: ghc] master: CorePrep: refactoring to reduce duplication (12372ba) Message-ID: <20160325092758.958043A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/12372baae6ff10c671ef50f3d681cffdf60e36ee/ghc >--------------------------------------------------------------- commit 12372baae6ff10c671ef50f3d681cffdf60e36ee Author: Simon Peyton Jones Date: Fri Mar 25 09:25:34 2016 +0000 CorePrep: refactoring to reduce duplication There's no functional change here, just tidying up >--------------------------------------------------------------- 12372baae6ff10c671ef50f3d681cffdf60e36ee compiler/coreSyn/CorePrep.hs | 49 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs index fb00f2b..b9b52dc 100644 --- a/compiler/coreSyn/CorePrep.hs +++ b/compiler/coreSyn/CorePrep.hs @@ -436,8 +436,6 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs ; return (floats4, bndr', rhs4) } where - is_strict_or_unlifted = (isStrictDmd dmd) || is_unlifted - platform = targetPlatform (cpe_dynFlags env) arity = idArity bndr -- We must match this arity @@ -445,14 +443,14 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs --------------------- float_from_rhs floats rhs | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs + | isTopLevel top_lvl = float_top floats rhs + | otherwise = float_nested floats rhs --------------------- float_nested floats rhs - | wantFloatNested is_rec is_strict_or_unlifted floats rhs + | wantFloatNested is_rec dmd is_unlifted floats rhs = return (floats, rhs) - | otherwise = dont_float floats rhs + | otherwise = dontFloat floats rhs --------------------- float_top floats rhs -- Urhgh! See Note [CafInfo and floating] @@ -465,16 +463,17 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs = return (floats', rhs') | otherwise - = dont_float floats rhs - - --------------------- - dont_float floats rhs - -- Non-empty floats, but do not want to float from rhs - -- So wrap the rhs in the floats - -- But: rhs1 might have lambdas, and we can't - -- put them inside a wrapBinds - = do { body <- rhsToBodyNF rhs - ; return (emptyFloats, wrapBinds floats body) } + = dontFloat floats rhs + +dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) +-- Non-empty floats, but do not want to float from rhs +-- So wrap the rhs in the floats +-- But: rhs1 might have lambdas, and we can't +-- put them inside a wrapBinds +dontFloat floats1 rhs + = do { (floats2, body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats1 $ + wrapBinds floats2 body) } {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -618,11 +617,6 @@ cpeBody env expr ; return (floats1 `appendFloats` floats2, body) } -------- -rhsToBodyNF :: CpeRhs -> UniqSM CpeBody -rhsToBodyNF rhs = do { (floats,body) <- rhsToBody rhs - ; return (wrapBinds floats body) } - --------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) -- Remove top level lambdas by let-binding @@ -763,8 +757,7 @@ cpeArg env dmd arg arg_ty = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; (floats2, arg2) <- if want_float floats1 arg1 then return (floats1, arg1) - else do { body1 <- rhsToBodyNF arg1 - ; return (emptyFloats, wrapBinds floats1 body1) } + else dontFloat floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -777,8 +770,7 @@ cpeArg env dmd arg arg_ty ; return (addFloat floats2 arg_float, varToCoreExpr v) } } where is_unlifted = isUnliftedType arg_ty - is_strict = isStrictDmd dmd - want_float = wantFloatNested NonRecursive (is_strict || is_unlifted) + want_float = wantFloatNested NonRecursive dmd is_unlifted {- Note [Floating unlifted arguments] @@ -1151,10 +1143,11 @@ canFloatFromNoCaf platform (Floats ok_to_spec fs) rhs (\i -> pprPanic "rhsIsStatic" (integer i)) -- Integer literals should not show up -wantFloatNested :: RecFlag -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec strict_or_unlifted floats rhs +wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool +wantFloatNested is_rec dmd is_unlifted floats rhs = isEmptyFloats floats - || strict_or_unlifted + || isStrictDmd dmd + || is_unlifted || (allLazyNested is_rec floats && exprIsHNF rhs) -- Why the test for allLazyNested? -- v = f (x `divInt#` y) From git at git.haskell.org Fri Mar 25 09:28:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 09:28:01 +0000 (UTC) Subject: [commit: ghc] master: Do not eta-reduce across Ticks in CorePrep (356e5e0) Message-ID: <20160325092801.467D83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/356e5e03e63558019fd0571b6c462740aceb7810/ghc >--------------------------------------------------------------- commit 356e5e03e63558019fd0571b6c462740aceb7810 Author: Simon Peyton Jones Date: Fri Mar 25 09:23:17 2016 +0000 Do not eta-reduce across Ticks in CorePrep The function tryEtaReducePrep was being over-ambitious. When Breakpoint ticks were involved (i.e. in GHCi), eta reduction left an out-of-scope variable in the Tick. Easily fixed. Fixes the original report in Trac #111728. >--------------------------------------------------------------- 356e5e03e63558019fd0571b6c462740aceb7810 compiler/coreSyn/CorePrep.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs index 58eda2f..fb00f2b 100644 --- a/compiler/coreSyn/CorePrep.hs +++ b/compiler/coreSyn/CorePrep.hs @@ -967,8 +967,13 @@ tryEtaReducePrep bndrs (Let bind@(NonRec _ r) body) where fvs = exprFreeVars r -tryEtaReducePrep bndrs (Tick tickish e) - = fmap (mkTick tickish) $ tryEtaReducePrep bndrs e +-- NB: do not attempt to eta-reduce across ticks +-- Otherwise we risk reducing +-- \x. (Tick (Breakpoint {x}) f x) +-- ==> Tick (breakpoint {x}) f +-- which is bogus (Trac #17228) +-- tryEtaReducePrep bndrs (Tick tickish e) +-- = fmap (mkTick tickish) $ tryEtaReducePrep bndrs e tryEtaReducePrep _ _ = Nothing From git at git.haskell.org Fri Mar 25 09:28:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 09:28:04 +0000 (UTC) Subject: [commit: ghc] master: A raft of comments about TyBinders (067335a) Message-ID: <20160325092804.01AE53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/067335a6724a406cbe0a956def8972682f531255/ghc >--------------------------------------------------------------- commit 067335a6724a406cbe0a956def8972682f531255 Author: Simon Peyton Jones Date: Fri Mar 25 09:28:31 2016 +0000 A raft of comments about TyBinders I had a conversation with Richard about TyBinders and VisibilityFlags. This patch adds a lot of comments to explain what is going on. I feel much more secure now. Richard please check. >--------------------------------------------------------------- 067335a6724a406cbe0a956def8972682f531255 compiler/basicTypes/DataCon.hs | 114 +++++++------- compiler/basicTypes/PatSyn.hs | 25 ++-- compiler/iface/BuildTyCl.hs | 73 ++++++++- compiler/typecheck/TcTyClsDecls.hs | 2 +- compiler/types/TyCoRep.hs | 300 +++++++++++++++++++++++++------------ compiler/types/TyCon.hs | 189 ++++++++++++----------- 6 files changed, 429 insertions(+), 274 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 067335a6724a406cbe0a956def8972682f531255 From git at git.haskell.org Fri Mar 25 10:20:37 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 10:20:37 +0000 (UTC) Subject: [commit: ghc] master: Test Trac #11728 (b416630f) Message-ID: <20160325102037.CA23D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/b416630faf92b5366fcc48941fa54b87f13994f8/ghc >--------------------------------------------------------------- commit b416630faf92b5366fcc48941fa54b87f13994f8 Author: Simon Peyton Jones Date: Fri Mar 25 10:22:07 2016 +0000 Test Trac #11728 >--------------------------------------------------------------- b416630faf92b5366fcc48941fa54b87f13994f8 testsuite/tests/ghci/scripts/T11728.hs | 30 ++++++++++++++++++++++++++++++ testsuite/tests/ghci/scripts/T11728.script | 1 + testsuite/tests/ghci/scripts/all.T | 1 + 3 files changed, 32 insertions(+) diff --git a/testsuite/tests/ghci/scripts/T11728.hs b/testsuite/tests/ghci/scripts/T11728.hs new file mode 100644 index 0000000..367a9db --- /dev/null +++ b/testsuite/tests/ghci/scripts/T11728.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE UndecidableInstances, PatternSynonyms, GADTs #-} + +module T11728 where + +import Data.Kind +import Data.Int +import GHC.TypeLits +import Text.Show.Functions + +data Ty ty where + I :: Ty Int + A :: Ty a -> Ty [a] + +class GetTy ty where getTy :: Ty ty +instance GetTy Int where getTy = I +instance GetTy ty => GetTy [ty] where + getTy = A getTy + +data E a where + UnOp :: Unary a b -> (E a -> E b) + +pattern LEN :: () => (GetTy a) => E [a] -> E Int +pattern LEN xs <- UnOp (Un OpLen _) xs where + LEN xs = UnOp (Un OpLen length) xs + +data Unary a b where + Un :: (GetTy a, GetTy b) => UnOp a b -> (a -> b) -> Unary a b + +data UnOp a b where + OpLen :: GetTy a => UnOp [a] Int diff --git a/testsuite/tests/ghci/scripts/T11728.script b/testsuite/tests/ghci/scripts/T11728.script new file mode 100644 index 0000000..fc96b81 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T11728.script @@ -0,0 +1 @@ +:l T11728 diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index f6de93b..8fab956 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -247,3 +247,4 @@ test('T11389', req_interp, run_command, ['$MAKE -s --no-print-directory T11389'] test('T11524a', normal, ghci_script, ['T11524a.script']) test('T11456', normal, ghci_script, ['T11456.script']) test('TypeAppData', normal, ghci_script, ['TypeAppData.script']) +test('T11728', normal, ghci_script, ['T11728.script']) From git at git.haskell.org Fri Mar 25 10:25:41 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 10:25:41 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: base: Fix GHC.Word and GHC.Int on 32-bit platforms (bf6e208) Message-ID: <20160325102541.7792E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/bf6e2085ce7e9de0c56b4b2ef8db24df65cd8d68/ghc >--------------------------------------------------------------- commit bf6e2085ce7e9de0c56b4b2ef8db24df65cd8d68 Author: Ben Gamari Date: Fri Mar 25 00:48:22 2016 +0100 base: Fix GHC.Word and GHC.Int on 32-bit platforms Due to a cut-and-paste error D1980 (#11688) broke 32-bit platforms. This should fix it. See #11750. (cherry picked from commit 26f86f3d397159f9c0db0b59766138f553ba5a86) >--------------------------------------------------------------- bf6e2085ce7e9de0c56b4b2ef8db24df65cd8d68 libraries/base/GHC/Int.hs | 4 ++-- libraries/base/GHC/Word.hs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/base/GHC/Int.hs b/libraries/base/GHC/Int.hs index 558d30d..62a5a68 100644 --- a/libraries/base/GHC/Int.hs +++ b/libraries/base/GHC/Int.hs @@ -600,8 +600,8 @@ instance Eq Int64 where (/=) = neInt64 eqInt64, neInt64 :: Int64 -> Int64 -> Bool -eqInt64 (I64# x) (I64# y) = isTrue# (x ==# y) -neInt64 (I64# x) (I64# y) = isTrue# (x /=# y) +eqInt64 (I64# x) (I64# y) = isTrue# (x `eqInt64#` y) +neInt64 (I64# x) (I64# y) = isTrue# (x `neInt64#` y) {-# INLINE [1] eqInt64 #-} {-# INLINE [1] neInt64 #-} diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs index 5022ffd..384cf38 100644 --- a/libraries/base/GHC/Word.hs +++ b/libraries/base/GHC/Word.hs @@ -602,8 +602,8 @@ instance Eq Word64 where (/=) = neWord64 eqWord64, neWord64 :: Word64 -> Word64 -> Bool -eqWord64 (W64# x) (W64# y) = isTrue# (x `eqWord#` y) -neWord64 (W64# x) (W64# y) = isTrue# (x `neWord#` y) +eqWord64 (W64# x) (W64# y) = isTrue# (x `eqWord64#` y) +neWord64 (W64# x) (W64# y) = isTrue# (x `neWord64#` y) {-# INLINE [1] eqWord64 #-} {-# INLINE [1] neWord64 #-} From git at git.haskell.org Fri Mar 25 10:30:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 10:30:10 +0000 (UTC) Subject: [commit: ghc] master: Document implicit quantification better (da4bc0c) Message-ID: <20160325103010.C3B103A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/da4bc0cff142225ed7fda7101cb6e559f025ebc1/ghc >--------------------------------------------------------------- commit da4bc0cff142225ed7fda7101cb6e559f025ebc1 Author: Simon Peyton Jones Date: Fri Mar 25 10:32:13 2016 +0000 Document implicit quantification better Addresses Trac #11726 >--------------------------------------------------------------- da4bc0cff142225ed7fda7101cb6e559f025ebc1 docs/users_guide/glasgow_exts.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 0128f33..7ecc929 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -9166,7 +9166,9 @@ the following pairs are equivalent: :: h x y = y in ... -Notice that GHC does *not* find the inner-most possible quantification +Notice that GHC always adds implicit quantfiers *at the outermost level* +of a user-written type; it +does *not* find the inner-most possible quantification point. For example: :: f :: (a -> a) -> Int @@ -9177,13 +9179,12 @@ point. For example: :: g :: (Ord a => a -> a) -> Int - -- MEANS the illegal type + -- MEANS g :: forall a. (Ord a => a -> a) -> Int -- NOT g :: (forall a. Ord a => a -> a) -> Int -The latter produces an illegal type, which you might think is silly, but -at least the rule is simple. If you want the latter type, you can write +If you want the latter type, you can write your ``forall``\s explicitly. Indeed, doing so is strongly advised for rank-2 types. From git at git.haskell.org Fri Mar 25 10:40:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 10:40:28 +0000 (UTC) Subject: [commit: ghc] master: More clarification in docs for implicit quantification (454585c) Message-ID: <20160325104028.C73373A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/454585c6802f0de4d23f9f16de591596533503b7/ghc >--------------------------------------------------------------- commit 454585c6802f0de4d23f9f16de591596533503b7 Author: Simon Peyton Jones Date: Fri Mar 25 10:41:57 2016 +0000 More clarification in docs for implicit quantification This is a follow-up patch to the previous one for #11726. It turns out that I'd missed the point of the ticket; this patch addresses it. >--------------------------------------------------------------- 454585c6802f0de4d23f9f16de591596533503b7 docs/users_guide/glasgow_exts.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 7ecc929..0735cfc 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -9148,7 +9148,7 @@ argument of constructor ``T1`` and that tells GHC all it needs to know. Implicit quantification ----------------------- -GHC performs implicit quantification as follows. At the top level +GHC performs implicit quantification as follows. At the outermost level (only) of user-written types, if and only if there is no explicit ``forall``, GHC finds all the type variables mentioned in the type that are not already in scope, and universally quantifies them. For example, @@ -9188,6 +9188,18 @@ If you want the latter type, you can write your ``forall``\s explicitly. Indeed, doing so is strongly advised for rank-2 types. +Sometimes there *is* no "outermost level", in which case no +implicit quanification happens: :: + + data PackMap a b s t = PackMap (Monad f => (a -> f b) -> s -> f t) + +This is rejected because there is no "outermost level" for the types on the RHS +(it would obviously be terrible to add extra parameters to ``PackMap``), +so no implicit quantificaiton happens, and the declaration is rejected +(with "``f`` is out of scope"). Solution: use an explicit ``forall``: :: + + data PackMap a b s t = PackMap (forall f. Monad f => (a -> f b) -> s -> f t) + .. _impredicative-polymorphism: Impredicative polymorphism From git at git.haskell.org Fri Mar 25 11:14:41 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 11:14:41 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Do not eta-reduce across Ticks in CorePrep (7f2d6f5) Message-ID: <20160325111441.8B9BC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/7f2d6f5a18d7b15b76bd1bf5cd59b81fb241365b/ghc >--------------------------------------------------------------- commit 7f2d6f5a18d7b15b76bd1bf5cd59b81fb241365b Author: Simon Peyton Jones Date: Fri Mar 25 09:23:17 2016 +0000 Do not eta-reduce across Ticks in CorePrep The function tryEtaReducePrep was being over-ambitious. When Breakpoint ticks were involved (i.e. in GHCi), eta reduction left an out-of-scope variable in the Tick. Easily fixed. Fixes the original report in Trac #111728. (cherry picked from commit 356e5e03e63558019fd0571b6c462740aceb7810) >--------------------------------------------------------------- 7f2d6f5a18d7b15b76bd1bf5cd59b81fb241365b compiler/coreSyn/CorePrep.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs index 04452d2..7df3409 100644 --- a/compiler/coreSyn/CorePrep.hs +++ b/compiler/coreSyn/CorePrep.hs @@ -971,8 +971,13 @@ tryEtaReducePrep bndrs (Let bind@(NonRec _ r) body) where fvs = exprFreeVars r -tryEtaReducePrep bndrs (Tick tickish e) - = fmap (mkTick tickish) $ tryEtaReducePrep bndrs e +-- NB: do not attempt to eta-reduce across ticks +-- Otherwise we risk reducing +-- \x. (Tick (Breakpoint {x}) f x) +-- ==> Tick (breakpoint {x}) f +-- which is bogus (Trac #17228) +-- tryEtaReducePrep bndrs (Tick tickish e) +-- = fmap (mkTick tickish) $ tryEtaReducePrep bndrs e tryEtaReducePrep _ _ = Nothing From git at git.haskell.org Fri Mar 25 11:14:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 11:14:44 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: CorePrep: refactoring to reduce duplication (eeb2ba1) Message-ID: <20160325111444.434323A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/eeb2ba141445ce369ffc50f15b7bbb0fb18338f3/ghc >--------------------------------------------------------------- commit eeb2ba141445ce369ffc50f15b7bbb0fb18338f3 Author: Simon Peyton Jones Date: Fri Mar 25 09:25:34 2016 +0000 CorePrep: refactoring to reduce duplication There's no functional change here, just tidying up (cherry picked from commit 12372baae6ff10c671ef50f3d681cffdf60e36ee) >--------------------------------------------------------------- eeb2ba141445ce369ffc50f15b7bbb0fb18338f3 compiler/coreSyn/CorePrep.hs | 49 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs index 7df3409..e550a67 100644 --- a/compiler/coreSyn/CorePrep.hs +++ b/compiler/coreSyn/CorePrep.hs @@ -440,8 +440,6 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs ; return (floats4, bndr', rhs4) } where - is_strict_or_unlifted = (isStrictDmd dmd) || is_unlifted - platform = targetPlatform (cpe_dynFlags env) arity = idArity bndr -- We must match this arity @@ -449,14 +447,14 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs --------------------- float_from_rhs floats rhs | isEmptyFloats floats = return (emptyFloats, rhs) - | isTopLevel top_lvl = float_top floats rhs - | otherwise = float_nested floats rhs + | isTopLevel top_lvl = float_top floats rhs + | otherwise = float_nested floats rhs --------------------- float_nested floats rhs - | wantFloatNested is_rec is_strict_or_unlifted floats rhs + | wantFloatNested is_rec dmd is_unlifted floats rhs = return (floats, rhs) - | otherwise = dont_float floats rhs + | otherwise = dontFloat floats rhs --------------------- float_top floats rhs -- Urhgh! See Note [CafInfo and floating] @@ -469,16 +467,17 @@ cpePair top_lvl is_rec dmd is_unlifted env bndr rhs = return (floats', rhs') | otherwise - = dont_float floats rhs - - --------------------- - dont_float floats rhs - -- Non-empty floats, but do not want to float from rhs - -- So wrap the rhs in the floats - -- But: rhs1 might have lambdas, and we can't - -- put them inside a wrapBinds - = do { body <- rhsToBodyNF rhs - ; return (emptyFloats, wrapBinds floats body) } + = dontFloat floats rhs + +dontFloat :: Floats -> CpeRhs -> UniqSM (Floats, CpeBody) +-- Non-empty floats, but do not want to float from rhs +-- So wrap the rhs in the floats +-- But: rhs1 might have lambdas, and we can't +-- put them inside a wrapBinds +dontFloat floats1 rhs + = do { (floats2, body) <- rhsToBody rhs + ; return (emptyFloats, wrapBinds floats1 $ + wrapBinds floats2 body) } {- Note [Silly extra arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -622,11 +621,6 @@ cpeBody env expr ; return (floats1 `appendFloats` floats2, body) } -------- -rhsToBodyNF :: CpeRhs -> UniqSM CpeBody -rhsToBodyNF rhs = do { (floats,body) <- rhsToBody rhs - ; return (wrapBinds floats body) } - --------- rhsToBody :: CpeRhs -> UniqSM (Floats, CpeBody) -- Remove top level lambdas by let-binding @@ -767,8 +761,7 @@ cpeArg env dmd arg arg_ty = do { (floats1, arg1) <- cpeRhsE env arg -- arg1 can be a lambda ; (floats2, arg2) <- if want_float floats1 arg1 then return (floats1, arg1) - else do { body1 <- rhsToBodyNF arg1 - ; return (emptyFloats, wrapBinds floats1 body1) } + else dontFloat floats1 arg1 -- Else case: arg1 might have lambdas, and we can't -- put them inside a wrapBinds @@ -781,8 +774,7 @@ cpeArg env dmd arg arg_ty ; return (addFloat floats2 arg_float, varToCoreExpr v) } } where is_unlifted = isUnliftedType arg_ty - is_strict = isStrictDmd dmd - want_float = wantFloatNested NonRecursive (is_strict || is_unlifted) + want_float = wantFloatNested NonRecursive dmd is_unlifted {- Note [Floating unlifted arguments] @@ -1155,10 +1147,11 @@ canFloatFromNoCaf platform (Floats ok_to_spec fs) rhs (\i -> pprPanic "rhsIsStatic" (integer i)) -- Integer literals should not show up -wantFloatNested :: RecFlag -> Bool -> Floats -> CpeRhs -> Bool -wantFloatNested is_rec strict_or_unlifted floats rhs +wantFloatNested :: RecFlag -> Demand -> Bool -> Floats -> CpeRhs -> Bool +wantFloatNested is_rec dmd is_unlifted floats rhs = isEmptyFloats floats - || strict_or_unlifted + || isStrictDmd dmd + || is_unlifted || (allLazyNested is_rec floats && exprIsHNF rhs) -- Why the test for allLazyNested? -- v = f (x `divInt#` y) From git at git.haskell.org Fri Mar 25 11:14:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 11:14:46 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Document implicit quantification better (590b84b) Message-ID: <20160325111446.EF4FC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/590b84bd6fff4ee43891c7a2e9ec81942edc8052/ghc >--------------------------------------------------------------- commit 590b84bd6fff4ee43891c7a2e9ec81942edc8052 Author: Simon Peyton Jones Date: Fri Mar 25 10:32:13 2016 +0000 Document implicit quantification better Addresses Trac #11726 (cherry picked from commit da4bc0cff142225ed7fda7101cb6e559f025ebc1) >--------------------------------------------------------------- 590b84bd6fff4ee43891c7a2e9ec81942edc8052 docs/users_guide/glasgow_exts.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 603ab95..38106b0 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -9145,7 +9145,9 @@ the following pairs are equivalent: :: h x y = y in ... -Notice that GHC does *not* find the inner-most possible quantification +Notice that GHC always adds implicit quantfiers *at the outermost level* +of a user-written type; it +does *not* find the inner-most possible quantification point. For example: :: f :: (a -> a) -> Int @@ -9156,13 +9158,12 @@ point. For example: :: g :: (Ord a => a -> a) -> Int - -- MEANS the illegal type + -- MEANS g :: forall a. (Ord a => a -> a) -> Int -- NOT g :: (forall a. Ord a => a -> a) -> Int -The latter produces an illegal type, which you might think is silly, but -at least the rule is simple. If you want the latter type, you can write +If you want the latter type, you can write your ``forall``\s explicitly. Indeed, doing so is strongly advised for rank-2 types. From git at git.haskell.org Fri Mar 25 11:14:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 11:14:49 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: More clarification in docs for implicit quantification (8c62c66) Message-ID: <20160325111449.A31353A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/8c62c669467bf7524635e8891201cdf92e6766fd/ghc >--------------------------------------------------------------- commit 8c62c669467bf7524635e8891201cdf92e6766fd Author: Simon Peyton Jones Date: Fri Mar 25 10:41:57 2016 +0000 More clarification in docs for implicit quantification This is a follow-up patch to the previous one for #11726. It turns out that I'd missed the point of the ticket; this patch addresses it. (cherry picked from commit 454585c6802f0de4d23f9f16de591596533503b7) >--------------------------------------------------------------- 8c62c669467bf7524635e8891201cdf92e6766fd docs/users_guide/glasgow_exts.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 38106b0..430431f 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -9127,7 +9127,7 @@ argument of constructor ``T1`` and that tells GHC all it needs to know. Implicit quantification ----------------------- -GHC performs implicit quantification as follows. At the top level +GHC performs implicit quantification as follows. At the outermost level (only) of user-written types, if and only if there is no explicit ``forall``, GHC finds all the type variables mentioned in the type that are not already in scope, and universally quantifies them. For example, @@ -9167,6 +9167,18 @@ If you want the latter type, you can write your ``forall``\s explicitly. Indeed, doing so is strongly advised for rank-2 types. +Sometimes there *is* no "outermost level", in which case no +implicit quanification happens: :: + + data PackMap a b s t = PackMap (Monad f => (a -> f b) -> s -> f t) + +This is rejected because there is no "outermost level" for the types on the RHS +(it would obviously be terrible to add extra parameters to ``PackMap``), +so no implicit quantificaiton happens, and the declaration is rejected +(with "``f`` is out of scope"). Solution: use an explicit ``forall``: :: + + data PackMap a b s t = PackMap (forall f. Monad f => (a -> f b) -> s -> f t) + .. _impredicative-polymorphism: Impredicative polymorphism From git at git.haskell.org Fri Mar 25 12:13:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 12:13:25 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: users-guide: Drop TODO in release notes (6d0a118) Message-ID: <20160325121325.8438D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/6d0a11852d820bc73d8aa8d804e73c31a626fbce/ghc >--------------------------------------------------------------- commit 6d0a11852d820bc73d8aa8d804e73c31a626fbce Author: Ben Gamari Date: Fri Mar 25 12:24:43 2016 +0100 users-guide: Drop TODO in release notes >--------------------------------------------------------------- 6d0a11852d820bc73d8aa8d804e73c31a626fbce docs/users_guide/8.0.1-notes.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst index 2ebba6e..1f4ab17 100644 --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -24,8 +24,6 @@ Highlights The highlights, since the 7.10 branch, are: -- TODO FIXME - - The new :ghc-flag:`-XTypeInType` allows promotion of all types into kinds, allowing kind synonyms, kind families, promoted GADTs, and other goodies. @@ -78,8 +76,6 @@ Full details Language ~~~~~~~~ -- TODO FIXME. - - :ghc-flag:`-XTypeInType` supports universal type promotion and merges the type and kind language. This allows, for example, higher-rank kinds, along with kind families and type-level GADTs. Support is still From git at git.haskell.org Fri Mar 25 12:13:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 12:13:28 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: TysPrim: Generalize kind of (->) (1b4750c) Message-ID: <20160325121328.40D4A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/1b4750c13764f29c898289421422cb06de58c231/ghc >--------------------------------------------------------------- commit 1b4750c13764f29c898289421422cb06de58c231 Author: Ben Gamari Date: Wed Mar 16 23:28:59 2016 +0100 TysPrim: Generalize kind of (->) >--------------------------------------------------------------- 1b4750c13764f29c898289421422cb06de58c231 compiler/prelude/TysPrim.hs | 22 ++++++++++------------ compiler/types/TyCon.hs | 6 +++--- compiler/types/Type.hs | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/compiler/prelude/TysPrim.hs b/compiler/prelude/TysPrim.hs index ce25c30..d61892c 100644 --- a/compiler/prelude/TysPrim.hs +++ b/compiler/prelude/TysPrim.hs @@ -20,7 +20,7 @@ module TysPrim( kKiVar, -- Kind constructors... - tYPETyConName, unliftedTypeKindTyConName, + tYPETyCon, tYPETyConName, unliftedTypeKindTyConName, -- Kinds tYPE, @@ -269,20 +269,18 @@ kKiVar = (mkTemplateTyVars $ repeat liftedTypeKind) !! 10 funTyConName :: Name funTyConName = mkPrimTyConName (fsLit "(->)") funTyConKey funTyCon +-- | The @(->)@ type constructor. +-- +-- @ +-- (->) :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). +-- TYPE rep1 -> TYPE rep2 -> * +-- @ funTyCon :: TyCon -funTyCon = mkFunTyCon funTyConName (map Anon [liftedTypeKind, liftedTypeKind]) - tc_rep_nm +funTyCon = mkFunTyCon funTyConName tyvars kind tc_rep_nm where - -- You might think that (->) should have type (?? -> ? -> *), and you'd be right - -- But if we do that we get kind errors when saying - -- instance Control.Arrow (->) - -- because the expected kind is (*->*->*). The trouble is that the - -- expected/actual stuff in the unifier does not go contra-variant, whereas - -- the kind sub-typing does. Sigh. It really only matters if you use (->) in - -- a prefix way, thus: (->) Int# Int#. And this is unusual. - -- because they are never in scope in the source - + tyvars = map (\tv -> Named tv Invisible) [runtimeRep1TyVar, runtimeRep2TyVar] tc_rep_nm = mkPrelTyConRepName funTyConName + kind = mkFunTys [tYPE runtimeRep1Ty, tYPE runtimeRep2Ty] liftedTypeKind {- ************************************************************************ diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs index 787da10..2aaea5e 100644 --- a/compiler/types/TyCon.hs +++ b/compiler/types/TyCon.hs @@ -1189,14 +1189,14 @@ So we compromise, and move their Kind calculation to the call site. -- | Given the name of the function type constructor and it's kind, create the -- corresponding 'TyCon'. It is reccomended to use 'TyCoRep.funTyCon' if you want -- this functionality -mkFunTyCon :: Name -> [TyBinder] -> Name -> TyCon -mkFunTyCon name binders rep_nm +mkFunTyCon :: Name -> [TyBinder] -> Kind -> Name -> TyCon +mkFunTyCon name binders kind rep_nm = FunTyCon { tyConUnique = nameUnique name, tyConName = name, tyConBinders = binders, tyConResKind = liftedTypeKind, - tyConKind = mkForAllTys binders liftedTypeKind, + tyConKind = mkForAllTys binders kind, tyConArity = 2, tcRepName = rep_nm } diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index c5561a3..6ea6a82 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -211,7 +211,7 @@ import Class import TyCon import TysPrim import {-# SOURCE #-} TysWiredIn ( listTyCon, typeNatKind - , typeSymbolKind, liftedTypeKind ) + , typeSymbolKind, runtimeRepTy, liftedTypeKind ) import PrelNames import CoAxiom import {-# SOURCE #-} Coercion @@ -980,6 +980,14 @@ tyConAppArgN n ty Just tys -> ASSERT2( n < length tys, ppr n <+> ppr tys ) tys `getNth` n Nothing -> pprPanic "tyConAppArgN" (ppr n <+> ppr ty) +-- | If given a type @TYPE (rr :: RuntimeRep)@ then returns @Just rr@ +-- otherwise @Nothing at . +tyRuntimeRep :: Type -> Maybe Type +tyRuntimeRep (TyConApp tc [rr]) + | tc == tYPETyCon = ASSERT(typeKind rr `eqType` runtimeRepTy) + Just rr +tyRuntimeRep _ = Nothing + -- | Attempts to tease a type apart into a type constructor and the application -- of a number of arguments to that constructor. Panics if that is not possible. -- See also 'splitTyConApp_maybe' @@ -998,7 +1006,9 @@ splitTyConApp_maybe ty = repSplitTyConApp_maybe ty -- assumes the synonyms have already been dealt with. repSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type]) repSplitTyConApp_maybe (TyConApp tc tys) = Just (tc, tys) -repSplitTyConApp_maybe (ForAllTy (Anon arg) res) = Just (funTyCon, [arg,res]) +repSplitTyConApp_maybe (ForAllTy (Anon arg) res) + | Just rep1 <- tyRuntimeRep arg + , Just rep2 <- tyRuntimeRep res = Just (funTyCon, [rep1, rep2, arg, res]) repSplitTyConApp_maybe _ = Nothing -- | Attempts to tease a list type apart and gives the type of the elements if From git at git.haskell.org Fri Mar 25 12:13:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 12:13:30 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Fixes (1d46fbd) Message-ID: <20160325121330.E1E463A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/1d46fbd3b6f30da1e0afc391aad63d5cda50081a/ghc >--------------------------------------------------------------- commit 1d46fbd3b6f30da1e0afc391aad63d5cda50081a Author: Ben Gamari Date: Fri Mar 25 12:48:08 2016 +0100 Fixes >--------------------------------------------------------------- 1d46fbd3b6f30da1e0afc391aad63d5cda50081a compiler/types/Type.hs | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 6ea6a82..7354b16 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -657,8 +657,10 @@ repSplitAppTy_maybe :: Type -> Maybe (Type,Type) -- ^ Does the AppTy split as in 'splitAppTy_maybe', but assumes that -- any Core view stuff is already done repSplitAppTy_maybe (ForAllTy (Anon ty1) ty2) - = Just (TyConApp funTyCon [ty1], ty2) -repSplitAppTy_maybe (AppTy ty1 ty2) = Just (ty1, ty2) + | Just rep1 <- tyRuntimeRep_maybe ty1 + , Just rep2 <- tyRuntimeRep_maybe ty2 = Just (TyConApp funTyCon [rep1, rep2, ty1], ty2) + | otherwise = pprPanic "repSplitAppTy_maybe" (ppr ty1 $$ ppr ty2) +repSplitAppTy_maybe (AppTy ty1 ty2) = Just (ty1, ty2) repSplitAppTy_maybe (TyConApp tc tys) | mightBeUnsaturatedTyCon tc || tys `lengthExceeds` tyConArity tc , Just (tys', ty') <- snocView tys @@ -673,7 +675,9 @@ tcRepSplitAppTy_maybe :: Type -> Maybe (Type,Type) -- any coreView stuff is already done. Refuses to look through (c => t) tcRepSplitAppTy_maybe (ForAllTy (Anon ty1) ty2) | isConstraintKind (typeKind ty1) = Nothing -- See Note [Decomposing fat arrow c=>t] - | otherwise = Just (TyConApp funTyCon [ty1], ty2) + | Just rep1 <- tyRuntimeRep_maybe ty1 + , Just rep2 <- tyRuntimeRep_maybe ty2 = Just (TyConApp funTyCon [rep1, rep2, ty1], ty2) + | otherwise = pprPanic "repSplitAppTy_maybe" (ppr ty1 $$ ppr ty2) tcRepSplitAppTy_maybe (AppTy ty1 ty2) = Just (ty1, ty2) tcRepSplitAppTy_maybe (TyConApp tc tys) | mightBeUnsaturatedTyCon tc || tys `lengthExceeds` tyConArity tc @@ -704,8 +708,11 @@ splitAppTys ty = split ty ty [] (tc_args1, tc_args2) = splitAt n tc_args in (TyConApp tc tc_args1, tc_args2 ++ args) - split _ (ForAllTy (Anon ty1) ty2) args = ASSERT( null args ) + split _ (ForAllTy (Anon ty1) ty2) args + | Just rep1 <- tyRuntimeRep_maybe ty1 + , Just rep2 <- tyRuntimeRep_maybe ty2 = ASSERT( null args ) (TyConApp funTyCon [], [ty1,ty2]) + | otherwise = pprPanic "splitAppTys" (ppr ty1 $$ ppr ty2 $$ ppr args) split orig_ty _ args = (orig_ty, args) -- | Like 'splitAppTys', but doesn't look through type synonyms @@ -719,8 +726,11 @@ repSplitAppTys ty = split ty [] (tc_args1, tc_args2) = splitAt n tc_args in (TyConApp tc tc_args1, tc_args2 ++ args) - split (ForAllTy (Anon ty1) ty2) args = ASSERT( null args ) + split (ForAllTy (Anon ty1) ty2) args + | Just rep1 <- tyRuntimeRep_maybe ty1 + , Just rep2 <- tyRuntimeRep_maybe ty2= ASSERT( null args ) (TyConApp funTyCon [], [ty1, ty2]) + | otherwise = pprPanic "repSplitAppTys" (ppr ty1 $$ ppr ty2 $$ ppr args) split ty args = (ty, args) {- @@ -935,7 +945,7 @@ applyTysX tvs body_ty arg_tys -- its arguments. Applies its arguments to the constructor from left to right. mkTyConApp :: TyCon -> [Type] -> Type mkTyConApp tycon tys - | isFunTyCon tycon, [ty1,ty2] <- tys + | isFunTyCon tycon, [_rep1,_rep2,ty1,ty2] <- tys = ForAllTy (Anon ty1) ty2 | otherwise @@ -982,11 +992,16 @@ tyConAppArgN n ty -- | If given a type @TYPE (rr :: RuntimeRep)@ then returns @Just rr@ -- otherwise @Nothing at . -tyRuntimeRep :: Type -> Maybe Type -tyRuntimeRep (TyConApp tc [rr]) - | tc == tYPETyCon = ASSERT(typeKind rr `eqType` runtimeRepTy) - Just rr -tyRuntimeRep _ = Nothing +tyRuntimeRep_maybe :: Type -> Maybe Type +tyRuntimeRep_maybe (TyConApp tc [rr]) + | tc == tYPETyCon = ASSERT(typeKind rr `eqType` runtimeRepTy) + Just rr +tyRuntimeRep_maybe _ = Nothing + +tyRuntimeRep :: Type -> Type +tyRuntimeRep ty + | Just rep <- tyRuntimeRep_maybe ty = rep + | otherwise = pprPanic "tyRuntimeRep" (ppr ty) -- | Attempts to tease a type apart into a type constructor and the application -- of a number of arguments to that constructor. Panics if that is not possible. @@ -1007,8 +1022,9 @@ splitTyConApp_maybe ty = repSplitTyConApp_maybe ty repSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type]) repSplitTyConApp_maybe (TyConApp tc tys) = Just (tc, tys) repSplitTyConApp_maybe (ForAllTy (Anon arg) res) - | Just rep1 <- tyRuntimeRep arg - , Just rep2 <- tyRuntimeRep res = Just (funTyCon, [rep1, rep2, arg, res]) + | Just rep1 <- tyRuntimeRep_maybe arg + , Just rep2 <- tyRuntimeRep_maybe res = Just (funTyCon, [rep1, rep2, arg, res]) + | otherwise = pprPanic "repSplitTyConApp_maybe" (ppr arg $$ ppr res) repSplitTyConApp_maybe _ = Nothing -- | Attempts to tease a list type apart and gives the type of the elements if From git at git.haskell.org Fri Mar 25 12:13:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 12:13:33 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Hi (38de61e) Message-ID: <20160325121333.8D2F93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/38de61e0c07cabfe05f1ade34409516054c1ffd0/ghc >--------------------------------------------------------------- commit 38de61e0c07cabfe05f1ade34409516054c1ffd0 Author: Ben Gamari Date: Fri Mar 25 13:04:39 2016 +0100 Hi >--------------------------------------------------------------- 38de61e0c07cabfe05f1ade34409516054c1ffd0 compiler/types/Type.hs | 71 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 7354b16..c516664 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -657,10 +657,10 @@ repSplitAppTy_maybe :: Type -> Maybe (Type,Type) -- ^ Does the AppTy split as in 'splitAppTy_maybe', but assumes that -- any Core view stuff is already done repSplitAppTy_maybe (ForAllTy (Anon ty1) ty2) - | Just rep1 <- tyRuntimeRep_maybe ty1 - , Just rep2 <- tyRuntimeRep_maybe ty2 = Just (TyConApp funTyCon [rep1, rep2, ty1], ty2) - | otherwise = pprPanic "repSplitAppTy_maybe" (ppr ty1 $$ ppr ty2) -repSplitAppTy_maybe (AppTy ty1 ty2) = Just (ty1, ty2) + | Just rep1 <- kindRuntimeRep_maybe ty1 + , Just rep2 <- kindRuntimeRep_maybe ty2 = Just (TyConApp funTyCon [rep1, rep2, ty1], ty2) + | otherwise = pprPanic "repSplitAppTy_maybe" (ppr ty1 $$ ppr ty2) +repSplitAppTy_maybe (AppTy ty1 ty2) = Just (ty1, ty2) repSplitAppTy_maybe (TyConApp tc tys) | mightBeUnsaturatedTyCon tc || tys `lengthExceeds` tyConArity tc , Just (tys', ty') <- snocView tys @@ -674,11 +674,11 @@ tcRepSplitAppTy_maybe :: Type -> Maybe (Type,Type) -- ^ Does the AppTy split as in 'tcSplitAppTy_maybe', but assumes that -- any coreView stuff is already done. Refuses to look through (c => t) tcRepSplitAppTy_maybe (ForAllTy (Anon ty1) ty2) - | isConstraintKind (typeKind ty1) = Nothing -- See Note [Decomposing fat arrow c=>t] - | Just rep1 <- tyRuntimeRep_maybe ty1 - , Just rep2 <- tyRuntimeRep_maybe ty2 = Just (TyConApp funTyCon [rep1, rep2, ty1], ty2) - | otherwise = pprPanic "repSplitAppTy_maybe" (ppr ty1 $$ ppr ty2) -tcRepSplitAppTy_maybe (AppTy ty1 ty2) = Just (ty1, ty2) + | isConstraintKind (typeKind ty1) = Nothing -- See Note [Decomposing fat arrow c=>t] + | Just rep1 <- kindRuntimeRep_maybe ty1 + , Just rep2 <- kindRuntimeRep_maybe ty2 = Just (TyConApp funTyCon [rep1, rep2, ty1], ty2) + | otherwise = pprPanic "repSplitAppTy_maybe" (ppr ty1 $$ ppr ty2) +tcRepSplitAppTy_maybe (AppTy ty1 ty2) = Just (ty1, ty2) tcRepSplitAppTy_maybe (TyConApp tc tys) | mightBeUnsaturatedTyCon tc || tys `lengthExceeds` tyConArity tc , Just (tys', ty') <- snocView tys @@ -709,11 +709,11 @@ splitAppTys ty = split ty ty [] in (TyConApp tc tc_args1, tc_args2 ++ args) split _ (ForAllTy (Anon ty1) ty2) args - | Just rep1 <- tyRuntimeRep_maybe ty1 - , Just rep2 <- tyRuntimeRep_maybe ty2 = ASSERT( null args ) - (TyConApp funTyCon [], [ty1,ty2]) - | otherwise = pprPanic "splitAppTys" (ppr ty1 $$ ppr ty2 $$ ppr args) - split orig_ty _ args = (orig_ty, args) + | Just rep1 <- kindRuntimeRep_maybe ty1 + , Just rep2 <- kindRuntimeRep_maybe ty2 = ASSERT( null args ) + (TyConApp funTyCon [], [rep1, rep2, ty1, ty2]) + | otherwise = pprPanic "splitAppTys" (ppr ty1 $$ ppr ty2 $$ ppr args) + split orig_ty _ args = (orig_ty, args) -- | Like 'splitAppTys', but doesn't look through type synonyms repSplitAppTys :: Type -> (Type, [Type]) @@ -727,10 +727,12 @@ repSplitAppTys ty = split ty [] in (TyConApp tc tc_args1, tc_args2 ++ args) split (ForAllTy (Anon ty1) ty2) args - | Just rep1 <- tyRuntimeRep_maybe ty1 - , Just rep2 <- tyRuntimeRep_maybe ty2= ASSERT( null args ) - (TyConApp funTyCon [], [ty1, ty2]) - | otherwise = pprPanic "repSplitAppTys" (ppr ty1 $$ ppr ty2 $$ ppr args) + | Just rep1 <- kindRuntimeRep_maybe ty1 + , Just rep2 <- kindRuntimeRep_maybe ty2 = + ASSERT( null args ) + (TyConApp funTyCon [], [rep1, rep2, ty1, ty2]) + | otherwise = + pprPanic "repSplitAppTys" (ppr ty1 $$ ppr ty2 $$ ppr args) split ty args = (ty, args) {- @@ -803,7 +805,30 @@ pprUserTypeErrorTy ty = FunTy ~~~~~ -Function types are represented with (ForAllTy (Anon ...) ...) +Note [Function types] +~~~~~~~~~~~~~~~~~~~~~ + +Functions (e.g. Int -> Char) are can be thought of as being applications +of funTyCon (known in Haskell surface syntax as (->)), + + (->) :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep) + (a :: TYPE r1) (b :: Type r2). + a -> b -> * + +However, for efficiency's sake we represent saturated applications of (->) +with ForAllTy. For instance, the type, + + (->) r1 r2 a b + +is equivalent to, + + ForAllTy (Anon a) b + +Note how the RuntimeReps are implied in the ForAllTy representation. For this +reason we must be careful when recontructing the TyConApp representation (see, +for instance, splitTyConApp_maybe). + +See #11714. -} isFunTy :: Type -> Bool @@ -1003,6 +1028,10 @@ tyRuntimeRep ty | Just rep <- tyRuntimeRep_maybe ty = rep | otherwise = pprPanic "tyRuntimeRep" (ppr ty) +-- | If given a type @a :: TYPE (rr :: RuntimeRep)@ then returns @Just rr at . +kindRuntimeRep_maybe :: Type -> Maybe Type +kindRuntimeRep_maybe = tyRuntimeRep_maybe . typeKind + -- | Attempts to tease a type apart into a type constructor and the application -- of a number of arguments to that constructor. Panics if that is not possible. -- See also 'splitTyConApp_maybe' @@ -1022,8 +1051,8 @@ splitTyConApp_maybe ty = repSplitTyConApp_maybe ty repSplitTyConApp_maybe :: Type -> Maybe (TyCon, [Type]) repSplitTyConApp_maybe (TyConApp tc tys) = Just (tc, tys) repSplitTyConApp_maybe (ForAllTy (Anon arg) res) - | Just rep1 <- tyRuntimeRep_maybe arg - , Just rep2 <- tyRuntimeRep_maybe res = Just (funTyCon, [rep1, rep2, arg, res]) + | Just rep1 <- kindRuntimeRep_maybe arg + , Just rep2 <- kindRuntimeRep_maybe res = Just (funTyCon, [rep1, rep2, arg, res]) | otherwise = pprPanic "repSplitTyConApp_maybe" (ppr arg $$ ppr res) repSplitTyConApp_maybe _ = Nothing From git at git.haskell.org Fri Mar 25 12:13:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 12:13:36 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Special case Constraint (9c9fa7f) Message-ID: <20160325121336.3BA483A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/9c9fa7f97a91cbf673ab6214b9fb3a3a08adcc11/ghc >--------------------------------------------------------------- commit 9c9fa7f97a91cbf673ab6214b9fb3a3a08adcc11 Author: Ben Gamari Date: Fri Mar 25 13:13:23 2016 +0100 Special case Constraint >--------------------------------------------------------------- 9c9fa7f97a91cbf673ab6214b9fb3a3a08adcc11 compiler/types/Type.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index c516664..bab28b7 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -211,7 +211,8 @@ import Class import TyCon import TysPrim import {-# SOURCE #-} TysWiredIn ( listTyCon, typeNatKind - , typeSymbolKind, runtimeRepTy, liftedTypeKind ) + , typeSymbolKind, runtimeRepTy, ptrRepLiftedTy + , liftedTypeKind ) import PrelNames import CoAxiom import {-# SOURCE #-} Coercion @@ -1018,6 +1019,8 @@ tyConAppArgN n ty -- | If given a type @TYPE (rr :: RuntimeRep)@ then returns @Just rr@ -- otherwise @Nothing at . tyRuntimeRep_maybe :: Type -> Maybe Type +tyRuntimeRep_maybe ty + | isConstraintKind ty = Just ptrRepLiftedTy -- FIXME This is a hack tyRuntimeRep_maybe (TyConApp tc [rr]) | tc == tYPETyCon = ASSERT(typeKind rr `eqType` runtimeRepTy) Just rr From git at git.haskell.org Fri Mar 25 12:13:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 12:13:38 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow's head updated: Special case Constraint (9c9fa7f) Message-ID: <20160325121338.9CC643A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/generalized-arrow' now includes: 84dd9d0 An extra traceTc in tcExpr for ExprWithSig 356e5e0 Do not eta-reduce across Ticks in CorePrep 12372ba CorePrep: refactoring to reduce duplication 067335a A raft of comments about TyBinders b416630f Test Trac #11728 da4bc0c Document implicit quantification better 454585c More clarification in docs for implicit quantification 6d0a118 users-guide: Drop TODO in release notes 1b4750c TysPrim: Generalize kind of (->) 1d46fbd Fixes 38de61e Hi 9c9fa7f Special case Constraint From git at git.haskell.org Fri Mar 25 20:18:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 20:18:55 +0000 (UTC) Subject: [commit: ghc] wip/rae: Fix #11754 by adding an additional check. (ccd68f2) Message-ID: <20160325201855.43F5F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/ccd68f22fe1bb48d81f941a8c0b9bd2a79e4566f/ghc >--------------------------------------------------------------- commit ccd68f22fe1bb48d81f941a8c0b9bd2a79e4566f Author: Richard Eisenberg Date: Fri Mar 25 15:11:24 2016 -0400 Fix #11754 by adding an additional check. This was just plain wrong previously. Test case: typecheck/should_compile/T11754 >--------------------------------------------------------------- ccd68f22fe1bb48d81f941a8c0b9bd2a79e4566f compiler/types/OptCoercion.hs | 7 +++--- testsuite/tests/typecheck/should_compile/T11754.hs | 28 ++++++++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/compiler/types/OptCoercion.hs b/compiler/types/OptCoercion.hs index fb6c68e..e39f0aa 100644 --- a/compiler/types/OptCoercion.hs +++ b/compiler/types/OptCoercion.hs @@ -874,10 +874,11 @@ etaTyConAppCo_maybe tc (TyConAppCo _ tc2 cos2) etaTyConAppCo_maybe tc co | mightBeUnsaturatedTyCon tc - , Pair ty1 ty2 <- coercionKind co - , Just (tc1, tys1) <- splitTyConApp_maybe ty1 - , Just (tc2, tys2) <- splitTyConApp_maybe ty2 + , (Pair ty1 ty2, r) <- coercionKindRole co + , Just (tc1, tys1) <- splitTyConApp_maybe ty1 + , Just (tc2, tys2) <- splitTyConApp_maybe ty2 , tc1 == tc2 + , isInjectiveTyCon tc r -- See Note [NthCo and newtypes] in TyCoRep , let n = length tys1 = ASSERT( tc == tc1 ) ASSERT( n == length tys2 ) diff --git a/testsuite/tests/typecheck/should_compile/T11754.hs b/testsuite/tests/typecheck/should_compile/T11754.hs new file mode 100644 index 0000000..248be2b --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11754.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE TypeOperators, UndecidableSuperClasses, KindSignatures, +TypeFamilies, FlexibleContexts #-} + +module T11754 where + +import Data.Kind +import Data.Void + +newtype K a x = K a +newtype I x = I x + +data (f + g) x = L (f x) | R (g x) +data (f ? g) x = f x :?: g x + +class Differentiable (D f) => Differentiable f where + type D (f :: Type -> Type) :: Type -> Type + +instance Differentiable (K a) where + type D (K a) = K Void + +instance Differentiable I where + type D I = K () + +instance (Differentiable f?, Differentiable f?) => Differentiable (f? + f?) where + type D (f? + f?) = D f? + D f? + +instance (Differentiable f?, Differentiable f?) => Differentiable (f? ? f?) where + type D (f? ? f?) = (D f? ? f?) + (f? ? D f?) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 267795b..0d99284 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -510,3 +510,4 @@ test('T11608', normal, compile, ['']) test('T11401', normal, compile, ['']) test('T11699', normal, compile, ['']) test('T11512', normal, compile, ['']) +test('T11754', normal, compile, ['']) From git at git.haskell.org Fri Mar 25 20:18:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 20:18:58 +0000 (UTC) Subject: [commit: ghc] wip/rae: Check for rep poly on wildcard binders. (b840ab7) Message-ID: <20160325201858.75D2D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/rae Link : http://ghc.haskell.org/trac/ghc/changeset/b840ab75d800f19d9bfba5d413bc93e545e1cebc/ghc >--------------------------------------------------------------- commit b840ab75d800f19d9bfba5d413bc93e545e1cebc Author: Richard Eisenberg Date: Fri Mar 25 16:18:09 2016 -0400 Check for rep poly on wildcard binders. I had just missed this case when adding my test. This is relevant to ticket #11473. >--------------------------------------------------------------- b840ab75d800f19d9bfba5d413bc93e545e1cebc compiler/typecheck/TcHsSyn.hs | 14 ++++++++------ testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs | 10 ++++++++++ .../tests/typecheck/should_fail/BadUnboxedTuple.stderr | 6 ++++++ testsuite/tests/typecheck/should_fail/all.T | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs index 88110b7..1baa4a3 100644 --- a/compiler/typecheck/TcHsSyn.hs +++ b/compiler/typecheck/TcHsSyn.hs @@ -283,7 +283,8 @@ zonkIdOccs env ids = map (zonkIdOcc env) ids zonkIdBndr :: ZonkEnv -> TcId -> TcM Id zonkIdBndr env id = do ty' <- zonkTcTypeToType env (idType id) - ensureNotRepresentationPolymorphic id ty' + ensureNotRepresentationPolymorphic ty' + (text "In the type of binder" <+> quotes (ppr id)) return (setIdType id ty') zonkIdBndrs :: ZonkEnv -> [TcId] -> TcM [Id] @@ -1160,6 +1161,8 @@ zonk_pat env (ParPat p) zonk_pat env (WildPat ty) = do { ty' <- zonkTcTypeToType env ty + ; ensureNotRepresentationPolymorphic ty' + (text "In a wildcard pattern") ; return (env, WildPat ty') } zonk_pat env (VarPat (L l v)) @@ -1663,14 +1666,13 @@ zonkTypeZapping tv -- isn't really a compositional property of a type system, so it's -- not a terrible surprise that the check has to go in an awkward spot. ensureNotRepresentationPolymorphic - :: TcId -- the id we're checking (for errors only) - -> Type -- its zonked type + :: Type -- its zonked type + -> SDoc -- where this happened -> TcM () -ensureNotRepresentationPolymorphic id ty +ensureNotRepresentationPolymorphic ty doc = whenNoErrs $ -- sometimes we end up zonking bogus definitions of type -- forall a. a. See, for example, test ghci/scripts/T9140 - checkForRepresentationPolymorphism - (text "In the type of binder" <+> quotes (ppr id)) ty + checkForRepresentationPolymorphism doc ty checkForRepresentationPolymorphism :: SDoc -> Type -> TcM () checkForRepresentationPolymorphism extra ty diff --git a/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs new file mode 100644 index 0000000..2935416 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilies, KindSignatures, TypeInType #-} + +module BadUnboxedTuple where + +import GHC.Exts + +type family F :: TYPE UnboxedTupleRep + +foo :: F -> () +foo _ = () diff --git a/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr new file mode 100644 index 0000000..7c5ad57 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr @@ -0,0 +1,6 @@ + +BadUnboxedTuple.hs:10:5: error: + The type ?F? is not an unboxed tuple, + and yet its kind suggests that it has the representation + of an unboxed tuple. This is not allowed. + In a wildcard pattern diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index f24736e..867ea38 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -411,3 +411,4 @@ test('T11541', normal, compile_fail, ['']) test('T11313', normal, compile_fail, ['']) test('T11723', normal, compile_fail, ['']) test('T11724', normal, compile_fail, ['']) +test('BadUnboxedTuple', normal, compile_fail, ['']) From git at git.haskell.org Fri Mar 25 20:19:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 20:19:00 +0000 (UTC) Subject: [commit: ghc] wip/rae's head updated: Check for rep poly on wildcard binders. (b840ab7) Message-ID: <20160325201900.BD9583A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/rae' now includes: 7e74079 Comment fix 7d5ff3d Move applyTysX near piResultTys db9e4eb Move DFunUnfolding generation to TcInstDcls e57b9ff Fix regression test for #11145. 2ddfb75 base: Fix ClockGetTime on OS X da3b29b Ensure T9646 dump-simpl output is cleaned 8048d51 ErrUtils: Add timings to compiler phases 997312b Add `PatSynSigSkol` and modify `PatSynCtxt` 2708c22 Close ticky profiling file stream after printing (#9405) 03a1bb4 Add unicode syntax for banana brackets 6c2c853 Various ticky-related work 9f9345e Create empty dump files (fixes #10320) 0db0594 DsExpr: Rip out static/dynamic check in list desugaring 8335cc7 Add expected output for T9405 ef653f1 Revert "Various ticky-related work" 1448f8a Show: Restore redundant parentheses around records 371608f Default RuntimeRep variables unless -fprint-explicit-runtime-reps 0bd0c31 Defer inlining of Eq for primitive types 2b5929c Comments only cb08f8d Tidy up handling of coercion variables 343349d Avoid local label syntax for assembler on AIX 2cebbe6 users_guide: Fix various issues 8ff6518 users-guide: Add -Wredundant-constraints to flags reference 173a5d8 users_guide: small improvements on pattern synonyms. 2414952 Add option `no-keep-hi-files` and `no-keep-o-files` (fixes #4114) df26b95 Add NCG support for AIX/ppc32 4dc8835 Remove code-duplication in the PPC NCG 26f86f3 base: Fix GHC.Word and GHC.Int on 32-bit platforms 84dd9d0 An extra traceTc in tcExpr for ExprWithSig 356e5e0 Do not eta-reduce across Ticks in CorePrep 12372ba CorePrep: refactoring to reduce duplication 067335a A raft of comments about TyBinders b416630f Test Trac #11728 da4bc0c Document implicit quantification better 454585c More clarification in docs for implicit quantification ccd68f2 Fix #11754 by adding an additional check. b840ab7 Check for rep poly on wildcard binders. From git at git.haskell.org Fri Mar 25 22:56:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 22:56:33 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Make it compile with ghc-7.8 (0a13e0c) Message-ID: <20160325225633.0F1A53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0a13e0c60416242bf7ed5715df489901119a9944/ghc >--------------------------------------------------------------- commit 0a13e0c60416242bf7ed5715df489901119a9944 Author: Erik de Castro Lopo Date: Fri Mar 25 15:45:17 2016 +1100 Make it compile with ghc-7.8 * Fix `getAllocationCounter` workaround for ghc-7.8. * Replace `pure` with `return`. >--------------------------------------------------------------- 0a13e0c60416242bf7ed5715df489901119a9944 compiler/llvmGen/LlvmMangler.hs | 2 +- compiler/main/CodeOutput.hs | 2 +- compiler/main/ErrUtils.hs | 8 ++++++-- compiler/main/GhcMake.hs | 2 +- compiler/simplCore/SimplCore.hs | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/llvmGen/LlvmMangler.hs b/compiler/llvmGen/LlvmMangler.hs index acf344f..6fb6b7e 100644 --- a/compiler/llvmGen/LlvmMangler.hs +++ b/compiler/llvmGen/LlvmMangler.hs @@ -23,7 +23,7 @@ import System.IO -- | Read in assembly file and process llvmFixupAsm :: DynFlags -> FilePath -> FilePath -> IO () llvmFixupAsm dflags f1 f2 = {-# SCC "llvm_mangler" #-} - withTiming (pure dflags) (text "LLVM Mangler") id $ + withTiming (return dflags) (text "LLVM Mangler") id $ withBinaryFile f1 ReadMode $ \r -> withBinaryFile f2 WriteMode $ \w -> do go r w hClose r diff --git a/compiler/main/CodeOutput.hs b/compiler/main/CodeOutput.hs index f172cf1..90eb2d0 100644 --- a/compiler/main/CodeOutput.hs +++ b/compiler/main/CodeOutput.hs @@ -64,7 +64,7 @@ codeOutput dflags this_mod filenm location foreign_stubs pkg_deps cmm_stream then Stream.mapM do_lint cmm_stream else cmm_stream - do_lint cmm = withTiming (pure dflags) + do_lint cmm = withTiming (return dflags) (text "CmmLint"<+>brackets (ppr this_mod)) (const ()) $ do { case cmmLint dflags cmm of diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs index 9b98b5e..3675b85 100644 --- a/compiler/main/ErrUtils.hs +++ b/compiler/main/ErrUtils.hs @@ -69,7 +69,11 @@ import Data.Time import Control.Monad import Control.Monad.IO.Class import System.IO +#if MIN_VERSION_base(4,8,0) import GHC.Conc ( getAllocationCounter ) +#else +import GHC.Int ( Int64 ) +#endif import System.CPUTime ------------------------- @@ -507,7 +511,7 @@ withTiming getDFlags what force_result action alloc0 <- liftIO getAllocationCounter start <- liftIO getCPUTime !r <- action - () <- pure $ force_result r + () <- return $ force_result r end <- liftIO getCPUTime alloc1 <- liftIO getAllocationCounter -- recall that allocation counter counts down @@ -520,7 +524,7 @@ withTiming getDFlags what force_result action <+> text "allocated" <+> doublePrec 3 (realToFrac alloc / 1024 / 1024) <+> text "megabytes") - pure r + return r else action debugTraceMsg :: DynFlags -> Int -> MsgDoc -> IO () diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs index 46a4990..9dc43cd 100644 --- a/compiler/main/GhcMake.hs +++ b/compiler/main/GhcMake.hs @@ -114,7 +114,7 @@ depanal excluded_mods allow_dup_roots = do targets = hsc_targets hsc_env old_graph = hsc_mod_graph hsc_env - withTiming (pure dflags) (text "Chasing dependencies") (const ()) $ do + withTiming (return dflags) (text "Chasing dependencies") (const ()) $ do liftIO $ debugTraceMsg dflags 2 (hcat [ text "Chasing modules from: ", hcat (punctuate comma (map pprTarget targets))]) diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs index 98bcf2a..5fadd03 100644 --- a/compiler/simplCore/SimplCore.hs +++ b/compiler/simplCore/SimplCore.hs @@ -507,7 +507,7 @@ simplifyExpr :: DynFlags -- includes spec of what core-to-core passes to do -- -- Also used by Template Haskell simplifyExpr dflags expr - = withTiming (pure dflags) (text "Simplify [expr]") (const ()) $ + = withTiming (return dflags) (text "Simplify [expr]") (const ()) $ do { ; us <- mkSplitUniqSupply 's' From git at git.haskell.org Fri Mar 25 23:24:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 23:24:20 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: DynFlags: Initialize unsafeGlobalDynFlags enough to be useful (49879ce) Message-ID: <20160325232420.377F43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/49879ceaa043530eb1ade11de30fbca2fe98fcea/ghc >--------------------------------------------------------------- commit 49879ceaa043530eb1ade11de30fbca2fe98fcea Author: Ben Gamari Date: Fri Mar 25 16:43:41 2016 +0100 DynFlags: Initialize unsafeGlobalDynFlags enough to be useful Previously unsafeGlobalDynFlags would bottom if used prior to initialization. This meant that any attempt to use the pretty-printer early in the initialization process of the compiler would fail. This is quite inconvenient. Here we initialize unsafeGlobalDynFlags with defaultDynFlags, bottoming only if settings is accessed. See #11755. >--------------------------------------------------------------- 49879ceaa043530eb1ade11de30fbca2fe98fcea compiler/main/DynFlags.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 99d80d6..9c67045 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -4855,7 +4855,15 @@ makeDynFlagsConsistent dflags -- Do not use it if you can help it. You may get the wrong value, or this -- panic! -GLOBAL_VAR(v_unsafeGlobalDynFlags, panic "v_unsafeGlobalDynFlags: not initialised", DynFlags) +-- | This is the value that 'unsafeGlobalDynFlags' takes before it is +-- initialized. +defaultGlobalDynFlags :: DynFlags +defaultGlobalDynFlags = + (defaultDynFlags settings) { verbosity = 2 } + where + settings = panic "v_unsafeGlobalDynFlags: not initialised" + +GLOBAL_VAR(v_unsafeGlobalDynFlags, defaultGlobalDynFlags, DynFlags) unsafeGlobalDynFlags :: DynFlags unsafeGlobalDynFlags = unsafePerformIO $ readIORef v_unsafeGlobalDynFlags From git at git.haskell.org Fri Mar 25 23:24:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 23:24:22 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Panic: Try outputting SDocs (f06d4fd) Message-ID: <20160325232422.DB0993A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/f06d4fd69334ac4b25ac173f7fc7f55b6ad739c8/ghc >--------------------------------------------------------------- commit f06d4fd69334ac4b25ac173f7fc7f55b6ad739c8 Author: Ben Gamari Date: Fri Mar 25 16:54:56 2016 +0100 Panic: Try outputting SDocs This works in conjunction with D2036 to allow useful debug output before DynFlags has been initializated. See #11755. >--------------------------------------------------------------- f06d4fd69334ac4b25ac173f7fc7f55b6ad739c8 compiler/utils/Outputable.hs-boot | 2 ++ compiler/utils/Panic.hs | 52 ++++++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/compiler/utils/Outputable.hs-boot b/compiler/utils/Outputable.hs-boot index 1c15a69..e5e8895 100644 --- a/compiler/utils/Outputable.hs-boot +++ b/compiler/utils/Outputable.hs-boot @@ -1,3 +1,5 @@ module Outputable where data SDoc + +showSDocUnsafe :: SDoc -> String diff --git a/compiler/utils/Panic.hs b/compiler/utils/Panic.hs index f1ccb7b..b19c770 100644 --- a/compiler/utils/Panic.hs +++ b/compiler/utils/Panic.hs @@ -27,7 +27,7 @@ module Panic ( ) where #include "HsVersions.h" -import {-# SOURCE #-} Outputable (SDoc) +import {-# SOURCE #-} Outputable (SDoc, showSDocUnsafe) import Config import Exception @@ -125,35 +125,47 @@ safeShowException e = do forceList xs@(x : xt) = x `seq` forceList xt `seq` xs -- | Append a description of the given exception to this string. -showGhcException :: GhcException -> String -> String +-- +-- Note that this uses 'DynFlags.unsafeGlobalDynFlags', which may have some +-- uninitialized fields if invoked before 'GHC.initGhcMonad' has been called. +-- If the error message to be printed includes a pretty-printer document +-- which forces one of these fields this call may bottom. +showGhcException :: GhcException -> ShowS showGhcException exception = case exception of UsageError str -> showString str . showChar '\n' . showString short_usage CmdLineError str -> showString str - PprProgramError str _ -> - showGhcException (ProgramError (str ++ "\n<
>")) + PprProgramError str sdoc -> + showString str . showString "\n\n" . + showString (showSDocUnsafe sdoc) ProgramError str -> showString str InstallationError str -> showString str Signal n -> showString "signal: " . shows n - PprPanic s _ -> - showGhcException (Panic (s ++ "\n<
>")) - Panic s - -> showString $ - "panic! (the 'impossible' happened)\n" - ++ " (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t" - ++ s ++ "\n\n" - ++ "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n" - - PprSorry s _ -> - showGhcException (Sorry (s ++ "\n<
>")) - Sorry s - -> showString $ - "sorry! (unimplemented feature or known bug)\n" - ++ " (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t" - ++ s ++ "\n" + PprPanic s sdoc -> + panicMsg $ showString s . showString "\n\n" + . showString (showSDocUnsafe sdoc) + Panic s -> panicMsg (showString s) + + PprSorry s sdoc -> + sorryMsg $ showString s . showString "\n\n" + . showString (showSDocUnsafe sdoc) + Sorry s -> sorryMsg (showString s) + where + sorryMsg :: ShowS -> ShowS + sorryMsg s = + showString "sorry! (unimplemented feature or known bug)\n" + . showString (" (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t") + . s . showString "\n" + + panicMsg :: ShowS -> ShowS + panicMsg s = + showString "panic! (the 'impossible' happened)\n" + . showString (" (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t") + . s . showString "\n\n" + . showString "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n" throwGhcException :: GhcException -> a From git at git.haskell.org Fri Mar 25 23:24:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 23:24:25 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: TysPrim: Generalize kind of (->) (776f7d0) Message-ID: <20160325232425.9997E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/776f7d09d55ea4d016a3c39e17746e4f7f87357e/ghc >--------------------------------------------------------------- commit 776f7d09d55ea4d016a3c39e17746e4f7f87357e Author: Ben Gamari Date: Wed Mar 16 23:28:59 2016 +0100 TysPrim: Generalize kind of (->) >--------------------------------------------------------------- 776f7d09d55ea4d016a3c39e17746e4f7f87357e compiler/prelude/TysPrim.hs | 25 ++++++------ compiler/typecheck/TcCanonical.hs | 9 ++++- compiler/typecheck/TcType.hs | 8 +++- compiler/types/Coercion.hs | 19 +++++++-- compiler/types/TyCon.hs | 2 +- compiler/types/Type.hs | 85 ++++++++++++++++++++++++++++++++------- compiler/types/Unify.hs | 7 +++- 7 files changed, 122 insertions(+), 33 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 776f7d09d55ea4d016a3c39e17746e4f7f87357e From git at git.haskell.org Fri Mar 25 23:24:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 23:24:28 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: CoreLint: Check that there are no saturated (->) applications (89b2685) Message-ID: <20160325232428.441FB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/89b26858b53be665cc1de3c5f4b36170fd67d01e/ghc >--------------------------------------------------------------- commit 89b26858b53be665cc1de3c5f4b36170fd67d01e Author: Ben Gamari Date: Fri Mar 25 13:28:40 2016 +0100 CoreLint: Check that there are no saturated (->) applications >--------------------------------------------------------------- 89b26858b53be665cc1de3c5f4b36170fd67d01e compiler/coreSyn/CoreLint.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index ef44aff..1c40049 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -127,6 +127,12 @@ Outstanding issues: -- may well be happening...); +Note [Linting function types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +As described in Note [Representation of function types], all saturated +applications of funTyCon are represented with ForAllTy. We check this +invariant in lintType. + Note [Linting type lets] ~~~~~~~~~~~~~~~~~~~~~~~~ In the desugarer, it's very very convenient to be able to say (in effect) @@ -1033,6 +1039,12 @@ lintType ty@(TyConApp tc tys) = lintType ty' -- Expand type synonyms, so that we do not bogusly complain -- about un-saturated type synonyms + -- We should never see a saturated application of funTyCon; such applications + -- should be represented with ForAllTy. See Note [Linting function types]. + | isFunTyCon tc + , length tys == 4 + = failWithL (hang (text "Saturated application of (->)") 2 (ppr ty)) + | isUnliftedTyCon tc || isTypeSynonymTyCon tc || isTypeFamilyTyCon tc -- Also type synonyms and type families , length tys < tyConArity tc From git at git.haskell.org Fri Mar 25 23:24:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 23:24:30 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Type: Special case tyRuntimeRep for Constraint (ef3e900) Message-ID: <20160325232430.F23B03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/ef3e9008e640a1a53ca6281718bbb3598a3fa59d/ghc >--------------------------------------------------------------- commit ef3e9008e640a1a53ca6281718bbb3598a3fa59d Author: Ben Gamari Date: Fri Mar 25 13:13:23 2016 +0100 Type: Special case tyRuntimeRep for Constraint Since we have been discussing unifying Constraint and * this seems reasonable for now. >--------------------------------------------------------------- ef3e9008e640a1a53ca6281718bbb3598a3fa59d compiler/types/Type.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index f7c007f..75be46e 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -213,7 +213,8 @@ import Class import TyCon import TysPrim import {-# SOURCE #-} TysWiredIn ( listTyCon, typeNatKind - , typeSymbolKind, runtimeRepTy, liftedTypeKind ) + , typeSymbolKind, runtimeRepTy, ptrRepLiftedTy + , liftedTypeKind ) import PrelNames import CoAxiom import {-# SOURCE #-} Coercion @@ -1023,6 +1024,8 @@ tyConAppArgN n ty -- | If given a type @TYPE (rr :: RuntimeRep)@ then returns @Just rr@ -- otherwise @Nothing at . tyRuntimeRep_maybe :: Type -> Maybe Type +tyRuntimeRep_maybe ty + | isConstraintKind ty = Just ptrRepLiftedTy -- FIXME This is a hack tyRuntimeRep_maybe (TyConApp tc [rr]) | tc == tYPETyCon = ASSERT(typeKind rr `eqType` runtimeRepTy) Just rr From git at git.haskell.org Fri Mar 25 23:24:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 23:24:33 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Try simplifying mkFunCo.mkRuntimeRepCo (8626f9c) Message-ID: <20160325232433.9AAB63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/8626f9c9d20291da021524c715ddd94746ffbed9/ghc >--------------------------------------------------------------- commit 8626f9c9d20291da021524c715ddd94746ffbed9 Author: Ben Gamari Date: Sat Mar 26 00:14:55 2016 +0100 Try simplifying mkFunCo.mkRuntimeRepCo >--------------------------------------------------------------- 8626f9c9d20291da021524c715ddd94746ffbed9 compiler/types/Coercion.hs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs index 37e57a8..b365f72 100644 --- a/compiler/types/Coercion.hs +++ b/compiler/types/Coercion.hs @@ -580,13 +580,7 @@ mkFunCo r co1 co2 = -- for each co :: (t1 :: TYPE r1) ~ (t2 :: TYPE r2) -- we need rep_co :: r1 ~ r2 mkRuntimeRepCo :: Coercion -> Coercion - mkRuntimeRepCo co - | Just (tc, [rep]) <- splitTyConAppCo_maybe $ mkKindCo co - , tc == tYPETyCon - = rep - | otherwise - = pprPanic "mkFunCo.mkRuntimeRepCo" - (ppr co $$ ppr co1 <+> arrow <+> ppr co2) + mkRuntimeRepCo = mkNthCo 0 . mkKindCo -- | Make nested function 'Coercion's From git at git.haskell.org Fri Mar 25 23:24:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Fri, 25 Mar 2016 23:24:36 +0000 (UTC) Subject: [commit: ghc] wip/generalized-arrow: Coercion: More assertion output (5b4d2ec) Message-ID: <20160325232436.4C3733A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/generalized-arrow Link : http://ghc.haskell.org/trac/ghc/changeset/5b4d2ec661460712d491cb557d27bee9901fefac/ghc >--------------------------------------------------------------- commit 5b4d2ec661460712d491cb557d27bee9901fefac Author: Ben Gamari Date: Sat Mar 26 00:21:37 2016 +0100 Coercion: More assertion output >--------------------------------------------------------------- 5b4d2ec661460712d491cb557d27bee9901fefac compiler/types/Coercion.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs index b365f72..72e9318 100644 --- a/compiler/types/Coercion.hs +++ b/compiler/types/Coercion.hs @@ -868,7 +868,7 @@ mkNthCo 0 (Refl _ ty) | Just (tv, _) <- splitForAllTy_maybe ty = Refl Nominal (tyVarKind tv) mkNthCo n (Refl r ty) - = ASSERT( ok_tc_app ty n ) + = ASSERT2( ok_tc_app ty n, ppr n $$ ppr ty ) mkReflCo r' (tyConAppArgN n ty) where tc = tyConAppTyCon ty r' = nthRole r tc n From git at git.haskell.org Sat Mar 26 00:57:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:57:58 +0000 (UTC) Subject: [commit: ghc] branch 'wip/eventlog-heap-profile' created Message-ID: <20160326005758.9C9E53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc New branch : wip/eventlog-heap-profile Referencing: c117e27f2e91990c8a96b92c130d341b8f3938d7 From git at git.haskell.org Sat Mar 26 00:58:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:01 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: DynFlags: Initialize unsafeGlobalDynFlags enough to be useful (4e98b4f) Message-ID: <20160326005801.6067F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902/ghc >--------------------------------------------------------------- commit 4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902 Author: Ben Gamari Date: Sat Mar 26 00:42:11 2016 +0100 DynFlags: Initialize unsafeGlobalDynFlags enough to be useful Previously unsafeGlobalDynFlags would bottom if used prior to initialization. This meant that any attempt to use the pretty-printer early in the initialization process of the compiler would fail. This is quite inconvenient. Here we initialize unsafeGlobalDynFlags with defaultDynFlags, bottoming only if settings is accessed. See #11755. Test Plan: Validate Reviewers: austin Reviewed By: austin Subscribers: thomie, gridaphobe Differential Revision: https://phabricator.haskell.org/D2036 GHC Trac Issues: #11755 >--------------------------------------------------------------- 4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902 compiler/main/DynFlags.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 99d80d6..9c67045 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -4855,7 +4855,15 @@ makeDynFlagsConsistent dflags -- Do not use it if you can help it. You may get the wrong value, or this -- panic! -GLOBAL_VAR(v_unsafeGlobalDynFlags, panic "v_unsafeGlobalDynFlags: not initialised", DynFlags) +-- | This is the value that 'unsafeGlobalDynFlags' takes before it is +-- initialized. +defaultGlobalDynFlags :: DynFlags +defaultGlobalDynFlags = + (defaultDynFlags settings) { verbosity = 2 } + where + settings = panic "v_unsafeGlobalDynFlags: not initialised" + +GLOBAL_VAR(v_unsafeGlobalDynFlags, defaultGlobalDynFlags, DynFlags) unsafeGlobalDynFlags :: DynFlags unsafeGlobalDynFlags = unsafePerformIO $ readIORef v_unsafeGlobalDynFlags From git at git.haskell.org Sat Mar 26 00:58:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:04 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: Panic: Try outputting SDocs (e8d3567) Message-ID: <20160326005804.0EF653A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/e8d356773b56c1e56911b6359a368fe2f5d3ed1c/ghc >--------------------------------------------------------------- commit e8d356773b56c1e56911b6359a368fe2f5d3ed1c Author: Ben Gamari Date: Sat Mar 26 00:42:27 2016 +0100 Panic: Try outputting SDocs This works in conjunction with D2036 to allow useful debug output before DynFlags has been initializated. See #11755. Reviewers: austin Reviewed By: austin Subscribers: thomie, gridaphobe Differential Revision: https://phabricator.haskell.org/D2037 GHC Trac Issues: #11755 >--------------------------------------------------------------- e8d356773b56c1e56911b6359a368fe2f5d3ed1c compiler/utils/Outputable.hs-boot | 2 ++ compiler/utils/Panic.hs | 52 ++++++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/compiler/utils/Outputable.hs-boot b/compiler/utils/Outputable.hs-boot index 1c15a69..e5e8895 100644 --- a/compiler/utils/Outputable.hs-boot +++ b/compiler/utils/Outputable.hs-boot @@ -1,3 +1,5 @@ module Outputable where data SDoc + +showSDocUnsafe :: SDoc -> String diff --git a/compiler/utils/Panic.hs b/compiler/utils/Panic.hs index f1ccb7b..b19c770 100644 --- a/compiler/utils/Panic.hs +++ b/compiler/utils/Panic.hs @@ -27,7 +27,7 @@ module Panic ( ) where #include "HsVersions.h" -import {-# SOURCE #-} Outputable (SDoc) +import {-# SOURCE #-} Outputable (SDoc, showSDocUnsafe) import Config import Exception @@ -125,35 +125,47 @@ safeShowException e = do forceList xs@(x : xt) = x `seq` forceList xt `seq` xs -- | Append a description of the given exception to this string. -showGhcException :: GhcException -> String -> String +-- +-- Note that this uses 'DynFlags.unsafeGlobalDynFlags', which may have some +-- uninitialized fields if invoked before 'GHC.initGhcMonad' has been called. +-- If the error message to be printed includes a pretty-printer document +-- which forces one of these fields this call may bottom. +showGhcException :: GhcException -> ShowS showGhcException exception = case exception of UsageError str -> showString str . showChar '\n' . showString short_usage CmdLineError str -> showString str - PprProgramError str _ -> - showGhcException (ProgramError (str ++ "\n<
>")) + PprProgramError str sdoc -> + showString str . showString "\n\n" . + showString (showSDocUnsafe sdoc) ProgramError str -> showString str InstallationError str -> showString str Signal n -> showString "signal: " . shows n - PprPanic s _ -> - showGhcException (Panic (s ++ "\n<
>")) - Panic s - -> showString $ - "panic! (the 'impossible' happened)\n" - ++ " (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t" - ++ s ++ "\n\n" - ++ "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n" - - PprSorry s _ -> - showGhcException (Sorry (s ++ "\n<
>")) - Sorry s - -> showString $ - "sorry! (unimplemented feature or known bug)\n" - ++ " (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t" - ++ s ++ "\n" + PprPanic s sdoc -> + panicMsg $ showString s . showString "\n\n" + . showString (showSDocUnsafe sdoc) + Panic s -> panicMsg (showString s) + + PprSorry s sdoc -> + sorryMsg $ showString s . showString "\n\n" + . showString (showSDocUnsafe sdoc) + Sorry s -> sorryMsg (showString s) + where + sorryMsg :: ShowS -> ShowS + sorryMsg s = + showString "sorry! (unimplemented feature or known bug)\n" + . showString (" (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t") + . s . showString "\n" + + panicMsg :: ShowS -> ShowS + panicMsg s = + showString "panic! (the 'impossible' happened)\n" + . showString (" (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t") + . s . showString "\n\n" + . showString "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n" throwGhcException :: GhcException -> a From git at git.haskell.org Sat Mar 26 00:58:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:06 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: testsuite: Identify framework failures in testsuite summary (d0787a2) Message-ID: <20160326005806.B20333A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/d0787a2c232b61f8be080048ea48af7697094c97/ghc >--------------------------------------------------------------- commit d0787a2c232b61f8be080048ea48af7697094c97 Author: Ben Gamari Date: Sat Mar 26 00:43:24 2016 +0100 testsuite: Identify framework failures in testsuite summary Currently the testsuite driver tells you how many tests failed due to a framework failure but you need to manually grep through the testsuite output to identify which ones. Test Plan: Validate with, e.g., a timing out testcase Reviewers: austin, thomie Reviewed By: austin, thomie Differential Revision: https://phabricator.haskell.org/D2026 GHC Trac Issues: #11165 >--------------------------------------------------------------- d0787a2c232b61f8be080048ea48af7697094c97 testsuite/driver/testlib.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index 0e2ba49..bba3516 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -2265,6 +2265,10 @@ def summary(t, file, short=False): file.write('Unexpected stat failures:\n') printFailingTestInfosSummary(file, t.unexpected_stat_failures) + if t.n_framework_failures > 0: + file.write('Test framework failures:\n') + printFrameworkFailureSummary(file, t.framework_failures) + if config.check_files_written: checkForFilesWrittenProblems(file) @@ -2310,6 +2314,16 @@ def printFailingTestInfosSummary(file, testInfos): ' (' + ','.join(testInfos[directory][test][reason]) + ')\n') file.write('\n') +def printFrameworkFailureSummary(file, testInfos): + names = list(testInfos.keys()) + names.sort() + maxNameLen = max(len(n) for n in names) + for name in names: + ways = testInfos[name] + file.write(' ' + name.ljust(maxNameLen + 2) + \ + ' (' + ','.join(ways) + ')\n') + file.write('\n') + def modify_lines(s, f): s = '\n'.join([f(l) for l in s.splitlines()]) if s and s[-1] != '\n': From git at git.haskell.org Sat Mar 26 00:58:09 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:09 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: DWARF: Add debugging information chapter to users guide (1b4d120) Message-ID: <20160326005809.E833D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/1b4d1201d6fe395db2b268ca111baa69d96ce211/ghc >--------------------------------------------------------------- commit 1b4d1201d6fe395db2b268ca111baa69d96ce211 Author: Ben Gamari Date: Sat Mar 26 00:44:21 2016 +0100 DWARF: Add debugging information chapter to users guide Test Plan: Proof-read Reviewers: scpmw, austin Subscribers: simonmar, thomie Differential Revision: https://phabricator.haskell.org/D1369 >--------------------------------------------------------------- 1b4d1201d6fe395db2b268ca111baa69d96ce211 docs/users_guide/debug-info.rst | 314 ++++++++++++++++++++++++++++++++++++++++ docs/users_guide/index.rst | 1 + 2 files changed, 315 insertions(+) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 1b4d1201d6fe395db2b268ca111baa69d96ce211 From git at git.haskell.org Sat Mar 26 00:58:12 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:12 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: Log heap profiler samples to event log (436be90) Message-ID: <20160326005812.9F5873A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/436be90ac8616ac504e91da917db67a1c469e6b9/ghc >--------------------------------------------------------------- commit 436be90ac8616ac504e91da917db67a1c469e6b9 Author: Ben Gamari Date: Wed Dec 30 22:32:32 2015 +0100 Log heap profiler samples to event log >--------------------------------------------------------------- 436be90ac8616ac504e91da917db67a1c469e6b9 includes/rts/EventLogFormat.h | 7 +- rts/ProfHeap.c | 32 +++++++- rts/Trace.c | 43 ++++++++++ rts/Trace.h | 19 +++++ rts/eventlog/EventLog.c | 183 ++++++++++++++++++++++++++++++++++++++++++ rts/eventlog/EventLog.h | 20 +++++ 6 files changed, 300 insertions(+), 4 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 436be90ac8616ac504e91da917db67a1c469e6b9 From git at git.haskell.org Sat Mar 26 00:58:15 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:15 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: Allow prof, eventlog, and threaded ways to coexist (a2dd1c3) Message-ID: <20160326005815.4A80E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/a2dd1c3d2ae4e318ab1f4a83015eb11381560f80/ghc >--------------------------------------------------------------- commit a2dd1c3d2ae4e318ab1f4a83015eb11381560f80 Author: Ben Gamari Date: Thu Dec 31 10:15:26 2015 +0100 Allow prof, eventlog, and threaded ways to coexist >--------------------------------------------------------------- a2dd1c3d2ae4e318ab1f4a83015eb11381560f80 compiler/main/DynFlags.hs | 1 + mk/config.mk.in | 2 +- mk/ways.mk | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 9c67045..e4451f4 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1259,6 +1259,7 @@ allowed_combination way = and [ x `allowedWith` y (WayCustom {}) `allowedWith` _ = True WayThreaded `allowedWith` WayProf = True WayThreaded `allowedWith` WayEventLog = True + WayProf `allowedWith` WayEventLog = True _ `allowedWith` _ = False mkBuildTag :: [Way] -> String diff --git a/mk/config.mk.in b/mk/config.mk.in index d2bf321..d811359 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -289,7 +289,7 @@ GhcRTSWays += debug # We always have the threaded versions, but note that SMP support may be disabled # (see GhcWithSMP). GhcRTSWays += thr thr_debug thr_l -GhcRTSWays += $(if $(findstring p, $(GhcLibWays)),thr_p,) +GhcRTSWays += $(if $(findstring p, $(GhcLibWays)),thr_p p_l thr_p_l,) GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn,) # We can only build GHCi threaded if we have a threaded RTS: diff --git a/mk/ways.mk b/mk/ways.mk index 996530e..80301f7 100644 --- a/mk/ways.mk +++ b/mk/ways.mk @@ -22,7 +22,7 @@ # # The ways currently defined. # -ALL_WAYS=v p l debug dyn thr thr_l p_dyn debug_dyn thr_dyn thr_p_dyn thr_debug_dyn thr_p thr_debug debug_p thr_debug_p l_dyn thr_l_dyn +ALL_WAYS=v p l debug dyn thr thr_l p_dyn p_l debug_dyn thr_dyn thr_p_dyn thr_debug_dyn thr_p thr_debug debug_p thr_debug_p l_dyn thr_l_dyn p_l thr_p_l # # The following ways currently are treated specially, @@ -68,6 +68,10 @@ WAY_debug_HC_OPTS= -static -optc-DDEBUG -ticky -DTICKY_TICKY WAY_debug_p_NAME=debug profiled WAY_debug_p_HC_OPTS= -static -optc-DDEBUG -prof +# Way 'p_l': +WAY_p_l_NAME=profiling event logging +WAY_p_l_HC_OPTS= -static -prof -eventlog + # Way 'thr_debug': WAY_thr_debug_NAME=threaded debug WAY_thr_debug_HC_OPTS= -static -optc-DTHREADED_RTS -optc-DDEBUG @@ -106,3 +110,6 @@ WAY_l_dyn_HC_OPTS= -fPIC -dynamic -eventlog WAY_thr_l_dyn_NAME=threaded event logging dynamic WAY_thr_l_dyn_HC_OPTS= -fPIC -dynamic -optc-DTHREADED_RTS -eventlog +# Way 'thr_p_l': +WAY_thr_p_l_NAME=threaded profiling event logging +WAY_thr_p_l_HC_OPTS= -static -prof -optc-DTHREADED_RTS -eventlog From git at git.haskell.org Sat Mar 26 00:58:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:17 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: Documentation (237f7ab) Message-ID: <20160326005817.F24783A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/237f7abac1730347e03e4dccf1c05909a79d50cb/ghc >--------------------------------------------------------------- commit 237f7abac1730347e03e4dccf1c05909a79d50cb Author: Ben Gamari Date: Thu Dec 31 19:57:10 2015 +0100 Documentation >--------------------------------------------------------------- 237f7abac1730347e03e4dccf1c05909a79d50cb docs/users_guide/profiling.rst | 108 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/docs/users_guide/profiling.rst b/docs/users_guide/profiling.rst index 4d0bb3a..2b38113 100644 --- a/docs/users_guide/profiling.rst +++ b/docs/users_guide/profiling.rst @@ -1361,3 +1361,111 @@ which includeds a link to the ticky-ticky profiling page. .. [3] This feature was added in GHC 7.4.1. + + + +Heap profiler event log output +------------------------------ + +The heap profiler can produce output to GHC's event log, allowing samples to +be correlated with other events over the program's lifecycle. + +This section defines the layout of these events. The ``String`` type below is +defined to be a UTF-8 encoded NUL-terminated string. + +Metadata event types +~~~~~~~~~~~~~~~~~~~~ + +Beginning of sample stream +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A single fixed-width event emitted during program start-up describing the samples that follow. + + * ``EVENT_HEAP_PROF_BEGIN`` + * ``Word8``: Profile ID + * ``Word64``: Sampling period in nanoseconds + * ``Word32``: Sample break-down type. One of, + * ``SAMPLE_TYPE_COST_CENTER`` (output from ``-hc``) + * ``SAMPLE_TYPE_CLOSURE_DESCR`` (output from ``-hd``) + * ``SAMPLE_TYPE_RETAINER`` (output from ``-hr``) + * ``SAMPLE_TYPE_MODULE`` (output from ``-hm``) + * ``SAMPLE_TYPE_TYPE_DESCR`` (output from ``-hy``) + * ``SAMPLE_TYPE_BIOGRAPHY`` (output from ``-hb``) + * ``String``: Cost centre filter + * ``String``: Closure description filter + * ``String``: Retainer filter + * ``String``: Module filter + * ``String``: Type description filter + +Cost center definitions +^^^^^^^^^^^^^^^^^^^^^^^ + +A variable-length packet produced once for each cost center, + + * ``EVENT_HEAP_PROF_COST_CENTRE`` + * ``Word32``: cost center number + * ``String``: label + * ``String``: module + * ``String``: source location + * ``Word8``: is a CAF? + + +Sample event types +~~~~~~~~~~~~~~~~~~ + +A sample (consisting of a list of break-down classes, e.g. cost centers, and +heap residency sizes), is to be encoded in the body of one or more events. + +We mark the beginning of a new sample with an ``EVENT_HEAP_PROF_SAMPLE_BEGIN`` +event, + + * ``EVENT_HEAP_PROF_SAMPLE_BEGIN`` + * ``Word64``: sample number + +A heap residency census will follow. Since events may only be up to 2^16^ bytes +in length a single sample may need to be split among multiple +``EVENT_HEAP_PROF_SAMPLE`` events. The precise format of the census entries is +determined by the break-down type. + + +Cost-center break-down +^^^^^^^^^^^^^^^^^^^^^^ + +A variable-length packet encoding a heap profile sample broken down by, + * cost-center (``-hc``) + * retainer (``-hr``) + + * ``EVENT_HEAP_PROF_SAMPLE`` + * ``Word8``: Profile ID + * ``Word64``: heap residency in bytes + * ``Word8``: stack depth + * ``Word32[]``: cost center stack starting with inner-most (cost center numbers) + + +String break-down +^^^^^^^^^^^^^^^^^ + +A variable-length event encoding a heap sample broken down by, + * type description (``-hy``) + * closure description (``-hd``) + * module (``-hm``) + + * ``EVENT_HEAP_PROF_SAMPLE`` + * ``Word8``: Profile ID + * The event shall contain packed pairs of, + * ``String``: type description + * ``Word64``: heap residency in bytes + + +Biography break-down +^^^^^^^^^^^^^^^^^^^^ + +A fixed-length event encoding a biography heap sample. + + * ``EVENT_HEAP_PROF_SAMPLE`` + * ``Word8``: Profile ID + * ``Word64``: Void + * ``Word64``: Lag + * ``Word64``: Use + * ``Word64``: Inherent use + * ``Word64``: Drag From git at git.haskell.org Sat Mar 26 00:58:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 00:58:20 +0000 (UTC) Subject: [commit: ghc] wip/eventlog-heap-profile: Fix ways (c117e27) Message-ID: <20160326005820.AB66B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/eventlog-heap-profile Link : http://ghc.haskell.org/trac/ghc/changeset/c117e27f2e91990c8a96b92c130d341b8f3938d7/ghc >--------------------------------------------------------------- commit c117e27f2e91990c8a96b92c130d341b8f3938d7 Author: Ben Gamari Date: Sat Mar 26 01:32:46 2016 +0100 Fix ways >--------------------------------------------------------------- c117e27f2e91990c8a96b92c130d341b8f3938d7 compiler/main/DynFlags.hs | 2 +- mk/config.mk.in | 24 +++++++++++++----------- mk/ways.mk | 44 +++++++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index e4451f4..1ab2c93 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -2345,7 +2345,7 @@ dynamic_flags_deps = [ d { enableTimeStats = True }))) ------- ways --------------------------------------------------------------- - , make_ord_flag defGhcFlag "prof" (NoArg (addWay WayProf)) + , make_ord_flag defGhcFlag "prof" (NoArg (addWay WayProf >> addWay WayEventLog)) , make_ord_flag defGhcFlag "eventlog" (NoArg (addWay WayEventLog)) , make_dep_flag defGhcFlag "smp" (NoArg $ addWay WayThreaded) "Use -threaded instead" diff --git a/mk/config.mk.in b/mk/config.mk.in index d811359..a3763a0 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -258,7 +258,7 @@ GhcLibWays = v # In addition to the normal sequential way, the default is to also build # profiled prelude libraries # $(if $(filter ...)) allows controlling this expression from build.mk. -GhcLibWays += $(if $(filter $(BUILD_PROF_LIBS),NO),,p) +GhcLibWays += $(if $(filter $(BUILD_PROF_LIBS),NO),,p_l) # Backward compatibility: although it would be cleaner to test for # PlatformSupportsSharedLibs, or perhaps a new variable BUILD_SHARED_LIBS, @@ -272,15 +272,17 @@ BuildSharedLibs=$(strip $(if $(findstring dyn,$(GhcLibWays)),YES,NO)) # In addition, the RTS is built in some further variations. Ways that # make sense here: # -# thr : threaded -# thr_p : threaded profiled -# debug : debugging (compile with -g for the C compiler, and -DDEBUG) -# debug_p : debugging profiled -# thr_debug : debugging threaded -# thr_debug_p : debugging threaded profiled -# l : event logging -# thr_l : threaded and event logging -# +# thr : threaded +# thr_p_l : threaded + profiled + event logging +# debug : debugging (compile with -g for the C compiler, and -DDEBUG) +# debug_p_l : debugging + profiled + event logging +# thr_debug : debugging + threaded, +# thr_debug_p_l : debugging + threaded + profiled + event logging +# l : event logging +# p_l : profiled + event logging +# thr_l : threaded + event logging +# +# Note how there is no plain "profiled" way, only p_l. GhcRTSWays=l # Usually want the debug version @@ -289,7 +291,7 @@ GhcRTSWays += debug # We always have the threaded versions, but note that SMP support may be disabled # (see GhcWithSMP). GhcRTSWays += thr thr_debug thr_l -GhcRTSWays += $(if $(findstring p, $(GhcLibWays)),thr_p p_l thr_p_l,) +GhcRTSWays += $(if $(findstring p_l, $(GhcLibWays)),p_l thr_p_l,) GhcRTSWays += $(if $(findstring dyn, $(GhcLibWays)),dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn,) # We can only build GHCi threaded if we have a threaded RTS: diff --git a/mk/ways.mk b/mk/ways.mk index 80301f7..f144e0e 100644 --- a/mk/ways.mk +++ b/mk/ways.mk @@ -18,11 +18,19 @@ # - WAY_p_HC_OPTS gives the list of command-line options # to the driver. # +# For consistency, the way name should be formed from the tags in the following +# order (the same ordering defined in DynFlags.Way), +# +# - thr: threaded +# - debug: debugging +# - p: profiled +# - l: eventlog +# - dyn: dynamically-linked # # The ways currently defined. # -ALL_WAYS=v p l debug dyn thr thr_l p_dyn p_l debug_dyn thr_dyn thr_p_dyn thr_debug_dyn thr_p thr_debug debug_p thr_debug_p l_dyn thr_l_dyn p_l thr_p_l +ALL_WAYS=v l debug dyn thr thr_l p_l_dyn p_l debug_dyn thr_dyn thr_p_l_dyn thr_debug_dyn thr_debug debug_p_l thr_debug_p_l l_dyn thr_l_dyn thr_p_l # # The following ways currently are treated specially, @@ -36,10 +44,6 @@ ALL_WAYS=v p l debug dyn thr thr_l p_dyn p_l debug_dyn thr_dyn thr_p_dyn thr_deb WAY_v_NAME=vanilla WAY_v_HC_OPTS= -static -# Way 'p': -WAY_p_NAME=profiling -WAY_p_HC_OPTS= -static -prof - # Way 'l': WAY_l_NAME=event logging WAY_l_HC_OPTS= -static -eventlog @@ -52,10 +56,6 @@ WAY_l_HC_OPTS= -static -eventlog WAY_thr_NAME=threaded WAY_thr_HC_OPTS= -static -optc-DTHREADED_RTS -# Way 'thr_p': -WAY_thr_p_NAME=threaded profiled -WAY_thr_p_HC_OPTS= -static -optc-DTHREADED_RTS -prof - # Way 'thr_l': WAY_thr_l_NAME=threaded event logging WAY_thr_l_HC_OPTS= -static -optc-DTHREADED_RTS -eventlog @@ -64,9 +64,9 @@ WAY_thr_l_HC_OPTS= -static -optc-DTHREADED_RTS -eventlog WAY_debug_NAME=debug WAY_debug_HC_OPTS= -static -optc-DDEBUG -ticky -DTICKY_TICKY -# Way 'debug_p': -WAY_debug_p_NAME=debug profiled -WAY_debug_p_HC_OPTS= -static -optc-DDEBUG -prof +# Way 'debug_p_l': +WAY_debug_p_l_NAME=debug profiled event logging +WAY_debug_p_l_HC_OPTS= -static -optc-DDEBUG -prof -eventlog # Way 'p_l': WAY_p_l_NAME=profiling event logging @@ -76,19 +76,21 @@ WAY_p_l_HC_OPTS= -static -prof -eventlog WAY_thr_debug_NAME=threaded debug WAY_thr_debug_HC_OPTS= -static -optc-DTHREADED_RTS -optc-DDEBUG -# Way 'thr_debug_p': -WAY_thr_debug_p_NAME=threaded debug profiling -WAY_thr_debug_p_HC_OPTS= -static -optc-DTHREADED_RTS -optc-DDEBUG -prof +# Way 'thr_debug_p_l': +WAY_thr_debug_p_NAME=threaded debug profiling event logging +WAY_thr_debug_p_HC_OPTS= -static -optc-DTHREADED_RTS -optc-DDEBUG -prof -eventlog # Way 'dyn': build dynamic shared libraries WAY_dyn_NAME=dyn WAY_dyn_HC_OPTS=-fPIC -dynamic -WAY_p_dyn_NAME=p_dyn -WAY_p_dyn_HC_OPTS=-fPIC -dynamic -prof +# Way 'p_l_dyn': +WAY_p_dyn_NAME=p_l_dyn +WAY_p_dyn_HC_OPTS=-fPIC -dynamic -prof -eventlog -WAY_thr_p_dyn_NAME=thr_p_dyn -WAY_thr_p_dyn_HC_OPTS=-fPIC -dynamic -prof -optc-DTHREADED_RTS +# Way 'thr_p_l_dyn': +WAY_thr_p_dyn_NAME=thr_p_l_dyn +WAY_thr_p_dyn_HC_OPTS=-fPIC -dynamic -prof -eventlog -optc-DTHREADED_RTS # Way 'thr_dyn': WAY_thr_dyn_NAME=thr_dyn @@ -108,8 +110,8 @@ WAY_l_dyn_HC_OPTS= -fPIC -dynamic -eventlog # Way 'thr_l_dyn': WAY_thr_l_dyn_NAME=threaded event logging dynamic -WAY_thr_l_dyn_HC_OPTS= -fPIC -dynamic -optc-DTHREADED_RTS -eventlog +WAY_thr_l_dyn_HC_OPTS= -fPIC -dynamic -eventlog -optc-DTHREADED_RTS # Way 'thr_p_l': WAY_thr_p_l_NAME=threaded profiling event logging -WAY_thr_p_l_HC_OPTS= -static -prof -optc-DTHREADED_RTS -eventlog +WAY_thr_p_l_HC_OPTS= -static -prof -eventlog -optc-DTHREADED_RTS From git at git.haskell.org Sat Mar 26 01:01:15 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 01:01:15 +0000 (UTC) Subject: [commit: ghc] master's head updated: DWARF: Add debugging information chapter to users guide (1b4d120) Message-ID: <20160326010115.089313A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'master' now includes: 4e98b4f DynFlags: Initialize unsafeGlobalDynFlags enough to be useful e8d3567 Panic: Try outputting SDocs d0787a2 testsuite: Identify framework failures in testsuite summary 1b4d120 DWARF: Add debugging information chapter to users guide From git at git.haskell.org Sat Mar 26 08:02:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 08:02:10 +0000 (UTC) Subject: [commit: ghc] master: RTS: Fix & refactor "portable inline" macros (882179d) Message-ID: <20160326080210.7D7243A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/882179de09f9bd466b0e7ca83522aee0d3d7144a/ghc >--------------------------------------------------------------- commit 882179de09f9bd466b0e7ca83522aee0d3d7144a Author: Herbert Valerio Riedel Date: Sat Mar 26 00:59:31 2016 +0100 RTS: Fix & refactor "portable inline" macros Turns out the current macros for gnu90-style inline semantics stopped working with GCC 5 (and possibly also with Apple's GCC) which switched on `__GNUC_STDC_INLINE__` by default falling back to using the suboptimal `static inline` mode. However, C99 supports an equivalent (as far as our use-case is concerned) `extern inline` mode. See also http://www.greenend.org.uk/rjk/tech/inline.html for a write-up of gnu90 vs C99 semantics. This patch also removes the MSVC case as VS2015 is supposed to finally catch up to C99 (and C11), so we don't need any special care for MSVC anymore. Reviewed By: erikd, austin Differential Revision: https://phabricator.haskell.org/D2039 >--------------------------------------------------------------- 882179de09f9bd466b0e7ca83522aee0d3d7144a includes/Stg.h | 76 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/includes/Stg.h b/includes/Stg.h index a8ab5ca..a2894a5 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -129,51 +129,53 @@ * EXTERN_INLINE is for functions that we want to inline sometimes * (we also compile a static version of the function; see Inlines.c) */ -#if defined(__GNUC__) || defined( __INTEL_COMPILER) -# define INLINE_HEADER static inline -# define INLINE_ME inline -# define STATIC_INLINE INLINE_HEADER - -// The special "extern inline" behaviour is now only supported by gcc -// when _GNUC_GNU_INLINE__ is defined, and you have to use -// __attribute__((gnu_inline)). So when we don't have this, we use -// ordinary static inline. -// -// Apple's gcc defines __GNUC_GNU_INLINE__ without providing -// gnu_inline, so we exclude MacOS X and fall through to the safe -// version. +// We generally assume C99 semantics albeit these two definitions work fine even +// when gnu90 semantics are active (i.e. when __GNUC_GNU_INLINE__ is defined or +// when a GCC older than 4.2 is used) // -#if defined(__GNUC_GNU_INLINE__) && !defined(__APPLE__) -# if defined(KEEP_INLINES) -# define EXTERN_INLINE inline -# else -# define EXTERN_INLINE extern inline __attribute__((gnu_inline)) -# endif -#else -# if defined(KEEP_INLINES) -# define EXTERN_INLINE -# else -# define EXTERN_INLINE INLINE_HEADER -# endif +// The problem, however, is with 'extern inline' whose semantics significantly +// differs between gnu90 and C99 +#define INLINE_HEADER static inline +#define INLINE_ME inline +#define STATIC_INLINE static inline + +// Figure out whether `__attributes__((gnu_inline))` is needed +// to force gnu90-style 'external inline' semantics. +#if defined(FORCE_GNU_INLINE) +// disable auto-detection since HAVE_GNU_INLINE has been defined externally +#elif __GNUC_GNU_INLINE__ && __GNUC__ == 4 && __GNUC_MINOR__ == 2 +// GCC 4.2.x didn't properly support C99 inline semantics (GCC 4.3 was the first +// release to properly support C99 inline semantics), and therefore warned when +// using 'extern inline' while in C99 mode unless `__attributes__((gnu_inline))` +// was explicitly set. +# define FORCE_GNU_INLINE 1 #endif -#elif defined(_MSC_VER) - -# define INLINE_HEADER __inline static -# define INLINE_ME __inline -# define STATIC_INLINE INLINE_HEADER - +#if FORCE_GNU_INLINE +// Force compiler into gnu90 semantics # if defined(KEEP_INLINES) -# define EXTERN_INLINE __inline +# define EXTERN_INLINE inline __attribute__((gnu_inline)) # else -# define EXTERN_INLINE __inline extern +# define EXTERN_INLINE extern inline __attribute__((gnu_inline)) +# endif +#elif __GNUC_GNU_INLINE__ +// we're currently in gnu90 inline mode by default and +// __attribute__((gnu_inline)) may not be supported, so better leave it off +# if defined(KEEP_INLINES) +# define EXTERN_INLINE inline +# else +# define EXTERN_INLINE extern inline # endif - #else - -# error "Don't know how to inline functions with your C compiler." - +// Assume C99 semantics (yes, this curiously results in swapped definitions!) +// This is the preferred branch, and at some point we may drop support for +// compilers not supporting C99 semantics altogether. +# if defined(KEEP_INLINES) +# define EXTERN_INLINE extern inline +# else +# define EXTERN_INLINE inline +# endif #endif From git at git.haskell.org Sat Mar 26 20:26:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 20:26:43 +0000 (UTC) Subject: [commit: ghc] master: Fix #11754 by adding an additional check. (4da8e73) Message-ID: <20160326202643.77F5A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/4da8e73d5235b0000ae27aa8ff8438a3687b6e9c/ghc >--------------------------------------------------------------- commit 4da8e73d5235b0000ae27aa8ff8438a3687b6e9c Author: Richard Eisenberg Date: Fri Mar 25 15:11:24 2016 -0400 Fix #11754 by adding an additional check. This was just plain wrong previously. Test case: typecheck/should_compile/T11754 >--------------------------------------------------------------- 4da8e73d5235b0000ae27aa8ff8438a3687b6e9c compiler/types/OptCoercion.hs | 7 +++--- testsuite/tests/typecheck/should_compile/T11754.hs | 28 ++++++++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/compiler/types/OptCoercion.hs b/compiler/types/OptCoercion.hs index fb6c68e..e39f0aa 100644 --- a/compiler/types/OptCoercion.hs +++ b/compiler/types/OptCoercion.hs @@ -874,10 +874,11 @@ etaTyConAppCo_maybe tc (TyConAppCo _ tc2 cos2) etaTyConAppCo_maybe tc co | mightBeUnsaturatedTyCon tc - , Pair ty1 ty2 <- coercionKind co - , Just (tc1, tys1) <- splitTyConApp_maybe ty1 - , Just (tc2, tys2) <- splitTyConApp_maybe ty2 + , (Pair ty1 ty2, r) <- coercionKindRole co + , Just (tc1, tys1) <- splitTyConApp_maybe ty1 + , Just (tc2, tys2) <- splitTyConApp_maybe ty2 , tc1 == tc2 + , isInjectiveTyCon tc r -- See Note [NthCo and newtypes] in TyCoRep , let n = length tys1 = ASSERT( tc == tc1 ) ASSERT( n == length tys2 ) diff --git a/testsuite/tests/typecheck/should_compile/T11754.hs b/testsuite/tests/typecheck/should_compile/T11754.hs new file mode 100644 index 0000000..248be2b --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11754.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE TypeOperators, UndecidableSuperClasses, KindSignatures, +TypeFamilies, FlexibleContexts #-} + +module T11754 where + +import Data.Kind +import Data.Void + +newtype K a x = K a +newtype I x = I x + +data (f + g) x = L (f x) | R (g x) +data (f ? g) x = f x :?: g x + +class Differentiable (D f) => Differentiable f where + type D (f :: Type -> Type) :: Type -> Type + +instance Differentiable (K a) where + type D (K a) = K Void + +instance Differentiable I where + type D I = K () + +instance (Differentiable f?, Differentiable f?) => Differentiable (f? + f?) where + type D (f? + f?) = D f? + D f? + +instance (Differentiable f?, Differentiable f?) => Differentiable (f? ? f?) where + type D (f? ? f?) = (D f? ? f?) + (f? ? D f?) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 267795b..0d99284 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -510,3 +510,4 @@ test('T11608', normal, compile, ['']) test('T11401', normal, compile, ['']) test('T11699', normal, compile, ['']) test('T11512', normal, compile, ['']) +test('T11754', normal, compile, ['']) From git at git.haskell.org Sat Mar 26 20:26:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 20:26:46 +0000 (UTC) Subject: [commit: ghc] master: Clarify Note [Kind coercions in Unify] (9f73e46) Message-ID: <20160326202646.6FFAC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/9f73e46c0f34b8b5e8318e6b488b7dade7db68e3/ghc >--------------------------------------------------------------- commit 9f73e46c0f34b8b5e8318e6b488b7dade7db68e3 Author: Richard Eisenberg Date: Fri Mar 25 17:25:25 2016 -0400 Clarify Note [Kind coercions in Unify] >--------------------------------------------------------------- 9f73e46c0f34b8b5e8318e6b488b7dade7db68e3 compiler/types/Unify.hs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/compiler/types/Unify.hs b/compiler/types/Unify.hs index ed4b224..0b5df14 100644 --- a/compiler/types/Unify.hs +++ b/compiler/types/Unify.hs @@ -79,10 +79,31 @@ may look nothing alike. So, we pass a kind coercion to the match/unify worker. This coercion witnesses the equality between the substed kind of the left-hand type and the substed -kind of the right-hand type. To get this coercion, we first have to match/unify +kind of the right-hand type. Note that we do not unify kinds at the leaves +(as we did previously). We thus have + +INVARIANT: In the call + unify_ty ty1 ty2 kco +it must be that subst(kco) :: subst(kind(ty1)) ~N subst(kind(ty2)), where +`subst` is the ambient substitution in the UM monad. + +To get this coercion, we first have to match/unify the kinds before looking at the types. Happily, we need look only one level up, as all kinds are guaranteed to have kind *. +When we're working with type applications (either TyConApp or AppTy) we +need to worry about establishing INVARIANT, as the kinds of the function +& arguments aren't (necessarily) included in the kind of the result. +When unifying two TyConApps, this is easy, because the two TyCons are +the same. Their kinds are thus the same. As long as we unify left-to-right, +we'll be sure to unify types' kinds before the types themselves. (For example, +think about Proxy :: forall k. k -> *. Unifying the first args matches up +the kinds of the second args.) + +For AppTy, we must unify the kinds of the functions, but once these are +unified, we can continue unifying arguments without worrying further about +kinds. + We thought, at one point, that this was all unnecessary: why should casts be in types in the first place? But they do. In dependent/should_compile/KindEqualities2, we see, for example @@ -760,6 +781,7 @@ unify_ty_app ty1 ty1args ty2 ty2args | otherwise = do { let ki1 = typeKind ty1 ki2 = typeKind ty2 + -- See Note [Kind coercions in Unify] ; unify_ty ki1 ki2 (mkNomReflCo liftedTypeKind) ; unify_ty ty1 ty2 (mkNomReflCo ki1) ; unify_tys ty1args ty2args } @@ -770,6 +792,7 @@ unify_tys orig_xs orig_ys where go [] [] = return () go (x:xs) (y:ys) + -- See Note [Kind coercions in Unify] = do { unify_ty x y (mkNomReflCo $ typeKind x) ; go xs ys } go _ _ = maybeApart -- See Note [Lists of different lengths are MaybeApart] From git at git.haskell.org Sat Mar 26 20:26:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sat, 26 Mar 2016 20:26:49 +0000 (UTC) Subject: [commit: ghc] master: Check for rep poly on wildcard binders. (12a76be) Message-ID: <20160326202649.E8EC53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/12a76bebe0864cdf1c9088ed16175d7b34369e24/ghc >--------------------------------------------------------------- commit 12a76bebe0864cdf1c9088ed16175d7b34369e24 Author: Richard Eisenberg Date: Fri Mar 25 16:18:09 2016 -0400 Check for rep poly on wildcard binders. I had just missed this case when adding my test. This is relevant to ticket #11473. Also adds lots of comments. >--------------------------------------------------------------- 12a76bebe0864cdf1c9088ed16175d7b34369e24 compiler/typecheck/TcHsSyn.hs | 83 +++++++++++++++++++--- .../tests/typecheck/should_fail/BadUnboxedTuple.hs | 10 +++ .../typecheck/should_fail/BadUnboxedTuple.stderr | 6 ++ testsuite/tests/typecheck/should_fail/all.T | 1 + 4 files changed, 90 insertions(+), 10 deletions(-) diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs index 88110b7..f6fa01a 100644 --- a/compiler/typecheck/TcHsSyn.hs +++ b/compiler/typecheck/TcHsSyn.hs @@ -283,7 +283,8 @@ zonkIdOccs env ids = map (zonkIdOcc env) ids zonkIdBndr :: ZonkEnv -> TcId -> TcM Id zonkIdBndr env id = do ty' <- zonkTcTypeToType env (idType id) - ensureNotRepresentationPolymorphic id ty' + ensureNotRepresentationPolymorphic ty' + (text "In the type of binder" <+> quotes (ppr id)) return (setIdType id ty') zonkIdBndrs :: ZonkEnv -> [TcId] -> TcM [Id] @@ -1160,6 +1161,8 @@ zonk_pat env (ParPat p) zonk_pat env (WildPat ty) = do { ty' <- zonkTcTypeToType env ty + ; ensureNotRepresentationPolymorphic ty' + (text "In a wildcard pattern") ; return (env, WildPat ty') } zonk_pat env (VarPat (L l v)) @@ -1653,6 +1656,70 @@ zonkTypeZapping tv ; return ty } --------------------------------------- +{- +Note [Unboxed tuples in representation polymorphism check] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Recall that all types that have values (that is, lifted and unlifted +types) have kinds that look like (TYPE rep), where (rep :: RuntimeRep) +tells how the values are represented at runtime. Lifted types have +kind (TYPE PtrRepLifted) (for which * is just a synonym) and, say, +Int# has kind (TYPE IntRep). + +It would be terrible if the code generator came upon a binder of a type +whose kind is something like TYPE r, where r is a skolem type variable. +The code generator wouldn't know what to do. So we eliminate that case +here. + +Although representation polymorphism and the RuntimeRep type catch +most ways of abusing unlifted types, it still isn't quite satisfactory +around unboxed tuples. That's because all unboxed tuple types have kind +TYPE UnboxedTupleRep, which is clearly a lie: it doesn't actually tell +you what the representation is. + +Naively, when checking for representation polymorphism, you might think we can +just look for free variables in a type's RuntimeRep. But this misses the +UnboxedTupleRep case. + +So, instead, we handle unboxed tuples specially. Only after unboxed tuples +are handled do we look for free tyvars in a RuntimeRep. + +We must still be careful in the UnboxedTupleRep case. A binder whose type +has kind UnboxedTupleRep is OK -- only as long as the type is really an +unboxed tuple, which the code generator treats specially. So we do this: + 1. Check if the type is an unboxed tuple. If so, recur. + 2. Check if the kind is TYPE UnboxedTupleRep. If so, error. + 3. Check if the kind has any free variables. If so, error. + +In case 1, we have a type that looks like + + (# , #) PtrRepLifted IntRep Bool Int# + +recalling that + + (# , #) :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep). + TYPE r1 -> TYPE r2 -> TYPE UnboxedTupleRep + +It's tempting just to look at the RuntimeRep arguments to make sure +that they are devoid of free variables and not UnboxedTupleRep. This +naive check, though, fails on nested unboxed tuples, like +(# Int#, (# Bool, Void# #) #). Thus, instead of looking at the RuntimeRep +args to the unboxed tuple constructor, we look at the types themselves. + +Here are a few examples: + + type family F r :: TYPE r + + x :: (F r :: TYPE r) -- REJECTED: simple representation polymorphism + where r is an in-scope type variable of kind RuntimeRep + + x :: (F PtrRepLifted :: TYPE PtrRepLifted) -- OK + x :: (F IntRep :: TYPE IntRep) -- OK + + x :: (F UnboxedTupleRep :: TYPE UnboxedTupleRep) -- REJECTED + + x :: ((# Int, Bool #) :: TYPE UnboxedTupleRep) -- OK +-} + -- | According to the rules around representation polymorphism -- (see https://ghc.haskell.org/trac/ghc/wiki/NoSubKinds), no binder -- can have a representation-polymorphic type. This check ensures @@ -1663,24 +1730,20 @@ zonkTypeZapping tv -- isn't really a compositional property of a type system, so it's -- not a terrible surprise that the check has to go in an awkward spot. ensureNotRepresentationPolymorphic - :: TcId -- the id we're checking (for errors only) - -> Type -- its zonked type + :: Type -- its zonked type + -> SDoc -- where this happened -> TcM () -ensureNotRepresentationPolymorphic id ty +ensureNotRepresentationPolymorphic ty doc = whenNoErrs $ -- sometimes we end up zonking bogus definitions of type -- forall a. a. See, for example, test ghci/scripts/T9140 - checkForRepresentationPolymorphism - (text "In the type of binder" <+> quotes (ppr id)) ty + checkForRepresentationPolymorphism doc ty + -- See Note [Unboxed tuples in representation polymorphism check] checkForRepresentationPolymorphism :: SDoc -> Type -> TcM () checkForRepresentationPolymorphism extra ty | Just (tc, tys) <- splitTyConApp_maybe ty , isUnboxedTupleTyCon tc = mapM_ (checkForRepresentationPolymorphism extra) (dropRuntimeRepArgs tys) - -- You might think that we can just check the RuntimeRep args themselves. - -- But this would fail in the case of nested unboxed tuples, for which - -- one of the RuntimeRep args would be UnboxedTupleRep. So we just check - -- the type args directly. | runtime_rep `eqType` unboxedTupleRepDataConTy = addErr (vcat [ text "The type" <+> quotes (ppr tidy_ty) <+> diff --git a/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs new file mode 100644 index 0000000..2935416 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilies, KindSignatures, TypeInType #-} + +module BadUnboxedTuple where + +import GHC.Exts + +type family F :: TYPE UnboxedTupleRep + +foo :: F -> () +foo _ = () diff --git a/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr new file mode 100644 index 0000000..7c5ad57 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr @@ -0,0 +1,6 @@ + +BadUnboxedTuple.hs:10:5: error: + The type ?F? is not an unboxed tuple, + and yet its kind suggests that it has the representation + of an unboxed tuple. This is not allowed. + In a wildcard pattern diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index f24736e..867ea38 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -411,3 +411,4 @@ test('T11541', normal, compile_fail, ['']) test('T11313', normal, compile_fail, ['']) test('T11723', normal, compile_fail, ['']) test('T11724', normal, compile_fail, ['']) +test('BadUnboxedTuple', normal, compile_fail, ['']) From git at git.haskell.org Sun Mar 27 18:13:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 27 Mar 2016 18:13:38 +0000 (UTC) Subject: [commit: ghc] master: Remove now obsolete LD_STAGE0 hack (06cd26b) Message-ID: <20160327181338.B373C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/06cd26b92a4dfe1f5036440085c602da798d5146/ghc >--------------------------------------------------------------- commit 06cd26b92a4dfe1f5036440085c602da798d5146 Author: Herbert Valerio Riedel Date: Sun Mar 27 20:03:33 2016 +0200 Remove now obsolete LD_STAGE0 hack This was introduced in 109a1e53287f50103e8a5b592275940b6e3dbb53 but isn't needed anymore because by now we're bootstrapping with GHC versions which already provide "ld command" in `ghc --info` (that field was added in GHC 7.8) >--------------------------------------------------------------- 06cd26b92a4dfe1f5036440085c602da798d5146 configure.ac | 4 +--- mk/config.mk.in | 4 +--- rules/build-package-data.mk | 5 ----- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index dbc19de..7d522b0 100644 --- a/configure.ac +++ b/configure.ac @@ -122,9 +122,7 @@ if test "$WithGhc" != ""; then GhcCanonVersion="$GhcMajVersion$GhcMinVersion2" BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command]) - dnl ToDo, once "ld command" is reliably available. - dnl Then, we can remove the LD_STAGE0 hack in mk/build-package-date.mk - dnl BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command]) + BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) diff --git a/mk/config.mk.in b/mk/config.mk.in index d2bf321..5d5e581 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -539,9 +539,7 @@ AS_STAGE1 = $(AS) AS_STAGE2 = $(AS) AS_STAGE3 = $(AS) -# We don't have an LD_STAGE0. CC_STAGE0 is determined by asking "ghc -# --info", and it doesn't report an LD. -LD_STAGE0 = error-no-ld-stage0 +LD_STAGE0 = @LD_STAGE0@ LD_STAGE1 = $(LD) LD_STAGE2 = $(LD) LD_STAGE3 = $(LD) diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk index e46ecd6..89b742c 100644 --- a/rules/build-package-data.mk +++ b/rules/build-package-data.mk @@ -105,12 +105,7 @@ $1_$2_CONFIGURE_OPTS += $$(BOOT_PKG_CONSTRAINTS) endif $1_$2_CONFIGURE_OPTS += --with-gcc="$$(CC_STAGE$3)" - -ifneq "$3" "0" -# There is no LD_STAGE0, Cabal will figure it out $1_$2_CONFIGURE_OPTS += --with-ld="$$(LD_STAGE$3)" -endif - $1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)" $1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)") $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)") From git at git.haskell.org Sun Mar 27 20:12:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 27 Mar 2016 20:12:51 +0000 (UTC) Subject: [commit: ghc] master: Remove now pointless INLINE_ME macro (c7b32ad) Message-ID: <20160327201251.71FD63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c7b32ad55f4a6ec59f431f47ac2a8a9099f87ab7/ghc >--------------------------------------------------------------- commit c7b32ad55f4a6ec59f431f47ac2a8a9099f87ab7 Author: Herbert Valerio Riedel Date: Sun Mar 27 21:43:44 2016 +0200 Remove now pointless INLINE_ME macro At some point there may have been a reason for the `INLINE_ME` macro, but not anymore... Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D2041 >--------------------------------------------------------------- c7b32ad55f4a6ec59f431f47ac2a8a9099f87ab7 includes/Stg.h | 1 - rts/win32/GetTime.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/Stg.h b/includes/Stg.h index a2894a5..b179db6 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -137,7 +137,6 @@ // The problem, however, is with 'extern inline' whose semantics significantly // differs between gnu90 and C99 #define INLINE_HEADER static inline -#define INLINE_ME inline #define STATIC_INLINE static inline // Figure out whether `__attributes__((gnu_inline))` is needed diff --git a/rts/win32/GetTime.c b/rts/win32/GetTime.c index 6a45248..30f1068 100644 --- a/rts/win32/GetTime.c +++ b/rts/win32/GetTime.c @@ -17,7 +17,7 @@ /* Convert FILETIMEs into secs */ -static INLINE_ME Time +static inline Time fileTimeToRtsTime(FILETIME ft) { Time t; From git at git.haskell.org Sun Mar 27 21:46:07 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Sun, 27 Mar 2016 21:46:07 +0000 (UTC) Subject: [commit: ghc] master: Fix AIX/ppc codegen in `-prof` compilation mode (61df7f8) Message-ID: <20160327214607.01DD13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/61df7f8fb4e76fc8987c0b4f02aa9ec795be7afb/ghc >--------------------------------------------------------------- commit 61df7f8fb4e76fc8987c0b4f02aa9ec795be7afb Author: Herbert Valerio Riedel Date: Sun Mar 27 23:41:12 2016 +0200 Fix AIX/ppc codegen in `-prof` compilation mode The implementation in df26b95559fd467abc0a3a4151127c95cb5011b9 wrongly assumed that all C-ABI subroutine calls would use a 'ForeignLabel' but it turns out that calls inserted via 'emitRtsCall' use 'CmmLabel's instead. >--------------------------------------------------------------- 61df7f8fb4e76fc8987c0b4f02aa9ec795be7afb compiler/nativeGen/PPC/Ppr.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs index 16e8dc1..59b0ad8 100644 --- a/compiler/nativeGen/PPC/Ppr.hs +++ b/compiler/nativeGen/PPC/Ppr.hs @@ -607,10 +607,16 @@ pprInstr (BCTR _ _) = hcat [ ] pprInstr (BL lbl _) = do sdocWithPlatform $ \platform -> case platformOS platform of - OSAIX | isForeignLabel lbl -> + OSAIX -> -- On AIX, "printf" denotes a function-descriptor (for use -- by function pointers), whereas the actual entry-code - -- address is denoted by the dot-prefixed ".printf" label + -- address is denoted by the dot-prefixed ".printf" label. + -- Moreover, the PPC NCG only ever emits a BL instruction + -- for calling C ABI functions. Most of the time these calls + -- originate from FFI imports and have a 'ForeignLabel', + -- but when profiling the codegen inserts calls via + -- 'emitRtsCallGen' which are 'CmmLabel's even though + -- they'd technically be more like 'ForeignLabel's. hcat [ text "\tbl\t.", ppr lbl From git at git.haskell.org Mon Mar 28 09:49:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 09:49:58 +0000 (UTC) Subject: [commit: ghc] master: Scrap IRIX support (0bca3f3) Message-ID: <20160328094958.47D183A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/0bca3f3a56c606e5060be03227f0ea9ca2197acc/ghc >--------------------------------------------------------------- commit 0bca3f3a56c606e5060be03227f0ea9ca2197acc Author: Herbert Valerio Riedel Date: Mon Mar 28 11:36:21 2016 +0200 Scrap IRIX support Long time ago, IRIX was way ahead of its time in the last century with its SMP capabilities of scaling up to 1024 processors and other features such as XFS or OpenGL that originated in IRIX and live on to this day in other operating systems. However, IRIX's last software update was in 2006 and support ended around 2013 according to [1], so it's considered an extinct platform by now. So this commit message is effectively an obituary for GHC's IRIX support. R.I.P. IRIX [1]: https://en.wikipedia.org/wiki/IRIX >--------------------------------------------------------------- 0bca3f3a56c606e5060be03227f0ea9ca2197acc aclocal.m4 | 4 ++-- compiler/ghc.mk | 10 ---------- includes/ghc.mk | 5 ----- libraries/base/System/CPUTime.hsc | 2 +- libraries/base/include/HsBase.h | 2 +- rts/posix/GetTime.c | 6 +++--- rts/posix/OSMem.c | 15 +-------------- 7 files changed, 8 insertions(+), 36 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index dd1ba73..7616cf4 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -277,7 +277,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], nto-qnx) test -z "[$]2" || eval "[$]2=OSQNXNTO" ;; - dragonfly|osf1|hpux|linuxaout|freebsd2|gnu|nextstep2|nextstep3|sunos4|ultrix|irix) + dragonfly|osf1|hpux|linuxaout|freebsd2|gnu|nextstep2|nextstep3|sunos4|ultrix) test -z "[$]2" || eval "[$]2=OSUnknown" ;; aix) @@ -1884,7 +1884,7 @@ case "$1-$2" in $3="linux" ;; # As far as I'm aware, none of these have relevant variants - freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|haiku) + freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|haiku) $3="$1" ;; aix*) # e.g. powerpc-ibm-aix7.1.3.0 diff --git a/compiler/ghc.mk b/compiler/ghc.mk index d3cd2a5..9f45a51 100644 --- a/compiler/ghc.mk +++ b/compiler/ghc.mk @@ -177,11 +177,6 @@ compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@ @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ -ifeq "$(TargetOS_CPP)" "irix" - @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@ - @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@ - @echo "#endif" >> $@ -endif @echo >> $@ @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@ @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@ @@ -223,11 +218,6 @@ compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@ @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ -ifeq "$(TargetOS_CPP)" "irix" - @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@ - @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@ - @echo "#endif" >> $@ -endif @echo >> $@ @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@ @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@ diff --git a/includes/ghc.mk b/includes/ghc.mk index aacca08..31b2650 100644 --- a/includes/ghc.mk +++ b/includes/ghc.mk @@ -143,11 +143,6 @@ $(includes_H_PLATFORM) : includes/Makefile | $$(dir $$@)/. @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@ @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@ @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@ -ifeq "$(HostOS_CPP)" "irix" - @echo "#ifndef $(IRIX_MAJOR)_HOST_OS" >> $@ - @echo "#define $(IRIX_MAJOR)_HOST_OS 1" >> $@ - @echo "#endif" >> $@ -endif @echo >> $@ @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@ @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@ diff --git a/libraries/base/System/CPUTime.hsc b/libraries/base/System/CPUTime.hsc index 0475975..6bc90f1 100644 --- a/libraries/base/System/CPUTime.hsc +++ b/libraries/base/System/CPUTime.hsc @@ -37,7 +37,7 @@ import qualified System.CPUTime.Windows as I #elif _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) && _POSIX_CPUTIME >= 0 import qualified System.CPUTime.Posix.ClockGetTime as I -#elif defined(HAVE_GETRUSAGE) && ! irix_HOST_OS && ! solaris2_HOST_OS +#elif defined(HAVE_GETRUSAGE) && ! solaris2_HOST_OS import qualified System.CPUTime.Posix.RUsage as I -- @getrusage()@ is right royal pain to deal with when targetting multiple diff --git a/libraries/base/include/HsBase.h b/libraries/base/include/HsBase.h index a5512cc..3fe514e 100644 --- a/libraries/base/include/HsBase.h +++ b/libraries/base/include/HsBase.h @@ -111,7 +111,7 @@ # include #endif -#if !defined(_WIN32) && !defined(irix_HOST_OS) +#if !defined(_WIN32) # if HAVE_SYS_RESOURCE_H # include # endif diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c index 24d0d50..ab0d15e 100644 --- a/rts/posix/GetTime.c +++ b/rts/posix/GetTime.c @@ -21,11 +21,11 @@ # include #endif -#if ! ((defined(HAVE_GETRUSAGE) && !irix_HOST_OS) || defined(HAVE_TIMES)) +#if ! (defined(HAVE_GETRUSAGE) || defined(HAVE_TIMES)) #error No implementation for getProcessCPUTime() available. #endif -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_GETRUSAGE) && !irix_HOST_OS +#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_GETRUSAGE) // we'll implement getProcessCPUTime() and getProcessElapsedTime() // separately, using getrusage() and gettimeofday() respectively @@ -190,7 +190,7 @@ void getUnixEpochTime(StgWord64 *sec, StgWord32 *nsec) W_ getPageFaults(void) { -#if !defined(HAVE_GETRUSAGE) || irix_HOST_OS || haiku_HOST_OS +#if !defined(HAVE_GETRUSAGE) || haiku_HOST_OS return 0; #else struct rusage t; diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index 2a3c294..20d27be 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -164,20 +164,7 @@ my_mmap (void *addr, W_ size, int operation) else flags = 0; -#if defined(irix_HOST_OS) - { - if (operation & MEM_RESERVE) - { - int fd = open("/dev/zero",O_RDONLY); - ret = mmap(addr, size, prot, flags | MAP_PRIVATE, fd, 0); - close(fd); - } - else - { - ret = mmap(addr, size, prot, flags | MAP_PRIVATE, -1, 0); - } - } -#elif hpux_HOST_OS +#if hpux_HOST_OS ret = mmap(addr, size, prot, flags | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); #elif linux_HOST_OS ret = mmap(addr, size, prot, flags | MAP_ANON | MAP_PRIVATE, -1, 0); From git at git.haskell.org Mon Mar 28 10:38:07 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 10:38:07 +0000 (UTC) Subject: [commit: ghc] master: Scrap DEC OSF/1 support (f911358) Message-ID: <20160328103807.20A863A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/f911358bd071a8ec311d3838f7f1119de196f19a/ghc >--------------------------------------------------------------- commit f911358bd071a8ec311d3838f7f1119de196f19a Author: Herbert Valerio Riedel Date: Mon Mar 28 12:24:37 2016 +0200 Scrap DEC OSF/1 support DEC OSF/1 (aka Tru64 UNIX) has been discontinued a few years ago already[1]. This removes the undoubtedly bitrotten support for `OSOsf3 :: OS` from GHC's code-base. Support for `ArchAlpha :: Arch` may be removed at some later point, as there may still be users out there running a more or less recent Linux/alpha distribution on their more-than-a-decade old Alpha hardware... [1]: https://en.wikipedia.org/wiki/Tru64_UNIX >--------------------------------------------------------------- f911358bd071a8ec311d3838f7f1119de196f19a aclocal.m4 | 8 ++------ compiler/main/DriverPipeline.hs | 5 ++--- compiler/utils/Platform.hs | 3 --- rts/RtsFlags.c | 11 ----------- 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 7616cf4..14b8481 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -271,13 +271,10 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], haiku) test -z "[$]2" || eval "[$]2=OSHaiku" ;; - osf3) - test -z "[$]2" || eval "[$]2=OSOsf3" - ;; nto-qnx) test -z "[$]2" || eval "[$]2=OSQNXNTO" ;; - dragonfly|osf1|hpux|linuxaout|freebsd2|gnu|nextstep2|nextstep3|sunos4|ultrix) + dragonfly|hpux|linuxaout|freebsd2|gnu|nextstep2|nextstep3|sunos4|ultrix) test -z "[$]2" || eval "[$]2=OSUnknown" ;; aix) @@ -814,7 +811,6 @@ case $HostPlatform in i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;; *) fptools_cv_leading_underscore=no ;; esac ;; -alpha-dec-osf*) fptools_cv_leading_underscore=no;; i386-unknown-mingw32) fptools_cv_leading_underscore=yes;; x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;; @@ -1884,7 +1880,7 @@ case "$1-$2" in $3="linux" ;; # As far as I'm aware, none of these have relevant variants - freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|haiku) + freebsd|netbsd|openbsd|dragonfly|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|haiku) $3="$1" ;; aix*) # e.g. powerpc-ibm-aix7.1.3.0 diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 89fbb42..1991bd3 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1834,9 +1834,8 @@ linkBinary' staticLink dflags o_files dep_packages = do let thread_opts | WayThreaded `elem` ways dflags = let os = platformOS (targetPlatform dflags) - in if os == OSOsf3 then ["-lpthread", "-lexc"] - else if os `elem` [OSMinGW32, OSFreeBSD, OSOpenBSD, - OSNetBSD, OSHaiku, OSQNXNTO, OSiOS, OSDarwin] + in if os `elem` [OSMinGW32, OSFreeBSD, OSOpenBSD, + OSNetBSD, OSHaiku, OSQNXNTO, OSiOS, OSDarwin] then [] else ["-lpthread"] | otherwise = [] diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs index cfd948e..600ed80 100644 --- a/compiler/utils/Platform.hs +++ b/compiler/utils/Platform.hs @@ -84,7 +84,6 @@ data OS | OSNetBSD | OSKFreeBSD | OSHaiku - | OSOsf3 | OSQNXNTO | OSAndroid | OSAIX @@ -136,8 +135,6 @@ osElfTarget OSiOS = False osElfTarget OSMinGW32 = False osElfTarget OSKFreeBSD = True osElfTarget OSHaiku = True -osElfTarget OSOsf3 = False -- I don't know if this is right, but as - -- per comment below it's safe osElfTarget OSQNXNTO = False osElfTarget OSAndroid = True osElfTarget OSAIX = False diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index cce799e..3387355 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -154,18 +154,7 @@ void initRtsFlagsDefaults(void) #else RtsFlags.GcFlags.doIdleGC = rtsFalse; #endif - -#if osf3_HOST_OS -/* ToDo: Perhaps by adjusting this value we can make linking without - * -static work (i.e., not generate a core-dumping executable)? */ -# if SIZEOF_VOID_P == 8 - RtsFlags.GcFlags.heapBase = 0x180000000L; -# else -# error I have no idea where to begin the heap on a non-64-bit osf3 machine. -# endif -#else RtsFlags.GcFlags.heapBase = 0; /* means don't care */ -#endif RtsFlags.GcFlags.allocLimitGrace = (100*1024) / BLOCK_SIZE; #ifdef DEBUG From git at git.haskell.org Mon Mar 28 11:01:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 11:01:25 +0000 (UTC) Subject: [commit: ghc] master: Drop Xcode 4.1 hack and fix ignored CC var issue (ffc802e) Message-ID: <20160328110125.F42113A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/ffc802e8f617d11de9ece7bed438725bde0300b8/ghc >--------------------------------------------------------------- commit ffc802e8f617d11de9ece7bed438725bde0300b8 Author: Herbert Valerio Riedel Date: Mon Mar 28 12:55:21 2016 +0200 Drop Xcode 4.1 hack and fix ignored CC var issue Xcode 4.1 was released back in 2011 for Mac OSX 10.6/10.7. However, OSX 10.7 reached EOL sometime around the end of 2014. So this `--with-gcc-4.2` hack shouldn't be needed anymore. Moreover, this patch changes ./configure to honor the CC env-var again (and thus fix #11231) while giving `--with-gcc=...` a higher priority over `CC=...`. So the following 3 invocations are equivalent now: CC=... ./configure ./configure CC=... ./configure --with-gcc=... Since `--with-{gcc,clang}=...` is a misnomer (as is made apparent by `--with-gcc=clang` or `--with-clang=gcc`), this would give us a neutral and idiomatic way to tell ./configure which C compiler to use. Moreover, `./configure --help` says at the end of its output: Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Consequently, by honoring CC=... (rather than ignoring it) we increase consistency and reduce user confusion. Ideally, CC=... would become the recommended way to set the C compiler, and `--with-{clang,gcc}=...` would be demoted to legacy aliases. Reviewed By: erikd, bgamari Differential Revision: https://phabricator.haskell.org/D2046 >--------------------------------------------------------------- ffc802e8f617d11de9ece7bed438725bde0300b8 aclocal.m4 | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 14b8481..5becadb 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -2033,22 +2033,19 @@ AC_DEFUN([FIND_GHC_BOOTSTRAP_PROG],[ # $2 = the with option name # $3 = the command to look for AC_DEFUN([FIND_GCC],[ - if test "$TargetOS_CPP" = "darwin" && - test "$XCodeVersion1" -eq 4 && - test "$XCodeVersion2" -lt 2 - then - # In Xcode 4.1, 'gcc-4.2' is the gcc legacy backend (rather - # than the LLVM backend). We prefer the legacy gcc, but in - # Xcode 4.2 'gcc-4.2' was removed. - FP_ARG_WITH_PATH_GNU_PROG([$1], [gcc-4.2], [gcc-4.2]) - elif test "$windows" = YES + if test "$windows" = YES then $1="$CC" else FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [$2], [$3]) + # fallback to CC if set and no --with-$2=... was used + if test -z "$With_$2" -a -n "$CC" + then + With_$2="$CC" + $1="$CC" # From Xcode 5 on/, OS X command line tools do not include gcc # anymore. Use clang. - if test -z "$$1" + elif test -z "$$1" then FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [clang], [clang]) fi From git at git.haskell.org Mon Mar 28 11:37:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 11:37:18 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Remove now obsolete LD_STAGE0 hack (92ec7e0) Message-ID: <20160328113718.957F93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/92ec7e0c3b02e6fe583949fe7889cb0417d11e15/ghc >--------------------------------------------------------------- commit 92ec7e0c3b02e6fe583949fe7889cb0417d11e15 Author: Herbert Valerio Riedel Date: Sun Mar 27 20:03:33 2016 +0200 Remove now obsolete LD_STAGE0 hack This was introduced in 109a1e53287f50103e8a5b592275940b6e3dbb53 but isn't needed anymore because by now we're bootstrapping with GHC versions which already provide "ld command" in `ghc --info` (that field was added in GHC 7.8) (cherry picked from commit 06cd26b92a4dfe1f5036440085c602da798d5146) >--------------------------------------------------------------- 92ec7e0c3b02e6fe583949fe7889cb0417d11e15 configure.ac | 4 +--- mk/config.mk.in | 4 +--- rules/build-package-data.mk | 5 ----- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 7b3e2de..b570045 100644 --- a/configure.ac +++ b/configure.ac @@ -122,9 +122,7 @@ if test "$WithGhc" != ""; then GhcCanonVersion="$GhcMajVersion$GhcMinVersion2" BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command]) - dnl ToDo, once "ld command" is reliably available. - dnl Then, we can remove the LD_STAGE0 hack in mk/build-package-date.mk - dnl BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command]) + BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) diff --git a/mk/config.mk.in b/mk/config.mk.in index 89c58cf..5a4c9ca 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -542,9 +542,7 @@ AS_STAGE1 = $(AS) AS_STAGE2 = $(AS) AS_STAGE3 = $(AS) -# We don't have an LD_STAGE0. CC_STAGE0 is determined by asking "ghc -# --info", and it doesn't report an LD. -LD_STAGE0 = error-no-ld-stage0 +LD_STAGE0 = @LD_STAGE0@ LD_STAGE1 = $(LD) LD_STAGE2 = $(LD) LD_STAGE3 = $(LD) diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk index e46ecd6..89b742c 100644 --- a/rules/build-package-data.mk +++ b/rules/build-package-data.mk @@ -105,12 +105,7 @@ $1_$2_CONFIGURE_OPTS += $$(BOOT_PKG_CONSTRAINTS) endif $1_$2_CONFIGURE_OPTS += --with-gcc="$$(CC_STAGE$3)" - -ifneq "$3" "0" -# There is no LD_STAGE0, Cabal will figure it out $1_$2_CONFIGURE_OPTS += --with-ld="$$(LD_STAGE$3)" -endif - $1_$2_CONFIGURE_OPTS += --with-ar="$$(AR_STAGE$3)" $1_$2_CONFIGURE_OPTS += $$(if $$(ALEX),--with-alex="$$(ALEX)") $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)") From git at git.haskell.org Mon Mar 28 11:37:21 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 11:37:21 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix #11754 by adding an additional check. (91a8e92) Message-ID: <20160328113721.958C33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/91a8e92606890ca191ca7227b11a95c9c76cb428/ghc >--------------------------------------------------------------- commit 91a8e92606890ca191ca7227b11a95c9c76cb428 Author: Richard Eisenberg Date: Fri Mar 25 15:11:24 2016 -0400 Fix #11754 by adding an additional check. This was just plain wrong previously. Test case: typecheck/should_compile/T11754 (cherry picked from commit 4da8e73d5235b0000ae27aa8ff8438a3687b6e9c) >--------------------------------------------------------------- 91a8e92606890ca191ca7227b11a95c9c76cb428 compiler/types/OptCoercion.hs | 7 +++--- testsuite/tests/typecheck/should_compile/T11754.hs | 28 ++++++++++++++++++++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/compiler/types/OptCoercion.hs b/compiler/types/OptCoercion.hs index fb6c68e..e39f0aa 100644 --- a/compiler/types/OptCoercion.hs +++ b/compiler/types/OptCoercion.hs @@ -874,10 +874,11 @@ etaTyConAppCo_maybe tc (TyConAppCo _ tc2 cos2) etaTyConAppCo_maybe tc co | mightBeUnsaturatedTyCon tc - , Pair ty1 ty2 <- coercionKind co - , Just (tc1, tys1) <- splitTyConApp_maybe ty1 - , Just (tc2, tys2) <- splitTyConApp_maybe ty2 + , (Pair ty1 ty2, r) <- coercionKindRole co + , Just (tc1, tys1) <- splitTyConApp_maybe ty1 + , Just (tc2, tys2) <- splitTyConApp_maybe ty2 , tc1 == tc2 + , isInjectiveTyCon tc r -- See Note [NthCo and newtypes] in TyCoRep , let n = length tys1 = ASSERT( tc == tc1 ) ASSERT( n == length tys2 ) diff --git a/testsuite/tests/typecheck/should_compile/T11754.hs b/testsuite/tests/typecheck/should_compile/T11754.hs new file mode 100644 index 0000000..248be2b --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T11754.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE TypeOperators, UndecidableSuperClasses, KindSignatures, +TypeFamilies, FlexibleContexts #-} + +module T11754 where + +import Data.Kind +import Data.Void + +newtype K a x = K a +newtype I x = I x + +data (f + g) x = L (f x) | R (g x) +data (f ? g) x = f x :?: g x + +class Differentiable (D f) => Differentiable f where + type D (f :: Type -> Type) :: Type -> Type + +instance Differentiable (K a) where + type D (K a) = K Void + +instance Differentiable I where + type D I = K () + +instance (Differentiable f?, Differentiable f?) => Differentiable (f? + f?) where + type D (f? + f?) = D f? + D f? + +instance (Differentiable f?, Differentiable f?) => Differentiable (f? ? f?) where + type D (f? ? f?) = (D f? ? f?) + (f? ? D f?) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index f1403da..158de37 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -508,3 +508,4 @@ test('T11608', normal, compile, ['']) test('T11401', normal, compile, ['']) test('T11699', normal, compile, ['']) test('T11512', normal, compile, ['']) +test('T11754', normal, compile, ['']) From git at git.haskell.org Mon Mar 28 11:37:24 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 11:37:24 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Check for rep poly on wildcard binders. (c4f7363) Message-ID: <20160328113724.DF5223A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/c4f7363465518be3c68a2bacec79d09554d4a886/ghc >--------------------------------------------------------------- commit c4f7363465518be3c68a2bacec79d09554d4a886 Author: Richard Eisenberg Date: Fri Mar 25 16:18:09 2016 -0400 Check for rep poly on wildcard binders. I had just missed this case when adding my test. This is relevant to ticket #11473. Also adds lots of comments. (cherry picked from commit 12a76bebe0864cdf1c9088ed16175d7b34369e24) >--------------------------------------------------------------- c4f7363465518be3c68a2bacec79d09554d4a886 compiler/typecheck/TcHsSyn.hs | 83 +++++++++++++++++++--- .../tests/typecheck/should_fail/BadUnboxedTuple.hs | 10 +++ .../typecheck/should_fail/BadUnboxedTuple.stderr | 6 ++ testsuite/tests/typecheck/should_fail/all.T | 1 + 4 files changed, 90 insertions(+), 10 deletions(-) diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs index 5bc48f8..5a5a3a7 100644 --- a/compiler/typecheck/TcHsSyn.hs +++ b/compiler/typecheck/TcHsSyn.hs @@ -280,7 +280,8 @@ zonkIdOccs env ids = map (zonkIdOcc env) ids zonkIdBndr :: ZonkEnv -> TcId -> TcM Id zonkIdBndr env id = do ty' <- zonkTcTypeToType env (idType id) - ensureNotRepresentationPolymorphic id ty' + ensureNotRepresentationPolymorphic ty' + (text "In the type of binder" <+> quotes (ppr id)) return (setIdType id ty') zonkIdBndrs :: ZonkEnv -> [TcId] -> TcM [Id] @@ -1157,6 +1158,8 @@ zonk_pat env (ParPat p) zonk_pat env (WildPat ty) = do { ty' <- zonkTcTypeToType env ty + ; ensureNotRepresentationPolymorphic ty' + (text "In a wildcard pattern") ; return (env, WildPat ty') } zonk_pat env (VarPat (L l v)) @@ -1649,6 +1652,70 @@ zonkTypeZapping tv ; return ty } --------------------------------------- +{- +Note [Unboxed tuples in representation polymorphism check] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Recall that all types that have values (that is, lifted and unlifted +types) have kinds that look like (TYPE rep), where (rep :: RuntimeRep) +tells how the values are represented at runtime. Lifted types have +kind (TYPE PtrRepLifted) (for which * is just a synonym) and, say, +Int# has kind (TYPE IntRep). + +It would be terrible if the code generator came upon a binder of a type +whose kind is something like TYPE r, where r is a skolem type variable. +The code generator wouldn't know what to do. So we eliminate that case +here. + +Although representation polymorphism and the RuntimeRep type catch +most ways of abusing unlifted types, it still isn't quite satisfactory +around unboxed tuples. That's because all unboxed tuple types have kind +TYPE UnboxedTupleRep, which is clearly a lie: it doesn't actually tell +you what the representation is. + +Naively, when checking for representation polymorphism, you might think we can +just look for free variables in a type's RuntimeRep. But this misses the +UnboxedTupleRep case. + +So, instead, we handle unboxed tuples specially. Only after unboxed tuples +are handled do we look for free tyvars in a RuntimeRep. + +We must still be careful in the UnboxedTupleRep case. A binder whose type +has kind UnboxedTupleRep is OK -- only as long as the type is really an +unboxed tuple, which the code generator treats specially. So we do this: + 1. Check if the type is an unboxed tuple. If so, recur. + 2. Check if the kind is TYPE UnboxedTupleRep. If so, error. + 3. Check if the kind has any free variables. If so, error. + +In case 1, we have a type that looks like + + (# , #) PtrRepLifted IntRep Bool Int# + +recalling that + + (# , #) :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep). + TYPE r1 -> TYPE r2 -> TYPE UnboxedTupleRep + +It's tempting just to look at the RuntimeRep arguments to make sure +that they are devoid of free variables and not UnboxedTupleRep. This +naive check, though, fails on nested unboxed tuples, like +(# Int#, (# Bool, Void# #) #). Thus, instead of looking at the RuntimeRep +args to the unboxed tuple constructor, we look at the types themselves. + +Here are a few examples: + + type family F r :: TYPE r + + x :: (F r :: TYPE r) -- REJECTED: simple representation polymorphism + where r is an in-scope type variable of kind RuntimeRep + + x :: (F PtrRepLifted :: TYPE PtrRepLifted) -- OK + x :: (F IntRep :: TYPE IntRep) -- OK + + x :: (F UnboxedTupleRep :: TYPE UnboxedTupleRep) -- REJECTED + + x :: ((# Int, Bool #) :: TYPE UnboxedTupleRep) -- OK +-} + -- | According to the rules around representation polymorphism -- (see https://ghc.haskell.org/trac/ghc/wiki/NoSubKinds), no binder -- can have a representation-polymorphic type. This check ensures @@ -1659,24 +1726,20 @@ zonkTypeZapping tv -- isn't really a compositional property of a type system, so it's -- not a terrible surprise that the check has to go in an awkward spot. ensureNotRepresentationPolymorphic - :: TcId -- the id we're checking (for errors only) - -> Type -- its zonked type + :: Type -- its zonked type + -> SDoc -- where this happened -> TcM () -ensureNotRepresentationPolymorphic id ty +ensureNotRepresentationPolymorphic ty doc = whenNoErrs $ -- sometimes we end up zonking bogus definitions of type -- forall a. a. See, for example, test ghci/scripts/T9140 - checkForRepresentationPolymorphism - (text "In the type of binder" <+> quotes (ppr id)) ty + checkForRepresentationPolymorphism doc ty + -- See Note [Unboxed tuples in representation polymorphism check] checkForRepresentationPolymorphism :: SDoc -> Type -> TcM () checkForRepresentationPolymorphism extra ty | Just (tc, tys) <- splitTyConApp_maybe ty , isUnboxedTupleTyCon tc = mapM_ (checkForRepresentationPolymorphism extra) (dropRuntimeRepArgs tys) - -- You might think that we can just check the RuntimeRep args themselves. - -- But this would fail in the case of nested unboxed tuples, for which - -- one of the RuntimeRep args would be UnboxedTupleRep. So we just check - -- the type args directly. | runtime_rep `eqType` unboxedTupleRepDataConTy = addErr (vcat [ text "The type" <+> quotes (ppr tidy_ty) <+> diff --git a/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs new file mode 100644 index 0000000..2935416 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilies, KindSignatures, TypeInType #-} + +module BadUnboxedTuple where + +import GHC.Exts + +type family F :: TYPE UnboxedTupleRep + +foo :: F -> () +foo _ = () diff --git a/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr new file mode 100644 index 0000000..7c5ad57 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr @@ -0,0 +1,6 @@ + +BadUnboxedTuple.hs:10:5: error: + The type ?F? is not an unboxed tuple, + and yet its kind suggests that it has the representation + of an unboxed tuple. This is not allowed. + In a wildcard pattern diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 57836fc..dd0c427 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -409,3 +409,4 @@ test('T11563', normal, compile_fail, ['']) test('T11313', normal, compile_fail, ['']) test('T11723', normal, compile_fail, ['']) test('T11724', normal, compile_fail, ['']) +test('BadUnboxedTuple', normal, compile_fail, ['']) From git at git.haskell.org Mon Mar 28 11:37:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 11:37:27 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Clarify Note [Kind coercions in Unify] (f260738) Message-ID: <20160328113727.854C13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/f260738db2937814757bc27851dcd4d8d3e93296/ghc >--------------------------------------------------------------- commit f260738db2937814757bc27851dcd4d8d3e93296 Author: Richard Eisenberg Date: Fri Mar 25 17:25:25 2016 -0400 Clarify Note [Kind coercions in Unify] (cherry picked from commit 9f73e46c0f34b8b5e8318e6b488b7dade7db68e3) >--------------------------------------------------------------- f260738db2937814757bc27851dcd4d8d3e93296 compiler/types/Unify.hs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/compiler/types/Unify.hs b/compiler/types/Unify.hs index bc53cac..76d3ec2 100644 --- a/compiler/types/Unify.hs +++ b/compiler/types/Unify.hs @@ -82,10 +82,31 @@ may look nothing alike. So, we pass a kind coercion to the match/unify worker. This coercion witnesses the equality between the substed kind of the left-hand type and the substed -kind of the right-hand type. To get this coercion, we first have to match/unify +kind of the right-hand type. Note that we do not unify kinds at the leaves +(as we did previously). We thus have + +INVARIANT: In the call + unify_ty ty1 ty2 kco +it must be that subst(kco) :: subst(kind(ty1)) ~N subst(kind(ty2)), where +`subst` is the ambient substitution in the UM monad. + +To get this coercion, we first have to match/unify the kinds before looking at the types. Happily, we need look only one level up, as all kinds are guaranteed to have kind *. +When we're working with type applications (either TyConApp or AppTy) we +need to worry about establishing INVARIANT, as the kinds of the function +& arguments aren't (necessarily) included in the kind of the result. +When unifying two TyConApps, this is easy, because the two TyCons are +the same. Their kinds are thus the same. As long as we unify left-to-right, +we'll be sure to unify types' kinds before the types themselves. (For example, +think about Proxy :: forall k. k -> *. Unifying the first args matches up +the kinds of the second args.) + +For AppTy, we must unify the kinds of the functions, but once these are +unified, we can continue unifying arguments without worrying further about +kinds. + We thought, at one point, that this was all unnecessary: why should casts be in types in the first place? But they do. In dependent/should_compile/KindEqualities2, we see, for example @@ -766,6 +787,7 @@ unify_ty_app ty1 ty1args ty2 ty2args | otherwise = do { let ki1 = typeKind ty1 ki2 = typeKind ty2 + -- See Note [Kind coercions in Unify] ; unify_ty ki1 ki2 (mkNomReflCo liftedTypeKind) ; unify_ty ty1 ty2 (mkNomReflCo ki1) ; unify_tys ty1args ty2args } @@ -776,6 +798,7 @@ unify_tys orig_xs orig_ys where go [] [] = return () go (x:xs) (y:ys) + -- See Note [Kind coercions in Unify] = do { unify_ty x y (mkNomReflCo $ typeKind x) ; go xs ys } go _ _ = maybeApart -- See Note [Lists of different lengths are MaybeApart] From git at git.haskell.org Mon Mar 28 11:37:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 11:37:30 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: DWARF: Add debugging information chapter to users guide (2b5f736) Message-ID: <20160328113730.B4A533A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/2b5f7362b19f0f7d23d9d8bad326d23406ec66a5/ghc >--------------------------------------------------------------- commit 2b5f7362b19f0f7d23d9d8bad326d23406ec66a5 Author: Ben Gamari Date: Sat Mar 26 00:44:21 2016 +0100 DWARF: Add debugging information chapter to users guide Test Plan: Proof-read Reviewers: scpmw, austin Subscribers: simonmar, thomie Differential Revision: https://phabricator.haskell.org/D1369 (cherry picked from commit 1b4d1201d6fe395db2b268ca111baa69d96ce211) >--------------------------------------------------------------- 2b5f7362b19f0f7d23d9d8bad326d23406ec66a5 docs/users_guide/debug-info.rst | 314 ++++++++++++++++++++++++++++++++++++++++ docs/users_guide/index.rst | 1 + 2 files changed, 315 insertions(+) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 2b5f7362b19f0f7d23d9d8bad326d23406ec66a5 From git at git.haskell.org Mon Mar 28 11:37:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 11:37:33 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Fix AIX/ppc codegen in `-prof` compilation mode (aa4349d) Message-ID: <20160328113733.625D03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/aa4349d68014c2d0cb1baa0f327226857b458b97/ghc >--------------------------------------------------------------- commit aa4349d68014c2d0cb1baa0f327226857b458b97 Author: Herbert Valerio Riedel Date: Sun Mar 27 23:41:12 2016 +0200 Fix AIX/ppc codegen in `-prof` compilation mode The implementation in df26b95559fd467abc0a3a4151127c95cb5011b9 wrongly assumed that all C-ABI subroutine calls would use a 'ForeignLabel' but it turns out that calls inserted via 'emitRtsCall' use 'CmmLabel's instead. (cherry picked from commit 61df7f8fb4e76fc8987c0b4f02aa9ec795be7afb) >--------------------------------------------------------------- aa4349d68014c2d0cb1baa0f327226857b458b97 compiler/nativeGen/PPC/Ppr.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs index 16e8dc1..59b0ad8 100644 --- a/compiler/nativeGen/PPC/Ppr.hs +++ b/compiler/nativeGen/PPC/Ppr.hs @@ -607,10 +607,16 @@ pprInstr (BCTR _ _) = hcat [ ] pprInstr (BL lbl _) = do sdocWithPlatform $ \platform -> case platformOS platform of - OSAIX | isForeignLabel lbl -> + OSAIX -> -- On AIX, "printf" denotes a function-descriptor (for use -- by function pointers), whereas the actual entry-code - -- address is denoted by the dot-prefixed ".printf" label + -- address is denoted by the dot-prefixed ".printf" label. + -- Moreover, the PPC NCG only ever emits a BL instruction + -- for calling C ABI functions. Most of the time these calls + -- originate from FFI imports and have a 'ForeignLabel', + -- but when profiling the codegen inserts calls via + -- 'emitRtsCallGen' which are 'CmmLabel's even though + -- they'd technically be more like 'ForeignLabel's. hcat [ text "\tbl\t.", ppr lbl From git at git.haskell.org Mon Mar 28 12:59:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 12:59:43 +0000 (UTC) Subject: [commit: ghc] master: Autoconf: detect and set CFLAGS/CPPFLAGS needed for C99 mode (afc48f8) Message-ID: <20160328125943.2BDC03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/afc48f8939b99a1a72b43b3e342d56193ed1f34c/ghc >--------------------------------------------------------------- commit afc48f8939b99a1a72b43b3e342d56193ed1f34c Author: Herbert Valerio Riedel Date: Mon Mar 28 14:34:22 2016 +0200 Autoconf: detect and set CFLAGS/CPPFLAGS needed for C99 mode This is the first phase of addressing #11757 which aims to make C99 support a base-line requirement for GHC and clean up the code-base to use C99 facilities when sensible. This patch exploits the logic/heuristic used by `AC_PROG_CC_C99` to determine the flags needed in case the C compiler isn't able to compile C99 code in its current mode. We can't use `AC_PROG_CC_C99` directly though because GHC's build-system expects CC to contain a filename without any flags, while `AC_PROG_CC_C99` would e.g. result in `CC="gcc -std=gnu99"`. Morever, we support different `CC`s for stage0/1/2, so we need a version of `AC_PROG_CC_C99` for which we can specify the `CC`/`CFLAGS` variables to operate on. This is what `FP_SET_CFLAGS_C99` does. Note that Clang has been defaulting to C99+ for a long time, while GCC 5 defaults to C99+ as well. So this has mostly an affect on older GCCs versions prior to 5.0 and possibly compilers other than GCC/Clang (which are not officially supported for building GHC anyway). Reviewers: kgardas, erikd, bgamari, austin Reviewed By: erikd Differential Revision: https://phabricator.haskell.org/D2045 >--------------------------------------------------------------- afc48f8939b99a1a72b43b3e342d56193ed1f34c aclocal.m4 | 42 ++++++++++++++++++++++++++++++++++++++++++ configure.ac | 5 +++++ distrib/configure.ac.in | 5 +++++ includes/Stg.h | 4 ++++ 4 files changed, 56 insertions(+) diff --git a/aclocal.m4 b/aclocal.m4 index 5becadb..6403748 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -514,6 +514,48 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsOptCommand) ]) +# Helper for cloning a shell variable's state +AC_DEFUN([FP_COPY_SHELLVAR], +[if test -n "${$1+set}"; then $2="$$1"; else unset $2; fi ]) + +# FP_SET_CFLAGS_C99 +# ---------------------------------- +# figure out which CFLAGS are needed to place the compiler into C99 mode +# $1 is name of CC variable (unmodified) +# $2 is name of CC flags variable (augmented if needed) +# $3 is name of CPP flags variable (augmented if needed) +AC_DEFUN([FP_SET_CFLAGS_C99], +[ + dnl save current state of AC_PROG_CC_C99 + FP_COPY_SHELLVAR([CC],[fp_save_CC]) + FP_COPY_SHELLVAR([CFLAGS],[fp_save_CFLAGS]) + FP_COPY_SHELLVAR([CPPFLAGS],[fp_save_CPPFLAGS]) + FP_COPY_SHELLVAR([ac_cv_prog_cc_c99],[fp_save_cc_c99]) + dnl set local state + CC="$$1" + CFLAGS="$$2" + CPPFLAGS="$$3" + unset ac_cv_prog_cc_c99 + dnl perform detection + _AC_PROG_CC_C99 + fp_cc_c99="$ac_cv_prog_cc_c99" + case "x$ac_cv_prog_cc_c99" in + x) ;; # noop + xno) AC_MSG_ERROR([C99-compatible compiler needed]) ;; + *) $2="$$2 $ac_cv_prog_cc_c99" + $3="$$3 $ac_cv_prog_cc_c99" + ;; + esac + dnl restore saved state + FP_COPY_SHELLVAR([fp_save_CC],[CC]) + FP_COPY_SHELLVAR([fp_save_CFLAGS],[CFLAGS]) + FP_COPY_SHELLVAR([fp_save_CPPFLAGS],[CPPFLAGS]) + FP_COPY_SHELLVAR([fp_save_cc_c99],[ac_cv_prog_cc_c99]) + dnl cleanup + unset fp_save_CC + unset fp_save_CFLAGS + unset fp_save_cc_c99 +]) # FPTOOLS_SET_C_LD_FLAGS # ---------------------------------- diff --git a/configure.ac b/configure.ac index 7d522b0..ac88433 100644 --- a/configure.ac +++ b/configure.ac @@ -461,6 +461,11 @@ FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs) AC_SUBST([HaskellCPPCmd]) AC_SUBST([HaskellCPPArgs]) +FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS]) +FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) + dnl ** Which ld to use? dnl -------------------------------------------------------------- FIND_LD([LdCmd]) diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in index 99b51f5..1df58d5 100644 --- a/distrib/configure.ac.in +++ b/distrib/configure.ac.in @@ -109,6 +109,11 @@ dnl ** Check gcc version and flags we need to pass it ** # FP_GCC_EXTRA_FLAGS +FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS]) +dnl FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) +FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) + FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS]) FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) diff --git a/includes/Stg.h b/includes/Stg.h index b179db6..f1949b1 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -26,6 +26,10 @@ #ifndef STG_H #define STG_H +#if !(__STDC_VERSION__ >= 199901L) +# error __STDC_VERSION__ does not advertise C99 or later +#endif + /* * If we are compiling a .hc file, then we want all the register * variables. This is the what happens if you #include "Stg.h" first: From git at git.haskell.org Mon Mar 28 13:19:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 13:19:54 +0000 (UTC) Subject: [commit: ghc] master: Do not test for existence of the executable (49b9d80) Message-ID: <20160328131954.4205E3A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/49b9d80a4666504f3f3524928c9ae7cc436bb8ba/ghc >--------------------------------------------------------------- commit 49b9d80a4666504f3f3524928c9ae7cc436bb8ba Author: Kai Harries Date: Mon Mar 28 15:18:05 2016 +0200 Do not test for existence of the executable Summary: The test for the existence of the executable breaks on MS Windows. It is furthermore needless, because if the test can be executed the executable is obviously there. Reviewers: austin, bgamari, Phyx Reviewed By: Phyx Subscribers: Phyx, thomie Differential Revision: https://phabricator.haskell.org/D2050 GHC Trac Issues: #4114 >--------------------------------------------------------------- 49b9d80a4666504f3f3524928c9ae7cc436bb8ba testsuite/tests/driver/T4114a.hs | 2 +- testsuite/tests/driver/T4114b.hs | 2 +- testsuite/tests/driver/T4114c.hs | 2 +- testsuite/tests/driver/T4114d.hs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testsuite/tests/driver/T4114a.hs b/testsuite/tests/driver/T4114a.hs index ff835d6..9664dab 100644 --- a/testsuite/tests/driver/T4114a.hs +++ b/testsuite/tests/driver/T4114a.hs @@ -4,7 +4,7 @@ module Main (main) where import T4114aSub keep, nokeep :: [FilePath] -keep = ["T4114a", "T4114aSub.hi", "T4114aSub.o", "T4114a.hi", "T4114a.o"] +keep = ["T4114aSub.hi", "T4114aSub.o", "T4114a.hi", "T4114a.o"] nokeep = [ ] diff --git a/testsuite/tests/driver/T4114b.hs b/testsuite/tests/driver/T4114b.hs index 07486c5..b010a73 100644 --- a/testsuite/tests/driver/T4114b.hs +++ b/testsuite/tests/driver/T4114b.hs @@ -4,7 +4,7 @@ module Main (main) where import T4114bSub keep, nokeep :: [FilePath] -keep = ["T4114b", "T4114bSub.o", "T4114b.o"] +keep = ["T4114bSub.o", "T4114b.o"] nokeep = ["T4114bSub.hi", "T4114b.hi"] main :: IO () diff --git a/testsuite/tests/driver/T4114c.hs b/testsuite/tests/driver/T4114c.hs index f7802e1..96e8625 100644 --- a/testsuite/tests/driver/T4114c.hs +++ b/testsuite/tests/driver/T4114c.hs @@ -4,7 +4,7 @@ module Main (main) where import T4114cSub keep, nokeep :: [FilePath] -keep = ["T4114c", "T4114cSub.hi", "T4114c.hi"] +keep = ["T4114cSub.hi", "T4114c.hi"] nokeep = ["T4114cSub.o", "T4114c.o"] diff --git a/testsuite/tests/driver/T4114d.hs b/testsuite/tests/driver/T4114d.hs index 2ff717b..45946a0 100644 --- a/testsuite/tests/driver/T4114d.hs +++ b/testsuite/tests/driver/T4114d.hs @@ -4,7 +4,7 @@ module Main (main) where import T4114dSub keep, nokeep :: [FilePath] -keep = ["T4114d", "T4114dSub.myhi", "T4114d.myhi"] +keep = ["T4114dSub.myhi", "T4114d.myhi"] nokeep = ["T4114dSub.myo", "T4114d.myo"] From git at git.haskell.org Mon Mar 28 15:29:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 15:29:57 +0000 (UTC) Subject: [commit: ghc] master: Update bytestring submodule to latest snapshot (eb25381) Message-ID: <20160328152957.7B7223A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/eb25381da2e4a95337ad9c2fabff60d699b41bc7/ghc >--------------------------------------------------------------- commit eb25381da2e4a95337ad9c2fabff60d699b41bc7 Author: Herbert Valerio Riedel Date: Mon Mar 28 17:28:49 2016 +0200 Update bytestring submodule to latest snapshot Most notably, this pulls in the following changes > Fix breakByte and spanByte rewrite rules > Implement `stripPrefix`/`stripSuffix` The first patch is related to #11688 >--------------------------------------------------------------- eb25381da2e4a95337ad9c2fabff60d699b41bc7 libraries/bytestring | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/bytestring b/libraries/bytestring index 84d0416..3d6d0f6 160000 --- a/libraries/bytestring +++ b/libraries/bytestring @@ -1 +1 @@ -Subproject commit 84d041649c39e7dc0fe8d348da10d6ed1679a8f9 +Subproject commit 3d6d0f60ac25736cc87a6f598886fe77e7b6ad90 From git at git.haskell.org Mon Mar 28 18:24:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 18:24:54 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: DynFlags: Initialize unsafeGlobalDynFlags enough to be useful (0f289b9) Message-ID: <20160328182454.BBC513A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0f289b93ef4993f2df922dc490799414d73c7b2e/ghc >--------------------------------------------------------------- commit 0f289b93ef4993f2df922dc490799414d73c7b2e Author: Ben Gamari Date: Sat Mar 26 00:42:11 2016 +0100 DynFlags: Initialize unsafeGlobalDynFlags enough to be useful Previously unsafeGlobalDynFlags would bottom if used prior to initialization. This meant that any attempt to use the pretty-printer early in the initialization process of the compiler would fail. This is quite inconvenient. Here we initialize unsafeGlobalDynFlags with defaultDynFlags, bottoming only if settings is accessed. See #11755. Test Plan: Validate Reviewers: austin Reviewed By: austin Subscribers: thomie, gridaphobe Differential Revision: https://phabricator.haskell.org/D2036 GHC Trac Issues: #11755 >--------------------------------------------------------------- 0f289b93ef4993f2df922dc490799414d73c7b2e compiler/main/DynFlags.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 6060244..bff0348 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -4813,7 +4813,15 @@ makeDynFlagsConsistent dflags -- Do not use it if you can help it. You may get the wrong value, or this -- panic! -GLOBAL_VAR(v_unsafeGlobalDynFlags, panic "v_unsafeGlobalDynFlags: not initialised", DynFlags) +-- | This is the value that 'unsafeGlobalDynFlags' takes before it is +-- initialized. +defaultGlobalDynFlags :: DynFlags +defaultGlobalDynFlags = + (defaultDynFlags settings) { verbosity = 2 } + where + settings = panic "v_unsafeGlobalDynFlags: not initialised" + +GLOBAL_VAR(v_unsafeGlobalDynFlags, defaultGlobalDynFlags, DynFlags) unsafeGlobalDynFlags :: DynFlags unsafeGlobalDynFlags = unsafePerformIO $ readIORef v_unsafeGlobalDynFlags From git at git.haskell.org Mon Mar 28 18:24:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 18:24:57 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Panic: Try outputting SDocs (0a0e113) Message-ID: <20160328182457.8A8263A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0a0e113c19067d364f9cf4a325efce365aa5a83c/ghc >--------------------------------------------------------------- commit 0a0e113c19067d364f9cf4a325efce365aa5a83c Author: Ben Gamari Date: Sat Mar 26 00:42:27 2016 +0100 Panic: Try outputting SDocs This works in conjunction with D2036 to allow useful debug output before DynFlags has been initializated. See #11755. Reviewers: austin Reviewed By: austin Subscribers: thomie, gridaphobe Differential Revision: https://phabricator.haskell.org/D2037 GHC Trac Issues: #11755 >--------------------------------------------------------------- 0a0e113c19067d364f9cf4a325efce365aa5a83c compiler/utils/Outputable.hs-boot | 2 ++ compiler/utils/Panic.hs | 52 ++++++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/compiler/utils/Outputable.hs-boot b/compiler/utils/Outputable.hs-boot index 1c15a69..e5e8895 100644 --- a/compiler/utils/Outputable.hs-boot +++ b/compiler/utils/Outputable.hs-boot @@ -1,3 +1,5 @@ module Outputable where data SDoc + +showSDocUnsafe :: SDoc -> String diff --git a/compiler/utils/Panic.hs b/compiler/utils/Panic.hs index f1ccb7b..b19c770 100644 --- a/compiler/utils/Panic.hs +++ b/compiler/utils/Panic.hs @@ -27,7 +27,7 @@ module Panic ( ) where #include "HsVersions.h" -import {-# SOURCE #-} Outputable (SDoc) +import {-# SOURCE #-} Outputable (SDoc, showSDocUnsafe) import Config import Exception @@ -125,35 +125,47 @@ safeShowException e = do forceList xs@(x : xt) = x `seq` forceList xt `seq` xs -- | Append a description of the given exception to this string. -showGhcException :: GhcException -> String -> String +-- +-- Note that this uses 'DynFlags.unsafeGlobalDynFlags', which may have some +-- uninitialized fields if invoked before 'GHC.initGhcMonad' has been called. +-- If the error message to be printed includes a pretty-printer document +-- which forces one of these fields this call may bottom. +showGhcException :: GhcException -> ShowS showGhcException exception = case exception of UsageError str -> showString str . showChar '\n' . showString short_usage CmdLineError str -> showString str - PprProgramError str _ -> - showGhcException (ProgramError (str ++ "\n<
>")) + PprProgramError str sdoc -> + showString str . showString "\n\n" . + showString (showSDocUnsafe sdoc) ProgramError str -> showString str InstallationError str -> showString str Signal n -> showString "signal: " . shows n - PprPanic s _ -> - showGhcException (Panic (s ++ "\n<
>")) - Panic s - -> showString $ - "panic! (the 'impossible' happened)\n" - ++ " (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t" - ++ s ++ "\n\n" - ++ "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n" - - PprSorry s _ -> - showGhcException (Sorry (s ++ "\n<
>")) - Sorry s - -> showString $ - "sorry! (unimplemented feature or known bug)\n" - ++ " (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t" - ++ s ++ "\n" + PprPanic s sdoc -> + panicMsg $ showString s . showString "\n\n" + . showString (showSDocUnsafe sdoc) + Panic s -> panicMsg (showString s) + + PprSorry s sdoc -> + sorryMsg $ showString s . showString "\n\n" + . showString (showSDocUnsafe sdoc) + Sorry s -> sorryMsg (showString s) + where + sorryMsg :: ShowS -> ShowS + sorryMsg s = + showString "sorry! (unimplemented feature or known bug)\n" + . showString (" (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t") + . s . showString "\n" + + panicMsg :: ShowS -> ShowS + panicMsg s = + showString "panic! (the 'impossible' happened)\n" + . showString (" (GHC version " ++ cProjectVersion ++ " for " ++ TargetPlatform_NAME ++ "):\n\t") + . s . showString "\n\n" + . showString "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\n" throwGhcException :: GhcException -> a From git at git.haskell.org Mon Mar 28 18:25:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 18:25:00 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Update bytestring submodule to latest snapshot (5f32cf1d) Message-ID: <20160328182500.3DAC63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/5f32cf1dc4e15f28b5b6e516fa32e5a4bd1e498f/ghc >--------------------------------------------------------------- commit 5f32cf1dc4e15f28b5b6e516fa32e5a4bd1e498f Author: Herbert Valerio Riedel Date: Mon Mar 28 17:28:49 2016 +0200 Update bytestring submodule to latest snapshot Most notably, this pulls in the following changes > Fix breakByte and spanByte rewrite rules > Implement `stripPrefix`/`stripSuffix` The first patch is related to #11688 (cherry picked from commit eb25381da2e4a95337ad9c2fabff60d699b41bc7) >--------------------------------------------------------------- 5f32cf1dc4e15f28b5b6e516fa32e5a4bd1e498f libraries/bytestring | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/bytestring b/libraries/bytestring index 84d0416..3d6d0f6 160000 --- a/libraries/bytestring +++ b/libraries/bytestring @@ -1 +1 @@ -Subproject commit 84d041649c39e7dc0fe8d348da10d6ed1679a8f9 +Subproject commit 3d6d0f60ac25736cc87a6f598886fe77e7b6ad90 From git at git.haskell.org Mon Mar 28 21:20:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Mon, 28 Mar 2016 21:20:46 +0000 (UTC) Subject: [commit: ghc] master: Remove obsolete --with-hc flag from ./configure (cd3fbff) Message-ID: <20160328212046.232A03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/cd3fbff946bce86b48cba60e018ac864ffc37e57/ghc >--------------------------------------------------------------- commit cd3fbff946bce86b48cba60e018ac864ffc37e57 Author: Herbert Valerio Riedel Date: Mon Mar 28 23:20:10 2016 +0200 Remove obsolete --with-hc flag from ./configure This was probably missed during the big build-system refactoring in 34cc75e1a62638f2833815746ebce0a9114dc26b >--------------------------------------------------------------- cd3fbff946bce86b48cba60e018ac864ffc37e57 configure.ac | 9 --------- 1 file changed, 9 deletions(-) diff --git a/configure.ac b/configure.ac index ac88433..a645aec 100644 --- a/configure.ac +++ b/configure.ac @@ -252,15 +252,6 @@ AC_ARG_ENABLE(unregisterised, ) AC_SUBST(Unregisterised) -AC_ARG_WITH(hc, -[AC_HELP_STRING([--with-hc=ARG], - [Use ARG as the path to the compiler for compiling ordinary - Haskell code (default= value of --with-ghc)])], -[WithHc="$withval"], -[WithHc=$WithGhc] -) -AC_SUBST(WithHc) - # Requires FPTOOLS_SET_PLATFORM_VARS to be run first. FP_FIND_ROOT From git at git.haskell.org Tue Mar 29 09:09:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:09:28 +0000 (UTC) Subject: [commit: ghc] master: fix compilation failure on Solaris 11 (91b96e1) Message-ID: <20160329090929.00C993A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/91b96e1ccce6a642d710ce40211e1795d01abf04/ghc >--------------------------------------------------------------- commit 91b96e1ccce6a642d710ce40211e1795d01abf04 Author: Karel Gardas Date: Tue Mar 29 00:06:48 2016 +0200 fix compilation failure on Solaris 11 Summary: Solaris is quite picky about C and POSIX version combination. For recent change to C99 we need to switch _XPG6 on which means _XOPEN_SOURCE should be defined to 600 Reviewers: austin, bgamari, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2053 >--------------------------------------------------------------- 91b96e1ccce6a642d710ce40211e1795d01abf04 rts/PosixSource.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rts/PosixSource.h b/rts/PosixSource.h index 6659cfe..6246e3e 100644 --- a/rts/PosixSource.h +++ b/rts/PosixSource.h @@ -11,7 +11,7 @@ #include -#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) +#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(solaris2_HOST_OS) #define _POSIX_C_SOURCE 200112L #define _XOPEN_SOURCE 600 #else From git at git.haskell.org Tue Mar 29 09:13:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:13:55 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Ticky: Do not count every entry twice (2c54f57) Message-ID: <20160329091355.C80043A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/2c54f57ff71f53fcfd162c2e2736ee00a26eb826/ghc >--------------------------------------------------------------- commit 2c54f57ff71f53fcfd162c2e2736ee00a26eb826 Author: Joachim Breitner Date: Thu Mar 17 17:25:36 2016 +0100 Ticky: Do not count every entry twice (likely introduced by 99d4e5b4a0bd32813ff8c74e91d2dcf6b3555176, possibly due to a merge mistake). >--------------------------------------------------------------- 2c54f57ff71f53fcfd162c2e2736ee00a26eb826 compiler/codeGen/StgCmmBind.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index b265153..eae599c 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -578,8 +578,7 @@ thunkCode cl_info fv_details _cc node arity body -- that cc of enclosing scope will be recorded -- in update frame CAF/DICT functions will be -- subsumed by this enclosing cc - do { tickyEnterThunk cl_info - ; enterCostCentreThunk (CmmReg nodeReg) + do { enterCostCentreThunk (CmmReg nodeReg) ; let lf_info = closureLFInfo cl_info ; fv_bindings <- mapM bind_fv fv_details ; load_fvs node lf_info fv_bindings From git at git.haskell.org Tue Mar 29 09:14:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:01 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Remove all mentions of IND_OLDGEN outside of docs/rts (8a28f2d) Message-ID: <20160329091401.17D2A3A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/8a28f2d5028a2e0491aab91e7d39bfa0ccb0ab32/ghc >--------------------------------------------------------------- commit 8a28f2d5028a2e0491aab91e7d39bfa0ccb0ab32 Author: Joachim Breitner Date: Fri Jan 22 10:31:25 2016 +0100 Remove all mentions of IND_OLDGEN outside of docs/rts >--------------------------------------------------------------- 8a28f2d5028a2e0491aab91e7d39bfa0ccb0ab32 compiler/codeGen/StgCmmProf.hs | 3 +-- rts/sm/Scav.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs index c1b149d..434d7b5 100644 --- a/compiler/codeGen/StgCmmProf.hs +++ b/compiler/codeGen/StgCmmProf.hs @@ -328,8 +328,7 @@ ldvRecordCreate closure = do -- -- | Called when a closure is entered, marks the closure as having -- been "used". The closure is not an "inherently used" one. The --- closure is not @IND@ or @IND_OLDGEN@ because neither is considered --- for LDV profiling. +-- closure is not @IND@ because that is not considered for LDV profiling. -- ldvEnterClosure :: ClosureInfo -> CmmReg -> FCode () ldvEnterClosure closure_info node_reg = do diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index 953f055..abb7726 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -1533,7 +1533,7 @@ scavenge_one(StgPtr p) } else { size = gen->scan - start; } - debugBelch("evac IND_OLDGEN: %ld bytes", size * sizeof(W_)); + debugBelch("evac IND: %ld bytes", size * sizeof(W_)); } #endif break; From git at git.haskell.org Tue Mar 29 09:13:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:13:58 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Be more explicit about thunk types in ticky-ticky-report (6c6ad1a) Message-ID: <20160329091358.6D2EB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/6c6ad1a322ee0241cbceffb44076ef5326930c4b/ghc >--------------------------------------------------------------- commit 6c6ad1a322ee0241cbceffb44076ef5326930c4b Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Be more explicit about thunk types in ticky-ticky-report and also, for standard thunks (AP and selector), do not count an entry when they are allocated. It is not possible to count their entries, as their code is shared, but better count nothing than count the wrong thing. (The removed line was added in 11a85cc7ea50d4b7c12ea2cc3c0ce39734dc4217) >--------------------------------------------------------------- 6c6ad1a322ee0241cbceffb44076ef5326930c4b compiler/codeGen/StgCmmBind.hs | 10 ++++--- compiler/codeGen/StgCmmTicky.hs | 62 ++++++++++++++++++++++++++++++----------- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index f34186a..b265153 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -206,7 +206,7 @@ cgRhs :: Id ) cgRhs id (StgRhsCon cc con args) - = withNewTickyCounterThunk False (idName id) $ -- False for "not static" + = withNewTickyCounterCon (idName id) $ buildDynCon id True cc con args {- See Note [GC recovery] in compiler/codeGen/StgCmmClosure.hs -} @@ -386,7 +386,7 @@ cgRhsStdThunk bndr lf_info payload } where gen_code reg -- AHA! A STANDARD-FORM THUNK - = withNewTickyCounterStdThunk False (idName bndr) $ -- False for "not static" + = withNewTickyCounterStdThunk (lfUpdatable lf_info) (idName bndr) $ do { -- LAY OUT THE OBJECT mod_name <- getModuleName @@ -402,7 +402,6 @@ cgRhsStdThunk bndr lf_info payload -- ; (use_cc, blame_cc) <- chooseDynCostCentres cc [{- no args-}] body ; let use_cc = curCCS; blame_cc = curCCS - ; tickyEnterStdThunk closure_info -- BUILD THE OBJECT ; let info_tbl = mkCmmInfo closure_info @@ -453,7 +452,10 @@ closureCodeBody :: Bool -- whether this is a top-level binding closureCodeBody top_lvl bndr cl_info cc _args arity body fv_details | arity == 0 -- No args i.e. thunk - = withNewTickyCounterThunk (isStaticClosure cl_info) (closureName cl_info) $ + = withNewTickyCounterThunk + (isStaticClosure cl_info) + (closureUpdReqd cl_info) + (closureName cl_info) $ emitClosureProcAndInfoTable top_lvl bndr lf_info info_tbl [] $ \(_, node, _) -> thunkCode cl_info fv_details cc node arity body where diff --git a/compiler/codeGen/StgCmmTicky.hs b/compiler/codeGen/StgCmmTicky.hs index 95dfa99..45b88da 100644 --- a/compiler/codeGen/StgCmmTicky.hs +++ b/compiler/codeGen/StgCmmTicky.hs @@ -70,6 +70,7 @@ module StgCmmTicky ( withNewTickyCounterLNE, withNewTickyCounterThunk, withNewTickyCounterStdThunk, + withNewTickyCounterCon, tickyDynAlloc, tickyAllocHeap, @@ -143,7 +144,13 @@ import Control.Monad ( unless, when ) -- ----------------------------------------------------------------------------- -data TickyClosureType = TickyFun | TickyThunk | TickyLNE +data TickyClosureType + = TickyFun + | TickyCon + | TickyThunk + Bool -- ^ True <-> updateable + Bool -- ^ True <-> standard thunk (AP or selector), has no entry counter + | TickyLNE withNewTickyCounterFun, withNewTickyCounterLNE :: Name -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterFun = withNewTickyCounter TickyFun @@ -152,15 +159,38 @@ withNewTickyCounterLNE nm args code = do b <- tickyLNEIsOn if not b then code else withNewTickyCounter TickyLNE nm args code -withNewTickyCounterThunk,withNewTickyCounterStdThunk :: - Bool -> Name -> FCode a -> FCode a -withNewTickyCounterThunk isStatic name code = do +withNewTickyCounterThunk + :: Bool -- ^ static + -> Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterThunk isStatic isUpdatable name code = do b <- tickyDynThunkIsOn if isStatic || not b -- ignore static thunks then code - else withNewTickyCounter TickyThunk name [] code + else withNewTickyCounter (TickyThunk isUpdatable False) name [] code + +withNewTickyCounterStdThunk + :: Bool -- ^ updateable + -> Name + -> FCode a + -> FCode a +withNewTickyCounterStdThunk isUpdatable name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter (TickyThunk isUpdatable True) name [] code -withNewTickyCounterStdThunk = withNewTickyCounterThunk +withNewTickyCounterCon + :: Name + -> FCode a + -> FCode a +withNewTickyCounterCon name code = do + b <- tickyDynThunkIsOn + if not b + then code + else withNewTickyCounter TickyCon name [] code -- args does not include the void arguments withNewTickyCounter :: TickyClosureType -> Name -> [NonVoid Id] -> FCode a -> FCode a @@ -184,21 +214,21 @@ emitTickyCounter cloType name args ; let ppr_for_ticky_name :: SDoc ppr_for_ticky_name = let n = ppr name + ext = case cloType of + TickyFun -> empty + TickyCon -> parens (text "con") + TickyThunk upd std -> parens $ hcat $ punctuate comma $ + [text "thk"] ++ [text "se"|not upd] ++ [text "std"|std] + TickyLNE | isInternalName name -> parens (text "LNE") + | otherwise -> panic "emitTickyCounter: how is this an external LNE?" p = case hasHaskellName parent of -- NB the default "top" ticky ctr does not -- have a Haskell name Just pname -> text "in" <+> ppr (nameUnique pname) _ -> empty - in (<+> p) $ if isInternalName name - then let s = n <+> (parens (ppr mod_name)) - in case cloType of - TickyFun -> s - TickyThunk -> s <+> parens (text "thk") - TickyLNE -> s <+> parens (text "LNE") - else case cloType of - TickyFun -> n - TickyThunk -> n <+> parens (text "thk") - TickyLNE -> panic "emitTickyCounter: how is this an external LNE?" + in if isInternalName name + then n <+> parens (ppr mod_name) <+> ext <+> p + else n <+> ext <+> p ; fun_descr_lit <- newStringCLit $ showSDocDebug dflags ppr_for_ticky_name ; arg_descr_lit <- newStringCLit $ map (showTypeCategory . idType . unsafe_stripNV) args From git at git.haskell.org Tue Mar 29 09:14:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:03 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Typo in Note name (1819e78) Message-ID: <20160329091403.BCE3D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/1819e7830116a19517666bd7974b2ffad5d8dd7a/ghc >--------------------------------------------------------------- commit 1819e7830116a19517666bd7974b2ffad5d8dd7a Author: Joachim Breitner Date: Tue Mar 22 11:14:08 2016 +0100 Typo in Note name >--------------------------------------------------------------- 1819e7830116a19517666bd7974b2ffad5d8dd7a compiler/coreSyn/CoreUtils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index d2da53a..1d9b83b 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -753,8 +753,8 @@ Note [exprIsTrivial] applications. Note that primop Ids aren't considered trivial unless -Note [Variable are trivial] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Variables are trivial] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There used to be a gruesome test for (hasNoBinding v) in the Var case: exprIsTrivial (Var v) | hasNoBinding v = idArity v == 0 From git at git.haskell.org Tue Mar 29 09:14:06 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:06 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Do not print DmdType in Core output (48c9183) Message-ID: <20160329091406.718813A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/48c918309c88c113282701458689ffba2b3fb0fa/ghc >--------------------------------------------------------------- commit 48c918309c88c113282701458689ffba2b3fb0fa Author: Joachim Breitner Date: Wed Mar 23 13:38:34 2016 +0100 Do not print DmdType in Core output too verbose, and usualy preceded by Str= anyways. >--------------------------------------------------------------- 48c918309c88c113282701458689ffba2b3fb0fa compiler/basicTypes/Demand.hs | 3 +-- .../tests/deSugar/should_compile/T2431.stderr | 18 ++++++------- .../tests/determinism/should_compile/determ004.hs | 2 +- .../simplCore/should_compile/spec-inline-determ.hs | 4 +-- .../tests/numeric/should_compile/T7116.stdout | 14 +++++----- testsuite/tests/perf/should_run/T4267.hs | 4 +-- testsuite/tests/perf/should_run/T5949.hs | 4 +-- .../tests/roles/should_compile/Roles13.stderr | 26 +++++++++--------- testsuite/tests/roles/should_compile/T8958.stderr | 2 -- .../tests/simplCore/should_compile/T3717.stderr | 10 +++---- .../tests/simplCore/should_compile/T3772.stdout | 10 +++---- .../tests/simplCore/should_compile/T4398.stderr | 6 ++--- .../tests/simplCore/should_compile/T4908.stderr | 12 ++++----- .../tests/simplCore/should_compile/T4930.stderr | 10 +++---- .../tests/simplCore/should_compile/T7360.stderr | 31 +++++++++++----------- .../tests/simplCore/should_compile/T9400.stderr | 8 +++--- .../tests/simplCore/should_compile/simpl016.stderr | 2 +- .../simplCore/should_compile/spec-inline.stderr | 24 ++++++++--------- .../tests/stranal/should_compile/T10694.stdout | 10 +++---- 19 files changed, 98 insertions(+), 102 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 48c918309c88c113282701458689ffba2b3fb0fa From git at git.haskell.org Tue Mar 29 09:14:09 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:09 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Ticky report: Mark single entry functions as such (877ef6a) Message-ID: <20160329091409.2C43A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/877ef6a2cd75008908e4f7200579e34944473fec/ghc >--------------------------------------------------------------- commit 877ef6a2cd75008908e4f7200579e34944473fec Author: Joachim Breitner Date: Tue Mar 22 16:36:22 2016 +0100 Ticky report: Mark single entry functions as such Based on the idOneShotInfo of their first argument, I hope that?s right. >--------------------------------------------------------------- 877ef6a2cd75008908e4f7200579e34944473fec compiler/codeGen/StgCmmBind.hs | 5 +++- compiler/codeGen/StgCmmClosure.hs | 49 +++++++++++++++++++++------------------ compiler/codeGen/StgCmmTicky.hs | 9 ++++--- 3 files changed, 37 insertions(+), 26 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 877ef6a2cd75008908e4f7200579e34944473fec From git at git.haskell.org Tue Mar 29 09:14:11 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:11 +0000 (UTC) Subject: [commit: ghc] wip/T10613: State hack hack in ticky report (5f237b7) Message-ID: <20160329091411.D65FD3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/5f237b725a455eb3d3f2817c5456a083764aa608/ghc >--------------------------------------------------------------- commit 5f237b725a455eb3d3f2817c5456a083764aa608 Author: Joachim Breitner Date: Wed Mar 23 11:10:25 2016 +0100 State hack hack in ticky report In the ticky report, do not mark a function with a State# argument as its first argument as single-entry. >--------------------------------------------------------------- 5f237b725a455eb3d3f2817c5456a083764aa608 compiler/codeGen/StgCmmClosure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index b467048..3b83b8e 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -234,7 +234,10 @@ mkLFReEntrant _ _ [] _ = pprPanic "mkLFReEntrant" empty mkLFReEntrant top fvs args arg_descr = LFReEntrant top os_info (length args) (null fvs) arg_descr - where os_info = idOneShotInfo (head args) + where + state_hack_hack = isStateHackType (idType (head args)) + os_info | state_hack_hack = noOneShotInfo + | otherwise = idOneShotInfo (head args) ------------- mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo From git at git.haskell.org Tue Mar 29 09:14:14 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:14 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Temporarily move regular entry counting to the COUNTING_IND (00349e7) Message-ID: <20160329091414.847E53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/00349e76d24f0ca6c154c961641b29870a20fcb9/ghc >--------------------------------------------------------------- commit 00349e76d24f0ca6c154c961641b29870a20fcb9 Author: Joachim Breitner Date: Wed Mar 23 14:28:34 2016 +0100 Temporarily move regular entry counting to the COUNTING_IND >--------------------------------------------------------------- 00349e76d24f0ca6c154c961641b29870a20fcb9 compiler/codeGen/StgCmmBind.hs | 8 ++++++-- rts/StgMiscClosures.cmm | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 5951175..8672273 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -609,9 +609,13 @@ thunkCode cl_info fv_details _cc node arity body -- Heap overflow check ; entryHeapCheck cl_info node' arity [] $ do - { -- Overwrite with black hole if necessary + { + -- Disabled for now, as we (temporarily unconditionally) move the + -- counting to the counting indirection + -- tickyEnterThunk cl_info + + -- Overwrite with black hole if necessary -- but *after* the heap-overflow check - ; tickyEnterThunk cl_info ; when (blackHoleOnEntry cl_info && node_points) (blackHoleIt node) diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 96b95aa..0f27fdb 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -283,6 +283,7 @@ INFO_TABLE(stg_COUNTING_IND,1,2,COUNTING_IND,"COUNTING_IND","COUNTING_IND") StgEntCounter_multi_entry_count(ent_ctr) = StgEntCounter_multi_entry_count(ent_ctr) + 1; } StgCountingInd_entries(clos) = entries + 1; + StgEntCounter_entry_count(ent_ctr) = StgEntCounter_entry_count(ent_ctr) + 1; #if defined(TICKY_TICKY) && !defined(PROFILING) /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than From git at git.haskell.org Tue Mar 29 09:14:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:17 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (b6067cd) Message-ID: <20160329091417.45B483A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/b6067cda718b984f08e9693fa6f9b2adde574a08/ghc >--------------------------------------------------------------- commit b6067cda718b984f08e9693fa6f9b2adde574a08 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- b6067cda718b984f08e9693fa6f9b2adde574a08 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc b6067cda718b984f08e9693fa6f9b2adde574a08 From git at git.haskell.org Tue Mar 29 09:14:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:19 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rename isNopSig to isTopSig (e8ddc6b) Message-ID: <20160329091419.E82653A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/e8ddc6b4e67d63264f97f9f6326a4ccd68f17901/ghc >--------------------------------------------------------------- commit e8ddc6b4e67d63264f97f9f6326a4ccd68f17901 Author: Joachim Breitner Date: Wed Mar 23 10:41:16 2016 +0100 Rename isNopSig to isTopSig to be consistent with the other uses of nop vs. top in Demand.hs. Also, stop prettyprinting top strictness signatures in Core dumps. >--------------------------------------------------------------- e8ddc6b4e67d63264f97f9f6326a4ccd68f17901 compiler/basicTypes/Demand.hs | 12 ++++++------ compiler/coreSyn/CoreArity.hs | 2 +- compiler/coreSyn/PprCore.hs | 3 ++- compiler/iface/MkIface.hs | 2 +- compiler/main/TidyPgm.hs | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/compiler/basicTypes/Demand.hs b/compiler/basicTypes/Demand.hs index 96e02b2..3ce9228 100644 --- a/compiler/basicTypes/Demand.hs +++ b/compiler/basicTypes/Demand.hs @@ -37,7 +37,7 @@ module Demand ( appIsBottom, isBottomingSig, pprIfaceStrictSig, trimCPRInfo, returnsCPR_maybe, StrictSig(..), mkStrictSig, mkClosedStrictSig, nopSig, botSig, cprProdSig, - isNopSig, splitStrictSig, increaseStrictSigArity, + isTopSig, splitStrictSig, increaseStrictSigArity, seqDemand, seqDemandList, seqDmdType, seqStrictSig, @@ -1262,10 +1262,10 @@ cprProdDmdType :: Arity -> DmdType cprProdDmdType arity = DmdType emptyDmdEnv [] (vanillaCprProdRes arity) -isNopDmdType :: DmdType -> Bool -isNopDmdType (DmdType env [] res) +isTopDmdType :: DmdType -> Bool +isTopDmdType (DmdType env [] res) | isTopRes res && isEmptyVarEnv env = True -isNopDmdType _ = False +isTopDmdType _ = False mkDmdType :: DmdEnv -> [Demand] -> DmdResult -> DmdType mkDmdType fv ds res = DmdType fv ds res @@ -1669,8 +1669,8 @@ increaseStrictSigArity :: Int -> StrictSig -> StrictSig increaseStrictSigArity arity_increase (StrictSig (DmdType env dmds res)) = StrictSig (DmdType env (replicate arity_increase topDmd ++ dmds) res) -isNopSig :: StrictSig -> Bool -isNopSig (StrictSig ty) = isNopDmdType ty +isTopSig :: StrictSig -> Bool +isTopSig (StrictSig ty) = isTopDmdType ty isBottomingSig :: StrictSig -> Bool -- True if the signature diverges or throws an exception diff --git a/compiler/coreSyn/CoreArity.hs b/compiler/coreSyn/CoreArity.hs index 8086299..cf6cd98 100644 --- a/compiler/coreSyn/CoreArity.hs +++ b/compiler/coreSyn/CoreArity.hs @@ -711,7 +711,7 @@ arityType env (Cast e co) arityType _ (Var v) | strict_sig <- idStrictness v - , not $ isNopSig strict_sig + , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds = if isBotRes res then ABot arity diff --git a/compiler/coreSyn/PprCore.hs b/compiler/coreSyn/PprCore.hs index 9ce1dad..0c62e4f 100644 --- a/compiler/coreSyn/PprCore.hs +++ b/compiler/coreSyn/PprCore.hs @@ -400,7 +400,7 @@ ppIdInfo id info , (has_arity, text "Arity=" <> int arity) , (has_called_arity, text "CallArity=" <> int called_arity) , (has_caf_info, text "Caf=" <> ppr caf_info) - , (True, text "Str=" <> pprStrictness str_info) + , (has_str_info, text "Str=" <> pprStrictness str_info) , (has_unf, text "Unf=" <> ppr unf_info) , (not (null rules), text "RULES:" <+> vcat (map pprRule rules)) ] -- Inline pragma, occ, demand, one-shot info @@ -421,6 +421,7 @@ ppIdInfo id info has_caf_info = not (mayHaveCafRefs caf_info) str_info = strictnessInfo info + has_str_info = not (isTopSig str_info) unf_info = unfoldingInfo info has_unf = hasSomeUnfolding unf_info diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 196dd19..7f8397b 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -1684,7 +1684,7 @@ toIfaceIdInfo id_info ------------ Strictness -------------- -- No point in explicitly exporting TopSig sig_info = strictnessInfo id_info - strict_hsinfo | not (isNopSig sig_info) = Just (HsStrictness sig_info) + strict_hsinfo | not (isTopSig sig_info) = Just (HsStrictness sig_info) | otherwise = Nothing ------------ Unfolding -------------- diff --git a/compiler/main/TidyPgm.hs b/compiler/main/TidyPgm.hs index 3a3a916..e31b0ed 100644 --- a/compiler/main/TidyPgm.hs +++ b/compiler/main/TidyPgm.hs @@ -37,7 +37,7 @@ import IdInfo import InstEnv import FamInstEnv import Type ( tidyTopType ) -import Demand ( appIsBottom, isNopSig, isBottomingSig ) +import Demand ( appIsBottom, isTopSig, isBottomingSig ) import BasicTypes import Name hiding (varName) import NameSet @@ -1242,7 +1242,7 @@ tidyTopIdInfo dflags rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold caf_ mb_bot_str = exprBotStrictness_maybe orig_rhs sig = strictnessInfo idinfo - final_sig | not $ isNopSig sig + final_sig | not $ isTopSig sig = WARN( _bottom_hidden sig , ppr name ) sig -- try a cheap-and-cheerful bottom analyser | Just (_, nsig) <- mb_bot_str = nsig From git at git.haskell.org Tue Mar 29 09:14:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:22 +0000 (UTC) Subject: [commit: ghc] wip/T10613: SpecConstr: Transport strictness annotation to specialization’s argument’s binders (450bb1b) Message-ID: <20160329091422.9668F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/450bb1b66b6c3fd91097b42f9643a745b6a9b55d/ghc >--------------------------------------------------------------- commit 450bb1b66b6c3fd91097b42f9643a745b6a9b55d Author: Joachim Breitner Date: Tue Mar 22 15:39:06 2016 +0100 SpecConstr: Transport strictness annotation to specialization?s argument?s binders This is a result of the discussion in ticket:11731#comment:9. >--------------------------------------------------------------- 450bb1b66b6c3fd91097b42f9643a745b6a9b55d compiler/specialise/SpecConstr.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs index 10d5614..12c2e12 100644 --- a/compiler/specialise/SpecConstr.hs +++ b/compiler/specialise/SpecConstr.hs @@ -1648,12 +1648,18 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) `setIdStrictness` spec_str `setIdArity` count isId spec_lam_args spec_str = calcSpecStrictness fn spec_lam_args pats + + -- Conditionally use result of new worker-wrapper transform (spec_lam_args, spec_call_args) = mkWorkerArgs (sc_dflags env) qvars NoOneShotInfo body_ty -- Usual w/w hack to avoid generating -- a spec_rhs of unlifted type and no args - spec_rhs = mkLams spec_lam_args spec_body + spec_lam_args_str = handOutStrictnessInformation (fst (splitStrictSig spec_str)) spec_lam_args + -- ^ Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + + spec_rhs = mkLams spec_lam_args_str spec_body body_ty = exprType spec_body rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn @@ -1663,6 +1669,16 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) -- See Note [Transfer activation] ; return (spec_usg, OS call_pat rule spec_id spec_rhs) } + +-- See Note [Strictness information in worker binders] +handOutStrictnessInformation :: [Demand] -> [Var] -> [Var] +handOutStrictnessInformation = go + where + go _ [] = [] + go [] vs = vs + go (d:dmds) (v:vs) | isId v = setIdDemandInfo v d : go dmds vs + go dmds (v:vs) = v : go dmds vs + calcSpecStrictness :: Id -- The original function -> [Var] -> [CoreExpr] -- Call pattern -> StrictSig -- Strictness of specialised thing @@ -1742,6 +1758,14 @@ See Trac #3437 for a good example. The function calcSpecStrictness performs the calculation. +Note [Strictness information in worker binders] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After having calculated the strictness annotation for the worker (see Note +[Transfer strictness] above), we also want to have this information attached to +the worker?s arguments, for the benefit of later passes. The function +handOutStrictnessInformation decomposes the stricntess annotation calculated by +calcSpecStrictness and attaches them to the variables. ************************************************************************ * * From git at git.haskell.org Tue Mar 29 09:14:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:25 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Evac: Do not evaluate selector thunks pointing to counting indirections (fa3c511) Message-ID: <20160329091425.5CFC83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/fa3c511fa5e0a8a089dc77c5120886ea524afbd6/ghc >--------------------------------------------------------------- commit fa3c511fa5e0a8a089dc77c5120886ea524afbd6 Author: Joachim Breitner Date: Wed Mar 23 13:50:00 2016 +0100 Evac: Do not evaluate selector thunks pointing to counting indirections >--------------------------------------------------------------- fa3c511fa5e0a8a089dc77c5120886ea524afbd6 rts/sm/Evac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 3b4314b..9369543 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -998,12 +998,17 @@ selector_loop: } case IND: - case COUNTING_IND: case IND_STATIC: // Again, we might need to untag a constructor. selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); goto selector_loop; + case COUNTING_IND: + // do not short cut a COUNTING_IND, as we would miss a the count + // Can we simply tick the counter here? Not really: If this selector + // thunk is not going to be used, we counted more than we wanted! + goto bale_out; + case BLACKHOLE: { StgClosure *r; From git at git.haskell.org Tue Mar 29 09:14:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 09:14:27 +0000 (UTC) Subject: [commit: ghc] wip/T10613's head updated: Temporarily move regular entry counting to the COUNTING_IND (00349e7) Message-ID: <20160329091427.CD9603A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T10613' now includes: 7e74079 Comment fix 7d5ff3d Move applyTysX near piResultTys db9e4eb Move DFunUnfolding generation to TcInstDcls e57b9ff Fix regression test for #11145. 2ddfb75 base: Fix ClockGetTime on OS X da3b29b Ensure T9646 dump-simpl output is cleaned 8048d51 ErrUtils: Add timings to compiler phases 997312b Add `PatSynSigSkol` and modify `PatSynCtxt` 2708c22 Close ticky profiling file stream after printing (#9405) 03a1bb4 Add unicode syntax for banana brackets 6c2c853 Various ticky-related work 9f9345e Create empty dump files (fixes #10320) 0db0594 DsExpr: Rip out static/dynamic check in list desugaring 8335cc7 Add expected output for T9405 ef653f1 Revert "Various ticky-related work" 1448f8a Show: Restore redundant parentheses around records 371608f Default RuntimeRep variables unless -fprint-explicit-runtime-reps 0bd0c31 Defer inlining of Eq for primitive types 2b5929c Comments only cb08f8d Tidy up handling of coercion variables 343349d Avoid local label syntax for assembler on AIX 2cebbe6 users_guide: Fix various issues 8ff6518 users-guide: Add -Wredundant-constraints to flags reference 173a5d8 users_guide: small improvements on pattern synonyms. 2414952 Add option `no-keep-hi-files` and `no-keep-o-files` (fixes #4114) df26b95 Add NCG support for AIX/ppc32 4dc8835 Remove code-duplication in the PPC NCG 26f86f3 base: Fix GHC.Word and GHC.Int on 32-bit platforms 84dd9d0 An extra traceTc in tcExpr for ExprWithSig 356e5e0 Do not eta-reduce across Ticks in CorePrep 12372ba CorePrep: refactoring to reduce duplication 067335a A raft of comments about TyBinders b416630f Test Trac #11728 da4bc0c Document implicit quantification better 454585c More clarification in docs for implicit quantification 4e98b4f DynFlags: Initialize unsafeGlobalDynFlags enough to be useful e8d3567 Panic: Try outputting SDocs d0787a2 testsuite: Identify framework failures in testsuite summary 1b4d120 DWARF: Add debugging information chapter to users guide 882179d RTS: Fix & refactor "portable inline" macros 4da8e73 Fix #11754 by adding an additional check. 12a76be Check for rep poly on wildcard binders. 9f73e46 Clarify Note [Kind coercions in Unify] 06cd26b Remove now obsolete LD_STAGE0 hack c7b32ad Remove now pointless INLINE_ME macro 61df7f8 Fix AIX/ppc codegen in `-prof` compilation mode 0bca3f3 Scrap IRIX support f911358 Scrap DEC OSF/1 support ffc802e Drop Xcode 4.1 hack and fix ignored CC var issue afc48f8 Autoconf: detect and set CFLAGS/CPPFLAGS needed for C99 mode 49b9d80 Do not test for existence of the executable eb25381 Update bytestring submodule to latest snapshot cd3fbff Remove obsolete --with-hc flag from ./configure 8a28f2d Remove all mentions of IND_OLDGEN outside of docs/rts 6c6ad1a Be more explicit about thunk types in ticky-ticky-report 2c54f57 Ticky: Do not count every entry twice 1819e78 Typo in Note name 450bb1b SpecConstr: Transport strictness annotation to specialization?s argument?s binders e8ddc6b Rename isNopSig to isTopSig 48c9183 Do not print DmdType in Core output b6067cd Rough working implementation of #10613 877ef6a Ticky report: Mark single entry functions as such 5f237b7 State hack hack in ticky report fa3c511 Evac: Do not evaluate selector thunks pointing to counting indirections 00349e7 Temporarily move regular entry counting to the COUNTING_IND From git at git.haskell.org Tue Mar 29 10:35:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:35:30 +0000 (UTC) Subject: [commit: ghc] master: base: Document caveats about Control.Concurrent.Chan (0f0c138) Message-ID: <20160329103530.19B0C3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/0f0c1387882be6a19af2cf3e6a005d70a3e84ae7/ghc >--------------------------------------------------------------- commit 0f0c1387882be6a19af2cf3e6a005d70a3e84ae7 Author: Erik de Castro Lopo Date: Mon Mar 28 14:52:35 2016 +0200 base: Document caveats about Control.Concurrent.Chan These are implemented using `MVars` which have known caveats. Suggest the use of `TChan` from the stm library instead. Test Plan: n/a Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2047 >--------------------------------------------------------------- 0f0c1387882be6a19af2cf3e6a005d70a3e84ae7 libraries/base/Control/Concurrent/Chan.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/base/Control/Concurrent/Chan.hs b/libraries/base/Control/Concurrent/Chan.hs index f5785f5..ed8e02b 100644 --- a/libraries/base/Control/Concurrent/Chan.hs +++ b/libraries/base/Control/Concurrent/Chan.hs @@ -14,6 +14,11 @@ -- -- Unbounded channels. -- +-- The channels are implemented with @MVar at s and therefore inherit all the +-- caveats that apply to @MVar at s (possibility of races, deadlocks etc). The +-- stm (software transactional memory) library has a more robust implementation +-- of channels called @TChan at s. +-- ----------------------------------------------------------------------------- module Control.Concurrent.Chan From git at git.haskell.org Tue Mar 29 10:35:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:35:32 +0000 (UTC) Subject: [commit: ghc] master: Reenable external-json linters (a658ad9) Message-ID: <20160329103532.B5BA23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/a658ad9f5b9849296ac25225174dac6a700a235e/ghc >--------------------------------------------------------------- commit a658ad9f5b9849296ac25225174dac6a700a235e Author: Ben Gamari Date: Mon Mar 28 14:51:24 2016 +0200 Reenable external-json linters This is to be merged once a fix for the Harbormaster build script has been applied. This reverts commit a14296c2660521db8ba965065687e45cee4e3401. These were previously disabled due to Harbormaster validation failures. Also, apply CPP check to .c and .h files in addition to Haskell sources. Test Plan: Let Harbormaster validate Reviewers: austin Reviewed By: austin Subscribers: hvr, thomie Differential Revision: https://phabricator.haskell.org/D1580 >--------------------------------------------------------------- a658ad9f5b9849296ac25225174dac6a700a235e .arcconfig | 6 +++++- .arclint | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.arcconfig b/.arcconfig index b9c3932..c886789 100644 --- a/.arcconfig +++ b/.arcconfig @@ -1,5 +1,9 @@ { "project.name" : "ghc", "repository.callsign" : "GHC", - "phabricator.uri" : "https://phabricator.haskell.org" + "phabricator.uri" : "https://phabricator.haskell.org", + + "load": [ + ".arc-linters/arcanist-external-json-linter" + ] } diff --git a/.arclint b/.arclint index 8f83776..69644ea 100644 --- a/.arclint +++ b/.arclint @@ -52,6 +52,15 @@ "severity": { "2": "disabled" } + }, + "check-binaries": { + "type": "external-json", + "external-json.script": "python .arc-linters/check-binaries.py" + }, + "bad-assert-clang-cpp": { + "type": "external-json", + "include": ["(\\.(l?hs|x|y\\.pp)(\\.in)?$)", "(\\.(c|h)$)"], + "external-json.script": "python .arc-linters/check-cpp.py" } }, From git at git.haskell.org Tue Mar 29 10:35:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:35:35 +0000 (UTC) Subject: [commit: ghc] master: users-guide: Wibbles (eb8bc4d) Message-ID: <20160329103535.647983A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/eb8bc4dadb767729ae267db7ec7d3bee29f48463/ghc >--------------------------------------------------------------- commit eb8bc4dadb767729ae267db7ec7d3bee29f48463 Author: Ben Gamari Date: Mon Mar 28 15:40:34 2016 +0200 users-guide: Wibbles >--------------------------------------------------------------- eb8bc4dadb767729ae267db7ec7d3bee29f48463 docs/users_guide/glasgow_exts.rst | 40 +++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 0735cfc..b828ef6 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -656,6 +656,8 @@ n+k patterns .. ghc-flag:: -XNPlusKPatterns + :since: 6.12 + Enable use of ``n+k`` patterns. .. _recursive-do-notation: @@ -1195,6 +1197,12 @@ Monad comprehensions .. index:: single: monad comprehensions +.. ghc-flag:: -XMonadComprehensions + + :since: 7.2 + + Enable list comprehension syntax for arbitrary monads. + Monad comprehensions generalise the list comprehension notation, including parallel comprehensions (:ref:`parallel-list-comprehensions`) and transform comprehensions (:ref:`generalised-list-comprehensions`) to @@ -1262,7 +1270,7 @@ Monad comprehensions support: return y) return (x+y) -All these features are enabled by default if the ``MonadComprehensions`` +All these features are enabled by default if the :ghc-flag:`-XMonadComprehensions` extension is enabled. The types and more detailed examples on how to use comprehensions are explained in the previous chapters :ref:`generalised-list-comprehensions` and @@ -1273,14 +1281,14 @@ comprehensions. .. note:: Even though most of these examples are using the list monad, monad comprehensions work for any monad. The ``base`` package offers all - necessary instances for lists, which make ``MonadComprehensions`` + necessary instances for lists, which make :ghc-flag:`-XMonadComprehensions` backward compatible to built-in, transform and parallel list comprehensions. More formally, the desugaring is as follows. We write ``D[ e | Q]`` to mean the desugaring of the monad comprehension ``[ e | Q]``: -:: +.. code-block:: none Expressions: e Declarations: d @@ -1483,6 +1491,8 @@ Tuple sections .. ghc-flag:: -XTupleSections + :since: 6.12 + Allow the use of tuple section syntax The :ghc-flag:`-XTupleSections` flag enables Python-style partially applied @@ -1746,6 +1756,8 @@ Safe imports -XUnsafe :noindex: + :since: 7.2 + Declare the Safe Haskell state of the current module. With the :ghc-flag:`-XSafe`, :ghc-flag:`-XTrustworthy` and :ghc-flag:`-XUnsafe` @@ -2380,6 +2392,8 @@ Declaring data types with explicit constructor signatures .. ghc-flag:: -XGADTSyntax + :since: 7.2 + Allow the use of GADT syntax in data type definitions (but not GADTs themselves; for this see :ghc-flag:`-XGADTs`) @@ -3268,18 +3282,26 @@ Deriving instances of extra classes (``Data``, etc.) .. ghc-flag:: -XDeriveGeneric + :since: 7.2 + Allow automatic deriving of instances for the ``Generic`` typeclass. .. ghc-flag:: -XDeriveFunctor + :since: 6.12 + Allow automatic deriving of instances for the ``Functor`` typeclass. .. ghc-flag:: -XDeriveFoldable + :since: 6.12 + Allow automatic deriving of instances for the ``Foldable`` typeclass. .. ghc-flag:: -XDeriveTraversable + :since: 6.12 + :implies: :ghc-flag:`-XDeriveFoldable`, :ghc-flag:`-XDeriveFunctor` Allow automatic deriving of instances for the ``Traversable`` typeclass. @@ -4554,6 +4576,8 @@ Default method signatures .. ghc-flag:: -XDefaultSignatures + :since: 7.2 + Allows the definition of default method signatures in class definitions. Haskell 98 allows you to define a default implementation when declaring @@ -7109,7 +7133,7 @@ See also :ghc-ticket:`7347`. Kind polymorphism and Type-in-Type ================================== -.. ghc-flag: -XTypeInType +.. ghc-flag:: -XTypeInType :implies: :ghc-flag:`-XPolyKinds`, :ghc-flag:`-XDataKinds`, :ghc-flag:`-XKindSignatures` :since: 8.0.1 @@ -8048,6 +8072,8 @@ Explicit universal quantification (forall) .. ghc-flag:: -XExplicitForAll + :since: 6.12 + Allow use of the ``forall`` keyword in places where universal quantification is implicit. @@ -8587,6 +8613,8 @@ Let-generalisation .. ghc-flag:: -XMonoLocalBinds + :since: 6.12 + Infer less polymorphic types for local bindings by default. An ML-style language usually generalises the type of any ``let``\-bound or @@ -8938,7 +8966,6 @@ Arbitrary-rank polymorphism .. ghc-flag:: -XRankNTypes - :implies: :ghc-flag:`-XExplicitForAll` Allow types of arbitrary rank. @@ -9874,12 +9901,13 @@ Syntax .. ghc-flag:: -XTemplateHaskell :implies: :ghc-flag:`-XTemplateHaskellQuotes` - :since: 8.0.1 Enable Template Haskell's splice and quotation syntax. .. ghc-flag:: -XTemplateHaskellQuotes + :since: 8.0.1 + Enable only Template Haskell's quotation syntax. Template Haskell has the following new syntactic constructions. You need to use From git at git.haskell.org Tue Mar 29 10:35:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:35:38 +0000 (UTC) Subject: [commit: ghc] master: users-guide: Add references to various issues in bugs section (aa61174) Message-ID: <20160329103538.144B93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/aa611746aa860e1884c9ad623d6939791f2645ff/ghc >--------------------------------------------------------------- commit aa611746aa860e1884c9ad623d6939791f2645ff Author: Ben Gamari Date: Tue Mar 29 10:58:04 2016 +0200 users-guide: Add references to various issues in bugs section Test Plan: Read it Reviewers: austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2052 GHC Trac Issues: #7411, #11197, #11554, #11715 >--------------------------------------------------------------- aa611746aa860e1884c9ad623d6939791f2645ff docs/users_guide/bugs.rst | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/users_guide/bugs.rst b/docs/users_guide/bugs.rst index ff43009..c4ac9ce 100644 --- a/docs/users_guide/bugs.rst +++ b/docs/users_guide/bugs.rst @@ -449,6 +449,43 @@ Bugs in GHC libraries that come with GHC are probably built without this option, unless you built GHC yourself. +- The :ghc-flag:`state hack <-fstate-hack>` optimization can result in + non-obvious changes in evaluation ordering which may hide exceptions, even + with :ghc-flag:`-fpedantic-bottoms` (see, e.g., :ghc-ticket:`7411`). For + instance, :: + + import Control.Exception + import Control.DeepSeq + main = do + evaluate (('a' : undefined) `deepseq` return () :: IO ()) + putStrLn "Hello" + + Compiling this program with ``-O`` results in ``Hello`` to be printed, + despite the fact that ``evaluate`` should have bottomed. Compiling + with ``-O -fno-state-hack`` results in the exception one would expect. + +- Programs compiled with :ghc-flag:`-fdefer-type-errors` may fail a bit + more eagerly than one might expect. For instance, :: + + {-# OPTIONS_GHC -fdefer-type-errors #-} + main = do + putStrLn "Hi there." + putStrLn True + + Will emit no output, despite the fact that the ill-typed term appears + after the well-typed ``putStrLn "Hi there."``. See :ghc-ticket:`11197`. + +- Despite appearances ``*`` and ``Constraint`` aren't really distinct kinds + in the compiler's internal representation and can be unified producing + unexpected results. See :ghc-ticket:`11715` for one example. + +- :ghc-flag:`-XTypeInType` still has a few rough edges, especially where + it interacts with other advanced type-system features. For instance, + this definition causes the typechecker to loop (:ghc-ticket:`11559`), :: + + data A :: Type where + B :: forall (a :: A). A + - There is known to be maleficent interactions between weak references and laziness. Particularly, it has been observed that placing a thunk containing a reference to a weak reference inside of another weak reference may cause From git at git.haskell.org Tue Mar 29 10:35:40 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:35:40 +0000 (UTC) Subject: [commit: ghc] master: users-guide: Provide more depth in table-of-contents (415b706) Message-ID: <20160329103540.BD3CA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/415b706ceb6fa3be55e7c96d8bafb0e98ce184b1/ghc >--------------------------------------------------------------- commit 415b706ceb6fa3be55e7c96d8bafb0e98ce184b1 Author: Ben Gamari Date: Mon Mar 28 14:57:56 2016 +0200 users-guide: Provide more depth in table-of-contents Per Simon's request. >--------------------------------------------------------------- 415b706ceb6fa3be55e7c96d8bafb0e98ce184b1 docs/users_guide/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/users_guide/index.rst b/docs/users_guide/index.rst index fe346bf..60f8c9a 100644 --- a/docs/users_guide/index.rst +++ b/docs/users_guide/index.rst @@ -7,7 +7,7 @@ Welcome to the GHC Users Guide Contents: .. toctree:: - :maxdepth: 3 + :maxdepth: 4 :numbered: license From git at git.haskell.org Tue Mar 29 10:38:14 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:38:14 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: base: Document caveats about Control.Concurrent.Chan (50a2b6a) Message-ID: <20160329103814.64E323A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/50a2b6af30f86a96384f608b145eb453ba45bcb4/ghc >--------------------------------------------------------------- commit 50a2b6af30f86a96384f608b145eb453ba45bcb4 Author: Erik de Castro Lopo Date: Mon Mar 28 14:52:35 2016 +0200 base: Document caveats about Control.Concurrent.Chan These are implemented using `MVars` which have known caveats. Suggest the use of `TChan` from the stm library instead. Test Plan: n/a Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2047 (cherry picked from commit 0f0c1387882be6a19af2cf3e6a005d70a3e84ae7) >--------------------------------------------------------------- 50a2b6af30f86a96384f608b145eb453ba45bcb4 libraries/base/Control/Concurrent/Chan.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/base/Control/Concurrent/Chan.hs b/libraries/base/Control/Concurrent/Chan.hs index f5785f5..ed8e02b 100644 --- a/libraries/base/Control/Concurrent/Chan.hs +++ b/libraries/base/Control/Concurrent/Chan.hs @@ -14,6 +14,11 @@ -- -- Unbounded channels. -- +-- The channels are implemented with @MVar at s and therefore inherit all the +-- caveats that apply to @MVar at s (possibility of races, deadlocks etc). The +-- stm (software transactional memory) library has a more robust implementation +-- of channels called @TChan at s. +-- ----------------------------------------------------------------------------- module Control.Concurrent.Chan From git at git.haskell.org Tue Mar 29 10:38:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:38:17 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users-guide: Provide more depth in table-of-contents (6e33081) Message-ID: <20160329103817.1B0663A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6e33081a71718d59caec7610661be94905fa15b8/ghc >--------------------------------------------------------------- commit 6e33081a71718d59caec7610661be94905fa15b8 Author: Ben Gamari Date: Mon Mar 28 14:57:56 2016 +0200 users-guide: Provide more depth in table-of-contents Per Simon's request. (cherry picked from commit 415b706ceb6fa3be55e7c96d8bafb0e98ce184b1) >--------------------------------------------------------------- 6e33081a71718d59caec7610661be94905fa15b8 docs/users_guide/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/users_guide/index.rst b/docs/users_guide/index.rst index fe346bf..60f8c9a 100644 --- a/docs/users_guide/index.rst +++ b/docs/users_guide/index.rst @@ -7,7 +7,7 @@ Welcome to the GHC Users Guide Contents: .. toctree:: - :maxdepth: 3 + :maxdepth: 4 :numbered: license From git at git.haskell.org Tue Mar 29 10:38:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:38:19 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users-guide: Wibbles (74cf491) Message-ID: <20160329103819.CB5BA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/74cf4919c715d0aaadb3f1c2b64420d53ea652ab/ghc >--------------------------------------------------------------- commit 74cf4919c715d0aaadb3f1c2b64420d53ea652ab Author: Ben Gamari Date: Mon Mar 28 15:40:34 2016 +0200 users-guide: Wibbles (cherry picked from commit eb8bc4dadb767729ae267db7ec7d3bee29f48463) >--------------------------------------------------------------- 74cf4919c715d0aaadb3f1c2b64420d53ea652ab docs/users_guide/glasgow_exts.rst | 40 +++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 430431f..f74cc88 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -652,6 +652,8 @@ n+k patterns .. ghc-flag:: -XNPlusKPatterns + :since: 6.12 + Enable use of ``n+k`` patterns. .. _recursive-do-notation: @@ -1174,6 +1176,12 @@ Monad comprehensions .. index:: single: monad comprehensions +.. ghc-flag:: -XMonadComprehensions + + :since: 7.2 + + Enable list comprehension syntax for arbitrary monads. + Monad comprehensions generalise the list comprehension notation, including parallel comprehensions (:ref:`parallel-list-comprehensions`) and transform comprehensions (:ref:`generalised-list-comprehensions`) to @@ -1241,7 +1249,7 @@ Monad comprehensions support: return y) return (x+y) -All these features are enabled by default if the ``MonadComprehensions`` +All these features are enabled by default if the :ghc-flag:`-XMonadComprehensions` extension is enabled. The types and more detailed examples on how to use comprehensions are explained in the previous chapters :ref:`generalised-list-comprehensions` and @@ -1252,14 +1260,14 @@ comprehensions. .. note:: Even though most of these examples are using the list monad, monad comprehensions work for any monad. The ``base`` package offers all - necessary instances for lists, which make ``MonadComprehensions`` + necessary instances for lists, which make :ghc-flag:`-XMonadComprehensions` backward compatible to built-in, transform and parallel list comprehensions. More formally, the desugaring is as follows. We write ``D[ e | Q]`` to mean the desugaring of the monad comprehension ``[ e | Q]``: -:: +.. code-block:: none Expressions: e Declarations: d @@ -1462,6 +1470,8 @@ Tuple sections .. ghc-flag:: -XTupleSections + :since: 6.12 + Allow the use of tuple section syntax The :ghc-flag:`-XTupleSections` flag enables Python-style partially applied @@ -1725,6 +1735,8 @@ Safe imports -XUnsafe :noindex: + :since: 7.2 + Declare the Safe Haskell state of the current module. With the :ghc-flag:`-XSafe`, :ghc-flag:`-XTrustworthy` and :ghc-flag:`-XUnsafe` @@ -2359,6 +2371,8 @@ Declaring data types with explicit constructor signatures .. ghc-flag:: -XGADTSyntax + :since: 7.2 + Allow the use of GADT syntax in data type definitions (but not GADTs themselves; for this see :ghc-flag:`-XGADTs`) @@ -3247,18 +3261,26 @@ Deriving instances of extra classes (``Data``, etc.) .. ghc-flag:: -XDeriveGeneric + :since: 7.2 + Allow automatic deriving of instances for the ``Generic`` typeclass. .. ghc-flag:: -XDeriveFunctor + :since: 6.12 + Allow automatic deriving of instances for the ``Functor`` typeclass. .. ghc-flag:: -XDeriveFoldable + :since: 6.12 + Allow automatic deriving of instances for the ``Foldable`` typeclass. .. ghc-flag:: -XDeriveTraversable + :since: 6.12 + :implies: :ghc-flag:`-XDeriveFoldable`, :ghc-flag:`-XDeriveFunctor` Allow automatic deriving of instances for the ``Traversable`` typeclass. @@ -4533,6 +4555,8 @@ Default method signatures .. ghc-flag:: -XDefaultSignatures + :since: 7.2 + Allows the definition of default method signatures in class definitions. Haskell 98 allows you to define a default implementation when declaring @@ -7088,7 +7112,7 @@ See also :ghc-ticket:`7347`. Kind polymorphism and Type-in-Type ================================== -.. ghc-flag: -XTypeInType +.. ghc-flag:: -XTypeInType :implies: :ghc-flag:`-XPolyKinds`, :ghc-flag:`-XDataKinds`, :ghc-flag:`-XKindSignatures` :since: 8.0.1 @@ -8027,6 +8051,8 @@ Explicit universal quantification (forall) .. ghc-flag:: -XExplicitForAll + :since: 6.12 + Allow use of the ``forall`` keyword in places where universal quantification is implicit. @@ -8566,6 +8592,8 @@ Let-generalisation .. ghc-flag:: -XMonoLocalBinds + :since: 6.12 + Infer less polymorphic types for local bindings by default. An ML-style language usually generalises the type of any ``let``\-bound or @@ -8917,7 +8945,6 @@ Arbitrary-rank polymorphism .. ghc-flag:: -XRankNTypes - :implies: :ghc-flag:`-XExplicitForAll` Allow types of arbitrary rank. @@ -9853,12 +9880,13 @@ Syntax .. ghc-flag:: -XTemplateHaskell :implies: :ghc-flag:`-XTemplateHaskellQuotes` - :since: 8.0.1 Enable Template Haskell's splice and quotation syntax. .. ghc-flag:: -XTemplateHaskellQuotes + :since: 8.0.1 + Enable only Template Haskell's quotation syntax. Template Haskell has the following new syntactic constructions. You need to use From git at git.haskell.org Tue Mar 29 10:38:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 10:38:22 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users-guide: Add references to various issues in bugs section (86d40d9) Message-ID: <20160329103822.833FB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/86d40d9fa6cb7d216aac1bf68e7371f0bb2a4d3f/ghc >--------------------------------------------------------------- commit 86d40d9fa6cb7d216aac1bf68e7371f0bb2a4d3f Author: Ben Gamari Date: Tue Mar 29 10:58:04 2016 +0200 users-guide: Add references to various issues in bugs section Test Plan: Read it Reviewers: austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2052 GHC Trac Issues: #7411, #11197, #11554, #11715 (cherry picked from commit aa611746aa860e1884c9ad623d6939791f2645ff) >--------------------------------------------------------------- 86d40d9fa6cb7d216aac1bf68e7371f0bb2a4d3f docs/users_guide/bugs.rst | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/users_guide/bugs.rst b/docs/users_guide/bugs.rst index ff43009..c4ac9ce 100644 --- a/docs/users_guide/bugs.rst +++ b/docs/users_guide/bugs.rst @@ -449,6 +449,43 @@ Bugs in GHC libraries that come with GHC are probably built without this option, unless you built GHC yourself. +- The :ghc-flag:`state hack <-fstate-hack>` optimization can result in + non-obvious changes in evaluation ordering which may hide exceptions, even + with :ghc-flag:`-fpedantic-bottoms` (see, e.g., :ghc-ticket:`7411`). For + instance, :: + + import Control.Exception + import Control.DeepSeq + main = do + evaluate (('a' : undefined) `deepseq` return () :: IO ()) + putStrLn "Hello" + + Compiling this program with ``-O`` results in ``Hello`` to be printed, + despite the fact that ``evaluate`` should have bottomed. Compiling + with ``-O -fno-state-hack`` results in the exception one would expect. + +- Programs compiled with :ghc-flag:`-fdefer-type-errors` may fail a bit + more eagerly than one might expect. For instance, :: + + {-# OPTIONS_GHC -fdefer-type-errors #-} + main = do + putStrLn "Hi there." + putStrLn True + + Will emit no output, despite the fact that the ill-typed term appears + after the well-typed ``putStrLn "Hi there."``. See :ghc-ticket:`11197`. + +- Despite appearances ``*`` and ``Constraint`` aren't really distinct kinds + in the compiler's internal representation and can be unified producing + unexpected results. See :ghc-ticket:`11715` for one example. + +- :ghc-flag:`-XTypeInType` still has a few rough edges, especially where + it interacts with other advanced type-system features. For instance, + this definition causes the typechecker to loop (:ghc-ticket:`11559`), :: + + data A :: Type where + B :: forall (a :: A). A + - There is known to be maleficent interactions between weak references and laziness. Particularly, it has been observed that placing a thunk containing a reference to a weak reference inside of another weak reference may cause From git at git.haskell.org Tue Mar 29 11:31:39 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 11:31:39 +0000 (UTC) Subject: [commit: ghc] master: Use a correct substitution in tcInstType (7393532) Message-ID: <20160329113139.60EBB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/73935326e0cf85ed077b9ab7dd8f197d39e2cd5b/ghc >--------------------------------------------------------------- commit 73935326e0cf85ed077b9ab7dd8f197d39e2cd5b Author: Bartosz Nitka Date: Tue Mar 29 12:41:59 2016 +0200 Use a correct substitution in tcInstType `ty` doesn't have to be a closed type, so we need to add its free vars to the in-scope set. They don't seem to be available anywhere nearby, so we have to compute them. Test Plan: ./validate Reviewers: goldfire, austin, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2042 GHC Trac Issues: #11371 >--------------------------------------------------------------- 73935326e0cf85ed077b9ab7dd8f197d39e2cd5b compiler/typecheck/TcMType.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index 628c9e3..cb9ed72 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -439,7 +439,7 @@ tcInstType inst_tyvars ty return ([], theta, tau) (tyvars, rho) -> do { (subst, tyvars') <- inst_tyvars tyvars - ; let (theta, tau) = tcSplitPhiTy (substTyUnchecked subst rho) + ; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho) ; return (tyvars', theta, tau) } tcSkolDFunType :: Type -> TcM ([TcTyVar], TcThetaType, TcType) From git at git.haskell.org Tue Mar 29 11:31:42 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 11:31:42 +0000 (UTC) Subject: [commit: ghc] master: Build correct substitution in instDFunType (a49228e) Message-ID: <20160329113142.076F43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/a49228e3b6e3737da750bce59ec721b3b2f18eed/ghc >--------------------------------------------------------------- commit a49228e3b6e3737da750bce59ec721b3b2f18eed Author: Bartosz Nitka Date: Tue Mar 29 12:42:16 2016 +0200 Build correct substitution in instDFunType We will use `ty` in the range of the substitution, hence the substitution needs `ty`'s free vars in-scope. They don't seem easily available by other means, so we just compute them. Test Plan: ./validate Reviewers: austin, goldfire, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2043 GHC Trac Issues: #11371 >--------------------------------------------------------------- a49228e3b6e3737da750bce59ec721b3b2f18eed compiler/typecheck/Inst.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/Inst.hs b/compiler/typecheck/Inst.hs index ab9a4e2..49f57a5 100644 --- a/compiler/typecheck/Inst.hs +++ b/compiler/typecheck/Inst.hs @@ -306,14 +306,16 @@ instDFunType :: DFunId -> [DFunInstType] -- See Note [DFunInstType: instantiating types] in InstEnv instDFunType dfun_id dfun_inst_tys = do { (subst, inst_tys) <- go emptyTCvSubst dfun_tvs dfun_inst_tys - ; return (inst_tys, substThetaUnchecked subst dfun_theta) } + ; return (inst_tys, substTheta subst dfun_theta) } where (dfun_tvs, dfun_theta, _) = tcSplitSigmaTy (idType dfun_id) go :: TCvSubst -> [TyVar] -> [DFunInstType] -> TcM (TCvSubst, [TcType]) go subst [] [] = return (subst, []) go subst (tv:tvs) (Just ty : mb_tys) - = do { (subst', tys) <- go (extendTvSubst subst tv ty) tvs mb_tys + = do { (subst', tys) <- go (extendTvSubstAndInScope subst tv ty) + tvs + mb_tys ; return (subst', ty : tys) } go subst (tv:tvs) (Nothing : mb_tys) = do { (subst', tv') <- newMetaTyVarX subst tv From git at git.haskell.org Tue Mar 29 11:31:44 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 11:31:44 +0000 (UTC) Subject: [commit: ghc] master: Use the correct substitution in lintCoercion (4a93e4f) Message-ID: <20160329113144.B99893A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/4a93e4f9a86a62d1cdf2e666f977b8b58e61eaaf/ghc >--------------------------------------------------------------- commit 4a93e4f9a86a62d1cdf2e666f977b8b58e61eaaf Author: Bartosz Nitka Date: Tue Mar 29 12:42:32 2016 +0200 Use the correct substitution in lintCoercion We need the free vars of `t2` to satisfy the substitution invariant. Luckily they are in the in-scope carried around. Test Plan: ./validate Reviewers: bgamari, austin, goldfire, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2044 GHC Trac Issues: #11371 >--------------------------------------------------------------- 4a93e4f9a86a62d1cdf2e666f977b8b58e61eaaf compiler/coreSyn/CoreLint.hs | 7 ++++++- compiler/types/TyCoRep.hs | 5 +++++ compiler/types/Type.hs | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index ef44aff..bd750a3 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -1291,9 +1291,14 @@ lintCoercion (ForAllCo tv1 kind_co co) = do { (_, k2) <- lintStarCoercion kind_co ; let tv2 = setTyVarKind tv1 k2 ; (k3, k4, t1, t2, r) <- addInScopeVar tv1 $ lintCoercion co + ; in_scope <- getInScope ; let tyl = mkNamedForAllTy tv1 Invisible t1 + subst = zipTvSubst [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo kind_co] + `extendTCvInScopeInScope` in_scope + -- We need free vars of `t2` in scope to satisfy + -- Note [The substitution invariant] tyr = mkNamedForAllTy tv2 Invisible $ - substTyWithUnchecked [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo kind_co] t2 + substTy subst t2 ; return (k3, k4, tyl, tyr, r) } lintCoercion (CoVarCo cv) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index 6cbdfda..46214e8 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -83,6 +83,7 @@ module TyCoRep ( getCvSubstEnv, getTCvInScope, isInScope, notElemTCvSubst, setTvSubstEnv, setCvSubstEnv, zapTCvSubst, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, + extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendCvSubstWithClone, extendTvSubst, extendTvSubstWithClone, @@ -1798,6 +1799,10 @@ extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst extendTCvInScopeSet (TCvSubst in_scope tenv cenv) vars = TCvSubst (extendInScopeSetSet in_scope vars) tenv cenv +extendTCvInScopeInScope :: TCvSubst -> InScopeSet -> TCvSubst +extendTCvInScopeInScope (TCvSubst in_scope tenv cenv) in_scope' + = TCvSubst (unionInScope in_scope in_scope') tenv cenv + extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst extendTCvSubst subst v ty | isTyVar v diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index c5561a3..a940200 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -158,6 +158,7 @@ module Type ( getTvSubstEnv, setTvSubstEnv, zapTCvSubst, getTCvInScope, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, + extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendTvSubst, extendTvSubstList, extendTvSubstAndInScope, isInScope, composeTCvSubstEnv, composeTCvSubst, zipTyEnv, zipCoEnv, From git at git.haskell.org Tue Mar 29 11:31:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 11:31:47 +0000 (UTC) Subject: [commit: ghc] master: Add Data.Functor.Classes instances for Proxy (trac issue #11756) (5097f38) Message-ID: <20160329113147.684AB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/5097f3802124cfbe6810bff8110df91d4c52096b/ghc >--------------------------------------------------------------- commit 5097f3802124cfbe6810bff8110df91d4c52096b Author: Andrew Martin Date: Tue Mar 29 10:57:47 2016 +0200 Add Data.Functor.Classes instances for Proxy (trac issue #11756) Test Plan: currently no test plan Reviewers: hvr, RyanGlScott, bgamari, austin Reviewed By: RyanGlScott, bgamari, austin Subscribers: thomie, RyanGlScott, andrewthad Differential Revision: https://phabricator.haskell.org/D2051 GHC Trac Issues: #11756 >--------------------------------------------------------------- 5097f3802124cfbe6810bff8110df91d4c52096b libraries/base/Data/Functor/Classes.hs | 18 ++++++++++++++++++ libraries/base/changelog.md | 3 +++ 2 files changed, 21 insertions(+) diff --git a/libraries/base/Data/Functor/Classes.hs b/libraries/base/Data/Functor/Classes.hs index 0ec6008..5f1b12c 100644 --- a/libraries/base/Data/Functor/Classes.hs +++ b/libraries/base/Data/Functor/Classes.hs @@ -62,6 +62,7 @@ module Data.Functor.Classes ( import Control.Applicative (Const(Const)) import Data.Functor.Identity (Identity(Identity)) +import Data.Proxy (Proxy(Proxy)) import Data.Monoid (mappend) import Text.Show (showListWith) @@ -354,6 +355,23 @@ instance (Read a) => Read1 (Const a) where instance (Show a) => Show1 (Const a) where liftShowsPrec = liftShowsPrec2 showsPrec showList +-- | @since 4.9.0.0 +instance Eq1 Proxy where + liftEq _ _ _ = True + +-- | @since 4.9.0.0 +instance Ord1 Proxy where + liftCompare _ _ _ = EQ + +-- | @since 4.9.0.0 +instance Show1 Proxy where + liftShowsPrec _ _ _ _ = showString "Proxy" + +-- | @since 4.9.0.0 +instance Read1 Proxy where + liftReadsPrec _ _ d = + readParen (d > 10) (\r -> [(Proxy, s) | ("Proxy",s) <- lex r ]) + -- Building blocks -- | @'readsData' p d@ is a parser for datatypes where each alternative diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 92451b9..cb3eced 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -78,6 +78,9 @@ `Data.Functor.Product`, and `Data.Functor.Sum` (previously provided by `transformers` package). (#11135) + * New instances for `Proxy`: `Eq1`, `Ord1`, `Show1`, `Read1`. All + of the classes are from `Data.Functor.Classes` (#11756). + * New module `Control.Monad.Fail` providing new `MonadFail(fail)` class (#10751) From git at git.haskell.org Tue Mar 29 11:32:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 11:32:50 +0000 (UTC) Subject: [commit: ghc] master: base: Add comment noting import loop (b0ab8db) Message-ID: <20160329113250.40B013A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/b0ab8db61568305f50947058fc5573e2382c84eb/ghc >--------------------------------------------------------------- commit b0ab8db61568305f50947058fc5573e2382c84eb Author: Ben Gamari Date: Tue Mar 29 13:34:45 2016 +0200 base: Add comment noting import loop >--------------------------------------------------------------- b0ab8db61568305f50947058fc5573e2382c84eb libraries/base/Data/Functor/Classes.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/base/Data/Functor/Classes.hs b/libraries/base/Data/Functor/Classes.hs index 5f1b12c..ce84af0 100644 --- a/libraries/base/Data/Functor/Classes.hs +++ b/libraries/base/Data/Functor/Classes.hs @@ -355,6 +355,8 @@ instance (Read a) => Read1 (Const a) where instance (Show a) => Show1 (Const a) where liftShowsPrec = liftShowsPrec2 showsPrec showList +-- Proxy unfortunately imports this module, hence these instances are placed +-- here, -- | @since 4.9.0.0 instance Eq1 Proxy where liftEq _ _ _ = True From git at git.haskell.org Tue Mar 29 12:04:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:04:54 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Be more explicit about closure types in ticky-ticky-report (c399939) Message-ID: <20160329120454.EDFE03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/c3999392419ec503b29c39bf609b2a767e2a6936/ghc >--------------------------------------------------------------- commit c3999392419ec503b29c39bf609b2a767e2a6936 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Be more explicit about closure types in ticky-ticky-report The report now distinguishes thunks (in the variants single-entry and standard thunks), constructors and functions (possibly single-entry). Forthermore, for standard thunks (AP and selector), do not count an entry when they are allocated. It is not possible to count their entries, as their code is shared, but better count nothing than count the wrong thing. >--------------------------------------------------------------- c3999392419ec503b29c39bf609b2a767e2a6936 compiler/codeGen/StgCmmBind.hs | 15 ++++++--- compiler/codeGen/StgCmmClosure.hs | 49 ++++++++++++++------------- compiler/codeGen/StgCmmTicky.hs | 69 +++++++++++++++++++++++++++++---------- 3 files changed, 88 insertions(+), 45 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc c3999392419ec503b29c39bf609b2a767e2a6936 From git at git.haskell.org Tue Mar 29 12:04:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:04:57 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rename isNopSig to isTopSig (79aaacf) Message-ID: <20160329120457.A177F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/79aaacf84b6395d2fc86ca53969c8485b7f30a7e/ghc >--------------------------------------------------------------- commit 79aaacf84b6395d2fc86ca53969c8485b7f30a7e Author: Joachim Breitner Date: Wed Mar 23 10:41:16 2016 +0100 Rename isNopSig to isTopSig to be consistent with the other uses of nop vs. top in Demand.hs. Also, stop prettyprinting top strictness signatures in Core dumps. >--------------------------------------------------------------- 79aaacf84b6395d2fc86ca53969c8485b7f30a7e compiler/basicTypes/Demand.hs | 12 ++++++------ compiler/coreSyn/CoreArity.hs | 2 +- compiler/coreSyn/PprCore.hs | 3 ++- compiler/iface/MkIface.hs | 2 +- compiler/main/TidyPgm.hs | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/compiler/basicTypes/Demand.hs b/compiler/basicTypes/Demand.hs index 96e02b2..3ce9228 100644 --- a/compiler/basicTypes/Demand.hs +++ b/compiler/basicTypes/Demand.hs @@ -37,7 +37,7 @@ module Demand ( appIsBottom, isBottomingSig, pprIfaceStrictSig, trimCPRInfo, returnsCPR_maybe, StrictSig(..), mkStrictSig, mkClosedStrictSig, nopSig, botSig, cprProdSig, - isNopSig, splitStrictSig, increaseStrictSigArity, + isTopSig, splitStrictSig, increaseStrictSigArity, seqDemand, seqDemandList, seqDmdType, seqStrictSig, @@ -1262,10 +1262,10 @@ cprProdDmdType :: Arity -> DmdType cprProdDmdType arity = DmdType emptyDmdEnv [] (vanillaCprProdRes arity) -isNopDmdType :: DmdType -> Bool -isNopDmdType (DmdType env [] res) +isTopDmdType :: DmdType -> Bool +isTopDmdType (DmdType env [] res) | isTopRes res && isEmptyVarEnv env = True -isNopDmdType _ = False +isTopDmdType _ = False mkDmdType :: DmdEnv -> [Demand] -> DmdResult -> DmdType mkDmdType fv ds res = DmdType fv ds res @@ -1669,8 +1669,8 @@ increaseStrictSigArity :: Int -> StrictSig -> StrictSig increaseStrictSigArity arity_increase (StrictSig (DmdType env dmds res)) = StrictSig (DmdType env (replicate arity_increase topDmd ++ dmds) res) -isNopSig :: StrictSig -> Bool -isNopSig (StrictSig ty) = isNopDmdType ty +isTopSig :: StrictSig -> Bool +isTopSig (StrictSig ty) = isTopDmdType ty isBottomingSig :: StrictSig -> Bool -- True if the signature diverges or throws an exception diff --git a/compiler/coreSyn/CoreArity.hs b/compiler/coreSyn/CoreArity.hs index 8086299..cf6cd98 100644 --- a/compiler/coreSyn/CoreArity.hs +++ b/compiler/coreSyn/CoreArity.hs @@ -711,7 +711,7 @@ arityType env (Cast e co) arityType _ (Var v) | strict_sig <- idStrictness v - , not $ isNopSig strict_sig + , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds = if isBotRes res then ABot arity diff --git a/compiler/coreSyn/PprCore.hs b/compiler/coreSyn/PprCore.hs index 9ce1dad..0c62e4f 100644 --- a/compiler/coreSyn/PprCore.hs +++ b/compiler/coreSyn/PprCore.hs @@ -400,7 +400,7 @@ ppIdInfo id info , (has_arity, text "Arity=" <> int arity) , (has_called_arity, text "CallArity=" <> int called_arity) , (has_caf_info, text "Caf=" <> ppr caf_info) - , (True, text "Str=" <> pprStrictness str_info) + , (has_str_info, text "Str=" <> pprStrictness str_info) , (has_unf, text "Unf=" <> ppr unf_info) , (not (null rules), text "RULES:" <+> vcat (map pprRule rules)) ] -- Inline pragma, occ, demand, one-shot info @@ -421,6 +421,7 @@ ppIdInfo id info has_caf_info = not (mayHaveCafRefs caf_info) str_info = strictnessInfo info + has_str_info = not (isTopSig str_info) unf_info = unfoldingInfo info has_unf = hasSomeUnfolding unf_info diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 196dd19..7f8397b 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -1684,7 +1684,7 @@ toIfaceIdInfo id_info ------------ Strictness -------------- -- No point in explicitly exporting TopSig sig_info = strictnessInfo id_info - strict_hsinfo | not (isNopSig sig_info) = Just (HsStrictness sig_info) + strict_hsinfo | not (isTopSig sig_info) = Just (HsStrictness sig_info) | otherwise = Nothing ------------ Unfolding -------------- diff --git a/compiler/main/TidyPgm.hs b/compiler/main/TidyPgm.hs index 3a3a916..e31b0ed 100644 --- a/compiler/main/TidyPgm.hs +++ b/compiler/main/TidyPgm.hs @@ -37,7 +37,7 @@ import IdInfo import InstEnv import FamInstEnv import Type ( tidyTopType ) -import Demand ( appIsBottom, isNopSig, isBottomingSig ) +import Demand ( appIsBottom, isTopSig, isBottomingSig ) import BasicTypes import Name hiding (varName) import NameSet @@ -1242,7 +1242,7 @@ tidyTopIdInfo dflags rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold caf_ mb_bot_str = exprBotStrictness_maybe orig_rhs sig = strictnessInfo idinfo - final_sig | not $ isNopSig sig + final_sig | not $ isTopSig sig = WARN( _bottom_hidden sig , ppr name ) sig -- try a cheap-and-cheerful bottom analyser | Just (_, nsig) <- mb_bot_str = nsig From git at git.haskell.org Tue Mar 29 12:05:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:00 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Ticky: Do not count every entry twice (37e6deb) Message-ID: <20160329120500.4F90E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/37e6deb242fcd8cc8956d05c393a081e70cd7533/ghc >--------------------------------------------------------------- commit 37e6deb242fcd8cc8956d05c393a081e70cd7533 Author: Joachim Breitner Date: Thu Mar 17 17:25:36 2016 +0100 Ticky: Do not count every entry twice (likely introduced by 99d4e5b4a0bd32813ff8c74e91d2dcf6b3555176, possibly due to a merge mistake). >--------------------------------------------------------------- 37e6deb242fcd8cc8956d05c393a081e70cd7533 compiler/codeGen/StgCmmBind.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index d5a3be9..8adf3b0 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -581,8 +581,7 @@ thunkCode cl_info fv_details _cc node arity body -- that cc of enclosing scope will be recorded -- in update frame CAF/DICT functions will be -- subsumed by this enclosing cc - do { tickyEnterThunk cl_info - ; enterCostCentreThunk (CmmReg nodeReg) + do { enterCostCentreThunk (CmmReg nodeReg) ; let lf_info = closureLFInfo cl_info ; fv_bindings <- mapM bind_fv fv_details ; load_fvs node lf_info fv_bindings From git at git.haskell.org Tue Mar 29 12:05:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:03 +0000 (UTC) Subject: [commit: ghc] wip/T10613: SpecConstr: Transport strictness annotation to specialization’s argument’s binders (058cfc9) Message-ID: <20160329120503.015733A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/058cfc9aea563c2c4e8d643274d2362964969038/ghc >--------------------------------------------------------------- commit 058cfc9aea563c2c4e8d643274d2362964969038 Author: Joachim Breitner Date: Tue Mar 22 15:39:06 2016 +0100 SpecConstr: Transport strictness annotation to specialization?s argument?s binders This is a result of the discussion in ticket:11731#comment:9. >--------------------------------------------------------------- 058cfc9aea563c2c4e8d643274d2362964969038 compiler/specialise/SpecConstr.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs index 10d5614..12c2e12 100644 --- a/compiler/specialise/SpecConstr.hs +++ b/compiler/specialise/SpecConstr.hs @@ -1648,12 +1648,18 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) `setIdStrictness` spec_str `setIdArity` count isId spec_lam_args spec_str = calcSpecStrictness fn spec_lam_args pats + + -- Conditionally use result of new worker-wrapper transform (spec_lam_args, spec_call_args) = mkWorkerArgs (sc_dflags env) qvars NoOneShotInfo body_ty -- Usual w/w hack to avoid generating -- a spec_rhs of unlifted type and no args - spec_rhs = mkLams spec_lam_args spec_body + spec_lam_args_str = handOutStrictnessInformation (fst (splitStrictSig spec_str)) spec_lam_args + -- ^ Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + + spec_rhs = mkLams spec_lam_args_str spec_body body_ty = exprType spec_body rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn @@ -1663,6 +1669,16 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) -- See Note [Transfer activation] ; return (spec_usg, OS call_pat rule spec_id spec_rhs) } + +-- See Note [Strictness information in worker binders] +handOutStrictnessInformation :: [Demand] -> [Var] -> [Var] +handOutStrictnessInformation = go + where + go _ [] = [] + go [] vs = vs + go (d:dmds) (v:vs) | isId v = setIdDemandInfo v d : go dmds vs + go dmds (v:vs) = v : go dmds vs + calcSpecStrictness :: Id -- The original function -> [Var] -> [CoreExpr] -- Call pattern -> StrictSig -- Strictness of specialised thing @@ -1742,6 +1758,14 @@ See Trac #3437 for a good example. The function calcSpecStrictness performs the calculation. +Note [Strictness information in worker binders] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After having calculated the strictness annotation for the worker (see Note +[Transfer strictness] above), we also want to have this information attached to +the worker?s arguments, for the benefit of later passes. The function +handOutStrictnessInformation decomposes the stricntess annotation calculated by +calcSpecStrictness and attaches them to the variables. ************************************************************************ * * From git at git.haskell.org Tue Mar 29 12:05:05 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:05 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Typo in Note name (2c372fd) Message-ID: <20160329120505.A77FA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/2c372fdc5fae8eb38f2693c391508b724b851954/ghc >--------------------------------------------------------------- commit 2c372fdc5fae8eb38f2693c391508b724b851954 Author: Joachim Breitner Date: Tue Mar 22 11:14:08 2016 +0100 Typo in Note name >--------------------------------------------------------------- 2c372fdc5fae8eb38f2693c391508b724b851954 compiler/coreSyn/CoreUtils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index d2da53a..1d9b83b 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -753,8 +753,8 @@ Note [exprIsTrivial] applications. Note that primop Ids aren't considered trivial unless -Note [Variable are trivial] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Variables are trivial] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There used to be a gruesome test for (hasNoBinding v) in the Var case: exprIsTrivial (Var v) | hasNoBinding v = idArity v == 0 From git at git.haskell.org Tue Mar 29 12:05:08 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:08 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Do not print DmdType in Core output (bc113a9) Message-ID: <20160329120508.584F83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/bc113a9a28ab9ff878f5ea8a200c9d6eb17db80c/ghc >--------------------------------------------------------------- commit bc113a9a28ab9ff878f5ea8a200c9d6eb17db80c Author: Joachim Breitner Date: Wed Mar 23 13:38:34 2016 +0100 Do not print DmdType in Core output too verbose, and usualy preceded by Str= anyways. >--------------------------------------------------------------- bc113a9a28ab9ff878f5ea8a200c9d6eb17db80c compiler/basicTypes/Demand.hs | 3 +-- .../tests/deSugar/should_compile/T2431.stderr | 18 ++++++------- .../tests/determinism/should_compile/determ004.hs | 2 +- .../simplCore/should_compile/spec-inline-determ.hs | 4 +-- .../tests/numeric/should_compile/T7116.stdout | 14 +++++----- testsuite/tests/perf/should_run/T4267.hs | 4 +-- testsuite/tests/perf/should_run/T5949.hs | 4 +-- .../tests/roles/should_compile/Roles13.stderr | 26 +++++++++--------- testsuite/tests/roles/should_compile/T8958.stderr | 2 -- .../tests/simplCore/should_compile/T3717.stderr | 10 +++---- .../tests/simplCore/should_compile/T3772.stdout | 10 +++---- .../tests/simplCore/should_compile/T4398.stderr | 6 ++--- .../tests/simplCore/should_compile/T4908.stderr | 12 ++++----- .../tests/simplCore/should_compile/T4930.stderr | 10 +++---- .../tests/simplCore/should_compile/T7360.stderr | 31 +++++++++++----------- .../tests/simplCore/should_compile/T9400.stderr | 8 +++--- .../tests/simplCore/should_compile/simpl016.stderr | 2 +- .../simplCore/should_compile/spec-inline.stderr | 24 ++++++++--------- testsuite/tests/stranal/should_compile/Makefile | 2 +- .../tests/stranal/should_compile/T10694.stdout | 10 +++---- 20 files changed, 99 insertions(+), 103 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc bc113a9a28ab9ff878f5ea8a200c9d6eb17db80c From git at git.haskell.org Tue Mar 29 12:05:11 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:11 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (ea3e534) Message-ID: <20160329120511.17C223A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/ea3e534eb33ccb541731f4fbf6cb81c73e6ade57/ghc >--------------------------------------------------------------- commit ea3e534eb33ccb541731f4fbf6cb81c73e6ade57 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- ea3e534eb33ccb541731f4fbf6cb81c73e6ade57 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc ea3e534eb33ccb541731f4fbf6cb81c73e6ade57 From git at git.haskell.org Tue Mar 29 12:05:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:13 +0000 (UTC) Subject: [commit: ghc] wip/T10613: State hack hack in ticky report (169ffb3) Message-ID: <20160329120513.B8C873A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/169ffb3a52c063482f4036d0d3bae51b50437ffa/ghc >--------------------------------------------------------------- commit 169ffb3a52c063482f4036d0d3bae51b50437ffa Author: Joachim Breitner Date: Wed Mar 23 11:10:25 2016 +0100 State hack hack in ticky report In the ticky report, do not mark a function with a State# argument as its first argument as single-entry. >--------------------------------------------------------------- 169ffb3a52c063482f4036d0d3bae51b50437ffa compiler/codeGen/StgCmmClosure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index b467048..3b83b8e 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -234,7 +234,10 @@ mkLFReEntrant _ _ [] _ = pprPanic "mkLFReEntrant" empty mkLFReEntrant top fvs args arg_descr = LFReEntrant top os_info (length args) (null fvs) arg_descr - where os_info = idOneShotInfo (head args) + where + state_hack_hack = isStateHackType (idType (head args)) + os_info | state_hack_hack = noOneShotInfo + | otherwise = idOneShotInfo (head args) ------------- mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo From git at git.haskell.org Tue Mar 29 12:05:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:16 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Evac: Do not evaluate selector thunks pointing to counting indirections (08c92ce) Message-ID: <20160329120516.622083A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/08c92ce6e3d7dcf934eda840cc64fa6fc45be88d/ghc >--------------------------------------------------------------- commit 08c92ce6e3d7dcf934eda840cc64fa6fc45be88d Author: Joachim Breitner Date: Wed Mar 23 13:50:00 2016 +0100 Evac: Do not evaluate selector thunks pointing to counting indirections >--------------------------------------------------------------- 08c92ce6e3d7dcf934eda840cc64fa6fc45be88d rts/sm/Evac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 3b4314b..9369543 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -998,12 +998,17 @@ selector_loop: } case IND: - case COUNTING_IND: case IND_STATIC: // Again, we might need to untag a constructor. selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); goto selector_loop; + case COUNTING_IND: + // do not short cut a COUNTING_IND, as we would miss a the count + // Can we simply tick the counter here? Not really: If this selector + // thunk is not going to be used, we counted more than we wanted! + goto bale_out; + case BLACKHOLE: { StgClosure *r; From git at git.haskell.org Tue Mar 29 12:05:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 12:05:19 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Temporarily move regular entry counting to the COUNTING_IND (b3ecf71) Message-ID: <20160329120519.124D13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/b3ecf71d57324a47b23616ff4b79b63b666b1f7c/ghc >--------------------------------------------------------------- commit b3ecf71d57324a47b23616ff4b79b63b666b1f7c Author: Joachim Breitner Date: Wed Mar 23 14:28:34 2016 +0100 Temporarily move regular entry counting to the COUNTING_IND >--------------------------------------------------------------- b3ecf71d57324a47b23616ff4b79b63b666b1f7c compiler/codeGen/StgCmmBind.hs | 8 ++++++-- rts/StgMiscClosures.cmm | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 5951175..8672273 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -609,9 +609,13 @@ thunkCode cl_info fv_details _cc node arity body -- Heap overflow check ; entryHeapCheck cl_info node' arity [] $ do - { -- Overwrite with black hole if necessary + { + -- Disabled for now, as we (temporarily unconditionally) move the + -- counting to the counting indirection + -- tickyEnterThunk cl_info + + -- Overwrite with black hole if necessary -- but *after* the heap-overflow check - ; tickyEnterThunk cl_info ; when (blackHoleOnEntry cl_info && node_points) (blackHoleIt node) diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 96b95aa..0f27fdb 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -283,6 +283,7 @@ INFO_TABLE(stg_COUNTING_IND,1,2,COUNTING_IND,"COUNTING_IND","COUNTING_IND") StgEntCounter_multi_entry_count(ent_ctr) = StgEntCounter_multi_entry_count(ent_ctr) + 1; } StgCountingInd_entries(clos) = entries + 1; + StgEntCounter_entry_count(ent_ctr) = StgEntCounter_entry_count(ent_ctr) + 1; #if defined(TICKY_TICKY) && !defined(PROFILING) /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than From git at git.haskell.org Tue Mar 29 13:52:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 13:52:46 +0000 (UTC) Subject: [commit: ghc] master: cleanup POSIX/XOPEN defines for switch to C99 (be2a7ba) Message-ID: <20160329135246.94E263A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/be2a7baf15c6cf414e2287bff3ed345c50de88bd/ghc >--------------------------------------------------------------- commit be2a7baf15c6cf414e2287bff3ed345c50de88bd Author: Karel Gardas Date: Tue Mar 29 12:21:54 2016 +0200 cleanup POSIX/XOPEN defines for switch to C99 Summary: This patch cleans up various POSIX and XOPEN defines. We aim to switch to C99 solely and for this the lowest version of supported POSIX/XOPEN is: _XOPEN_SOURCE 600 _POSIX_C_SOURCE 200112L Test Plan: tested on Solaris 11 and OpenBSD 5.9. Should be good also on Solaris 10, FreeBSD and DragonFlyBSD. We need to test on Mac OS X, Linux and MinGW Reviewers: austin, bgamari, erikd, hvr Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2056 >--------------------------------------------------------------- be2a7baf15c6cf414e2287bff3ed345c50de88bd rts/PosixSource.h | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/rts/PosixSource.h b/rts/PosixSource.h index 6246e3e..f4b880e 100644 --- a/rts/PosixSource.h +++ b/rts/PosixSource.h @@ -11,25 +11,21 @@ #include -#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(solaris2_HOST_OS) +/* We aim for C99 so we need to define following two defines in a consistent way + with what POSIX/XOPEN provide for C99. Some OSes are particularly picky about + the right versions defined here, e.g. Solaris + We also settle on lowest version of POSIX/XOPEN needed for proper C99 support + here which is POSIX.1-2001 compilation and Open Group Technical Standard, + Issue 6 (XPG6). XPG6 itself is a result of the merge of X/Open and POSIX + specification. It is also referred as IEEE Std. 1003.1-2001 or ISO/IEC + 9945:2002 or UNIX 03 and SUSv3. + Please also see trac ticket #11757 for more information about switch + to C99/C11. +*/ #define _POSIX_C_SOURCE 200112L #define _XOPEN_SOURCE 600 -#else -#define _POSIX_SOURCE 1 -#define _POSIX_C_SOURCE 199506L -#define _XOPEN_SOURCE 500 -// FreeBSD takes a different approach to _ISOC99_SOURCE: on FreeBSD it -// means "I want *just* C99 things", whereas on GNU libc and Solaris -// it means "I also want C99 things". -// -// On both GNU libc and FreeBSD, _ISOC99_SOURCE is implied by -// _XOPEN_SOURCE==600, but on Solaris it is an error to omit it. -#define _ISOC99_SOURCE -// Defining __USE_MINGW_ANSI_STDIO is the most portable way to tell -// mingw that we want to use the standard %lld style format specifiers, -// rather than the Windows %I64d style + #define __USE_MINGW_ANSI_STDIO 1 -#endif #if defined(darwin_HOST_OS) /* If we don't define this the including sysctl breaks with things like From git at git.haskell.org Tue Mar 29 14:50:45 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:50:45 +0000 (UTC) Subject: [commit: ghc] master: Ticky: Do not count every entry twice (38c7714) Message-ID: <20160329145045.8AD703A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/38c7714b334a28cdc10febd7763eef2a7ddd4413/ghc >--------------------------------------------------------------- commit 38c7714b334a28cdc10febd7763eef2a7ddd4413 Author: Joachim Breitner Date: Thu Mar 17 17:25:36 2016 +0100 Ticky: Do not count every entry twice (likely introduced by 99d4e5b4a0bd32813ff8c74e91d2dcf6b3555176, possibly due to a merge mistake). >--------------------------------------------------------------- 38c7714b334a28cdc10febd7763eef2a7ddd4413 compiler/codeGen/StgCmmBind.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index d5a3be9..8adf3b0 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -581,8 +581,7 @@ thunkCode cl_info fv_details _cc node arity body -- that cc of enclosing scope will be recorded -- in update frame CAF/DICT functions will be -- subsumed by this enclosing cc - do { tickyEnterThunk cl_info - ; enterCostCentreThunk (CmmReg nodeReg) + do { enterCostCentreThunk (CmmReg nodeReg) ; let lf_info = closureLFInfo cl_info ; fv_bindings <- mapM bind_fv fv_details ; load_fvs node lf_info fv_bindings From git at git.haskell.org Tue Mar 29 14:50:48 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:50:48 +0000 (UTC) Subject: [commit: ghc] master: Remove all mentions of IND_OLDGEN outside of docs/rts (85e6997) Message-ID: <20160329145048.54FE03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/85e699729491d3afb921158f905d353c7d40517b/ghc >--------------------------------------------------------------- commit 85e699729491d3afb921158f905d353c7d40517b Author: Joachim Breitner Date: Fri Jan 22 10:31:25 2016 +0100 Remove all mentions of IND_OLDGEN outside of docs/rts >--------------------------------------------------------------- 85e699729491d3afb921158f905d353c7d40517b compiler/codeGen/StgCmmProf.hs | 3 +-- rts/sm/Scav.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs index c1b149d..434d7b5 100644 --- a/compiler/codeGen/StgCmmProf.hs +++ b/compiler/codeGen/StgCmmProf.hs @@ -328,8 +328,7 @@ ldvRecordCreate closure = do -- -- | Called when a closure is entered, marks the closure as having -- been "used". The closure is not an "inherently used" one. The --- closure is not @IND@ or @IND_OLDGEN@ because neither is considered --- for LDV profiling. +-- closure is not @IND@ because that is not considered for LDV profiling. -- ldvEnterClosure :: ClosureInfo -> CmmReg -> FCode () ldvEnterClosure closure_info node_reg = do diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index 953f055..abb7726 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -1533,7 +1533,7 @@ scavenge_one(StgPtr p) } else { size = gen->scan - start; } - debugBelch("evac IND_OLDGEN: %ld bytes", size * sizeof(W_)); + debugBelch("evac IND: %ld bytes", size * sizeof(W_)); } #endif break; From git at git.haskell.org Tue Mar 29 14:50:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:50:51 +0000 (UTC) Subject: [commit: ghc] master: Typo in Note name (8af1d08) Message-ID: <20160329145051.0354E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/8af1d0870e0a410fec8113fe867c287b2436c9c6/ghc >--------------------------------------------------------------- commit 8af1d0870e0a410fec8113fe867c287b2436c9c6 Author: Joachim Breitner Date: Tue Mar 22 11:14:08 2016 +0100 Typo in Note name >--------------------------------------------------------------- 8af1d0870e0a410fec8113fe867c287b2436c9c6 compiler/coreSyn/CoreUtils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index d2da53a..1d9b83b 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -753,8 +753,8 @@ Note [exprIsTrivial] applications. Note that primop Ids aren't considered trivial unless -Note [Variable are trivial] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Variables are trivial] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There used to be a gruesome test for (hasNoBinding v) in the Var case: exprIsTrivial (Var v) | hasNoBinding v = idArity v == 0 From git at git.haskell.org Tue Mar 29 14:50:53 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:50:53 +0000 (UTC) Subject: [commit: ghc] master: Be more explicit about closure types in ticky-ticky-report (30b9061) Message-ID: <20160329145053.ADB853A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/30b9061317ea7b834339d9458c46bd6b9108d947/ghc >--------------------------------------------------------------- commit 30b9061317ea7b834339d9458c46bd6b9108d947 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Be more explicit about closure types in ticky-ticky-report The report now distinguishes thunks (in the variants single-entry and standard thunks), constructors and functions (possibly single-entry). Forthermore, for standard thunks (AP and selector), do not count an entry when they are allocated. It is not possible to count their entries, as their code is shared, but better count nothing than count the wrong thing. >--------------------------------------------------------------- 30b9061317ea7b834339d9458c46bd6b9108d947 compiler/codeGen/StgCmmBind.hs | 15 ++++++--- compiler/codeGen/StgCmmClosure.hs | 49 ++++++++++++++------------- compiler/codeGen/StgCmmTicky.hs | 69 +++++++++++++++++++++++++++++---------- 3 files changed, 88 insertions(+), 45 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 30b9061317ea7b834339d9458c46bd6b9108d947 From git at git.haskell.org Tue Mar 29 14:50:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:50:56 +0000 (UTC) Subject: [commit: ghc] master: SpecConstr: Transport strictness data to specialization’s argument’s binders (80d4fdf) Message-ID: <20160329145056.5E99B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/80d4fdf0756ce7edc534b9277d7c6c63c8ceb501/ghc >--------------------------------------------------------------- commit 80d4fdf0756ce7edc534b9277d7c6c63c8ceb501 Author: Joachim Breitner Date: Tue Mar 22 15:39:06 2016 +0100 SpecConstr: Transport strictness data to specialization?s argument?s binders This is a result of the discussion in ticket:11731#comment:9. >--------------------------------------------------------------- 80d4fdf0756ce7edc534b9277d7c6c63c8ceb501 compiler/specialise/SpecConstr.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs index 10d5614..218f8ce 100644 --- a/compiler/specialise/SpecConstr.hs +++ b/compiler/specialise/SpecConstr.hs @@ -1648,12 +1648,18 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) `setIdStrictness` spec_str `setIdArity` count isId spec_lam_args spec_str = calcSpecStrictness fn spec_lam_args pats + + -- Conditionally use result of new worker-wrapper transform (spec_lam_args, spec_call_args) = mkWorkerArgs (sc_dflags env) qvars NoOneShotInfo body_ty -- Usual w/w hack to avoid generating -- a spec_rhs of unlifted type and no args - spec_rhs = mkLams spec_lam_args spec_body + spec_lam_args_str = handOutStrictnessInformation (fst (splitStrictSig spec_str)) spec_lam_args + -- Annotate the variables with the strictness information from + -- the function (see Note [Strictness information in worker binders]) + + spec_rhs = mkLams spec_lam_args_str spec_body body_ty = exprType spec_body rule_rhs = mkVarApps (Var spec_id) spec_call_args inline_act = idInlineActivation fn @@ -1663,6 +1669,16 @@ spec_one env fn arg_bndrs body (call_pat@(qvars, pats), rule_number) -- See Note [Transfer activation] ; return (spec_usg, OS call_pat rule spec_id spec_rhs) } + +-- See Note [Strictness information in worker binders] +handOutStrictnessInformation :: [Demand] -> [Var] -> [Var] +handOutStrictnessInformation = go + where + go _ [] = [] + go [] vs = vs + go (d:dmds) (v:vs) | isId v = setIdDemandInfo v d : go dmds vs + go dmds (v:vs) = v : go dmds vs + calcSpecStrictness :: Id -- The original function -> [Var] -> [CoreExpr] -- Call pattern -> StrictSig -- Strictness of specialised thing @@ -1742,6 +1758,14 @@ See Trac #3437 for a good example. The function calcSpecStrictness performs the calculation. +Note [Strictness information in worker binders] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After having calculated the strictness annotation for the worker (see Note +[Transfer strictness] above), we also want to have this information attached to +the worker?s arguments, for the benefit of later passes. The function +handOutStrictnessInformation decomposes the stricntess annotation calculated by +calcSpecStrictness and attaches them to the variables. ************************************************************************ * * From git at git.haskell.org Tue Mar 29 14:50:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:50:59 +0000 (UTC) Subject: [commit: ghc] master: Rename isNopSig to isTopSig (e6e17a0) Message-ID: <20160329145059.19C053A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e6e17a095f68509d60b06202e49daaf275b7c320/ghc >--------------------------------------------------------------- commit e6e17a095f68509d60b06202e49daaf275b7c320 Author: Joachim Breitner Date: Wed Mar 23 10:41:16 2016 +0100 Rename isNopSig to isTopSig to be consistent with the other uses of nop vs. top in Demand.hs. Also, stop prettyprinting top strictness signatures in Core dumps. >--------------------------------------------------------------- e6e17a095f68509d60b06202e49daaf275b7c320 compiler/basicTypes/Demand.hs | 12 ++++++------ compiler/coreSyn/CoreArity.hs | 2 +- compiler/coreSyn/PprCore.hs | 3 ++- compiler/iface/MkIface.hs | 2 +- compiler/main/TidyPgm.hs | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/compiler/basicTypes/Demand.hs b/compiler/basicTypes/Demand.hs index 96e02b2..3ce9228 100644 --- a/compiler/basicTypes/Demand.hs +++ b/compiler/basicTypes/Demand.hs @@ -37,7 +37,7 @@ module Demand ( appIsBottom, isBottomingSig, pprIfaceStrictSig, trimCPRInfo, returnsCPR_maybe, StrictSig(..), mkStrictSig, mkClosedStrictSig, nopSig, botSig, cprProdSig, - isNopSig, splitStrictSig, increaseStrictSigArity, + isTopSig, splitStrictSig, increaseStrictSigArity, seqDemand, seqDemandList, seqDmdType, seqStrictSig, @@ -1262,10 +1262,10 @@ cprProdDmdType :: Arity -> DmdType cprProdDmdType arity = DmdType emptyDmdEnv [] (vanillaCprProdRes arity) -isNopDmdType :: DmdType -> Bool -isNopDmdType (DmdType env [] res) +isTopDmdType :: DmdType -> Bool +isTopDmdType (DmdType env [] res) | isTopRes res && isEmptyVarEnv env = True -isNopDmdType _ = False +isTopDmdType _ = False mkDmdType :: DmdEnv -> [Demand] -> DmdResult -> DmdType mkDmdType fv ds res = DmdType fv ds res @@ -1669,8 +1669,8 @@ increaseStrictSigArity :: Int -> StrictSig -> StrictSig increaseStrictSigArity arity_increase (StrictSig (DmdType env dmds res)) = StrictSig (DmdType env (replicate arity_increase topDmd ++ dmds) res) -isNopSig :: StrictSig -> Bool -isNopSig (StrictSig ty) = isNopDmdType ty +isTopSig :: StrictSig -> Bool +isTopSig (StrictSig ty) = isTopDmdType ty isBottomingSig :: StrictSig -> Bool -- True if the signature diverges or throws an exception diff --git a/compiler/coreSyn/CoreArity.hs b/compiler/coreSyn/CoreArity.hs index 8086299..cf6cd98 100644 --- a/compiler/coreSyn/CoreArity.hs +++ b/compiler/coreSyn/CoreArity.hs @@ -711,7 +711,7 @@ arityType env (Cast e co) arityType _ (Var v) | strict_sig <- idStrictness v - , not $ isNopSig strict_sig + , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds = if isBotRes res then ABot arity diff --git a/compiler/coreSyn/PprCore.hs b/compiler/coreSyn/PprCore.hs index 9ce1dad..0c62e4f 100644 --- a/compiler/coreSyn/PprCore.hs +++ b/compiler/coreSyn/PprCore.hs @@ -400,7 +400,7 @@ ppIdInfo id info , (has_arity, text "Arity=" <> int arity) , (has_called_arity, text "CallArity=" <> int called_arity) , (has_caf_info, text "Caf=" <> ppr caf_info) - , (True, text "Str=" <> pprStrictness str_info) + , (has_str_info, text "Str=" <> pprStrictness str_info) , (has_unf, text "Unf=" <> ppr unf_info) , (not (null rules), text "RULES:" <+> vcat (map pprRule rules)) ] -- Inline pragma, occ, demand, one-shot info @@ -421,6 +421,7 @@ ppIdInfo id info has_caf_info = not (mayHaveCafRefs caf_info) str_info = strictnessInfo info + has_str_info = not (isTopSig str_info) unf_info = unfoldingInfo info has_unf = hasSomeUnfolding unf_info diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 196dd19..7f8397b 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -1684,7 +1684,7 @@ toIfaceIdInfo id_info ------------ Strictness -------------- -- No point in explicitly exporting TopSig sig_info = strictnessInfo id_info - strict_hsinfo | not (isNopSig sig_info) = Just (HsStrictness sig_info) + strict_hsinfo | not (isTopSig sig_info) = Just (HsStrictness sig_info) | otherwise = Nothing ------------ Unfolding -------------- diff --git a/compiler/main/TidyPgm.hs b/compiler/main/TidyPgm.hs index 3a3a916..e31b0ed 100644 --- a/compiler/main/TidyPgm.hs +++ b/compiler/main/TidyPgm.hs @@ -37,7 +37,7 @@ import IdInfo import InstEnv import FamInstEnv import Type ( tidyTopType ) -import Demand ( appIsBottom, isNopSig, isBottomingSig ) +import Demand ( appIsBottom, isTopSig, isBottomingSig ) import BasicTypes import Name hiding (varName) import NameSet @@ -1242,7 +1242,7 @@ tidyTopIdInfo dflags rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold caf_ mb_bot_str = exprBotStrictness_maybe orig_rhs sig = strictnessInfo idinfo - final_sig | not $ isNopSig sig + final_sig | not $ isTopSig sig = WARN( _bottom_hidden sig , ppr name ) sig -- try a cheap-and-cheerful bottom analyser | Just (_, nsig) <- mb_bot_str = nsig From git at git.haskell.org Tue Mar 29 14:51:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:51:01 +0000 (UTC) Subject: [commit: ghc] master: Do not print DmdType in Core output (c8138c8) Message-ID: <20160329145101.CAFF43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c8138c8505cd5f7f1b9ef33580a443a5c2c4f928/ghc >--------------------------------------------------------------- commit c8138c8505cd5f7f1b9ef33580a443a5c2c4f928 Author: Joachim Breitner Date: Wed Mar 23 13:38:34 2016 +0100 Do not print DmdType in Core output too verbose, and usualy preceded by Str= anyways. >--------------------------------------------------------------- c8138c8505cd5f7f1b9ef33580a443a5c2c4f928 compiler/basicTypes/Demand.hs | 3 +-- .../tests/deSugar/should_compile/T2431.stderr | 18 ++++++------- .../tests/determinism/should_compile/determ004.hs | 2 +- .../simplCore/should_compile/spec-inline-determ.hs | 4 +-- .../tests/numeric/should_compile/T7116.stdout | 14 +++++----- testsuite/tests/perf/should_run/T4267.hs | 4 +-- testsuite/tests/perf/should_run/T5949.hs | 4 +-- .../tests/roles/should_compile/Roles13.stderr | 26 +++++++++--------- testsuite/tests/roles/should_compile/T8958.stderr | 2 -- .../tests/simplCore/should_compile/T3717.stderr | 10 +++---- .../tests/simplCore/should_compile/T3772.stdout | 10 +++---- .../tests/simplCore/should_compile/T4398.stderr | 6 ++--- .../tests/simplCore/should_compile/T4908.stderr | 12 ++++----- .../tests/simplCore/should_compile/T4930.stderr | 10 +++---- .../tests/simplCore/should_compile/T7360.stderr | 31 +++++++++++----------- .../tests/simplCore/should_compile/T9400.stderr | 8 +++--- .../tests/simplCore/should_compile/simpl016.stderr | 2 +- .../simplCore/should_compile/spec-inline.stderr | 24 ++++++++--------- testsuite/tests/stranal/should_compile/Makefile | 2 +- .../tests/stranal/should_compile/T10694.stdout | 10 +++---- 20 files changed, 99 insertions(+), 103 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc c8138c8505cd5f7f1b9ef33580a443a5c2c4f928 From git at git.haskell.org Tue Mar 29 14:51:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 14:51:04 +0000 (UTC) Subject: [commit: ghc] master: Tes suite output updates (cf768ec) Message-ID: <20160329145104.81E973A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/cf768ec062dee47cf72cbddf42d69d9508ec3afb/ghc >--------------------------------------------------------------- commit cf768ec062dee47cf72cbddf42d69d9508ec3afb Author: Joachim Breitner Date: Tue Mar 29 16:47:53 2016 +0200 Tes suite output updates >--------------------------------------------------------------- cf768ec062dee47cf72cbddf42d69d9508ec3afb testsuite/tests/perf/haddock/all.T | 3 +- .../tests/profiling/should_run/scc003.prof.sample | 46 +++++++++++----------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/testsuite/tests/perf/haddock/all.T b/testsuite/tests/perf/haddock/all.T index 606d391..fd44f2b 100644 --- a/testsuite/tests/perf/haddock/all.T +++ b/testsuite/tests/perf/haddock/all.T @@ -51,7 +51,7 @@ test('haddock.base', test('haddock.Cabal', [unless(in_tree_compiler(), skip), req_haddock ,stats_num_field('bytes allocated', - [(wordsize(64), 10519532424, 5) + [(wordsize(64), 11517963232, 5) # 2012-08-14: 3255435248 (amd64/Linux) # 2012-08-29: 3324606664 (amd64/Linux, new codegen) # 2012-10-08: 3373401360 (amd64/Linux) @@ -75,6 +75,7 @@ test('haddock.Cabal', # 2015-12-11: 8114833312 (amd64/Linux) - TypeInType (See #11196) # 2015-12-17: 9982130512 (amd64/Linux) - Update Haddock to master # 2015-12-22: 10519532424 (amd64/Linux) - Lots of new Semigroup instances in Cabal + # 2016-03-29: 11517963232 (amd64/Linux) - not yet investigated ,(platform('i386-unknown-mingw32'), 3293415576, 5) # 2012-10-30: 1733638168 (x86/Windows) diff --git a/testsuite/tests/profiling/should_run/scc003.prof.sample b/testsuite/tests/profiling/should_run/scc003.prof.sample index 69633d4..9e39de0 100644 --- a/testsuite/tests/profiling/should_run/scc003.prof.sample +++ b/testsuite/tests/profiling/should_run/scc003.prof.sample @@ -1,35 +1,35 @@ - Tue Dec 8 08:29 2015 Time and Allocation Profiling Report (Final) + Tue Mar 29 16:44 2016 Time and Allocation Profiling Report (Final) scc003 +RTS -hc -p -RTS - total time = 0.04 secs (40 ticks @ 1000 us, 1 processor) - total alloc = 48,912 bytes (excludes profiling overheads) + total time = 0.08 secs (84 ticks @ 1000 us, 1 processor) + total alloc = 48,880 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc fib Main 100.0 0.0 MAIN MAIN 0.0 1.8 -main Main 0.0 19.6 -CAF GHC.Conc.Signal 0.0 1.3 +CAF GHC.IO.Handle.FD 0.0 70.7 CAF GHC.IO.Encoding 0.0 5.9 -CAF GHC.IO.Handle.FD 0.0 70.6 +CAF GHC.Conc.Signal 0.0 1.3 +main Main 0.0 19.5 - individual inherited -COST CENTRE MODULE no. entries %time %alloc %time %alloc + individual inherited +COST CENTRE MODULE no. entries %time %alloc %time %alloc -MAIN MAIN 105 0 0.0 1.8 100.0 100.0 - main Main 211 0 0.0 18.9 0.0 18.9 - CAF GHC.IO.Handle.Text 140 0 0.0 0.2 0.0 0.2 - CAF GHC.IO.Handle.FD 138 0 0.0 70.6 0.0 70.6 - CAF GHC.IO.Encoding.Iconv 130 0 0.0 0.5 0.0 0.5 - CAF GHC.IO.Encoding 128 0 0.0 5.9 0.0 5.9 - CAF GHC.Conc.Signal 118 0 0.0 1.3 0.0 1.3 - CAF Main 112 0 0.0 0.0 100.0 0.8 - main Main 210 1 0.0 0.7 100.0 0.8 - f Main 212 1 0.0 0.0 100.0 0.1 - f.\ Main 216 1 0.0 0.0 100.0 0.0 - fib Main 217 2692537 100.0 0.0 100.0 0.0 - f.x' Main 213 1 0.0 0.0 0.0 0.0 - f.(...) Main 214 1 0.0 0.0 0.0 0.0 - fib Main 215 21891 0.0 0.0 0.0 0.0 +MAIN MAIN 105 0 0.0 1.8 100.0 100.0 + main Main 211 0 0.0 18.9 0.0 18.9 + CAF Main 209 0 0.0 0.0 100.0 0.7 + main Main 210 1 0.0 0.6 100.0 0.7 + f Main 212 1 0.0 0.0 100.0 0.1 + f.\ Main 216 1 0.0 0.0 100.0 0.0 + fib Main 217 2692537 100.0 0.0 100.0 0.0 + f.x' Main 215 1 0.0 0.0 0.0 0.0 + f.(...) Main 213 1 0.0 0.0 0.0 0.0 + fib Main 214 21891 0.0 0.0 0.0 0.0 + CAF GHC.Conc.Signal 203 0 0.0 1.3 0.0 1.3 + CAF GHC.IO.Encoding 193 0 0.0 5.9 0.0 5.9 + CAF GHC.IO.Encoding.Iconv 191 0 0.0 0.5 0.0 0.5 + CAF GHC.IO.Handle.FD 183 0 0.0 70.7 0.0 70.7 + CAF GHC.IO.Handle.Text 181 0 0.0 0.2 0.0 0.2 From git at git.haskell.org Tue Mar 29 15:49:53 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 15:49:53 +0000 (UTC) Subject: [commit: ghc] wip/T10613: State hack hack in ticky report (78d3a0e) Message-ID: <20160329154953.4AAAC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/78d3a0e4871868cb55aed2d77413e0f583d422b7/ghc >--------------------------------------------------------------- commit 78d3a0e4871868cb55aed2d77413e0f583d422b7 Author: Joachim Breitner Date: Wed Mar 23 11:10:25 2016 +0100 State hack hack in ticky report In the ticky report, do not mark a function with a State# argument as its first argument as single-entry. >--------------------------------------------------------------- 78d3a0e4871868cb55aed2d77413e0f583d422b7 compiler/codeGen/StgCmmClosure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index b467048..3b83b8e 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -234,7 +234,10 @@ mkLFReEntrant _ _ [] _ = pprPanic "mkLFReEntrant" empty mkLFReEntrant top fvs args arg_descr = LFReEntrant top os_info (length args) (null fvs) arg_descr - where os_info = idOneShotInfo (head args) + where + state_hack_hack = isStateHackType (idType (head args)) + os_info | state_hack_hack = noOneShotInfo + | otherwise = idOneShotInfo (head args) ------------- mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo From git at git.haskell.org Tue Mar 29 15:49:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 15:49:55 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Evac: Do not evaluate selector thunks pointing to counting indirections (dfe5006) Message-ID: <20160329154955.E62633A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/dfe5006a4139affd277944ddff2baa1c64dce2c6/ghc >--------------------------------------------------------------- commit dfe5006a4139affd277944ddff2baa1c64dce2c6 Author: Joachim Breitner Date: Wed Mar 23 13:50:00 2016 +0100 Evac: Do not evaluate selector thunks pointing to counting indirections >--------------------------------------------------------------- dfe5006a4139affd277944ddff2baa1c64dce2c6 rts/sm/Evac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 3b4314b..9369543 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -998,12 +998,17 @@ selector_loop: } case IND: - case COUNTING_IND: case IND_STATIC: // Again, we might need to untag a constructor. selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); goto selector_loop; + case COUNTING_IND: + // do not short cut a COUNTING_IND, as we would miss a the count + // Can we simply tick the counter here? Not really: If this selector + // thunk is not going to be used, we counted more than we wanted! + goto bale_out; + case BLACKHOLE: { StgClosure *r; From git at git.haskell.org Tue Mar 29 15:49:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 15:49:58 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (d952edd) Message-ID: <20160329154958.A52AB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/d952edd1f90f68f0c5b3a1f50c69be75b9daec23/ghc >--------------------------------------------------------------- commit d952edd1f90f68f0c5b3a1f50c69be75b9daec23 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- d952edd1f90f68f0c5b3a1f50c69be75b9daec23 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc d952edd1f90f68f0c5b3a1f50c69be75b9daec23 From git at git.haskell.org Tue Mar 29 15:50:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 15:50:01 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Temporarily move regular entry counting to the COUNTING_IND (c025fe5) Message-ID: <20160329155001.5BAFF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/c025fe5d7b231a461eb639ec7b48439075e75b1b/ghc >--------------------------------------------------------------- commit c025fe5d7b231a461eb639ec7b48439075e75b1b Author: Joachim Breitner Date: Wed Mar 23 14:28:34 2016 +0100 Temporarily move regular entry counting to the COUNTING_IND >--------------------------------------------------------------- c025fe5d7b231a461eb639ec7b48439075e75b1b compiler/codeGen/StgCmmBind.hs | 8 ++++++-- rts/StgMiscClosures.cmm | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 5951175..8672273 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -609,9 +609,13 @@ thunkCode cl_info fv_details _cc node arity body -- Heap overflow check ; entryHeapCheck cl_info node' arity [] $ do - { -- Overwrite with black hole if necessary + { + -- Disabled for now, as we (temporarily unconditionally) move the + -- counting to the counting indirection + -- tickyEnterThunk cl_info + + -- Overwrite with black hole if necessary -- but *after* the heap-overflow check - ; tickyEnterThunk cl_info ; when (blackHoleOnEntry cl_info && node_points) (blackHoleIt node) diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 96b95aa..0f27fdb 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -283,6 +283,7 @@ INFO_TABLE(stg_COUNTING_IND,1,2,COUNTING_IND,"COUNTING_IND","COUNTING_IND") StgEntCounter_multi_entry_count(ent_ctr) = StgEntCounter_multi_entry_count(ent_ctr) + 1; } StgCountingInd_entries(clos) = entries + 1; + StgEntCounter_entry_count(ent_ctr) = StgEntCounter_entry_count(ent_ctr) + 1; #if defined(TICKY_TICKY) && !defined(PROFILING) /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than From git at git.haskell.org Tue Mar 29 15:50:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 15:50:03 +0000 (UTC) Subject: [commit: ghc] wip/T10613's head updated: Temporarily move regular entry counting to the COUNTING_IND (c025fe5) Message-ID: <20160329155003.A36673A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T10613' now includes: 91b96e1 fix compilation failure on Solaris 11 a658ad9 Reenable external-json linters 0f0c138 base: Document caveats about Control.Concurrent.Chan 415b706 users-guide: Provide more depth in table-of-contents eb8bc4d users-guide: Wibbles aa61174 users-guide: Add references to various issues in bugs section 7393532 Use a correct substitution in tcInstType a49228e Build correct substitution in instDFunType 4a93e4f Use the correct substitution in lintCoercion 5097f38 Add Data.Functor.Classes instances for Proxy (trac issue #11756) b0ab8db base: Add comment noting import loop be2a7ba cleanup POSIX/XOPEN defines for switch to C99 85e6997 Remove all mentions of IND_OLDGEN outside of docs/rts 30b9061 Be more explicit about closure types in ticky-ticky-report 38c7714 Ticky: Do not count every entry twice 8af1d08 Typo in Note name 80d4fdf SpecConstr: Transport strictness data to specialization?s argument?s binders e6e17a0 Rename isNopSig to isTopSig c8138c8 Do not print DmdType in Core output cf768ec Tes suite output updates d952edd Rough working implementation of #10613 78d3a0e State hack hack in ticky report dfe5006 Evac: Do not evaluate selector thunks pointing to counting indirections c025fe5 Temporarily move regular entry counting to the COUNTING_IND From git at git.haskell.org Tue Mar 29 16:56:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 16:56:17 +0000 (UTC) Subject: [commit: ghc] master: users-guide/rel-notes: Note broken-ness of ImpredicativeTypes (ae6a56e) Message-ID: <20160329165617.5FD2D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/ae6a56ee467d675776be75dc982f5efb2135d3d4/ghc >--------------------------------------------------------------- commit ae6a56ee467d675776be75dc982f5efb2135d3d4 Author: Ben Gamari Date: Tue Mar 29 16:30:29 2016 +0200 users-guide/rel-notes: Note broken-ness of ImpredicativeTypes >--------------------------------------------------------------- ae6a56ee467d675776be75dc982f5efb2135d3d4 docs/users_guide/8.0.1-notes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst index 2ebba6e..fe77bf4 100644 --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -205,6 +205,14 @@ Language result, :ghc-flag:`-XDeriveTraversable` now works on datatypes that contain arguments which have unlifted types. +- Note that the :ghc-flag:`-XImpredicativeTypes` extension, which has been + :ghc-wiki:`known ` to be broken for many years, is even more + broken than usual in this release (see :ghc-ticket:`11319`, + :ghc-ticket:`11675`, and others). During pre-release testing we encountered + a number of projects that broke with confusing type errors due to (often + unnecessary) use of :ghc-flag:`-XImpredicativeTypes`. Users of + :ghc-flag:`-XImpredicativeTypes` do so at their own risk! + Compiler ~~~~~~~~ From git at git.haskell.org Tue Mar 29 16:56:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 16:56:20 +0000 (UTC) Subject: [commit: ghc] master: rename: Disallow type signatures in patterns in plain Haskell (d5d6804) Message-ID: <20160329165620.A3BB03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/d5d6804d37960ece2652196f3661604a70c12ffc/ghc >--------------------------------------------------------------- commit d5d6804d37960ece2652196f3661604a70c12ffc Author: Ben Gamari Date: Tue Mar 29 14:11:57 2016 +0200 rename: Disallow type signatures in patterns in plain Haskell This should require -XScopedTypeVariables. It seems this was previously handled by RnTypes.rnHsBndrSig which called RnTypes.badKindSigErr but this was broken in Simon's refactor of wildcards, 1e041b7382b6aa329e4ad9625439f811e0f27232. Here we re-introduce a check in RnPat. See #11663. Test Plan: Validate with `T11663` Reviewers: austin, simonpj Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2054 GHC Trac Issues: #11663 >--------------------------------------------------------------- d5d6804d37960ece2652196f3661604a70c12ffc compiler/rename/RnTypes.hs | 11 ++++++++++- testsuite/tests/rename/should_fail/T11663.hs | 8 ++++++++ testsuite/tests/rename/should_fail/T11663.stderr | 16 ++++++++++++++++ testsuite/tests/rename/should_fail/all.T | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs index d14769e..7a9f75d 100644 --- a/compiler/rename/RnTypes.hs +++ b/compiler/rename/RnTypes.hs @@ -84,8 +84,12 @@ rnHsSigWcTypeScoped :: HsDocContext -> LHsSigWcType RdrName -- - Signatures on binders in a RULE -- - Pattern type signatures -- Wildcards are allowed +-- type signatures on binders only allowed with ScopedTypeVariables rnHsSigWcTypeScoped ctx sig_ty thing_inside - = rn_hs_sig_wc_type False ctx sig_ty thing_inside + = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables + ; checkErr ty_sig_okay (unexpectedTypeSigErr sig_ty) + ; rn_hs_sig_wc_type False ctx sig_ty thing_inside + } -- False: for pattern type sigs and rules we /do/ want -- to bring those type variables into scope -- e.g \ (x :: forall a. a-> b) -> e @@ -1389,6 +1393,11 @@ ppr_opfix (op, fixity) = pp_op <+> brackets (ppr fixity) * * ***************************************************** -} +unexpectedTypeSigErr :: LHsSigWcType RdrName -> SDoc +unexpectedTypeSigErr ty + = hang (text "Illegal type signature:" <+> quotes (ppr ty)) + 2 (text "Type signatures are only allowed in patterns with ScopedTypeVariables") + badKindBndrs :: HsDocContext -> [Located RdrName] -> SDoc badKindBndrs doc kvs = withHsDocContext doc $ diff --git a/testsuite/tests/rename/should_fail/T11663.hs b/testsuite/tests/rename/should_fail/T11663.hs new file mode 100644 index 0000000..2b8380f --- /dev/null +++ b/testsuite/tests/rename/should_fail/T11663.hs @@ -0,0 +1,8 @@ +module T11663 where + +-- All of these should fail as type signatures are not allowed +-- in patterns without -XScopedTypeVariables. +hello0 = \(h :: Int) -> print h +hello1 (h :: Int) = print h +hello2 = case 54 of (x :: Int) -> print x +hello4 = case Just 54 of Just (x :: Int) -> print x diff --git a/testsuite/tests/rename/should_fail/T11663.stderr b/testsuite/tests/rename/should_fail/T11663.stderr new file mode 100644 index 0000000..18ee6e6 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T11663.stderr @@ -0,0 +1,16 @@ + +T11663.hs:5:12: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables + +T11663.hs:6:9: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables + +T11663.hs:7:22: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables + +T11663.hs:8:32: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index ebe6797..195b729 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -137,3 +137,4 @@ test('T5001b', normal, compile_fail, ['']) test('T10781', normal, compile_fail, ['']) test('T11071', normal, compile_fail, ['']) test('T11071a', normal, compile_fail, ['']) +test('T11663', normal, compile_fail, ['']) \ No newline at end of file From git at git.haskell.org Tue Mar 29 16:57:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 16:57:35 +0000 (UTC) Subject: [commit: ghc] master: base: Fix haddock typo (eb6b709) Message-ID: <20160329165735.F26ED3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/eb6b7094c80fda5cc7c1d1ed3386486996f24bff/ghc >--------------------------------------------------------------- commit eb6b7094c80fda5cc7c1d1ed3386486996f24bff Author: Ben Gamari Date: Tue Mar 29 18:59:57 2016 +0200 base: Fix haddock typo >--------------------------------------------------------------- eb6b7094c80fda5cc7c1d1ed3386486996f24bff libraries/base/Data/Typeable/Internal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 87e5c88..dfc089f 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -224,7 +224,7 @@ mkFunTy :: TypeRep -> TypeRep -> TypeRep mkFunTy f a = mkTyConApp tcFun [f,a] -- | Splits a type constructor application. --- Note that if the type construcotr is polymorphic, this will +-- Note that if the type constructor is polymorphic, this will -- not return the kinds that were used. -- See 'splitPolyTyConApp' if you need all parts. splitTyConApp :: TypeRep -> (TyCon,[TypeRep]) From git at git.haskell.org Tue Mar 29 17:38:19 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:19 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Use a correct substitution in tcInstType (1ca01bb) Message-ID: <20160329173819.5A3DF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1ca01bb8932b2c646ec1190ff854a1a3c456123e/ghc >--------------------------------------------------------------- commit 1ca01bb8932b2c646ec1190ff854a1a3c456123e Author: Bartosz Nitka Date: Tue Mar 29 12:41:59 2016 +0200 Use a correct substitution in tcInstType `ty` doesn't have to be a closed type, so we need to add its free vars to the in-scope set. They don't seem to be available anywhere nearby, so we have to compute them. Test Plan: ./validate Reviewers: goldfire, austin, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2042 GHC Trac Issues: #11371 (cherry picked from commit 73935326e0cf85ed077b9ab7dd8f197d39e2cd5b) >--------------------------------------------------------------- 1ca01bb8932b2c646ec1190ff854a1a3c456123e compiler/typecheck/TcMType.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index 628c9e3..cb9ed72 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -439,7 +439,7 @@ tcInstType inst_tyvars ty return ([], theta, tau) (tyvars, rho) -> do { (subst, tyvars') <- inst_tyvars tyvars - ; let (theta, tau) = tcSplitPhiTy (substTyUnchecked subst rho) + ; let (theta, tau) = tcSplitPhiTy (substTyAddInScope subst rho) ; return (tyvars', theta, tau) } tcSkolDFunType :: Type -> TcM ([TcTyVar], TcThetaType, TcType) From git at git.haskell.org Tue Mar 29 17:38:22 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:22 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Build correct substitution in instDFunType (6b3927f) Message-ID: <20160329173822.0C7E43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/6b3927f5637e016d562ba59d046f1dc1edf7e08d/ghc >--------------------------------------------------------------- commit 6b3927f5637e016d562ba59d046f1dc1edf7e08d Author: Bartosz Nitka Date: Tue Mar 29 12:42:16 2016 +0200 Build correct substitution in instDFunType We will use `ty` in the range of the substitution, hence the substitution needs `ty`'s free vars in-scope. They don't seem easily available by other means, so we just compute them. Test Plan: ./validate Reviewers: austin, goldfire, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2043 GHC Trac Issues: #11371 (cherry picked from commit a49228e3b6e3737da750bce59ec721b3b2f18eed) >--------------------------------------------------------------- 6b3927f5637e016d562ba59d046f1dc1edf7e08d compiler/typecheck/Inst.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/Inst.hs b/compiler/typecheck/Inst.hs index ab9a4e2..49f57a5 100644 --- a/compiler/typecheck/Inst.hs +++ b/compiler/typecheck/Inst.hs @@ -306,14 +306,16 @@ instDFunType :: DFunId -> [DFunInstType] -- See Note [DFunInstType: instantiating types] in InstEnv instDFunType dfun_id dfun_inst_tys = do { (subst, inst_tys) <- go emptyTCvSubst dfun_tvs dfun_inst_tys - ; return (inst_tys, substThetaUnchecked subst dfun_theta) } + ; return (inst_tys, substTheta subst dfun_theta) } where (dfun_tvs, dfun_theta, _) = tcSplitSigmaTy (idType dfun_id) go :: TCvSubst -> [TyVar] -> [DFunInstType] -> TcM (TCvSubst, [TcType]) go subst [] [] = return (subst, []) go subst (tv:tvs) (Just ty : mb_tys) - = do { (subst', tys) <- go (extendTvSubst subst tv ty) tvs mb_tys + = do { (subst', tys) <- go (extendTvSubstAndInScope subst tv ty) + tvs + mb_tys ; return (subst', ty : tys) } go subst (tv:tvs) (Nothing : mb_tys) = do { (subst', tv') <- newMetaTyVarX subst tv From git at git.haskell.org Tue Mar 29 17:38:24 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:24 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add Data.Functor.Classes instances for Proxy (trac issue #11756) (dc81cca) Message-ID: <20160329173824.A782D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/dc81cca703559ffd4acb0a2f47c2f20956c22a3a/ghc >--------------------------------------------------------------- commit dc81cca703559ffd4acb0a2f47c2f20956c22a3a Author: Andrew Martin Date: Tue Mar 29 10:57:47 2016 +0200 Add Data.Functor.Classes instances for Proxy (trac issue #11756) Test Plan: currently no test plan Reviewers: hvr, RyanGlScott, bgamari, austin Reviewed By: RyanGlScott, bgamari, austin Subscribers: thomie, RyanGlScott, andrewthad Differential Revision: https://phabricator.haskell.org/D2051 GHC Trac Issues: #11756 (cherry picked from commit 5097f3802124cfbe6810bff8110df91d4c52096b) >--------------------------------------------------------------- dc81cca703559ffd4acb0a2f47c2f20956c22a3a libraries/base/Data/Functor/Classes.hs | 18 ++++++++++++++++++ libraries/base/changelog.md | 3 +++ 2 files changed, 21 insertions(+) diff --git a/libraries/base/Data/Functor/Classes.hs b/libraries/base/Data/Functor/Classes.hs index 0ec6008..5f1b12c 100644 --- a/libraries/base/Data/Functor/Classes.hs +++ b/libraries/base/Data/Functor/Classes.hs @@ -62,6 +62,7 @@ module Data.Functor.Classes ( import Control.Applicative (Const(Const)) import Data.Functor.Identity (Identity(Identity)) +import Data.Proxy (Proxy(Proxy)) import Data.Monoid (mappend) import Text.Show (showListWith) @@ -354,6 +355,23 @@ instance (Read a) => Read1 (Const a) where instance (Show a) => Show1 (Const a) where liftShowsPrec = liftShowsPrec2 showsPrec showList +-- | @since 4.9.0.0 +instance Eq1 Proxy where + liftEq _ _ _ = True + +-- | @since 4.9.0.0 +instance Ord1 Proxy where + liftCompare _ _ _ = EQ + +-- | @since 4.9.0.0 +instance Show1 Proxy where + liftShowsPrec _ _ _ _ = showString "Proxy" + +-- | @since 4.9.0.0 +instance Read1 Proxy where + liftReadsPrec _ _ d = + readParen (d > 10) (\r -> [(Proxy, s) | ("Proxy",s) <- lex r ]) + -- Building blocks -- | @'readsData' p d@ is a parser for datatypes where each alternative diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 92451b9..cb3eced 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -78,6 +78,9 @@ `Data.Functor.Product`, and `Data.Functor.Sum` (previously provided by `transformers` package). (#11135) + * New instances for `Proxy`: `Eq1`, `Ord1`, `Show1`, `Read1`. All + of the classes are from `Data.Functor.Classes` (#11756). + * New module `Control.Monad.Fail` providing new `MonadFail(fail)` class (#10751) From git at git.haskell.org Tue Mar 29 17:38:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:27 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Use the correct substitution in lintCoercion (b7ee635) Message-ID: <20160329173827.597DA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/b7ee63556c14adbf793b30a65e2cc6770023b7c2/ghc >--------------------------------------------------------------- commit b7ee63556c14adbf793b30a65e2cc6770023b7c2 Author: Bartosz Nitka Date: Tue Mar 29 12:42:32 2016 +0200 Use the correct substitution in lintCoercion We need the free vars of `t2` to satisfy the substitution invariant. Luckily they are in the in-scope carried around. Test Plan: ./validate Reviewers: bgamari, austin, goldfire, simonpj Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2044 GHC Trac Issues: #11371 (cherry picked from commit 4a93e4f9a86a62d1cdf2e666f977b8b58e61eaaf) >--------------------------------------------------------------- b7ee63556c14adbf793b30a65e2cc6770023b7c2 compiler/coreSyn/CoreLint.hs | 7 ++++++- compiler/types/TyCoRep.hs | 5 +++++ compiler/types/Type.hs | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index 59673ae..64543f9 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -1273,9 +1273,14 @@ lintCoercion (ForAllCo tv1 kind_co co) = do { (_, k2) <- lintStarCoercion kind_co ; let tv2 = setTyVarKind tv1 k2 ; (k3, k4, t1, t2, r) <- addInScopeVar tv1 $ lintCoercion co + ; in_scope <- getInScope ; let tyl = mkNamedForAllTy tv1 Invisible t1 + subst = zipTvSubst [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo kind_co] + `extendTCvInScopeInScope` in_scope + -- We need free vars of `t2` in scope to satisfy + -- Note [The substitution invariant] tyr = mkNamedForAllTy tv2 Invisible $ - substTyWithUnchecked [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo kind_co] t2 + substTy subst t2 ; return (k3, k4, tyl, tyr, r) } lintCoercion (CoVarCo cv) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index acff6a2..165350d 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -83,6 +83,7 @@ module TyCoRep ( getCvSubstEnv, getTCvInScope, isInScope, notElemTCvSubst, setTvSubstEnv, setCvSubstEnv, zapTCvSubst, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, + extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendCvSubstWithClone, extendTvSubst, extendTvSubstWithClone, @@ -1668,6 +1669,10 @@ extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst extendTCvInScopeSet (TCvSubst in_scope tenv cenv) vars = TCvSubst (extendInScopeSetSet in_scope vars) tenv cenv +extendTCvInScopeInScope :: TCvSubst -> InScopeSet -> TCvSubst +extendTCvInScopeInScope (TCvSubst in_scope tenv cenv) in_scope' + = TCvSubst (unionInScope in_scope in_scope') tenv cenv + extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst extendTCvSubst subst v ty | isTyVar v diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 7b5922f..47a234e 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -158,6 +158,7 @@ module Type ( getTvSubstEnv, setTvSubstEnv, zapTCvSubst, getTCvInScope, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, + extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendTvSubst, extendTvSubstList, extendTvSubstAndInScope, isInScope, composeTCvSubstEnv, composeTCvSubst, zipTyEnv, zipCoEnv, From git at git.haskell.org Tue Mar 29 17:38:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:30 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: base: Fix haddock typo (13bef02) Message-ID: <20160329173830.06B9B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/13bef024146892b877109bba534a908f3b0f29d2/ghc >--------------------------------------------------------------- commit 13bef024146892b877109bba534a908f3b0f29d2 Author: Ben Gamari Date: Tue Mar 29 18:59:57 2016 +0200 base: Fix haddock typo (cherry picked from commit eb6b7094c80fda5cc7c1d1ed3386486996f24bff) >--------------------------------------------------------------- 13bef024146892b877109bba534a908f3b0f29d2 libraries/base/Data/Typeable/Internal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 87e5c88..dfc089f 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -224,7 +224,7 @@ mkFunTy :: TypeRep -> TypeRep -> TypeRep mkFunTy f a = mkTyConApp tcFun [f,a] -- | Splits a type constructor application. --- Note that if the type construcotr is polymorphic, this will +-- Note that if the type constructor is polymorphic, this will -- not return the kinds that were used. -- See 'splitPolyTyConApp' if you need all parts. splitTyConApp :: TypeRep -> (TyCon,[TypeRep]) From git at git.haskell.org Tue Mar 29 17:38:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:32 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: base: Add comment noting import loop (802042e) Message-ID: <20160329173832.AE2873A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/802042e0d94e47ce81f7b6f54b1a262ba75d7872/ghc >--------------------------------------------------------------- commit 802042e0d94e47ce81f7b6f54b1a262ba75d7872 Author: Ben Gamari Date: Tue Mar 29 13:34:45 2016 +0200 base: Add comment noting import loop (cherry picked from commit b0ab8db61568305f50947058fc5573e2382c84eb) >--------------------------------------------------------------- 802042e0d94e47ce81f7b6f54b1a262ba75d7872 libraries/base/Data/Functor/Classes.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/base/Data/Functor/Classes.hs b/libraries/base/Data/Functor/Classes.hs index 5f1b12c..ce84af0 100644 --- a/libraries/base/Data/Functor/Classes.hs +++ b/libraries/base/Data/Functor/Classes.hs @@ -355,6 +355,8 @@ instance (Read a) => Read1 (Const a) where instance (Show a) => Show1 (Const a) where liftShowsPrec = liftShowsPrec2 showsPrec showList +-- Proxy unfortunately imports this module, hence these instances are placed +-- here, -- | @since 4.9.0.0 instance Eq1 Proxy where liftEq _ _ _ = True From git at git.haskell.org Tue Mar 29 17:38:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:35 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: users-guide/rel-notes: Note broken-ness of ImpredicativeTypes (b855259) Message-ID: <20160329173835.58D963A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/b85525985cba56c34faf636853825da5fe060205/ghc >--------------------------------------------------------------- commit b85525985cba56c34faf636853825da5fe060205 Author: Ben Gamari Date: Tue Mar 29 16:30:29 2016 +0200 users-guide/rel-notes: Note broken-ness of ImpredicativeTypes (cherry picked from commit ae6a56ee467d675776be75dc982f5efb2135d3d4) >--------------------------------------------------------------- b85525985cba56c34faf636853825da5fe060205 docs/users_guide/8.0.1-notes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst index 288141b..ea82fc1 100644 --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -197,6 +197,14 @@ Language result, :ghc-flag:`-XDeriveTraversable` now works on datatypes that contain arguments which have unlifted types. +- Note that the :ghc-flag:`-XImpredicativeTypes` extension, which has been + :ghc-wiki:`known ` to be broken for many years, is even more + broken than usual in this release (see :ghc-ticket:`11319`, + :ghc-ticket:`11675`, and others). During pre-release testing we encountered + a number of projects that broke with confusing type errors due to (often + unnecessary) use of :ghc-flag:`-XImpredicativeTypes`. Users of + :ghc-flag:`-XImpredicativeTypes` do so at their own risk! + Compiler ~~~~~~~~ From git at git.haskell.org Tue Mar 29 17:38:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Tue, 29 Mar 2016 17:38:38 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: rename: Disallow type signatures in patterns in plain Haskell (0178633) Message-ID: <20160329173838.97B513A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/01786339bce247cc8ca008d2be20a7b4b5519d40/ghc >--------------------------------------------------------------- commit 01786339bce247cc8ca008d2be20a7b4b5519d40 Author: Ben Gamari Date: Tue Mar 29 14:11:57 2016 +0200 rename: Disallow type signatures in patterns in plain Haskell This should require -XScopedTypeVariables. It seems this was previously handled by RnTypes.rnHsBndrSig which called RnTypes.badKindSigErr but this was broken in Simon's refactor of wildcards, 1e041b7382b6aa329e4ad9625439f811e0f27232. Here we re-introduce a check in RnPat. See #11663. Test Plan: Validate with `T11663` Reviewers: austin, simonpj Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2054 GHC Trac Issues: #11663 (cherry picked from commit d5d6804d37960ece2652196f3661604a70c12ffc) >--------------------------------------------------------------- 01786339bce247cc8ca008d2be20a7b4b5519d40 compiler/rename/RnTypes.hs | 11 ++++++++++- testsuite/tests/rename/should_fail/T11663.hs | 8 ++++++++ testsuite/tests/rename/should_fail/T11663.stderr | 16 ++++++++++++++++ testsuite/tests/rename/should_fail/all.T | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs index fa15660..09f4ebb 100644 --- a/compiler/rename/RnTypes.hs +++ b/compiler/rename/RnTypes.hs @@ -88,8 +88,12 @@ rnHsSigWcTypeScoped :: HsDocContext -> LHsSigWcType RdrName -- - Signatures on binders in a RULE -- - Pattern type signatures -- Wildcards are allowed +-- type signatures on binders only allowed with ScopedTypeVariables rnHsSigWcTypeScoped ctx sig_ty thing_inside - = rn_hs_sig_wc_type False ctx sig_ty thing_inside + = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables + ; checkErr ty_sig_okay (unexpectedTypeSigErr sig_ty) + ; rn_hs_sig_wc_type False ctx sig_ty thing_inside + } -- False: for pattern type sigs and rules we /do/ want -- to bring those type variables into scope -- e.g \ (x :: forall a. a-> b) -> e @@ -1393,6 +1397,11 @@ ppr_opfix (op, fixity) = pp_op <+> brackets (ppr fixity) * * ***************************************************** -} +unexpectedTypeSigErr :: LHsSigWcType RdrName -> SDoc +unexpectedTypeSigErr ty + = hang (text "Illegal type signature:" <+> quotes (ppr ty)) + 2 (text "Type signatures are only allowed in patterns with ScopedTypeVariables") + badKindBndrs :: HsDocContext -> [Located RdrName] -> SDoc badKindBndrs doc kvs = withHsDocContext doc $ diff --git a/testsuite/tests/rename/should_fail/T11663.hs b/testsuite/tests/rename/should_fail/T11663.hs new file mode 100644 index 0000000..2b8380f --- /dev/null +++ b/testsuite/tests/rename/should_fail/T11663.hs @@ -0,0 +1,8 @@ +module T11663 where + +-- All of these should fail as type signatures are not allowed +-- in patterns without -XScopedTypeVariables. +hello0 = \(h :: Int) -> print h +hello1 (h :: Int) = print h +hello2 = case 54 of (x :: Int) -> print x +hello4 = case Just 54 of Just (x :: Int) -> print x diff --git a/testsuite/tests/rename/should_fail/T11663.stderr b/testsuite/tests/rename/should_fail/T11663.stderr new file mode 100644 index 0000000..18ee6e6 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T11663.stderr @@ -0,0 +1,16 @@ + +T11663.hs:5:12: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables + +T11663.hs:6:9: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables + +T11663.hs:7:22: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables + +T11663.hs:8:32: error: + Illegal type signature: ?Int? + Type signatures are only allowed in patterns with ScopedTypeVariables diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index 82d341b..e9ea297 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -140,3 +140,4 @@ test('T5001b', normal, compile_fail, ['']) test('T10781', normal, compile_fail, ['']) test('T11071', normal, compile_fail, ['']) test('T11071a', normal, compile_fail, ['']) +test('T11663', normal, compile_fail, ['']) \ No newline at end of file From git at git.haskell.org Wed Mar 30 07:58:36 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 07:58:36 +0000 (UTC) Subject: [commit: ghc] master: Add testcase for #11770 (cb9a1e6) Message-ID: <20160330075836.2DC343A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/cb9a1e6875ac636f7c150ffacc272a2594a192dc/ghc >--------------------------------------------------------------- commit cb9a1e6875ac636f7c150ffacc272a2594a192dc Author: Joachim Breitner Date: Wed Mar 30 09:59:09 2016 +0200 Add testcase for #11770 and use normalise_errmsg_fun to check the core output in all.T, instead relying on code in the Makefile. >--------------------------------------------------------------- cb9a1e6875ac636f7c150ffacc272a2594a192dc testsuite/tests/stranal/should_compile/Makefile | 18 ----- .../{T10482.stdout => T10482.stderr} | 0 .../{T10482a.stdout => T10482a.stderr} | 0 .../{T10694.stdout => T10694.stderr} | 0 testsuite/tests/stranal/should_compile/T11770.hs | 11 +++ .../tests/stranal/should_compile/T11770.stderr | 85 ++++++++++++++++++++++ testsuite/tests/stranal/should_compile/all.T | 28 +++++-- 7 files changed, 119 insertions(+), 23 deletions(-) diff --git a/testsuite/tests/stranal/should_compile/Makefile b/testsuite/tests/stranal/should_compile/Makefile index 1b289c6..9101fbd 100644 --- a/testsuite/tests/stranal/should_compile/Makefile +++ b/testsuite/tests/stranal/should_compile/Makefile @@ -1,21 +1,3 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk - -# T10482 -# The intent here is to check that $wfoo has type -# $wfoo :: Int# -> Int# -> Int -# with two unboxed args. See Trac #10482 for background -T10482: - $(RM) -f T10482.o T10482.hi - # Set -dppr-cols to ensure output doesn't wrap - '$(TEST_HC)' $(TEST_HC_OPTS) -dppr-cols=200 -O -c -ddump-simpl T10482.hs | grep 'T10482.*wfoo.*Int' - -T10482a: - $(RM) -f T10482a.o T10482a.hi - # Set -dppr-cols to ensure output doesn't wrap - '$(TEST_HC)' $(TEST_HC_OPTS) -dppr-cols=200 -O -c -ddump-simpl T10482a.hs | grep 'wf.*Int' - -T10694: - $(RM) -f T10694.o - '$(TEST_HC)' $(TEST_HC_OPTS) -O -c -ddump-simpl T10694.hs | grep 'Str=' diff --git a/testsuite/tests/stranal/should_compile/T10482.stdout b/testsuite/tests/stranal/should_compile/T10482.stderr similarity index 100% rename from testsuite/tests/stranal/should_compile/T10482.stdout rename to testsuite/tests/stranal/should_compile/T10482.stderr diff --git a/testsuite/tests/stranal/should_compile/T10482a.stdout b/testsuite/tests/stranal/should_compile/T10482a.stderr similarity index 100% rename from testsuite/tests/stranal/should_compile/T10482a.stdout rename to testsuite/tests/stranal/should_compile/T10482a.stderr diff --git a/testsuite/tests/stranal/should_compile/T10694.stdout b/testsuite/tests/stranal/should_compile/T10694.stderr similarity index 100% rename from testsuite/tests/stranal/should_compile/T10694.stdout rename to testsuite/tests/stranal/should_compile/T10694.stderr diff --git a/testsuite/tests/stranal/should_compile/T11770.hs b/testsuite/tests/stranal/should_compile/T11770.hs new file mode 100644 index 0000000..6b669f9 --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T11770.hs @@ -0,0 +1,11 @@ +module T11770 where + + +foo :: Int -> Int -> Int +foo 10 c = 0 +foo n c = + -- Bar should not be marked as one-shot + let bar :: Int -> Int + bar n = n + c + {-# NOINLINE bar #-} + in bar n + foo (bar (n+1)) c diff --git a/testsuite/tests/stranal/should_compile/T11770.stderr b/testsuite/tests/stranal/should_compile/T11770.stderr new file mode 100644 index 0000000..82f6a9d --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T11770.stderr @@ -0,0 +1,85 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core = {terms: 56, types: 25, coercions: 0} + +-- RHS size: {terms: 2, types: 0, coercions: 0} +T11770.$trModule2 :: GHC.Types.TrName +[GblId, + Caf=NoCafRefs, + Str=m1, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 20}] +T11770.$trModule2 = GHC.Types.TrNameS "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0} +T11770.$trModule1 :: GHC.Types.TrName +[GblId, + Caf=NoCafRefs, + Str=m1, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 40 20}] +T11770.$trModule1 = GHC.Types.TrNameS "T11770"# + +-- RHS size: {terms: 3, types: 0, coercions: 0} +T11770.$trModule :: GHC.Types.Module +[GblId, + Caf=NoCafRefs, + Str=m, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] +T11770.$trModule = + GHC.Types.Module T11770.$trModule2 T11770.$trModule1 + +Rec { +-- RHS size: {terms: 32, types: 11, coercions: 0} +T11770.$wfoo [InlPrag=[0], Occ=LoopBreaker] + :: GHC.Prim.Int# -> Int -> GHC.Prim.Int# +[GblId, Arity=2, Caf=NoCafRefs, Str=] +T11770.$wfoo = + \ (ww_s1Mj :: GHC.Prim.Int#) (w_s1Mg :: Int) -> + case ww_s1Mj of ds_X1Lc { + __DEFAULT -> + let { + bar_s1LA [InlPrag=NOINLINE] :: Int -> Int + [LclId, Arity=1, Str=m {axl->}] + bar_s1LA = + \ (n_axp :: Int) -> + GHC.Num.$fNumInt_$c+ n_axp w_s1Mg } in + case bar_s1LA (GHC.Types.I# ds_X1Lc) + of _ [Occ=Dead] { GHC.Types.I# x_a1Lp -> + case bar_s1LA (GHC.Types.I# (GHC.Prim.+# ds_X1Lc 1#)) + of _ [Occ=Dead] { GHC.Types.I# ww2_X1MK -> + case T11770.$wfoo ww2_X1MK w_s1Mg of ww3_s1Mn { __DEFAULT -> + GHC.Prim.+# x_a1Lp ww3_s1Mn + } + } + }; + 10# -> 0# + } +end Rec } + +-- RHS size: {terms: 12, types: 5, coercions: 0} +foo [InlPrag=INLINE[0]] :: Int -> Int -> Int +[GblId, + Arity=2, + Caf=NoCafRefs, + Str=m, + Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) + Tmpl= \ (w_s1Mf [Occ=Once!] :: Int) (w1_s1Mg [Occ=Once] :: Int) -> + case w_s1Mf of _ [Occ=Dead] { GHC.Types.I# ww1_s1Mj [Occ=Once] -> + case T11770.$wfoo ww1_s1Mj w1_s1Mg of ww2_s1Mn { __DEFAULT -> + GHC.Types.I# ww2_s1Mn + } + }}] +foo = + \ (w_s1Mf :: Int) (w1_s1Mg :: Int) -> + case w_s1Mf of _ [Occ=Dead] { GHC.Types.I# ww1_s1Mj -> + case T11770.$wfoo ww1_s1Mj w1_s1Mg of ww2_s1Mn { __DEFAULT -> + GHC.Types.I# ww2_s1Mn + } + } + + + diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T index d2fc18d..3ac075b 100644 --- a/testsuite/tests/stranal/should_compile/all.T +++ b/testsuite/tests/stranal/should_compile/all.T @@ -1,6 +1,19 @@ # Only compile with optimisation setTestOpts( only_ways(['optasm']) ) +def checkCoreString(needle): + def norm(str): + if needle in str: + return "%s contained in -ddump-simpl\n" % needle + else: + return "%s not contained in -ddump-simpl\n" % needle + return normalise_errmsg_fun(norm) + +def grepCoreString(needle): + def norm(str): + return "".join(filter(lambda l: re.search(needle, l), str.splitlines(True))) + return normalise_errmsg_fun(norm) + test('default', normal, compile, ['']) test('fact', normal, compile, ['']) test('fun', normal, compile, ['']) @@ -20,13 +33,18 @@ test('T8467', normal, compile, ['']) test('T8037', normal, compile, ['']) test('T8743', [ extra_clean(['T8743.o-boot', 'T8743a.hi', 'T8743a.o', 'T8743.hi-boot']) ], multimod_compile, ['T8743', '-v0']) -# test('T10482', normal, compile, ['']) - -test('T10482', only_ways(['normal']), run_command, ['$MAKE -s --no-print-directory T10482']) -test('T10482a', only_ways(['normal']), run_command, ['$MAKE -s --no-print-directory T10482a']) +# T10482 +# The intent here is to check that $wfoo has type +# $wfoo :: Int# -> Int# -> Int +# with two unboxed args. See Trac #10482 for background +test('T10482', [ grepCoreString(r'wfoo.*Int') ], compile, ['-dppr-cols=200 -ddump-simpl']) +test('T10482a', [ grepCoreString(r'wf.*Int') ], compile, ['-dppr-cols=200 -ddump-simpl']) test('T9208', when(compiler_debugged(), expect_broken(9208)), compile, ['']) # T9208 fails (and should do so) if you have assertion checking on in the compiler # Hence the above expect_broken. See comments in the Trac ticket -test('T10694', only_ways(['normal']), run_command, ['$MAKE -s --no-print-directory T10694']) +test('T10694', [ grepCoreString(r'Str=') ], compile, ['-dppr-cols=200 -ddump-simpl']) +test('T11770', [ expect_broken(117700), checkCoreString("OneShot") ], compile, ['-ddump-simpl']) + + From git at git.haskell.org Wed Mar 30 08:05:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 08:05:56 +0000 (UTC) Subject: [commit: ghc] branch 'wip/T11770' created Message-ID: <20160330080556.53FA13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc New branch : wip/T11770 Referencing: d14050006e3db1aa90d063884c4cd98f0fd5e859 From git at git.haskell.org Wed Mar 30 08:05:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 08:05:59 +0000 (UTC) Subject: [commit: ghc] wip/T11770: Demand Analyzer: Do not set OneShot information (d140500) Message-ID: <20160330080559.0C0043A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11770 Link : http://ghc.haskell.org/trac/ghc/changeset/d14050006e3db1aa90d063884c4cd98f0fd5e859/ghc >--------------------------------------------------------------- commit d14050006e3db1aa90d063884c4cd98f0fd5e859 Author: Joachim Breitner Date: Wed Mar 30 10:05:28 2016 +0200 Demand Analyzer: Do not set OneShot information as suggested in ticket:11770#comment:1. This naturally fixes issue #117700; performance validation pending. (Pushing this as a branch to get perf.haskell.org to measure it). >--------------------------------------------------------------- d14050006e3db1aa90d063884c4cd98f0fd5e859 compiler/stranal/DmdAnal.hs | 27 +++------------------------ testsuite/tests/stranal/should_compile/all.T | 2 +- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/compiler/stranal/DmdAnal.hs b/compiler/stranal/DmdAnal.hs index 6ef911f..aae0c74 100644 --- a/compiler/stranal/DmdAnal.hs +++ b/compiler/stranal/DmdAnal.hs @@ -260,17 +260,13 @@ dmdAnal' env dmd (Case scrut case_bndr ty alts) (res_ty, Case scrut' case_bndr' ty alts') dmdAnal' env dmd (Let (NonRec id rhs) body) - = (body_ty2, Let (NonRec id2 annotated_rhs) body') + = (body_ty2, Let (NonRec id2 rhs') body') where (sig, lazy_fv, id1, rhs') = dmdAnalRhs NotTopLevel Nothing env id rhs (body_ty, body') = dmdAnal (extendAnalEnv NotTopLevel env id sig) dmd body (body_ty1, id2) = annotateBndr env body_ty id1 body_ty2 = addLazyFVs body_ty1 lazy_fv - -- Annotate top-level lambdas at RHS basing on the aggregated demand info - -- See Note [Annotating lambdas at right-hand side] - annotated_rhs = annLamWithShotness (idDemandInfo id2) rhs' - -- If the actual demand is better than the vanilla call -- demand, you might think that we might do better to re-analyse -- the RHS with the stronger demand. @@ -317,8 +313,8 @@ annLamWithShotness d e | Just (c, u') <- peelUseCall u , Lam bndr body <- e = if isTyVar bndr - then Lam bndr (go u body) - else Lam (setOneShotness c bndr) (go u' body) + then Lam bndr (go u body) + else Lam bndr (go u' body) | otherwise = e @@ -432,23 +428,6 @@ free variable |y|. Conversely, if the demand on |h| is unleashed right on the spot, we will get the desired result, namely, that |f| is strict in |y|. -Note [Annotating lambdas at right-hand side] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Let us take a look at the following example: - -g f = let x = 100 - h = \y -> f x y - in h 5 - -One can see that |h| is called just once, therefore the RHS of h can -be annotated as a one-shot lambda. This is done by the function -annLamWithShotness *a posteriori*, i.e., basing on the aggregated -usage demand on |h| from the body of |let|-expression, which is C1(U) -in this case. - -In other words, for locally-bound lambdas we can infer -one-shotness. - ************************************************************************ * * diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T index 3ac075b..dabc9fc 100644 --- a/testsuite/tests/stranal/should_compile/all.T +++ b/testsuite/tests/stranal/should_compile/all.T @@ -45,6 +45,6 @@ test('T9208', when(compiler_debugged(), expect_broken(9208)), compile, ['']) # Hence the above expect_broken. See comments in the Trac ticket test('T10694', [ grepCoreString(r'Str=') ], compile, ['-dppr-cols=200 -ddump-simpl']) -test('T11770', [ expect_broken(117700), checkCoreString("OneShot") ], compile, ['-ddump-simpl']) +test('T11770', [ checkCoreString('OneShot') ], compile, ['-ddump-simpl']) From git at git.haskell.org Wed Mar 30 09:03:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 09:03:43 +0000 (UTC) Subject: [commit: ghc] master: Typos in non-code (a76e6f5) Message-ID: <20160330090343.58D093A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/a76e6f55c28a176c175b45b7279a1d20286bf56b/ghc >--------------------------------------------------------------- commit a76e6f55c28a176c175b45b7279a1d20286bf56b Author: Gabor Greif Date: Wed Mar 30 11:04:37 2016 +0200 Typos in non-code >--------------------------------------------------------------- a76e6f55c28a176c175b45b7279a1d20286bf56b compiler/coreSyn/CoreSubst.hs | 2 +- compiler/coreSyn/CoreUnfold.hs | 2 +- compiler/coreSyn/MkCore.hs | 2 +- compiler/ghci/ByteCodeGen.hs | 2 +- compiler/parser/Lexer.x | 2 +- compiler/simplCore/CallArity.hs | 2 +- compiler/simplCore/OccurAnal.hs | 2 +- compiler/simplCore/SetLevels.hs | 2 +- compiler/specialise/SpecConstr.hs | 2 +- compiler/typecheck/TcExpr.hs | 2 +- compiler/types/TyCoRep.hs | 4 ++-- docs/stg-spec/stg-spec.mng | 2 +- docs/users_guide/glasgow_exts.rst | 2 +- testsuite/tests/primops/should_run/T7689.hs | 2 +- testsuite/tests/typecheck/should_compile/tc195.hs | 2 +- testsuite/tests/warnings/should_compile/T11128.hs | 2 +- testsuite/tests/warnings/should_compile/T11128b.hs | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a76e6f55c28a176c175b45b7279a1d20286bf56b From git at git.haskell.org Wed Mar 30 09:18:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 09:18:13 +0000 (UTC) Subject: [commit: ghc] wip/T11770: Demand Analyzer: Do not set OneShot information (cc6e1e5) Message-ID: <20160330091813.414ED3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11770 Link : http://ghc.haskell.org/trac/ghc/changeset/cc6e1e5226253311ec9d9bda5c6df8211d65cf44/ghc >--------------------------------------------------------------- commit cc6e1e5226253311ec9d9bda5c6df8211d65cf44 Author: Joachim Breitner Date: Wed Mar 30 10:05:28 2016 +0200 Demand Analyzer: Do not set OneShot information as suggested in ticket:11770#comment:1. This code was buggy (#11770), and the occurrence analyzer does the same job anyways. This also elaborates the notes in the occurrence analyzer accordingly. >--------------------------------------------------------------- cc6e1e5226253311ec9d9bda5c6df8211d65cf44 compiler/simplCore/OccurAnal.hs | 33 ++++++++++++++++++++-------- compiler/stranal/DmdAnal.hs | 27 +++-------------------- testsuite/tests/stranal/should_compile/all.T | 2 +- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/compiler/simplCore/OccurAnal.hs b/compiler/simplCore/OccurAnal.hs index 3eb20d0..36d6e7a 100644 --- a/compiler/simplCore/OccurAnal.hs +++ b/compiler/simplCore/OccurAnal.hs @@ -1395,19 +1395,29 @@ markManyIf False uds = uds {- Note [Use one-shot information] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The occurrrence analyser propagates one-shot-lambda information in two situation - * Applications: eg build (\cn -> blah) +The occurrrence analyser propagates one-shot-lambda information in two +situations: + + * Applications: eg build (\c n -> blah) + Propagate one-shot info from the strictness signature of 'build' to - the \cn + the \c n. + + This strictness signature can come from a module interface, in the case of + an imported function, or from a previous run of the demand analyser. * Let-bindings: eg let f = \c. let ... in \n -> blah in (build f, build f) + Propagate one-shot info from the demanand-info on 'f' to the lambdas in its RHS (which may not be syntactically at the top) -Some of this is done by the demand analyser, but this way it happens -much earlier, taking advantage of the strictness signature of -imported functions. + This information must have come from a previous run of the demanand + analyser. + +Previously, the demand analyser would *also* set the one-shot information, but +that code was buggy (see #11770), so doing it only in on place, namely here, is +saner. Note [Binders in case alternatives] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1534,7 +1544,7 @@ oneShotGroup :: OccEnv -> [CoreBndr] -> ( OccEnv , [CoreBndr] ) -- The result binders have one-shot-ness set that they might not have had originally. - -- This happens in (build (\cn -> e)). Here the occurrence analyser + -- This happens in (build (\c n -> e)). Here the occurrence analyser -- linearity context knows that c,n are one-shot, and it records that fact in -- the binder. This is useful to guide subsequent float-in/float-out tranformations @@ -1555,8 +1565,13 @@ oneShotGroup env@(OccEnv { occ_one_shots = ctxt }) bndrs = case ctxt of [] -> go [] bndrs (bndr : rev_bndrs) (one_shot : ctxt) -> go ctxt bndrs (bndr': rev_bndrs) - where - bndr' = updOneShotInfo bndr one_shot + where + bndr' = updOneShotInfo bndr one_shot + -- Use updOneShotInfo, not setOneShotInfo, as pre-existing + -- one-shot info might be better than what we can infer, e.g. + -- due to explicit use of the magic 'oneShot' function. + -- See Note [The oneShot function] + | otherwise = go ctxt bndrs (bndr:rev_bndrs) diff --git a/compiler/stranal/DmdAnal.hs b/compiler/stranal/DmdAnal.hs index 6ef911f..aae0c74 100644 --- a/compiler/stranal/DmdAnal.hs +++ b/compiler/stranal/DmdAnal.hs @@ -260,17 +260,13 @@ dmdAnal' env dmd (Case scrut case_bndr ty alts) (res_ty, Case scrut' case_bndr' ty alts') dmdAnal' env dmd (Let (NonRec id rhs) body) - = (body_ty2, Let (NonRec id2 annotated_rhs) body') + = (body_ty2, Let (NonRec id2 rhs') body') where (sig, lazy_fv, id1, rhs') = dmdAnalRhs NotTopLevel Nothing env id rhs (body_ty, body') = dmdAnal (extendAnalEnv NotTopLevel env id sig) dmd body (body_ty1, id2) = annotateBndr env body_ty id1 body_ty2 = addLazyFVs body_ty1 lazy_fv - -- Annotate top-level lambdas at RHS basing on the aggregated demand info - -- See Note [Annotating lambdas at right-hand side] - annotated_rhs = annLamWithShotness (idDemandInfo id2) rhs' - -- If the actual demand is better than the vanilla call -- demand, you might think that we might do better to re-analyse -- the RHS with the stronger demand. @@ -317,8 +313,8 @@ annLamWithShotness d e | Just (c, u') <- peelUseCall u , Lam bndr body <- e = if isTyVar bndr - then Lam bndr (go u body) - else Lam (setOneShotness c bndr) (go u' body) + then Lam bndr (go u body) + else Lam bndr (go u' body) | otherwise = e @@ -432,23 +428,6 @@ free variable |y|. Conversely, if the demand on |h| is unleashed right on the spot, we will get the desired result, namely, that |f| is strict in |y|. -Note [Annotating lambdas at right-hand side] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Let us take a look at the following example: - -g f = let x = 100 - h = \y -> f x y - in h 5 - -One can see that |h| is called just once, therefore the RHS of h can -be annotated as a one-shot lambda. This is done by the function -annLamWithShotness *a posteriori*, i.e., basing on the aggregated -usage demand on |h| from the body of |let|-expression, which is C1(U) -in this case. - -In other words, for locally-bound lambdas we can infer -one-shotness. - ************************************************************************ * * diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T index 3ac075b..dabc9fc 100644 --- a/testsuite/tests/stranal/should_compile/all.T +++ b/testsuite/tests/stranal/should_compile/all.T @@ -45,6 +45,6 @@ test('T9208', when(compiler_debugged(), expect_broken(9208)), compile, ['']) # Hence the above expect_broken. See comments in the Trac ticket test('T10694', [ grepCoreString(r'Str=') ], compile, ['-dppr-cols=200 -ddump-simpl']) -test('T11770', [ expect_broken(117700), checkCoreString("OneShot") ], compile, ['-ddump-simpl']) +test('T11770', [ checkCoreString('OneShot') ], compile, ['-ddump-simpl']) From git at git.haskell.org Wed Mar 30 10:36:03 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 10:36:03 +0000 (UTC) Subject: [commit: ghc] wip/T11770: Demand Analyzer: Do not set OneShot information (7a8dae3) Message-ID: <20160330103603.3219B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11770 Link : http://ghc.haskell.org/trac/ghc/changeset/7a8dae3b6ac0d5b4a5581072561ae4b02315b5d6/ghc >--------------------------------------------------------------- commit 7a8dae3b6ac0d5b4a5581072561ae4b02315b5d6 Author: Joachim Breitner Date: Wed Mar 30 10:05:28 2016 +0200 Demand Analyzer: Do not set OneShot information as suggested in ticket:11770#comment:1. This code was buggy (#11770), and the occurrence analyzer does the same job anyways. This also elaborates the notes in the occurrence analyzer accordingly. >--------------------------------------------------------------- 7a8dae3b6ac0d5b4a5581072561ae4b02315b5d6 compiler/simplCore/OccurAnal.hs | 33 ++++++++++++----- compiler/stranal/DmdAnal.hs | 55 +++------------------------- testsuite/tests/stranal/should_compile/all.T | 2 +- 3 files changed, 30 insertions(+), 60 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 7a8dae3b6ac0d5b4a5581072561ae4b02315b5d6 From git at git.haskell.org Wed Mar 30 10:54:50 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 10:54:50 +0000 (UTC) Subject: [commit: ghc] branch 'wip/T11731' created Message-ID: <20160330105450.571CA3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc New branch : wip/T11731 Referencing: 7ac5610606e8f338cd2eb92eb5d711e054d9d55a From git at git.haskell.org Wed Mar 30 10:54:53 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 10:54:53 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Used-once variables are not trivial (7ac5610) Message-ID: <20160330105453.7340B3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/7ac5610606e8f338cd2eb92eb5d711e054d9d55a/ghc >--------------------------------------------------------------- commit 7ac5610606e8f338cd2eb92eb5d711e054d9d55a Author: Joachim Breitner Date: Wed Mar 30 12:55:10 2016 +0200 Used-once variables are not trivial The specification for exprIsTrivial demands that we are unconditionally happy to duplicate the expression. This is not true for variables where we would like to exploit (or already have exploited) that they are used at most once. In order to preserve this property, they must not be duplicated nilly-willy. This fixes #11731 and comes with a test case. >--------------------------------------------------------------- 7ac5610606e8f338cd2eb92eb5d711e054d9d55a compiler/coreSyn/CoreUtils.hs | 12 +++++++- testsuite/.gitignore | 1 + testsuite/tests/simplCore/should_run/T11731.hs | 36 ++++++++++++++++++++++ testsuite/tests/simplCore/should_run/T11731.stderr | 1 + testsuite/tests/simplCore/should_run/all.T | 1 + 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index 1d9b83b..d02b934 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -62,6 +62,7 @@ import DataCon import PrimOp import Id import IdInfo +import Demand ( isUsedOnce ) import Type import Coercion import TyCon @@ -755,6 +756,13 @@ Note [exprIsTrivial] Note [Variables are trivial] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Variables are usually trivial. + +Except if 'isUsedOnce (idDemandInfo v) == True': +In this case we have previously determined that a variable is used at most +once, and we likely rely on this information, e.g. during code generation. In +this case, we are not unconditionally happy to duplicate, so we don?t. See #11731. + There used to be a gruesome test for (hasNoBinding v) in the Var case: exprIsTrivial (Var v) | hasNoBinding v = idArity v == 0 @@ -793,7 +801,9 @@ it off at source. -} exprIsTrivial :: CoreExpr -> Bool -exprIsTrivial (Var _) = True -- See Note [Variables are trivial] +exprIsTrivial (Var v) -- See Note [Variables are trivial] + | isUsedOnce (idDemandInfo v) = False + | otherwise = True exprIsTrivial (Type _) = True exprIsTrivial (Coercion _) = True exprIsTrivial (Lit lit) = litIsTrivial lit diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 8926e4e..b578602 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1474,6 +1474,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/simplCore/should_run/T5997 /tests/simplCore/should_run/T7101 /tests/simplCore/should_run/T7924 +/tests/simplCore/should_run/T11731 /tests/simplCore/should_run/T9128 /tests/simplCore/should_run/T9390 /tests/simplCore/should_run/runST diff --git a/testsuite/tests/simplCore/should_run/T11731.hs b/testsuite/tests/simplCore/should_run/T11731.hs new file mode 100644 index 0000000..e148507 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.hs @@ -0,0 +1,36 @@ +module Main (main ) where + +import Debug.Trace + +foo :: (a,b) -> a +foo (x,y) = x +{-# NOINLINE foo #-} + +wwMe :: Int -> (Int,Int) -> (Int, Int) +wwMe 0 p = + let a = fst p + b = snd p + -- This ensure sharing of b, as seen by the demand analyzer + + in foo p `seq` + -- This ensures that wwMe is strict in the tuple, but that the tuple + -- is preserved. + (b + a, a + b) + +wwMe n p = wwMe (n-1) (0,0) + -- ^ Make it recursive, so that it is attractive to worker-wrapper + +go :: Int -> IO () +go seed = do + let shareMeThunk = trace "Evaluated (should only happen once)" (seed + 1) + {-# NOINLINE shareMeThunk #-} + -- ^ This is the thunk that is wrongly evaluated twice. + + let (x,y) = wwMe 0 (seed,shareMeThunk) + + (x + y) `seq` return () + -- ^ Use both components +{-# NOINLINE go #-} + +main :: IO () +main = go 42 diff --git a/testsuite/tests/simplCore/should_run/T11731.stderr b/testsuite/tests/simplCore/should_run/T11731.stderr new file mode 100644 index 0000000..8d1fc60 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.stderr @@ -0,0 +1 @@ +Evaluated (should only happen once) diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T index 9c15b0f..7fd1812 100644 --- a/testsuite/tests/simplCore/should_run/all.T +++ b/testsuite/tests/simplCore/should_run/all.T @@ -71,3 +71,4 @@ test('T9128', normal, compile_and_run, ['']) test('T9390', normal, compile_and_run, ['']) test('T10830', extra_run_opts('+RTS -K100k -RTS'), compile_and_run, ['']) test('T11172', normal, compile_and_run, ['']) +test('T11731', normal, compile_and_run, ['-fspec-constr']) From git at git.haskell.org Wed Mar 30 12:42:40 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 12:42:40 +0000 (UTC) Subject: [commit: ghc] master: Don't recompute some free vars in lintCoercion (1757dd8) Message-ID: <20160330124240.EC8273A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1757dd8ebed0732018319e43e6468b868a6aceeb/ghc >--------------------------------------------------------------- commit 1757dd8ebed0732018319e43e6468b868a6aceeb Author: Bartosz Nitka Date: Tue Mar 29 19:37:54 2016 -0700 Don't recompute some free vars in lintCoercion As pointed out by @simonpj on D2044 we don't need to compute the free vars of the range of the substitution as most of them are already carried by the monad. This should be a tiny performance improvement over the version from before D2044. Also removes an extra function that is now unnecessary. Test Plan: ./validate && ./validate --slow Reviewers: goldfire, simonpj, austin, bgamari Reviewed By: simonpj Subscribers: thomie, simonmar, simonpj Differential Revision: https://phabricator.haskell.org/D2060 GHC Trac Issues: #11371 >--------------------------------------------------------------- 1757dd8ebed0732018319e43e6468b868a6aceeb compiler/coreSyn/CoreLint.hs | 18 ++++++++++++------ compiler/types/TyCoRep.hs | 5 ----- compiler/types/Type.hs | 1 - 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index bd750a3..ffbd659 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -1290,16 +1290,22 @@ lintCoercion co@(AppCo co1 co2) lintCoercion (ForAllCo tv1 kind_co co) = do { (_, k2) <- lintStarCoercion kind_co ; let tv2 = setTyVarKind tv1 k2 - ; (k3, k4, t1, t2, r) <- addInScopeVar tv1 $ lintCoercion co + ; addInScopeVar tv1 $ + do { + ; (k3, k4, t1, t2, r) <- lintCoercion co ; in_scope <- getInScope ; let tyl = mkNamedForAllTy tv1 Invisible t1 - subst = zipTvSubst [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo kind_co] - `extendTCvInScopeInScope` in_scope - -- We need free vars of `t2` in scope to satisfy - -- Note [The substitution invariant] + subst = mkTvSubst in_scope $ + -- We need both the free vars of the `t2` and the + -- free vars of the range of the substitution in + -- scope. All the free vars of `t2` and `kind_co` should + -- already be in `in_scope`, because they've been + -- linted and `tv2` has the same unique as `tv1`. + -- See Note [The substitution invariant] + unitVarEnv tv1 (TyVarTy tv2 `mkCastTy` mkSymCo kind_co) tyr = mkNamedForAllTy tv2 Invisible $ substTy subst t2 - ; return (k3, k4, tyl, tyr, r) } + ; return (k3, k4, tyl, tyr, r) } } lintCoercion (CoVarCo cv) | not (isCoVar cv) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index d6f5516..b1f35da 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -83,7 +83,6 @@ module TyCoRep ( getCvSubstEnv, getTCvInScope, isInScope, notElemTCvSubst, setTvSubstEnv, setCvSubstEnv, zapTCvSubst, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, - extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendCvSubstWithClone, extendTvSubst, extendTvSubstWithClone, @@ -1799,10 +1798,6 @@ extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst extendTCvInScopeSet (TCvSubst in_scope tenv cenv) vars = TCvSubst (extendInScopeSetSet in_scope vars) tenv cenv -extendTCvInScopeInScope :: TCvSubst -> InScopeSet -> TCvSubst -extendTCvInScopeInScope (TCvSubst in_scope tenv cenv) in_scope' - = TCvSubst (unionInScope in_scope in_scope') tenv cenv - extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst extendTCvSubst subst v ty | isTyVar v diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index a940200..c5561a3 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -158,7 +158,6 @@ module Type ( getTvSubstEnv, setTvSubstEnv, zapTCvSubst, getTCvInScope, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, - extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendTvSubst, extendTvSubstList, extendTvSubstAndInScope, isInScope, composeTCvSubstEnv, composeTCvSubst, zipTyEnv, zipCoEnv, From git at git.haskell.org Wed Mar 30 16:02:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:02:18 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Demand Analyzer: Do not set OneShot information (40ea4ea) Message-ID: <20160330160218.1AFF83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/40ea4ea1c424bc2889ea8ff32a59767dddd24bac/ghc >--------------------------------------------------------------- commit 40ea4ea1c424bc2889ea8ff32a59767dddd24bac Author: Joachim Breitner Date: Wed Mar 30 10:05:28 2016 +0200 Demand Analyzer: Do not set OneShot information as suggested in ticket:11770#comment:1. This code was buggy (#11770), and the occurrence analyzer does the same job anyways. This also elaborates the notes in the occurrence analyzer accordingly. >--------------------------------------------------------------- 40ea4ea1c424bc2889ea8ff32a59767dddd24bac compiler/simplCore/OccurAnal.hs | 33 ++++++++++++----- compiler/stranal/DmdAnal.hs | 55 +++------------------------- testsuite/tests/stranal/should_compile/all.T | 2 +- 3 files changed, 30 insertions(+), 60 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 40ea4ea1c424bc2889ea8ff32a59767dddd24bac From git at git.haskell.org Wed Mar 30 16:02:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:02:23 +0000 (UTC) Subject: [commit: ghc] wip/T11731: CSE: Do not add a "trivial_scrut -> case binder" mapping (89b4b03) Message-ID: <20160330160223.7C3F13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/89b4b0363d865c7adbb98793e51e4f7b4e91ec31/ghc >--------------------------------------------------------------- commit 89b4b0363d865c7adbb98793e51e4f7b4e91ec31 Author: Joachim Breitner Date: Wed Mar 30 18:00:15 2016 +0200 CSE: Do not add a "trivial_scrut -> case binder" mapping according to the existing strategy to replace, in the body of the expression "case x of y in e", occurrences of y with x (and not the other way around with non-trivial case expressions). Previously, the mapping was added to the environment, but never used, due to the exprIsTrivial guard in tryForCSE. But this is fragile if exprIsTrivial is modified, as proposed in #11731, hence the removal of this code smell. >--------------------------------------------------------------- 89b4b0363d865c7adbb98793e51e4f7b4e91ec31 compiler/simplCore/CSE.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/simplCore/CSE.hs b/compiler/simplCore/CSE.hs index b4e6e14..0a053d3 100644 --- a/compiler/simplCore/CSE.hs +++ b/compiler/simplCore/CSE.hs @@ -174,8 +174,13 @@ cseRhs :: CSEnv -> (OutBndr, InExpr) -> (CSEnv, (OutBndr, OutExpr)) cseRhs env (id',rhs) = case lookupCSEnv env rhs'' of Nothing - | always_active -> (extendCSEnv env rhs' id', (zapped_id, rhs')) - | otherwise -> (env, (id', rhs')) + | always_active -> (env', (zapped_id, rhs')) + | otherwise -> (env, (id', rhs')) + where + -- Do not add an unwanted trivial_scrut -> case binder mapping, according + -- to Note [Case binders 2]. + env' | Var {} <- rhs' = env + | otherwise = extendCSEnv env rhs' id' Just id | always_active -> (extendCSSubst env id' id_expr, (id', mkTicks ticks id_expr)) | otherwise -> (env, (id', mkTicks ticks id_expr)) From git at git.haskell.org Wed Mar 30 16:02:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:02:20 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Core pretty printer: Omit wild case binders (3250e00) Message-ID: <20160330160220.CE3FE3A301@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/3250e0000eaea87169d9de99a1cbab87f32f15b7/ghc >--------------------------------------------------------------- commit 3250e0000eaea87169d9de99a1cbab87f32f15b7 Author: Joachim Breitner Date: Wed Mar 30 13:22:26 2016 +0200 Core pretty printer: Omit wild case binders as they (especially their id info with absence information) clutter the output too much. They come back with debug_on. >--------------------------------------------------------------- 3250e0000eaea87169d9de99a1cbab87f32f15b7 compiler/coreSyn/PprCore.hs | 28 ++++++++++++++-------- compiler/hsSyn/HsBinds.hs | 2 +- compiler/stgSyn/StgSyn.hs | 2 +- compiler/utils/Outputable.hs | 2 +- .../tests/deSugar/should_compile/T2431.stderr | 2 +- .../tests/numeric/should_compile/T7116.stdout | 16 +++++-------- .../tests/simplCore/should_compile/T3717.stderr | 4 ++-- .../tests/simplCore/should_compile/T3772.stdout | 5 ++-- .../tests/simplCore/should_compile/T4908.stderr | 8 +++---- .../tests/simplCore/should_compile/T4930.stderr | 10 ++++---- .../tests/simplCore/should_compile/T5366.stdout | 3 ++- .../tests/simplCore/should_compile/T7360.stderr | 12 +++------- .../tests/simplCore/should_compile/T7865.stdout | 4 ++-- .../simplCore/should_compile/spec-inline.stderr | 28 +++++++++------------- 14 files changed, 59 insertions(+), 67 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 3250e0000eaea87169d9de99a1cbab87f32f15b7 From git at git.haskell.org Wed Mar 30 16:02:26 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:02:26 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Used-once variables are not trivial (3d7a846) Message-ID: <20160330160226.A07DE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/3d7a846f56db5eb0234f574c796abf7d81d502e5/ghc >--------------------------------------------------------------- commit 3d7a846f56db5eb0234f574c796abf7d81d502e5 Author: Joachim Breitner Date: Wed Mar 30 12:55:10 2016 +0200 Used-once variables are not trivial The specification for exprIsTrivial demands that we are unconditionally happy to duplicate the expression. This is not true for variables where we would like to exploit (or already have exploited) that they are used at most once. In order to preserve this property, they must not be duplicated nilly-willy. This fixes #11731 and comes with a test case. >--------------------------------------------------------------- 3d7a846f56db5eb0234f574c796abf7d81d502e5 compiler/coreSyn/CoreUtils.hs | 12 +++++++- testsuite/.gitignore | 1 + testsuite/tests/simplCore/should_run/T11731.hs | 36 ++++++++++++++++++++++ testsuite/tests/simplCore/should_run/T11731.stderr | 1 + testsuite/tests/simplCore/should_run/all.T | 1 + 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs index 1d9b83b..d02b934 100644 --- a/compiler/coreSyn/CoreUtils.hs +++ b/compiler/coreSyn/CoreUtils.hs @@ -62,6 +62,7 @@ import DataCon import PrimOp import Id import IdInfo +import Demand ( isUsedOnce ) import Type import Coercion import TyCon @@ -755,6 +756,13 @@ Note [exprIsTrivial] Note [Variables are trivial] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Variables are usually trivial. + +Except if 'isUsedOnce (idDemandInfo v) == True': +In this case we have previously determined that a variable is used at most +once, and we likely rely on this information, e.g. during code generation. In +this case, we are not unconditionally happy to duplicate, so we don?t. See #11731. + There used to be a gruesome test for (hasNoBinding v) in the Var case: exprIsTrivial (Var v) | hasNoBinding v = idArity v == 0 @@ -793,7 +801,9 @@ it off at source. -} exprIsTrivial :: CoreExpr -> Bool -exprIsTrivial (Var _) = True -- See Note [Variables are trivial] +exprIsTrivial (Var v) -- See Note [Variables are trivial] + | isUsedOnce (idDemandInfo v) = False + | otherwise = True exprIsTrivial (Type _) = True exprIsTrivial (Coercion _) = True exprIsTrivial (Lit lit) = litIsTrivial lit diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 8926e4e..b578602 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1474,6 +1474,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/simplCore/should_run/T5997 /tests/simplCore/should_run/T7101 /tests/simplCore/should_run/T7924 +/tests/simplCore/should_run/T11731 /tests/simplCore/should_run/T9128 /tests/simplCore/should_run/T9390 /tests/simplCore/should_run/runST diff --git a/testsuite/tests/simplCore/should_run/T11731.hs b/testsuite/tests/simplCore/should_run/T11731.hs new file mode 100644 index 0000000..e148507 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.hs @@ -0,0 +1,36 @@ +module Main (main ) where + +import Debug.Trace + +foo :: (a,b) -> a +foo (x,y) = x +{-# NOINLINE foo #-} + +wwMe :: Int -> (Int,Int) -> (Int, Int) +wwMe 0 p = + let a = fst p + b = snd p + -- This ensure sharing of b, as seen by the demand analyzer + + in foo p `seq` + -- This ensures that wwMe is strict in the tuple, but that the tuple + -- is preserved. + (b + a, a + b) + +wwMe n p = wwMe (n-1) (0,0) + -- ^ Make it recursive, so that it is attractive to worker-wrapper + +go :: Int -> IO () +go seed = do + let shareMeThunk = trace "Evaluated (should only happen once)" (seed + 1) + {-# NOINLINE shareMeThunk #-} + -- ^ This is the thunk that is wrongly evaluated twice. + + let (x,y) = wwMe 0 (seed,shareMeThunk) + + (x + y) `seq` return () + -- ^ Use both components +{-# NOINLINE go #-} + +main :: IO () +main = go 42 diff --git a/testsuite/tests/simplCore/should_run/T11731.stderr b/testsuite/tests/simplCore/should_run/T11731.stderr new file mode 100644 index 0000000..8d1fc60 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.stderr @@ -0,0 +1 @@ +Evaluated (should only happen once) diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T index 9c15b0f..7fd1812 100644 --- a/testsuite/tests/simplCore/should_run/all.T +++ b/testsuite/tests/simplCore/should_run/all.T @@ -71,3 +71,4 @@ test('T9128', normal, compile_and_run, ['']) test('T9390', normal, compile_and_run, ['']) test('T10830', extra_run_opts('+RTS -K100k -RTS'), compile_and_run, ['']) test('T11172', normal, compile_and_run, ['']) +test('T11731', normal, compile_and_run, ['-fspec-constr']) From git at git.haskell.org Wed Mar 30 16:02:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:02:29 +0000 (UTC) Subject: [commit: ghc] wip/T11731's head updated: Used-once variables are not trivial (3d7a846) Message-ID: <20160330160229.021223A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T11731' now includes: a76e6f5 Typos in non-code 40ea4ea Demand Analyzer: Do not set OneShot information 3250e00 Core pretty printer: Omit wild case binders 89b4b03 CSE: Do not add a "trivial_scrut -> case binder" mapping 3d7a846 Used-once variables are not trivial From git at git.haskell.org Wed Mar 30 16:03:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:03:29 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (d01be44) Message-ID: <20160330160329.5FEC13A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/d01be445b8839e48ab8b1c9dbc921c36f5150c24/ghc >--------------------------------------------------------------- commit d01be445b8839e48ab8b1c9dbc921c36f5150c24 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- d01be445b8839e48ab8b1c9dbc921c36f5150c24 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc d01be445b8839e48ab8b1c9dbc921c36f5150c24 From git at git.haskell.org Wed Mar 30 16:03:32 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:03:32 +0000 (UTC) Subject: [commit: ghc] wip/T10613: State hack hack in ticky report (8ecac0e) Message-ID: <20160330160332.1CAF23A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/8ecac0e40f8dc54c8e010c43b36dfa5e71dd2f33/ghc >--------------------------------------------------------------- commit 8ecac0e40f8dc54c8e010c43b36dfa5e71dd2f33 Author: Joachim Breitner Date: Wed Mar 23 11:10:25 2016 +0100 State hack hack in ticky report In the ticky report, do not mark a function with a State# argument as its first argument as single-entry. >--------------------------------------------------------------- 8ecac0e40f8dc54c8e010c43b36dfa5e71dd2f33 compiler/codeGen/StgCmmClosure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index b467048..3b83b8e 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -234,7 +234,10 @@ mkLFReEntrant _ _ [] _ = pprPanic "mkLFReEntrant" empty mkLFReEntrant top fvs args arg_descr = LFReEntrant top os_info (length args) (null fvs) arg_descr - where os_info = idOneShotInfo (head args) + where + state_hack_hack = isStateHackType (idType (head args)) + os_info | state_hack_hack = noOneShotInfo + | otherwise = idOneShotInfo (head args) ------------- mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo From git at git.haskell.org Wed Mar 30 16:03:34 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:03:34 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Evac: Do not evaluate selector thunks pointing to counting indirections (2ce00cd) Message-ID: <20160330160334.BA2273A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/2ce00cd7f1fe352087b0c0d7a0c0b371a2e58802/ghc >--------------------------------------------------------------- commit 2ce00cd7f1fe352087b0c0d7a0c0b371a2e58802 Author: Joachim Breitner Date: Wed Mar 23 13:50:00 2016 +0100 Evac: Do not evaluate selector thunks pointing to counting indirections >--------------------------------------------------------------- 2ce00cd7f1fe352087b0c0d7a0c0b371a2e58802 rts/sm/Evac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 3b4314b..9369543 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -998,12 +998,17 @@ selector_loop: } case IND: - case COUNTING_IND: case IND_STATIC: // Again, we might need to untag a constructor. selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); goto selector_loop; + case COUNTING_IND: + // do not short cut a COUNTING_IND, as we would miss a the count + // Can we simply tick the counter here? Not really: If this selector + // thunk is not going to be used, we counted more than we wanted! + goto bale_out; + case BLACKHOLE: { StgClosure *r; From git at git.haskell.org Wed Mar 30 16:03:37 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:03:37 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Temporarily move regular entry counting to the COUNTING_IND (e3fd9f4) Message-ID: <20160330160337.6EE2E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/e3fd9f4d0a670ffca0929f7911eced8221ff1f08/ghc >--------------------------------------------------------------- commit e3fd9f4d0a670ffca0929f7911eced8221ff1f08 Author: Joachim Breitner Date: Wed Mar 23 14:28:34 2016 +0100 Temporarily move regular entry counting to the COUNTING_IND >--------------------------------------------------------------- e3fd9f4d0a670ffca0929f7911eced8221ff1f08 compiler/codeGen/StgCmmBind.hs | 8 ++++++-- rts/StgMiscClosures.cmm | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 5951175..8672273 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -609,9 +609,13 @@ thunkCode cl_info fv_details _cc node arity body -- Heap overflow check ; entryHeapCheck cl_info node' arity [] $ do - { -- Overwrite with black hole if necessary + { + -- Disabled for now, as we (temporarily unconditionally) move the + -- counting to the counting indirection + -- tickyEnterThunk cl_info + + -- Overwrite with black hole if necessary -- but *after* the heap-overflow check - ; tickyEnterThunk cl_info ; when (blackHoleOnEntry cl_info && node_points) (blackHoleIt node) diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 96b95aa..0f27fdb 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -283,6 +283,7 @@ INFO_TABLE(stg_COUNTING_IND,1,2,COUNTING_IND,"COUNTING_IND","COUNTING_IND") StgEntCounter_multi_entry_count(ent_ctr) = StgEntCounter_multi_entry_count(ent_ctr) + 1; } StgCountingInd_entries(clos) = entries + 1; + StgEntCounter_entry_count(ent_ctr) = StgEntCounter_entry_count(ent_ctr) + 1; #if defined(TICKY_TICKY) && !defined(PROFILING) /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than From git at git.haskell.org Wed Mar 30 16:03:39 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:03:39 +0000 (UTC) Subject: [commit: ghc] wip/T10613's head updated: Temporarily move regular entry counting to the COUNTING_IND (e3fd9f4) Message-ID: <20160330160339.A76443A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T10613' now includes: d5d6804 rename: Disallow type signatures in patterns in plain Haskell ae6a56e users-guide/rel-notes: Note broken-ness of ImpredicativeTypes eb6b709 base: Fix haddock typo cb9a1e6 Add testcase for #11770 a76e6f5 Typos in non-code 40ea4ea Demand Analyzer: Do not set OneShot information 3250e00 Core pretty printer: Omit wild case binders 89b4b03 CSE: Do not add a "trivial_scrut -> case binder" mapping 3d7a846 Used-once variables are not trivial d01be44 Rough working implementation of #10613 8ecac0e State hack hack in ticky report 2ce00cd Evac: Do not evaluate selector thunks pointing to counting indirections e3fd9f4 Temporarily move regular entry counting to the COUNTING_IND From git at git.haskell.org Wed Mar 30 16:04:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:04:58 +0000 (UTC) Subject: [commit: ghc] master: Do not claim that -O2 does not do better than -O (3d245bf) Message-ID: <20160330160458.E0ED83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/3d245bf5255ebfb72813596fa93b9051f7518321/ghc >--------------------------------------------------------------- commit 3d245bf5255ebfb72813596fa93b9051f7518321 Author: Joachim Breitner Date: Wed Mar 30 16:09:36 2016 +0200 Do not claim that -O2 does not do better than -O when in fact it does. This was pointed out by Johannes Bechberger and supported with seemingly statistically sound evidence in his Bachelor thesis: Of the benchmark shootout programs, 80% benefit significantly by switchtng from -O to -O2. See https://uqudy.serpens.uberspace.de/blog/2016/02/08/ghc-performance-over-time/ for a few raw numbers. Differential Revision: https://phabricator.haskell.org/D2065 >--------------------------------------------------------------- 3d245bf5255ebfb72813596fa93b9051f7518321 docs/users_guide/using-optimisation.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/users_guide/using-optimisation.rst b/docs/users_guide/using-optimisation.rst index bc8e700..5e4995d 100644 --- a/docs/users_guide/using-optimisation.rst +++ b/docs/users_guide/using-optimisation.rst @@ -79,9 +79,6 @@ one reason to stick to no-optimisation when developing code. runtime or space *worse* if you're unlucky. They are normally turned on or off individually. - At the moment, ``-O2`` is *unlikely* to produce better code than - ``-O``. - .. ghc-flag:: -Odph .. index:: From git at git.haskell.org Wed Mar 30 16:41:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 16:41:51 +0000 (UTC) Subject: [commit: ghc] master: Comments only in Unify.hs (973633a) Message-ID: <20160330164151.EDB583A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/973633ae3327238162ce0e497ce049265ea3e6ee/ghc >--------------------------------------------------------------- commit 973633ae3327238162ce0e497ce049265ea3e6ee Author: Simon Peyton Jones Date: Wed Mar 30 17:43:14 2016 +0100 Comments only in Unify.hs To clarify what the "pure unifier" does, compared to the "impure unifiers" in the type checker. >--------------------------------------------------------------- 973633ae3327238162ce0e497ce049265ea3e6ee compiler/types/Unify.hs | 150 ++++++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 69 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 973633ae3327238162ce0e497ce049265ea3e6ee From git at git.haskell.org Wed Mar 30 18:49:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 18:49:18 +0000 (UTC) Subject: [commit: ghc] master: rts/posix/Itimer.c: Handle EINTR when reading timerfd (7aa4c52) Message-ID: <20160330184918.A4BA33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/7aa4c52f9df1705258f43f9c003c17af97401693/ghc >--------------------------------------------------------------- commit 7aa4c52f9df1705258f43f9c003c17af97401693 Author: Erik de Castro Lopo Date: Mon Mar 28 14:29:37 2016 +1100 rts/posix/Itimer.c: Handle EINTR when reading timerfd Commit 8626d76a72 added checking of the return value when reading from the `timer_fd` and calling `sysErrorBelch` to print a warning message. However some error causes (like EINTR) are benign and should just be ignored. Test Plan: validate Reviewers: hvr, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2040 >--------------------------------------------------------------- 7aa4c52f9df1705258f43f9c003c17af97401693 rts/posix/Itimer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index b833295..8915446 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -202,10 +202,15 @@ static void *itimer_thread_func(void *_handle_tick) while (1) { if (USE_TIMERFD_FOR_ITIMER) { - if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) - sysErrorBelch("Itimer: read(timer_fd) failed"); + if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) { + if (errno != EINTR) { + sysErrorBelch("Itimer: read(timerfd) failed"); + } + } } else { - usleep(TimeToUS(itimer_interval)); + if (usleep(TimeToUS(itimer_interval)) != 0 && errno != EINTR) { + sysErrorBelch("usleep(TimeToUS(itimer_interval) failed"); + } } switch (itimer_state) { case RUNNING: @@ -222,7 +227,7 @@ static void *itimer_thread_func(void *_handle_tick) return NULL; } } - return NULL; + return NULL; // Never reached. } #endif From git at git.haskell.org Wed Mar 30 19:20:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:20:27 +0000 (UTC) Subject: [commit: ghc] master: ghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE (58bbb40) Message-ID: <20160330192027.ED8B43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/58bbb40ba23860df2ede1275493ef32ba69a2083/ghc >--------------------------------------------------------------- commit 58bbb40ba23860df2ede1275493ef32ba69a2083 Author: Ben Gamari Date: Wed Mar 30 10:29:02 2016 +0200 ghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE There is no benefit to be had from inlining this function and it may defeat rewrite rules if inlined early. See #11772.. Test Plan: Validate, nofib Reviewers: simonpj, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2057 GHC Trac Issues: #11772 >--------------------------------------------------------------- 58bbb40ba23860df2ede1275493ef32ba69a2083 libraries/ghc-prim/GHC/CString.hs | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/libraries/ghc-prim/GHC/CString.hs b/libraries/ghc-prim/GHC/CString.hs index 53d1ddd..19e6f75 100644 --- a/libraries/ghc-prim/GHC/CString.hs +++ b/libraries/ghc-prim/GHC/CString.hs @@ -24,7 +24,7 @@ import GHC.Types import GHC.Prim ----------------------------------------------------------------------------- --- Unpacking C strings} +-- Unpacking C strings ----------------------------------------------------------------------------- -- This code is needed for virtually all programs, since it's used for @@ -34,11 +34,33 @@ import GHC.Prim -- stuff uses Strings in the representation, so to give representations for -- ghc-prim types we need unpackCString# +{- +Note [Inlining unpackCString#] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +There's really no point in ever inlining things like unpackCString# as the loop +doesn't specialise in an interesting way and we can't deforest the list +constructors (we'd want to use unpackFoldrCString# for this). Moreover, it's +pretty small, so there's a danger that it'll be inlined at every literal, which +is a waste. + +Moreover, inlining early may interfere with a variety of rules that are supposed +to match unpackCString#, + + * BuiltInRules in PrelRules.hs; e.g. + eqString (unpackCString# (Lit s1)) (unpackCString# (Lit s2) + = s1 == s2 + + * unpacking rules; e.g. in GHC.Base, + unpackCString# a + = build (unpackFoldrCString# a) + + * stream fusion rules; e.g. in the `text` library, + unstream (S.map safe (S.streamList (GHC.unpackCString# a))) + = unpackCString# a +-} + unpackCString# :: Addr# -> [Char] {-# NOINLINE unpackCString# #-} - -- There's really no point in inlining this, ever, as the loop doesn't - -- specialise in an interesting But it's pretty small, so there's a danger - -- that it'll be inlined at every literal, which is a waste unpackCString# addr = unpack 0# where @@ -64,7 +86,7 @@ unpackFoldrCString# :: Addr# -> (Char -> a -> a) -> a -> a -- Usually the unpack-list rule turns unpackFoldrCString# into unpackCString# --- It also has a BuiltInRule in PrelRules.lhs: +-- It also has a BuiltInRule in PrelRules.hs: -- unpackFoldrCString# "foo" c (unpackFoldrCString# "baz" c n) -- = unpackFoldrCString# "foobaz" c n @@ -85,7 +107,10 @@ unpackFoldrCString# addr f z where !ch = indexCharOffAddr# addr nh +-- There's really no point in inlining this for the same reasons as +-- unpackCString. See Note [Inlining unpackCString#] above for details. unpackCStringUtf8# :: Addr# -> [Char] +{-# NOINLINE unpackCStringUtf8# #-} unpackCStringUtf8# addr = unpack 0# where @@ -110,7 +135,10 @@ unpackCStringUtf8# addr where !ch = indexCharOffAddr# addr nh +-- There's really no point in inlining this for the same reasons as +-- unpackCString. See Note [Inlining unpackCString#] above for details. unpackNBytes# :: Addr# -> Int# -> [Char] +{-# NOINLINE unpackNBytes# #-} unpackNBytes# _addr 0# = [] unpackNBytes# addr len# = unpack [] (len# -# 1#) where From git at git.haskell.org Wed Mar 30 19:20:30 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:20:30 +0000 (UTC) Subject: [commit: ghc] master: Defer inlining of Ord methods (c0e3e63) Message-ID: <20160330192030.A130F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/c0e3e63eca6b0f7a21ae51d992c88821195ad94d/ghc >--------------------------------------------------------------- commit c0e3e63eca6b0f7a21ae51d992c88821195ad94d Author: Ben Gamari Date: Wed Mar 30 10:46:39 2016 +0200 Defer inlining of Ord methods This performs the same refactoring performed in D1980 for Eq on Ord, rewriting the class operations in terms of monomorphic helpers than can be reliably matched in rewrite rules. >--------------------------------------------------------------- c0e3e63eca6b0f7a21ae51d992c88821195ad94d libraries/base/GHC/Int.hs | 100 +++++++++++++++++++++++++++++++++----- libraries/base/GHC/Word.hs | 100 +++++++++++++++++++++++++++++++++----- libraries/ghc-prim/GHC/Classes.hs | 38 +++++++++++++-- 3 files changed, 207 insertions(+), 31 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc c0e3e63eca6b0f7a21ae51d992c88821195ad94d From git at git.haskell.org Wed Mar 30 19:20:33 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:20:33 +0000 (UTC) Subject: [commit: ghc] master: ghc-prim: Delay inlining of {gt, ge, lt, le}Int to phase 1 (d1179c4) Message-ID: <20160330192033.4C12F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/d1179c4bff6d05cc9e86eee3e2d2cee707983c90/ghc >--------------------------------------------------------------- commit d1179c4bff6d05cc9e86eee3e2d2cee707983c90 Author: Ben Gamari Date: Wed Mar 30 10:09:36 2016 +0200 ghc-prim: Delay inlining of {gt,ge,lt,le}Int to phase 1 Otherwise rewrite rules may not get an opporunity to fire. >--------------------------------------------------------------- d1179c4bff6d05cc9e86eee3e2d2cee707983c90 libraries/ghc-prim/GHC/Classes.hs | 18 ++++++++++++------ testsuite/tests/perf/compiler/T4007.stdout | 4 ++-- testsuite/tests/perf/haddock/all.T | 5 +++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs index a9d5111..65fdfcc 100644 --- a/libraries/ghc-prim/GHC/Classes.hs +++ b/libraries/ghc-prim/GHC/Classes.hs @@ -90,8 +90,8 @@ the @(==)@ class operation rule may rewrite the predicate before our @break@ rule has a chance to fire. For this reason, most of the primitive types in @base@ have 'Eq' instances -defined in terms of helper functions with delayed inlinings. For instance, - at Word8@\'s @Eq@ instance looks like, +defined in terms of helper functions with inlinings delayed to phase 1. For +instance, @Word8@\'s @Eq@ instance looks like, > instance Eq Word8 where > (==) = eqWord8 @@ -176,6 +176,7 @@ instance Eq Word where (==) = eqWord (/=) = neWord +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqWord #-} {-# INLINE [1] neWord #-} eqWord, neWord :: Word -> Word -> Bool @@ -187,6 +188,7 @@ instance Eq Char where (==) = eqChar (/=) = neChar +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqChar #-} {-# INLINE [1] neChar #-} eqChar, neChar :: Char -> Char -> Bool @@ -196,6 +198,7 @@ eqChar, neChar :: Char -> Char -> Bool instance Eq Float where (==) = eqFloat +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqFloat #-} eqFloat :: Float -> Float -> Bool (F# x) `eqFloat` (F# y) = isTrue# (x `eqFloat#` y) @@ -203,6 +206,7 @@ eqFloat :: Float -> Float -> Bool instance Eq Double where (==) = eqDouble +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqDouble #-} eqDouble :: Double -> Double -> Bool (D# x) `eqDouble` (D# y) = isTrue# (x ==## y) @@ -211,6 +215,7 @@ instance Eq Int where (==) = eqInt (/=) = neInt +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqInt #-} {-# INLINE [1] neInt #-} eqInt, neInt :: Int -> Int -> Bool @@ -363,10 +368,11 @@ instance Ord Int where (>=) = geInt (>) = gtInt -{-# INLINE gtInt #-} -{-# INLINE geInt #-} -{-# INLINE ltInt #-} -{-# INLINE leInt #-} +-- See GHC.Classes#matching_overloaded_methods_in_rules +{-# INLINE [1] gtInt #-} +{-# INLINE [1] geInt #-} +{-# INLINE [1] ltInt #-} +{-# INLINE [1] leInt #-} gtInt, geInt, ltInt, leInt :: Int -> Int -> Bool (I# x) `gtInt` (I# y) = isTrue# (x ># y) (I# x) `geInt` (I# y) = isTrue# (x >=# y) diff --git a/testsuite/tests/perf/compiler/T4007.stdout b/testsuite/tests/perf/compiler/T4007.stdout index c924781..e7ccd42 100644 --- a/testsuite/tests/perf/compiler/T4007.stdout +++ b/testsuite/tests/perf/compiler/T4007.stdout @@ -7,8 +7,8 @@ Rule fired: Class op return Rule fired: Class op foldr Rule fired: Class op >> Rule fired: Class op return -Rule fired: <# -Rule fired: tagToEnum# Rule fired: Class op foldr Rule fired: fold/build +Rule fired: <# +Rule fired: tagToEnum# Rule fired: unpack-list diff --git a/testsuite/tests/perf/haddock/all.T b/testsuite/tests/perf/haddock/all.T index fd44f2b..ebba365 100644 --- a/testsuite/tests/perf/haddock/all.T +++ b/testsuite/tests/perf/haddock/all.T @@ -51,7 +51,7 @@ test('haddock.base', test('haddock.Cabal', [unless(in_tree_compiler(), skip), req_haddock ,stats_num_field('bytes allocated', - [(wordsize(64), 11517963232, 5) + [(wordsize(64), 10941742184, 5) # 2012-08-14: 3255435248 (amd64/Linux) # 2012-08-29: 3324606664 (amd64/Linux, new codegen) # 2012-10-08: 3373401360 (amd64/Linux) @@ -75,7 +75,8 @@ test('haddock.Cabal', # 2015-12-11: 8114833312 (amd64/Linux) - TypeInType (See #11196) # 2015-12-17: 9982130512 (amd64/Linux) - Update Haddock to master # 2015-12-22: 10519532424 (amd64/Linux) - Lots of new Semigroup instances in Cabal - # 2016-03-29: 11517963232 (amd64/Linux) - not yet investigated + # 2016-03-29: 11517963232 (amd64/Linux) - not yet investigated + # 2016-03-30: 10941742184 (amd64/Linux) - defer inlining of Int* Ord methods ,(platform('i386-unknown-mingw32'), 3293415576, 5) # 2012-10-30: 1733638168 (x86/Windows) From git at git.haskell.org Wed Mar 30 19:49:35 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:49:35 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: RTS: Fix & refactor "portable inline" macros (0e95953) Message-ID: <20160330194935.CD89E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/0e959533b52741f1735d0290caf359659e64bbe3/ghc >--------------------------------------------------------------- commit 0e959533b52741f1735d0290caf359659e64bbe3 Author: Herbert Valerio Riedel Date: Sat Mar 26 00:59:31 2016 +0100 RTS: Fix & refactor "portable inline" macros Turns out the current macros for gnu90-style inline semantics stopped working with GCC 5 (and possibly also with Apple's GCC) which switched on `__GNUC_STDC_INLINE__` by default falling back to using the suboptimal `static inline` mode. However, C99 supports an equivalent (as far as our use-case is concerned) `extern inline` mode. See also http://www.greenend.org.uk/rjk/tech/inline.html for a write-up of gnu90 vs C99 semantics. This patch also removes the MSVC case as VS2015 is supposed to finally catch up to C99 (and C11), so we don't need any special care for MSVC anymore. Reviewed By: erikd, austin Differential Revision: https://phabricator.haskell.org/D2039 (cherry picked from commit 882179de09f9bd466b0e7ca83522aee0d3d7144a) >--------------------------------------------------------------- 0e959533b52741f1735d0290caf359659e64bbe3 includes/Stg.h | 76 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/includes/Stg.h b/includes/Stg.h index a8ab5ca..a2894a5 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -129,51 +129,53 @@ * EXTERN_INLINE is for functions that we want to inline sometimes * (we also compile a static version of the function; see Inlines.c) */ -#if defined(__GNUC__) || defined( __INTEL_COMPILER) -# define INLINE_HEADER static inline -# define INLINE_ME inline -# define STATIC_INLINE INLINE_HEADER - -// The special "extern inline" behaviour is now only supported by gcc -// when _GNUC_GNU_INLINE__ is defined, and you have to use -// __attribute__((gnu_inline)). So when we don't have this, we use -// ordinary static inline. -// -// Apple's gcc defines __GNUC_GNU_INLINE__ without providing -// gnu_inline, so we exclude MacOS X and fall through to the safe -// version. +// We generally assume C99 semantics albeit these two definitions work fine even +// when gnu90 semantics are active (i.e. when __GNUC_GNU_INLINE__ is defined or +// when a GCC older than 4.2 is used) // -#if defined(__GNUC_GNU_INLINE__) && !defined(__APPLE__) -# if defined(KEEP_INLINES) -# define EXTERN_INLINE inline -# else -# define EXTERN_INLINE extern inline __attribute__((gnu_inline)) -# endif -#else -# if defined(KEEP_INLINES) -# define EXTERN_INLINE -# else -# define EXTERN_INLINE INLINE_HEADER -# endif +// The problem, however, is with 'extern inline' whose semantics significantly +// differs between gnu90 and C99 +#define INLINE_HEADER static inline +#define INLINE_ME inline +#define STATIC_INLINE static inline + +// Figure out whether `__attributes__((gnu_inline))` is needed +// to force gnu90-style 'external inline' semantics. +#if defined(FORCE_GNU_INLINE) +// disable auto-detection since HAVE_GNU_INLINE has been defined externally +#elif __GNUC_GNU_INLINE__ && __GNUC__ == 4 && __GNUC_MINOR__ == 2 +// GCC 4.2.x didn't properly support C99 inline semantics (GCC 4.3 was the first +// release to properly support C99 inline semantics), and therefore warned when +// using 'extern inline' while in C99 mode unless `__attributes__((gnu_inline))` +// was explicitly set. +# define FORCE_GNU_INLINE 1 #endif -#elif defined(_MSC_VER) - -# define INLINE_HEADER __inline static -# define INLINE_ME __inline -# define STATIC_INLINE INLINE_HEADER - +#if FORCE_GNU_INLINE +// Force compiler into gnu90 semantics # if defined(KEEP_INLINES) -# define EXTERN_INLINE __inline +# define EXTERN_INLINE inline __attribute__((gnu_inline)) # else -# define EXTERN_INLINE __inline extern +# define EXTERN_INLINE extern inline __attribute__((gnu_inline)) +# endif +#elif __GNUC_GNU_INLINE__ +// we're currently in gnu90 inline mode by default and +// __attribute__((gnu_inline)) may not be supported, so better leave it off +# if defined(KEEP_INLINES) +# define EXTERN_INLINE inline +# else +# define EXTERN_INLINE extern inline # endif - #else - -# error "Don't know how to inline functions with your C compiler." - +// Assume C99 semantics (yes, this curiously results in swapped definitions!) +// This is the preferred branch, and at some point we may drop support for +// compilers not supporting C99 semantics altogether. +# if defined(KEEP_INLINES) +# define EXTERN_INLINE extern inline +# else +# define EXTERN_INLINE inline +# endif #endif From git at git.haskell.org Wed Mar 30 19:49:38 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:49:38 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: ghc-prim: Delay inlining of {gt, ge, lt, le}Int to phase 1 (c816395) Message-ID: <20160330194938.819E63A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/c8163959e03d9c5777d3b02be38f3591d3d169a2/ghc >--------------------------------------------------------------- commit c8163959e03d9c5777d3b02be38f3591d3d169a2 Author: Ben Gamari Date: Wed Mar 30 10:09:36 2016 +0200 ghc-prim: Delay inlining of {gt,ge,lt,le}Int to phase 1 Otherwise rewrite rules may not get an opporunity to fire. (cherry picked from commit d1179c4bff6d05cc9e86eee3e2d2cee707983c90) >--------------------------------------------------------------- c8163959e03d9c5777d3b02be38f3591d3d169a2 libraries/ghc-prim/GHC/Classes.hs | 18 ++++++++++++------ testsuite/tests/perf/compiler/T4007.stdout | 4 ++-- testsuite/tests/perf/haddock/all.T | 5 +++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs index a9d5111..65fdfcc 100644 --- a/libraries/ghc-prim/GHC/Classes.hs +++ b/libraries/ghc-prim/GHC/Classes.hs @@ -90,8 +90,8 @@ the @(==)@ class operation rule may rewrite the predicate before our @break@ rule has a chance to fire. For this reason, most of the primitive types in @base@ have 'Eq' instances -defined in terms of helper functions with delayed inlinings. For instance, - at Word8@\'s @Eq@ instance looks like, +defined in terms of helper functions with inlinings delayed to phase 1. For +instance, @Word8@\'s @Eq@ instance looks like, > instance Eq Word8 where > (==) = eqWord8 @@ -176,6 +176,7 @@ instance Eq Word where (==) = eqWord (/=) = neWord +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqWord #-} {-# INLINE [1] neWord #-} eqWord, neWord :: Word -> Word -> Bool @@ -187,6 +188,7 @@ instance Eq Char where (==) = eqChar (/=) = neChar +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqChar #-} {-# INLINE [1] neChar #-} eqChar, neChar :: Char -> Char -> Bool @@ -196,6 +198,7 @@ eqChar, neChar :: Char -> Char -> Bool instance Eq Float where (==) = eqFloat +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqFloat #-} eqFloat :: Float -> Float -> Bool (F# x) `eqFloat` (F# y) = isTrue# (x `eqFloat#` y) @@ -203,6 +206,7 @@ eqFloat :: Float -> Float -> Bool instance Eq Double where (==) = eqDouble +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqDouble #-} eqDouble :: Double -> Double -> Bool (D# x) `eqDouble` (D# y) = isTrue# (x ==## y) @@ -211,6 +215,7 @@ instance Eq Int where (==) = eqInt (/=) = neInt +-- See GHC.Classes#matching_overloaded_methods_in_rules {-# INLINE [1] eqInt #-} {-# INLINE [1] neInt #-} eqInt, neInt :: Int -> Int -> Bool @@ -363,10 +368,11 @@ instance Ord Int where (>=) = geInt (>) = gtInt -{-# INLINE gtInt #-} -{-# INLINE geInt #-} -{-# INLINE ltInt #-} -{-# INLINE leInt #-} +-- See GHC.Classes#matching_overloaded_methods_in_rules +{-# INLINE [1] gtInt #-} +{-# INLINE [1] geInt #-} +{-# INLINE [1] ltInt #-} +{-# INLINE [1] leInt #-} gtInt, geInt, ltInt, leInt :: Int -> Int -> Bool (I# x) `gtInt` (I# y) = isTrue# (x ># y) (I# x) `geInt` (I# y) = isTrue# (x >=# y) diff --git a/testsuite/tests/perf/compiler/T4007.stdout b/testsuite/tests/perf/compiler/T4007.stdout index c924781..e7ccd42 100644 --- a/testsuite/tests/perf/compiler/T4007.stdout +++ b/testsuite/tests/perf/compiler/T4007.stdout @@ -7,8 +7,8 @@ Rule fired: Class op return Rule fired: Class op foldr Rule fired: Class op >> Rule fired: Class op return -Rule fired: <# -Rule fired: tagToEnum# Rule fired: Class op foldr Rule fired: fold/build +Rule fired: <# +Rule fired: tagToEnum# Rule fired: unpack-list diff --git a/testsuite/tests/perf/haddock/all.T b/testsuite/tests/perf/haddock/all.T index 4818c20..c33efcf 100644 --- a/testsuite/tests/perf/haddock/all.T +++ b/testsuite/tests/perf/haddock/all.T @@ -51,7 +51,7 @@ test('haddock.base', test('haddock.Cabal', [unless(in_tree_compiler(), skip), req_haddock ,stats_num_field('bytes allocated', - [(wordsize(64), 11123698216, 5) + [(wordsize(64), 10941742184, 5) # 2012-08-14: 3255435248 (amd64/Linux) # 2012-08-29: 3324606664 (amd64/Linux, new codegen) # 2012-10-08: 3373401360 (amd64/Linux) @@ -75,7 +75,8 @@ test('haddock.Cabal', # 2015-12-11: 8114833312 (amd64/Linux) - TypeInType (See #11196) # 2015-12-17: 9982130512 (amd64/Linux) - Update Haddock to master # 2015-12-22: 10519532424 (amd64/Linux) - Lots of new Semigroup instances in Cabal - # 2015-03-08: 11123698216 (amd64/Linux) - Cabal update + # 2016-03-29: 11517963232 (amd64/Linux) - not yet investigated + # 2016-03-30: 10941742184 (amd64/Linux) - defer inlining of Int* Ord methods ,(platform('i386-unknown-mingw32'), 3293415576, 5) # 2012-10-30: 1733638168 (x86/Windows) From git at git.haskell.org Wed Mar 30 19:49:41 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:49:41 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Defer inlining of Ord methods (007bb34) Message-ID: <20160330194941.3B0663A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/007bb3477302a6e0146ece9ce15993afb20a00c2/ghc >--------------------------------------------------------------- commit 007bb3477302a6e0146ece9ce15993afb20a00c2 Author: Ben Gamari Date: Wed Mar 30 10:46:39 2016 +0200 Defer inlining of Ord methods This performs the same refactoring performed in D1980 for Eq on Ord, rewriting the class operations in terms of monomorphic helpers than can be reliably matched in rewrite rules. (cherry picked from commit c0e3e63eca6b0f7a21ae51d992c88821195ad94d) >--------------------------------------------------------------- 007bb3477302a6e0146ece9ce15993afb20a00c2 libraries/base/GHC/Int.hs | 100 +++++++++++++++++++++++++++++++++----- libraries/base/GHC/Word.hs | 100 +++++++++++++++++++++++++++++++++----- libraries/ghc-prim/GHC/Classes.hs | 38 +++++++++++++-- 3 files changed, 207 insertions(+), 31 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 007bb3477302a6e0146ece9ce15993afb20a00c2 From git at git.haskell.org Wed Mar 30 19:49:43 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:49:43 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: ghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE (c261a15) Message-ID: <20160330194943.DC7343A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/c261a15d454962df965d839d262feb08a0c78f48/ghc >--------------------------------------------------------------- commit c261a15d454962df965d839d262feb08a0c78f48 Author: Ben Gamari Date: Wed Mar 30 10:29:02 2016 +0200 ghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE There is no benefit to be had from inlining this function and it may defeat rewrite rules if inlined early. See #11772.. Test Plan: Validate, nofib Reviewers: simonpj, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2057 GHC Trac Issues: #11772 (cherry picked from commit 58bbb40ba23860df2ede1275493ef32ba69a2083) >--------------------------------------------------------------- c261a15d454962df965d839d262feb08a0c78f48 libraries/ghc-prim/GHC/CString.hs | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/libraries/ghc-prim/GHC/CString.hs b/libraries/ghc-prim/GHC/CString.hs index 53d1ddd..19e6f75 100644 --- a/libraries/ghc-prim/GHC/CString.hs +++ b/libraries/ghc-prim/GHC/CString.hs @@ -24,7 +24,7 @@ import GHC.Types import GHC.Prim ----------------------------------------------------------------------------- --- Unpacking C strings} +-- Unpacking C strings ----------------------------------------------------------------------------- -- This code is needed for virtually all programs, since it's used for @@ -34,11 +34,33 @@ import GHC.Prim -- stuff uses Strings in the representation, so to give representations for -- ghc-prim types we need unpackCString# +{- +Note [Inlining unpackCString#] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +There's really no point in ever inlining things like unpackCString# as the loop +doesn't specialise in an interesting way and we can't deforest the list +constructors (we'd want to use unpackFoldrCString# for this). Moreover, it's +pretty small, so there's a danger that it'll be inlined at every literal, which +is a waste. + +Moreover, inlining early may interfere with a variety of rules that are supposed +to match unpackCString#, + + * BuiltInRules in PrelRules.hs; e.g. + eqString (unpackCString# (Lit s1)) (unpackCString# (Lit s2) + = s1 == s2 + + * unpacking rules; e.g. in GHC.Base, + unpackCString# a + = build (unpackFoldrCString# a) + + * stream fusion rules; e.g. in the `text` library, + unstream (S.map safe (S.streamList (GHC.unpackCString# a))) + = unpackCString# a +-} + unpackCString# :: Addr# -> [Char] {-# NOINLINE unpackCString# #-} - -- There's really no point in inlining this, ever, as the loop doesn't - -- specialise in an interesting But it's pretty small, so there's a danger - -- that it'll be inlined at every literal, which is a waste unpackCString# addr = unpack 0# where @@ -64,7 +86,7 @@ unpackFoldrCString# :: Addr# -> (Char -> a -> a) -> a -> a -- Usually the unpack-list rule turns unpackFoldrCString# into unpackCString# --- It also has a BuiltInRule in PrelRules.lhs: +-- It also has a BuiltInRule in PrelRules.hs: -- unpackFoldrCString# "foo" c (unpackFoldrCString# "baz" c n) -- = unpackFoldrCString# "foobaz" c n @@ -85,7 +107,10 @@ unpackFoldrCString# addr f z where !ch = indexCharOffAddr# addr nh +-- There's really no point in inlining this for the same reasons as +-- unpackCString. See Note [Inlining unpackCString#] above for details. unpackCStringUtf8# :: Addr# -> [Char] +{-# NOINLINE unpackCStringUtf8# #-} unpackCStringUtf8# addr = unpack 0# where @@ -110,7 +135,10 @@ unpackCStringUtf8# addr where !ch = indexCharOffAddr# addr nh +-- There's really no point in inlining this for the same reasons as +-- unpackCString. See Note [Inlining unpackCString#] above for details. unpackNBytes# :: Addr# -> Int# -> [Char] +{-# NOINLINE unpackNBytes# #-} unpackNBytes# _addr 0# = [] unpackNBytes# addr len# = unpack [] (len# -# 1#) where From git at git.haskell.org Wed Mar 30 19:49:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 19:49:46 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Drop Xcode 4.1 hack and fix ignored CC var issue (56eaed1) Message-ID: <20160330194946.8E2B03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/56eaed1d6c98febf2b3c2f80c0b1e08e13cb8c9f/ghc >--------------------------------------------------------------- commit 56eaed1d6c98febf2b3c2f80c0b1e08e13cb8c9f Author: Herbert Valerio Riedel Date: Mon Mar 28 12:55:21 2016 +0200 Drop Xcode 4.1 hack and fix ignored CC var issue Xcode 4.1 was released back in 2011 for Mac OSX 10.6/10.7. However, OSX 10.7 reached EOL sometime around the end of 2014. So this `--with-gcc-4.2` hack shouldn't be needed anymore. Moreover, this patch changes ./configure to honor the CC env-var again (and thus fix #11231) while giving `--with-gcc=...` a higher priority over `CC=...`. So the following 3 invocations are equivalent now: CC=... ./configure ./configure CC=... ./configure --with-gcc=... Since `--with-{gcc,clang}=...` is a misnomer (as is made apparent by `--with-gcc=clang` or `--with-clang=gcc`), this would give us a neutral and idiomatic way to tell ./configure which C compiler to use. Moreover, `./configure --help` says at the end of its output: Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Consequently, by honoring CC=... (rather than ignoring it) we increase consistency and reduce user confusion. Ideally, CC=... would become the recommended way to set the C compiler, and `--with-{clang,gcc}=...` would be demoted to legacy aliases. Reviewed By: erikd, bgamari Differential Revision: https://phabricator.haskell.org/D2046 (cherry picked from commit ffc802e8f617d11de9ece7bed438725bde0300b8) >--------------------------------------------------------------- 56eaed1d6c98febf2b3c2f80c0b1e08e13cb8c9f aclocal.m4 | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index d0e7f3d..18b9529 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -2053,22 +2053,19 @@ AC_DEFUN([FIND_GHC_BOOTSTRAP_PROG],[ # $2 = the with option name # $3 = the command to look for AC_DEFUN([FIND_GCC],[ - if test "$TargetOS_CPP" = "darwin" && - test "$XCodeVersion1" -eq 4 && - test "$XCodeVersion2" -lt 2 - then - # In Xcode 4.1, 'gcc-4.2' is the gcc legacy backend (rather - # than the LLVM backend). We prefer the legacy gcc, but in - # Xcode 4.2 'gcc-4.2' was removed. - FP_ARG_WITH_PATH_GNU_PROG([$1], [gcc-4.2], [gcc-4.2]) - elif test "$windows" = YES + if test "$windows" = YES then $1="$CC" else FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [$2], [$3]) + # fallback to CC if set and no --with-$2=... was used + if test -z "$With_$2" -a -n "$CC" + then + With_$2="$CC" + $1="$CC" # From Xcode 5 on/, OS X command line tools do not include gcc # anymore. Use clang. - if test -z "$$1" + elif test -z "$$1" then FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [clang], [clang]) fi From git at git.haskell.org Wed Mar 30 20:46:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 20:46:56 +0000 (UTC) Subject: [commit: ghc] master: Add -f(no-)version-macro to explicitly control macros. (bc953fc) Message-ID: <20160330204656.57E3E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/bc953fcdbc76ffbb4f06a2b74be271268f73328f/ghc >--------------------------------------------------------------- commit bc953fcdbc76ffbb4f06a2b74be271268f73328f Author: Edward Z. Yang Date: Wed Mar 30 21:44:09 2016 +0200 Add -f(no-)version-macro to explicitly control macros. Test Plan: validate Reviewers: thomie, austin, bgamari Reviewed By: bgamari Subscribers: hvr Differential Revision: https://phabricator.haskell.org/D2058 GHC Trac Issues: #11763 >--------------------------------------------------------------- bc953fcdbc76ffbb4f06a2b74be271268f73328f compiler/main/DriverPipeline.hs | 2 +- compiler/main/DynFlags.hs | 5 ++++- testsuite/.gitignore | 1 + testsuite/tests/driver/T11763.hs | 5 +++++ .../{simplCore/should_run/T5453.stdout => driver/T11763.stdout} | 0 testsuite/tests/driver/all.T | 1 + 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index bc9c19b..586754f 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -2056,7 +2056,7 @@ doCpp dflags raw input_fn output_fn = do let uids = explicitPackages (pkgState dflags) pkgs = catMaybes (map (lookupPackage dflags) uids) mb_macro_include <- - if not (null pkgs) + if not (null pkgs) && gopt Opt_VersionMacros dflags then do macro_stub <- newTempName dflags "h" writeFile macro_stub (generatePackageVersionMacros pkgs) -- Include version macros for every *exposed* package. diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 9c67045..9e06445 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -486,6 +486,7 @@ data GeneralFlag | Opt_FlatCache | Opt_ExternalInterpreter | Opt_OptimalApplicativeDo + | Opt_VersionMacros -- PreInlining is on by default. The option is there just to see how -- bad things get if you turn it off! @@ -3397,6 +3398,7 @@ fFlagsDeps = [ flagSpec "unbox-strict-fields" Opt_UnboxStrictFields, flagSpec "vectorisation-avoidance" Opt_VectorisationAvoidance, flagSpec "vectorise" Opt_Vectorise, + flagSpec "version-macros" Opt_VersionMacros, flagSpec "worker-wrapper" Opt_WorkerWrapper, flagSpec "show-warning-groups" Opt_ShowWarnGroups ] @@ -3640,7 +3642,8 @@ defaultFlags settings Opt_ProfCountEntries, Opt_RPath, Opt_SharedImplib, - Opt_SimplPreInlining + Opt_SimplPreInlining, + Opt_VersionMacros ] ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns] diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 8926e4e..655e3da 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -571,6 +571,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/driver/T8526/A.inc /tests/driver/T8602/t8602.sh /tests/driver/T9562/Main +/tests/driver/T11763 /tests/driver/Test.081b /tests/driver/Test.081b.hs /tests/driver/Test_081a diff --git a/testsuite/tests/driver/T11763.hs b/testsuite/tests/driver/T11763.hs new file mode 100644 index 0000000..3fd5df9 --- /dev/null +++ b/testsuite/tests/driver/T11763.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE CPP #-} +main = do +#ifndef VERSION_containers + putStrLn "OK" +#endif diff --git a/testsuite/tests/simplCore/should_run/T5453.stdout b/testsuite/tests/driver/T11763.stdout similarity index 100% copy from testsuite/tests/simplCore/should_run/T5453.stdout copy to testsuite/tests/driver/T11763.stdout diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 23aeb99..761ad62 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -475,6 +475,7 @@ test('T11381', normal, compile_fail, ['']) test('T11429a', normal, compile, ['-Wunrecognised-warning-flags -Wfoobar']) test('T11429b', normal, compile, ['-Wno-unrecognised-warning-flags -Wfoobar']) test('T11429c', normal, compile_fail, ['-Wunrecognised-warning-flags -Werror -Wfoobar']) +test('T11763', normal, compile_and_run, ['-fno-version-macros']) test('T10320', [ ignore_output From git at git.haskell.org Wed Mar 30 20:46:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 20:46:59 +0000 (UTC) Subject: [commit: ghc] master: Kill the magic of Any (24d7615) Message-ID: <20160330204659.14C853A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/24d761531cfc18152598becc0aeb90376fd19198/ghc >--------------------------------------------------------------- commit 24d761531cfc18152598becc0aeb90376fd19198 Author: Ben Gamari Date: Wed Mar 30 21:58:24 2016 +0200 Kill the magic of Any This turns `Any` into a standard wired-in type family defined in `GHC.Types`, instead its current incarnation as a magical creature provided by the `GHC.Prim`. Also kill `AnyK`. See #10886. Test Plan: Validate Reviewers: simonpj, goldfire, austin, hvr Reviewed By: simonpj Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D2049 GHC Trac Issues: #10886 >--------------------------------------------------------------- 24d761531cfc18152598becc0aeb90376fd19198 compiler/prelude/PrelNames.hs | 18 ++--- compiler/prelude/TysPrim.hs | 81 ----------------------- compiler/prelude/TysWiredIn.hs | 87 +++++++++++++++++++++++++ compiler/prelude/primops.txt.pp | 46 ------------- compiler/specialise/Rules.hs | 2 +- libraries/base/GHC/Exts.hs | 3 + libraries/ghc-prim/GHC/Types.hs | 21 +++++- testsuite/tests/simplCore/should_run/T5441a.hs | 2 +- testsuite/tests/stranal/should_compile/T9208.hs | 2 +- 9 files changed, 123 insertions(+), 139 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 24d761531cfc18152598becc0aeb90376fd19198 From git at git.haskell.org Wed Mar 30 20:47:01 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 20:47:01 +0000 (UTC) Subject: [commit: ghc] master: Don't require -hide-all-packages for MIN_VERSION_* macros (e9c2555) Message-ID: <20160330204701.BC5E83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/e9c2555ac666912f7dff56448ced4bfa06d14e76/ghc >--------------------------------------------------------------- commit e9c2555ac666912f7dff56448ced4bfa06d14e76 Author: Thomas Miedema Date: Wed Mar 30 21:43:51 2016 +0200 Don't require -hide-all-packages for MIN_VERSION_* macros Define MIN_VERSION_pkgname and VERSION_pkgname macros for all exposed packages, without requiring -hide-all-packages. See #10970 comment 7-10 for discussion. Reviewers: duncan, ezyang, bgamari, austin Reviewed By: ezyang Subscribers: hvr, rwbarton Differential Revision: https://phabricator.haskell.org/D1869 GHC Trac Issues: #10970 >--------------------------------------------------------------- e9c2555ac666912f7dff56448ced4bfa06d14e76 compiler/main/DriverPipeline.hs | 15 ++++++++------- docs/users_guide/phases.rst | 6 ++---- testsuite/tests/driver/T10970a.hs | 8 -------- testsuite/tests/driver/T10970a.stdout | 2 -- testsuite/tests/driver/T3389.hs | 4 ++-- testsuite/tests/driver/all.T | 3 +-- 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 1991bd3..bc9c19b 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -2056,13 +2056,14 @@ doCpp dflags raw input_fn output_fn = do let uids = explicitPackages (pkgState dflags) pkgs = catMaybes (map (lookupPackage dflags) uids) mb_macro_include <- - -- Only generate if we have (1) we have set -hide-all-packages - -- (so we don't generate a HUGE macro file of things we don't - -- care about but are exposed) and (2) we actually have packages - -- to write macros for! - if gopt Opt_HideAllPackages dflags && not (null pkgs) + if not (null pkgs) then do macro_stub <- newTempName dflags "h" writeFile macro_stub (generatePackageVersionMacros pkgs) + -- Include version macros for every *exposed* package. + -- Without -hide-all-packages and with a package database + -- size of 1000 packages, it takes cpp an estimated 2 + -- milliseconds to process this file. See Trac #10970 + -- comment 8. return [SysTools.FileOption "-include" macro_stub] else return [] @@ -2110,8 +2111,8 @@ getBackendDefs _ = generatePackageVersionMacros :: [PackageConfig] -> String generatePackageVersionMacros pkgs = concat - [ "/* package " ++ sourcePackageIdString pkg ++ " */\n" - ++ generateMacros "" pkgname version + -- Do not add any C-style comments. See Trac #3389. + [ generateMacros "" pkgname version | pkg <- pkgs , let version = packageVersion pkg pkgname = map fixchar (packageNameString pkg) diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst index ed05add..0c3b59f 100644 --- a/docs/users_guide/phases.rst +++ b/docs/users_guide/phases.rst @@ -313,16 +313,14 @@ defined by your local GHC installation, the following trick is useful: ``VERSION_pkgname`` This macro is available starting GHC 8.0. It is defined for every - exposed package, but only if the ``-hide-all-packages`` flag - is set. This macro expands to a string recording the + exposed package. This macro expands to a string recording the version of ``pkgname`` that is exposed for module import. It is identical in behavior to the ``VERSION_pkgname`` macros that Cabal defines. ``MIN_VERSION_pkgname(x,y,z)`` This macro is available starting GHC 8.0. It is defined for every - exposed package, but only if the ``-hide-all-packages`` flag - is set. This macro is provided for convenience to write CPP + exposed package. This macro is provided for convenience to write CPP conditionals testing if a package version is ``x.y.z`` or less. It is identical in behavior to the ``MIN_VERSION_pkgname`` macros that Cabal defines. diff --git a/testsuite/tests/driver/T10970a.hs b/testsuite/tests/driver/T10970a.hs deleted file mode 100644 index 8e7aa60..0000000 --- a/testsuite/tests/driver/T10970a.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE CPP #-} -main = do -#ifndef VERSION_containers - putStrLn "OK" -#endif -#ifndef MIN_VERSION_base - putStrLn "OK" -#endif diff --git a/testsuite/tests/driver/T10970a.stdout b/testsuite/tests/driver/T10970a.stdout deleted file mode 100644 index 2c94e48..0000000 --- a/testsuite/tests/driver/T10970a.stdout +++ /dev/null @@ -1,2 +0,0 @@ -OK -OK diff --git a/testsuite/tests/driver/T3389.hs b/testsuite/tests/driver/T3389.hs index c6a5666..e574fc4 100644 --- a/testsuite/tests/driver/T3389.hs +++ b/testsuite/tests/driver/T3389.hs @@ -6,7 +6,7 @@ main :: IO () main = putStrLn [A, --- /* +-- CPP treats this as the beginning of a multiline C-style comment: /usr/local/* 'b', --- */ +-- And */ close it. By passing `-optP -C` we tell CPP not to delete it. 'c'] diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 2798dd5..23aeb99 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -468,8 +468,7 @@ test('T365', test('T9360a', normal, run_command, ['{compiler} --interactive -e "" -ignore-dot-ghci']) test('T9360b', normal, run_command, ['{compiler} -e "" --interactive -ignore-dot-ghci']) -test('T10970', normal, compile_and_run, ['-hide-all-packages -package base -package containers']) -test('T10970a', normal, compile_and_run, ['']) +test('T10970', normal, compile_and_run, ['']) test('T4931', normal, compile_and_run, ['']) test('T11182', normal, compile_and_run, ['']) test('T11381', normal, compile_fail, ['']) From git at git.haskell.org Wed Mar 30 21:24:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 21:24:46 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Do not claim that -O2 does not do better than -O (d332df3) Message-ID: <20160330212446.7AC293A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/d332df3fd95f2116c138073ccc5d85f8efe5f402/ghc >--------------------------------------------------------------- commit d332df3fd95f2116c138073ccc5d85f8efe5f402 Author: Joachim Breitner Date: Wed Mar 30 16:09:36 2016 +0200 Do not claim that -O2 does not do better than -O when in fact it does. This was pointed out by Johannes Bechberger and supported with seemingly statistically sound evidence in his Bachelor thesis: Of the benchmark shootout programs, 80% benefit significantly by switchtng from -O to -O2. See https://uqudy.serpens.uberspace.de/blog/2016/02/08/ghc-performance-over-time/ for a few raw numbers. Differential Revision: https://phabricator.haskell.org/D2065 (cherry picked from commit 3d245bf5255ebfb72813596fa93b9051f7518321) >--------------------------------------------------------------- d332df3fd95f2116c138073ccc5d85f8efe5f402 docs/users_guide/using-optimisation.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/users_guide/using-optimisation.rst b/docs/users_guide/using-optimisation.rst index bc8e700..5e4995d 100644 --- a/docs/users_guide/using-optimisation.rst +++ b/docs/users_guide/using-optimisation.rst @@ -79,9 +79,6 @@ one reason to stick to no-optimisation when developing code. runtime or space *worse* if you're unlucky. They are normally turned on or off individually. - At the moment, ``-O2`` is *unlikely* to produce better code than - ``-O``. - .. ghc-flag:: -Odph .. index:: From git at git.haskell.org Wed Mar 30 21:24:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 21:24:49 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Don't recompute some free vars in lintCoercion (1547b9c) Message-ID: <20160330212449.3BDBB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/1547b9cf8a950066f47c0759e1a6120d2e75762b/ghc >--------------------------------------------------------------- commit 1547b9cf8a950066f47c0759e1a6120d2e75762b Author: Bartosz Nitka Date: Tue Mar 29 19:37:54 2016 -0700 Don't recompute some free vars in lintCoercion As pointed out by @simonpj on D2044 we don't need to compute the free vars of the range of the substitution as most of them are already carried by the monad. This should be a tiny performance improvement over the version from before D2044. Also removes an extra function that is now unnecessary. Test Plan: ./validate && ./validate --slow Reviewers: goldfire, simonpj, austin, bgamari Reviewed By: simonpj Subscribers: thomie, simonmar, simonpj Differential Revision: https://phabricator.haskell.org/D2060 GHC Trac Issues: #11371 (cherry picked from commit 1757dd8ebed0732018319e43e6468b868a6aceeb) >--------------------------------------------------------------- 1547b9cf8a950066f47c0759e1a6120d2e75762b compiler/coreSyn/CoreLint.hs | 18 ++++++++++++------ compiler/types/TyCoRep.hs | 5 ----- compiler/types/Type.hs | 1 - 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index 64543f9..c5bbf90 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -1272,16 +1272,22 @@ lintCoercion co@(AppCo co1 co2) lintCoercion (ForAllCo tv1 kind_co co) = do { (_, k2) <- lintStarCoercion kind_co ; let tv2 = setTyVarKind tv1 k2 - ; (k3, k4, t1, t2, r) <- addInScopeVar tv1 $ lintCoercion co + ; addInScopeVar tv1 $ + do { + ; (k3, k4, t1, t2, r) <- lintCoercion co ; in_scope <- getInScope ; let tyl = mkNamedForAllTy tv1 Invisible t1 - subst = zipTvSubst [tv1] [TyVarTy tv2 `mkCastTy` mkSymCo kind_co] - `extendTCvInScopeInScope` in_scope - -- We need free vars of `t2` in scope to satisfy - -- Note [The substitution invariant] + subst = mkTvSubst in_scope $ + -- We need both the free vars of the `t2` and the + -- free vars of the range of the substitution in + -- scope. All the free vars of `t2` and `kind_co` should + -- already be in `in_scope`, because they've been + -- linted and `tv2` has the same unique as `tv1`. + -- See Note [The substitution invariant] + unitVarEnv tv1 (TyVarTy tv2 `mkCastTy` mkSymCo kind_co) tyr = mkNamedForAllTy tv2 Invisible $ substTy subst t2 - ; return (k3, k4, tyl, tyr, r) } + ; return (k3, k4, tyl, tyr, r) } } lintCoercion (CoVarCo cv) | not (isCoVar cv) diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index 165350d..acff6a2 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -83,7 +83,6 @@ module TyCoRep ( getCvSubstEnv, getTCvInScope, isInScope, notElemTCvSubst, setTvSubstEnv, setCvSubstEnv, zapTCvSubst, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, - extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendCvSubstWithClone, extendTvSubst, extendTvSubstWithClone, @@ -1669,10 +1668,6 @@ extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst extendTCvInScopeSet (TCvSubst in_scope tenv cenv) vars = TCvSubst (extendInScopeSetSet in_scope vars) tenv cenv -extendTCvInScopeInScope :: TCvSubst -> InScopeSet -> TCvSubst -extendTCvInScopeInScope (TCvSubst in_scope tenv cenv) in_scope' - = TCvSubst (unionInScope in_scope in_scope') tenv cenv - extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst extendTCvSubst subst v ty | isTyVar v diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 47a234e..7b5922f 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -158,7 +158,6 @@ module Type ( getTvSubstEnv, setTvSubstEnv, zapTCvSubst, getTCvInScope, extendTCvInScope, extendTCvInScopeList, extendTCvInScopeSet, - extendTCvInScopeInScope, extendTCvSubst, extendCvSubst, extendTvSubst, extendTvSubstList, extendTvSubstAndInScope, isInScope, composeTCvSubstEnv, composeTCvSubst, zipTyEnv, zipCoEnv, From git at git.haskell.org Wed Mar 30 21:24:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 21:24:51 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: rts/posix/Itimer.c: Handle EINTR when reading timerfd (37936e2) Message-ID: <20160330212451.E17843A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/37936e2b23e58b8a855b7ece5a375b930d1a29bc/ghc >--------------------------------------------------------------- commit 37936e2b23e58b8a855b7ece5a375b930d1a29bc Author: Erik de Castro Lopo Date: Mon Mar 28 14:29:37 2016 +1100 rts/posix/Itimer.c: Handle EINTR when reading timerfd Commit 8626d76a72 added checking of the return value when reading from the `timer_fd` and calling `sysErrorBelch` to print a warning message. However some error causes (like EINTR) are benign and should just be ignored. Test Plan: validate Reviewers: hvr, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2040 (cherry picked from commit 7aa4c52f9df1705258f43f9c003c17af97401693) >--------------------------------------------------------------- 37936e2b23e58b8a855b7ece5a375b930d1a29bc rts/posix/Itimer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index b833295..8915446 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -202,10 +202,15 @@ static void *itimer_thread_func(void *_handle_tick) while (1) { if (USE_TIMERFD_FOR_ITIMER) { - if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) - sysErrorBelch("Itimer: read(timer_fd) failed"); + if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) { + if (errno != EINTR) { + sysErrorBelch("Itimer: read(timerfd) failed"); + } + } } else { - usleep(TimeToUS(itimer_interval)); + if (usleep(TimeToUS(itimer_interval)) != 0 && errno != EINTR) { + sysErrorBelch("usleep(TimeToUS(itimer_interval) failed"); + } } switch (itimer_state) { case RUNNING: @@ -222,7 +227,7 @@ static void *itimer_thread_func(void *_handle_tick) return NULL; } } - return NULL; + return NULL; // Never reached. } #endif From git at git.haskell.org Wed Mar 30 21:24:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 21:24:54 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Don't require -hide-all-packages for MIN_VERSION_* macros (b6be8a1) Message-ID: <20160330212454.C857A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/b6be8a106c6c6fb477832220b606f19a5943f083/ghc >--------------------------------------------------------------- commit b6be8a106c6c6fb477832220b606f19a5943f083 Author: Thomas Miedema Date: Wed Mar 30 21:43:51 2016 +0200 Don't require -hide-all-packages for MIN_VERSION_* macros Define MIN_VERSION_pkgname and VERSION_pkgname macros for all exposed packages, without requiring -hide-all-packages. See #10970 comment 7-10 for discussion. Reviewers: duncan, ezyang, bgamari, austin Reviewed By: ezyang Subscribers: hvr, rwbarton Differential Revision: https://phabricator.haskell.org/D1869 GHC Trac Issues: #10970 (cherry picked from commit e9c2555ac666912f7dff56448ced4bfa06d14e76) >--------------------------------------------------------------- b6be8a106c6c6fb477832220b606f19a5943f083 compiler/main/DriverPipeline.hs | 15 ++++++++------- docs/users_guide/phases.rst | 6 ++---- testsuite/tests/driver/T10970a.hs | 8 -------- testsuite/tests/driver/T10970a.stdout | 2 -- testsuite/tests/driver/T3389.hs | 4 ++-- testsuite/tests/driver/all.T | 3 +-- 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index c9174f4..5f1e25b 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -2056,13 +2056,14 @@ doCpp dflags raw input_fn output_fn = do let uids = explicitPackages (pkgState dflags) pkgs = catMaybes (map (lookupPackage dflags) uids) mb_macro_include <- - -- Only generate if we have (1) we have set -hide-all-packages - -- (so we don't generate a HUGE macro file of things we don't - -- care about but are exposed) and (2) we actually have packages - -- to write macros for! - if gopt Opt_HideAllPackages dflags && not (null pkgs) + if not (null pkgs) then do macro_stub <- newTempName dflags "h" writeFile macro_stub (generatePackageVersionMacros pkgs) + -- Include version macros for every *exposed* package. + -- Without -hide-all-packages and with a package database + -- size of 1000 packages, it takes cpp an estimated 2 + -- milliseconds to process this file. See Trac #10970 + -- comment 8. return [SysTools.FileOption "-include" macro_stub] else return [] @@ -2110,8 +2111,8 @@ getBackendDefs _ = generatePackageVersionMacros :: [PackageConfig] -> String generatePackageVersionMacros pkgs = concat - [ "/* package " ++ sourcePackageIdString pkg ++ " */\n" - ++ generateMacros "" pkgname version + -- Do not add any C-style comments. See Trac #3389. + [ generateMacros "" pkgname version | pkg <- pkgs , let version = packageVersion pkg pkgname = map fixchar (packageNameString pkg) diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst index ed05add..0c3b59f 100644 --- a/docs/users_guide/phases.rst +++ b/docs/users_guide/phases.rst @@ -313,16 +313,14 @@ defined by your local GHC installation, the following trick is useful: ``VERSION_pkgname`` This macro is available starting GHC 8.0. It is defined for every - exposed package, but only if the ``-hide-all-packages`` flag - is set. This macro expands to a string recording the + exposed package. This macro expands to a string recording the version of ``pkgname`` that is exposed for module import. It is identical in behavior to the ``VERSION_pkgname`` macros that Cabal defines. ``MIN_VERSION_pkgname(x,y,z)`` This macro is available starting GHC 8.0. It is defined for every - exposed package, but only if the ``-hide-all-packages`` flag - is set. This macro is provided for convenience to write CPP + exposed package. This macro is provided for convenience to write CPP conditionals testing if a package version is ``x.y.z`` or less. It is identical in behavior to the ``MIN_VERSION_pkgname`` macros that Cabal defines. diff --git a/testsuite/tests/driver/T10970a.hs b/testsuite/tests/driver/T10970a.hs deleted file mode 100644 index 8e7aa60..0000000 --- a/testsuite/tests/driver/T10970a.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE CPP #-} -main = do -#ifndef VERSION_containers - putStrLn "OK" -#endif -#ifndef MIN_VERSION_base - putStrLn "OK" -#endif diff --git a/testsuite/tests/driver/T10970a.stdout b/testsuite/tests/driver/T10970a.stdout deleted file mode 100644 index 2c94e48..0000000 --- a/testsuite/tests/driver/T10970a.stdout +++ /dev/null @@ -1,2 +0,0 @@ -OK -OK diff --git a/testsuite/tests/driver/T3389.hs b/testsuite/tests/driver/T3389.hs index c6a5666..e574fc4 100644 --- a/testsuite/tests/driver/T3389.hs +++ b/testsuite/tests/driver/T3389.hs @@ -6,7 +6,7 @@ main :: IO () main = putStrLn [A, --- /* +-- CPP treats this as the beginning of a multiline C-style comment: /usr/local/* 'b', --- */ +-- And */ close it. By passing `-optP -C` we tell CPP not to delete it. 'c'] diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index a50476a..077ac66 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -462,8 +462,7 @@ test('T365', test('T9360a', normal, run_command, ['{compiler} --interactive -e "" -ignore-dot-ghci']) test('T9360b', normal, run_command, ['{compiler} -e "" --interactive -ignore-dot-ghci']) -test('T10970', normal, compile_and_run, ['-hide-all-packages -package base -package containers']) -test('T10970a', normal, compile_and_run, ['']) +test('T10970', normal, compile_and_run, ['']) test('T4931', normal, compile_and_run, ['']) test('T11182', normal, compile_and_run, ['']) test('T11381', normal, compile_fail, ['']) From git at git.haskell.org Wed Mar 30 21:24:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 21:24:57 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Add -f(no-)version-macro to explicitly control macros. (eb2c0ed) Message-ID: <20160330212457.D5A483A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/eb2c0edf950e4c1d8e2ce058eda017e6bd6e398c/ghc >--------------------------------------------------------------- commit eb2c0edf950e4c1d8e2ce058eda017e6bd6e398c Author: Edward Z. Yang Date: Wed Mar 30 21:44:09 2016 +0200 Add -f(no-)version-macro to explicitly control macros. Test Plan: validate Reviewers: thomie, austin, bgamari Reviewed By: bgamari Subscribers: hvr Differential Revision: https://phabricator.haskell.org/D2058 GHC Trac Issues: #11763 (cherry picked from commit bc953fcdbc76ffbb4f06a2b74be271268f73328f) >--------------------------------------------------------------- eb2c0edf950e4c1d8e2ce058eda017e6bd6e398c compiler/main/DriverPipeline.hs | 2 +- compiler/main/DynFlags.hs | 5 ++++- testsuite/.gitignore | 1 + testsuite/tests/driver/T11763.hs | 5 +++++ .../{simplCore/should_run/T5453.stdout => driver/T11763.stdout} | 0 testsuite/tests/driver/all.T | 1 + 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 5f1e25b..2f59678 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -2056,7 +2056,7 @@ doCpp dflags raw input_fn output_fn = do let uids = explicitPackages (pkgState dflags) pkgs = catMaybes (map (lookupPackage dflags) uids) mb_macro_include <- - if not (null pkgs) + if not (null pkgs) && gopt Opt_VersionMacros dflags then do macro_stub <- newTempName dflags "h" writeFile macro_stub (generatePackageVersionMacros pkgs) -- Include version macros for every *exposed* package. diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index bff0348..327cb97 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -487,6 +487,7 @@ data GeneralFlag | Opt_Hpc | Opt_FlatCache | Opt_ExternalInterpreter + | Opt_VersionMacros -- PreInlining is on by default. The option is there just to see how -- bad things get if you turn it off! @@ -3372,6 +3373,7 @@ fFlagsDeps = [ flagSpec "unbox-strict-fields" Opt_UnboxStrictFields, flagSpec "vectorisation-avoidance" Opt_VectorisationAvoidance, flagSpec "vectorise" Opt_Vectorise, + flagSpec "version-macros" Opt_VersionMacros, flagSpec "worker-wrapper" Opt_WorkerWrapper, flagSpec "show-warning-groups" Opt_ShowWarnGroups ] @@ -3613,7 +3615,8 @@ defaultFlags settings Opt_ProfCountEntries, Opt_RPath, Opt_SharedImplib, - Opt_SimplPreInlining + Opt_SimplPreInlining, + Opt_VersionMacros ] ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns] diff --git a/testsuite/.gitignore b/testsuite/.gitignore index e8e4114..e37a101 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -569,6 +569,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/driver/T8526/A.inc /tests/driver/T8602/t8602.sh /tests/driver/T9562/Main +/tests/driver/T11763 /tests/driver/Test.081b /tests/driver/Test.081b.hs /tests/driver/Test_081a diff --git a/testsuite/tests/driver/T11763.hs b/testsuite/tests/driver/T11763.hs new file mode 100644 index 0000000..3fd5df9 --- /dev/null +++ b/testsuite/tests/driver/T11763.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE CPP #-} +main = do +#ifndef VERSION_containers + putStrLn "OK" +#endif diff --git a/testsuite/tests/simplCore/should_run/T5453.stdout b/testsuite/tests/driver/T11763.stdout similarity index 100% copy from testsuite/tests/simplCore/should_run/T5453.stdout copy to testsuite/tests/driver/T11763.stdout diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 077ac66..7c15ddc 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -469,6 +469,7 @@ test('T11381', normal, compile_fail, ['']) test('T11429a', normal, compile, ['-Wunrecognised-warning-flags -Wfoobar']) test('T11429b', normal, compile, ['-Wno-unrecognised-warning-flags -Wfoobar']) test('T11429c', normal, compile_fail, ['-Wunrecognised-warning-flags -Werror -Wfoobar']) +test('T11763', normal, compile_and_run, ['-fno-version-macros']) test('T10320', [ ignore_output From git at git.haskell.org Wed Mar 30 21:25:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Wed, 30 Mar 2016 21:25:00 +0000 (UTC) Subject: [commit: ghc] ghc-8.0: Always do eta-reduction (392b9d7) Message-ID: <20160330212500.E3C1F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : ghc-8.0 Link : http://ghc.haskell.org/trac/ghc/changeset/392b9d7a866c74935e7c740c84c61802148fb6c8/ghc >--------------------------------------------------------------- commit 392b9d7a866c74935e7c740c84c61802148fb6c8 Author: Simon Peyton Jones Date: Thu Feb 11 10:38:33 2016 +0000 Always do eta-reduction See Note [Eta-reduction in -O0] in DynFlags. Bottom line: doing eta reduction unconditionally is benign, and removes an ASSERT failure (Trac #11562). (cherry picked from commit 850085555a1103810d57f0d9835f4d525fd8ec00) >--------------------------------------------------------------- 392b9d7a866c74935e7c740c84c61802148fb6c8 compiler/main/DynFlags.hs | 17 ++++++++++- testsuite/tests/simplCore/should_compile/T11562.hs | 35 ++++++++++++++++++++++ testsuite/tests/simplCore/should_compile/all.T | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 327cb97..959a68d 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -3723,6 +3723,7 @@ impliedXFlags optLevelFlags :: [([Int], GeneralFlag)] optLevelFlags -- see Note [Documenting optimisation flags] = [ ([0,1,2], Opt_DoLambdaEtaExpansion) + , ([0,1,2], Opt_DoEtaReduction) -- See Note [Eta-reduction in -O0] , ([0,1,2], Opt_DmdTxDictSel) , ([0,1,2], Opt_LlvmTBAA) , ([0,1,2], Opt_VectorisationAvoidance) @@ -3739,7 +3740,6 @@ optLevelFlags -- see Note [Documenting optimisation flags] , ([1,2], Opt_CmmElimCommonBlocks) , ([1,2], Opt_CmmSink) , ([1,2], Opt_CSE) - , ([1,2], Opt_DoEtaReduction) , ([1,2], Opt_EnableRewriteRules) -- Off for -O0; see Note [Scoping for Builtin rules] -- in PrelRules , ([1,2], Opt_FloatIn) @@ -3761,6 +3761,21 @@ optLevelFlags -- see Note [Documenting optimisation flags] -- Static Argument Transformation needs investigation. See #9374 ] +{- Note [Eta-reduction in -O0] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Trac #11562 showed an example which tripped an ASSERT in CoreToStg; a +function was marked as MayHaveCafRefs when in fact it obviously +didn't. Reason was: + * Eta reduction wasn't happening in the simplifier, but it was + happening in CorePrep, on + $fBla = MkDict (/\a. K a) + * Result: rhsIsStatic told TidyPgm that $fBla might have CAF refs + but the eta-reduced version (MkDict K) obviously doesn't +Simple solution: just let the simplifier do eta-reduction even in -O0. +After all, CorePrep does it unconditionally! Not a big deal, but +removes an assertion failure. -} + + -- ----------------------------------------------------------------------------- -- Standard sets of warning options diff --git a/testsuite/tests/simplCore/should_compile/T11562.hs b/testsuite/tests/simplCore/should_compile/T11562.hs new file mode 100644 index 0000000..873e1af --- /dev/null +++ b/testsuite/tests/simplCore/should_compile/T11562.hs @@ -0,0 +1,35 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE Rank2Types #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE NoImplicitPrelude #-} + +-- Trac #11562 reported an ASSERT error +-- It only showed up /without/ -O, and obviously +-- with a compiler built with -DDEBUG + +module T11562 where +import qualified GHC.Types as C (Constraint) + +class Category (cat :: k -> k -> *) where + id :: cat a a + (.) :: cat b c -> cat a b -> cat a c + +data Dict :: C.Constraint -> * where + Dict :: a => Dict a + +newtype C2D a b = Sub (a => Dict b) + +instance Category C2D where + id = Sub Dict + f . g = Sub (sub (sub Dict f) g) + +sub :: a => (b => r) -> (C2D a b) -> r +sub r (Sub Dict) = r + +{- +$ inplace/bin/ghc-stage2 -fforce-recomp -c C.hs -O0 + +WARNING: file compiler/stgSyn/CoreToStg.hs, line 250 + $fCategoryConstraint:- True False +-} diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T index 0050bee..225b524 100644 --- a/testsuite/tests/simplCore/should_compile/all.T +++ b/testsuite/tests/simplCore/should_compile/all.T @@ -229,4 +229,5 @@ test('T11155', run_command, ['$MAKE -s --no-print-directory T11155']) test('T11232', normal, compile, ['-O2']) +test('T11562', normal, compile, ['-O2']) test('T11644', normal, compile, ['-O2']) From git at git.haskell.org Thu Mar 31 07:01:46 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 07:01:46 +0000 (UTC) Subject: [commit: ghc] master: Comments only (2e5e822) Message-ID: <20160331070146.5611D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/2e5e8223e2fd0fe7f6082a15627dfd54e3560b06/ghc >--------------------------------------------------------------- commit 2e5e8223e2fd0fe7f6082a15627dfd54e3560b06 Author: Simon Peyton Jones Date: Wed Mar 30 17:09:10 2016 +0100 Comments only >--------------------------------------------------------------- 2e5e8223e2fd0fe7f6082a15627dfd54e3560b06 compiler/basicTypes/Demand.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/basicTypes/Demand.hs b/compiler/basicTypes/Demand.hs index 5359c2f..7dc575e 100644 --- a/compiler/basicTypes/Demand.hs +++ b/compiler/basicTypes/Demand.hs @@ -1446,7 +1446,7 @@ peelManyCalls n (JD { sd = str, ud = abs }) go_str n (SCall d') = go_str (n-1) d' go_str _ _ = Lazy - go_abs :: Int -> UseDmd -> Use () -- Many <=> unsaturated, or at least + go_abs :: Int -> UseDmd -> Use () -- Many <=> unsaturated, or at least go_abs 0 _ = Use One () -- one UCall Many in the demand go_abs n (UCall One d') = go_abs (n-1) d' go_abs _ _ = Use Many () @@ -1776,7 +1776,9 @@ argsOneShots (StrictSig (DmdType _ arg_ds _)) n_val_args cons [] [] = [] cons a as = a:as -argOneShots :: OneShotInfo -> Demand -> [OneShotInfo] +argOneShots :: OneShotInfo -- OneShotLam or ProbOneShot, + -> Demand -- depending on saturation + -> [OneShotInfo] argOneShots one_shot_info (JD { ud = usg }) = case usg of Use _ arg_usg -> go arg_usg From git at git.haskell.org Thu Mar 31 07:01:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 07:01:49 +0000 (UTC) Subject: [commit: ghc] master: Minor refactoring in mkExport (1f68da1) Message-ID: <20160331070149.1DD3F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/1f68da14e44144925d1c7dd277523c48224902b8/ghc >--------------------------------------------------------------- commit 1f68da14e44144925d1c7dd277523c48224902b8 Author: Simon Peyton Jones Date: Tue Mar 29 09:57:29 2016 +0100 Minor refactoring in mkExport No change in behaviour >--------------------------------------------------------------- 1f68da14e44144925d1c7dd277523c48224902b8 compiler/typecheck/TcBinds.hs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/compiler/typecheck/TcBinds.hs b/compiler/typecheck/TcBinds.hs index 3d5a401..6ce9aed 100644 --- a/compiler/typecheck/TcBinds.hs +++ b/compiler/typecheck/TcBinds.hs @@ -675,16 +675,7 @@ mkExport prag_fn qtvs theta , mbi_sig = mb_sig , mbi_mono_id = mono_id }) = do { mono_ty <- zonkTcType (idType mono_id) - ; poly_id <- case mb_sig of - Just sig | Just poly_id <- completeIdSigPolyId_maybe sig - -> return poly_id - _other -> checkNoErrs $ - mkInferredPolyId qtvs theta - poly_name mb_sig mono_ty - -- The checkNoErrs ensures that if the type is ambiguous - -- we don't carry on to the impedence matching, and generate - -- a duplicate ambiguity error. There is a similar - -- checkNoErrs for complete type signatures too. + ; poly_id <- mkInferredPolyId qtvs theta poly_name mb_sig mono_ty -- NB: poly_id has a zonked type ; poly_id <- addInlinePrags poly_id prag_sigs @@ -723,7 +714,16 @@ mkInferredPolyId :: [TyVar] -> TcThetaType -> Name -> Maybe TcIdSigInfo -> TcType -> TcM TcId mkInferredPolyId qtvs inferred_theta poly_name mb_sig mono_ty - = do { fam_envs <- tcGetFamInstEnvs + | Just sig <- mb_sig + , Just poly_id <- completeIdSigPolyId_maybe sig + = return poly_id + + | otherwise -- Either no type sig or partial type sig + = checkNoErrs $ -- The checkNoErrs ensures that if the type is ambiguous + -- we don't carry on to the impedence matching, and generate + -- a duplicate ambiguity error. There is a similar + -- checkNoErrs for complete type signatures too. + do { fam_envs <- tcGetFamInstEnvs ; let (_co, mono_ty') = normaliseType fam_envs Nominal mono_ty -- Unification may not have normalised the type, -- (see Note [Lazy flattening] in TcFlatten) so do it @@ -754,7 +754,8 @@ chooseInferredQuantifiers :: TcThetaType -- inferred -> Maybe TcIdSigInfo -> TcM ([TcTyBinder], TcThetaType) chooseInferredQuantifiers inferred_theta tau_tvs qtvs Nothing - = do { let free_tvs = closeOverKinds (growThetaTyVars inferred_theta tau_tvs) + = -- No type signature for this binder + do { let free_tvs = closeOverKinds (growThetaTyVars inferred_theta tau_tvs) -- Include kind variables! Trac #7916 my_theta = pickQuantifiablePreds free_tvs inferred_theta binders = [ mkNamedBinder Invisible tv @@ -805,7 +806,8 @@ chooseInferredQuantifiers inferred_theta tau_tvs qtvs ; return (mk_binders free_tvs, final_theta) } - | otherwise = pprPanic "chooseInferredQuantifiers" (ppr bndr_info) + | otherwise -- A complete type signature is dealt with in mkInferredPolyId + = pprPanic "chooseInferredQuantifiers" (ppr bndr_info) where pts_hint = text "To use the inferred type, enable PartialTypeSignatures" From git at git.haskell.org Thu Mar 31 07:01:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 07:01:51 +0000 (UTC) Subject: [commit: ghc] master: Comments only (8f66bac) Message-ID: <20160331070151.C27243A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/8f66bac9ba4c3ebe6c26b0c72e03b6754782ecbe/ghc >--------------------------------------------------------------- commit 8f66bac9ba4c3ebe6c26b0c72e03b6754782ecbe Author: Simon Peyton Jones Date: Tue Mar 29 09:57:06 2016 +0100 Comments only >--------------------------------------------------------------- 8f66bac9ba4c3ebe6c26b0c72e03b6754782ecbe compiler/basicTypes/DataCon.hs | 16 +++++++--------- compiler/typecheck/TcSimplify.hs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/basicTypes/DataCon.hs b/compiler/basicTypes/DataCon.hs index 1e4af2d..9a754dd 100644 --- a/compiler/basicTypes/DataCon.hs +++ b/compiler/basicTypes/DataCon.hs @@ -291,10 +291,9 @@ data DataCon -- dcRepTyCon = T -- In general, the dcUnivTyVars are NOT NECESSARILY THE SAME AS THE TYVARS - -- FOR THE PARENT TyCon. With GADTs the data con might not even have - -- the same number of type variables! - -- [This is a change (Oct05): previously, vanilla datacons guaranteed to - -- have the same type variables as their parent TyCon, but that seems ugly.] + -- FOR THE PARENT TyCon. (This is a change (Oct05): previously, vanilla + -- datacons guaranteed to have the same type variables as their parent TyCon, + -- but that seems ugly.) dcVanilla :: Bool, -- True <=> This is a vanilla Haskell 98 data constructor -- Its type is of form @@ -307,12 +306,11 @@ data DataCon -- The declaration format is held in the TyCon (algTcGadtSyntax) -- Universally-quantified type vars [a,b,c] + -- INVARIANT: length matches arity of the dcRepTyCon + -- INVARIANT: result type of data con worker is exactly (T a b c) dcUnivTyVars :: [TyVar], -- Two linked fields dcUnivTyBinders :: [TyBinder], -- see Note [TyBinders in DataCons] - -- INVARIANT: length matches arity of the dcRepTyCon - -- - -- INFARIANT: result type of (rep) data con is exactly (T a b c) -- Existentially-quantified type vars [x,y] dcExTyVars :: [TyVar], -- Two linked fields @@ -441,8 +439,8 @@ Specifically: the corresponding tyvar in the TyVars list. * Each Visibilty flag (va, vb, etc) is Invisible or Specified. - None are Visible. (See Note [No Visible TyBinder in terms]; - a DataCon is a term-level function.) + None are Visible. (A DataCon is a term-level function; see + Note [No Visible TyBinder in terms] in TyCoRep.) Why store these fields redundantly? Purely convenience. In most places in GHC, it's just the TyVars that are needed, so that's what's diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs index 51a3588..3adb77e 100644 --- a/compiler/typecheck/TcSimplify.hs +++ b/compiler/typecheck/TcSimplify.hs @@ -768,7 +768,7 @@ decideQuantification apply_mr sigs name_taus constraints -- to *. So, don't grow the kvs. ; constraints <- TcM.zonkTcTypes constraints - -- quantiyTyVars turned some meta tyvars into + -- quantifyTyVars turned some meta tyvars into -- quantified skolems, so we have to zonk again ; let theta = pickQuantifiablePreds (mkVarSet qtvs) constraints From git at git.haskell.org Thu Mar 31 07:01:54 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 07:01:54 +0000 (UTC) Subject: [commit: ghc] master: Refactor in TcMatches (bdd9042) Message-ID: <20160331070154.844B53A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/bdd90426a7f88d57bedf15411fa00f62aeb22172/ghc >--------------------------------------------------------------- commit bdd90426a7f88d57bedf15411fa00f62aeb22172 Author: Simon Peyton Jones Date: Wed Mar 30 17:14:11 2016 +0100 Refactor in TcMatches * Move the several calls of tauifyMultipleMatches into tcMatches, so that it can be called only once, and the invariants are clearer * I discovered in doing this that HsLamCase had a redundant and tiresome argument, so I removed it. That in turn allowed some modest but nice code simplification >--------------------------------------------------------------- bdd90426a7f88d57bedf15411fa00f62aeb22172 compiler/deSugar/Coverage.hs | 2 +- compiler/deSugar/DsExpr.hs | 7 +++---- compiler/deSugar/DsMeta.hs | 2 +- compiler/hsSyn/Convert.hs | 3 +-- compiler/hsSyn/HsExpr.hs | 16 +++++++++------- compiler/parser/Parser.y | 2 +- compiler/rename/RnExpr.hs | 5 ++--- compiler/typecheck/TcExpr.hs | 17 +++++++++-------- compiler/typecheck/TcHsSyn.hs | 7 +++---- compiler/typecheck/TcMatches.hs | 24 ++++++++---------------- compiler/typecheck/TcRnTypes.hs | 2 +- 11 files changed, 39 insertions(+), 48 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc bdd90426a7f88d57bedf15411fa00f62aeb22172 From git at git.haskell.org Thu Mar 31 07:01:57 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 07:01:57 +0000 (UTC) Subject: [commit: ghc] master: Small refactor of TcMType.tauifyExpType (174d3a5) Message-ID: <20160331070157.3B8823A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/174d3a53c7a6a60277adae0f4aee2407b03d6f44/ghc >--------------------------------------------------------------- commit 174d3a53c7a6a60277adae0f4aee2407b03d6f44 Author: Simon Peyton Jones Date: Wed Mar 30 17:19:51 2016 +0100 Small refactor of TcMType.tauifyExpType Mainly to make it clearer that tauifyExpType is a no-op on (Check ty) >--------------------------------------------------------------- 174d3a53c7a6a60277adae0f4aee2407b03d6f44 compiler/typecheck/TcMType.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index cb9ed72..296f88c 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -393,14 +393,18 @@ checkingExpType err et = pprPanic "checkingExpType" (text err $$ ppr et) tauifyExpType :: ExpType -> TcM ExpType -- ^ Turn a (Infer hole) type into a (Check alpha), -- where alpha is a fresh unificaiton variable -tauifyExpType exp_ty = do { ty <- expTypeToType exp_ty - ; return (Check ty) } +tauifyExpType (Check ty) = return (Check ty) -- No-op for (Check ty) +tauifyExpType (Infer u tc_lvl ki ref) = do { ty <- inferTypeToType u tc_lvl ki ref + ; return (Check ty) } -- | Extracts the expected type if there is one, or generates a new -- TauTv if there isn't. expTypeToType :: ExpType -> TcM TcType -expTypeToType (Check ty) = return ty -expTypeToType (Infer u tc_lvl ki ref) +expTypeToType (Check ty) = return ty +expTypeToType (Infer u tc_lvl ki ref) = inferTypeToType u tc_lvl ki ref + +inferTypeToType :: Unique -> TcLevel -> Kind -> IORef (Maybe TcType) -> TcM Type +inferTypeToType u tc_lvl ki ref = do { uniq <- newUnique ; tv_ref <- newMutVar Flexi ; let details = MetaTv { mtv_info = TauTv From git at git.haskell.org Thu Mar 31 07:01:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 07:01:59 +0000 (UTC) Subject: [commit: ghc] master: Make SigSkol take TcType not ExpType (0ad2021) Message-ID: <20160331070159.E7C303A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/0ad2021b39ed39940d0f6332d58c7b6debd366ad/ghc >--------------------------------------------------------------- commit 0ad2021b39ed39940d0f6332d58c7b6debd366ad Author: Simon Peyton Jones Date: Wed Mar 30 17:23:37 2016 +0100 Make SigSkol take TcType not ExpType For some reason a SigSkol had an ExpType in it, and there were lots of places where we needed it to have a TcType. And was indeed always a Check. All a lot of fuss about nothing. Delete code, fewer failure points, types are more precise. All good. >--------------------------------------------------------------- 0ad2021b39ed39940d0f6332d58c7b6debd366ad compiler/typecheck/TcBinds.hs | 4 ++-- compiler/typecheck/TcExpr.hs | 2 +- compiler/typecheck/TcMType.hs | 9 +++------ compiler/typecheck/TcPat.hs | 3 +-- compiler/typecheck/TcRnTypes.hs | 4 ++-- compiler/typecheck/TcUnify.hs | 6 ++---- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/compiler/typecheck/TcBinds.hs b/compiler/typecheck/TcBinds.hs index 6ce9aed..3bad211 100644 --- a/compiler/typecheck/TcBinds.hs +++ b/compiler/typecheck/TcBinds.hs @@ -585,7 +585,7 @@ tcPolyCheck rec_tc prag_fn , sig_loc = loc }) bind = do { ev_vars <- newEvVars theta - ; let skol_info = SigSkol ctxt (mkCheckExpType $ mkPhiTy theta tau) + ; let skol_info = SigSkol ctxt (mkPhiTy theta tau) prag_sigs = lookupPragEnv prag_fn name skol_tvs = map snd skol_prs -- Find the location of the original source type sig, if @@ -764,7 +764,7 @@ chooseInferredQuantifiers inferred_theta tau_tvs qtvs Nothing ; return (binders, my_theta) } chooseInferredQuantifiers inferred_theta tau_tvs qtvs - (Just (TISI { sig_bndr = bndr_info + (Just (TISI { sig_bndr = bndr_info -- Always PartialSig , sig_ctxt = ctxt , sig_theta = annotated_theta , sig_skols = annotated_tvs })) diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs index 5eb28f0..a65e60f 100644 --- a/compiler/typecheck/TcExpr.hs +++ b/compiler/typecheck/TcExpr.hs @@ -1480,7 +1480,7 @@ tcExprSig expr sig@(TISI { sig_bndr = s_bndr | otherwise = panic "tcExprSig" -- Can't happen where - skol_info = SigSkol ExprSigCtxt (mkCheckExpType $ mkPhiTy theta tau) + skol_info = SigSkol ExprSigCtxt (mkPhiTy theta tau) skol_tvs = map snd skol_prs {- ********************************************************************* diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index 296f88c..3a03e4d 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -1270,9 +1270,8 @@ zonkCtEvidence ctev@(CtDerived { ctev_pred = pred }) ; return (ctev { ctev_pred = pred' }) } zonkSkolemInfo :: SkolemInfo -> TcM SkolemInfo -zonkSkolemInfo (SigSkol cx ty) = do { ty <- readExpType ty - ; ty' <- zonkTcType ty - ; return (SigSkol cx (mkCheckExpType ty')) } +zonkSkolemInfo (SigSkol cx ty) = do { ty' <- zonkTcType ty + ; return (SigSkol cx ty') } zonkSkolemInfo (InferSkol ntys) = do { ntys' <- mapM do_one ntys ; return (InferSkol ntys') } where @@ -1458,9 +1457,7 @@ tidyEvVar env var = setVarType var (tidyType env (varType var)) ---------------- tidySkolemInfo :: TidyEnv -> SkolemInfo -> SkolemInfo tidySkolemInfo env (DerivSkol ty) = DerivSkol (tidyType env ty) -tidySkolemInfo env (SigSkol cx ty) = SigSkol cx (mkCheckExpType $ - tidyType env $ - checkingExpType "tidySkolemInfo" ty) +tidySkolemInfo env (SigSkol cx ty) = SigSkol cx (tidyType env ty) tidySkolemInfo env (InferSkol ids) = InferSkol (mapSnd (tidyType env) ids) tidySkolemInfo env (UnifyForAllSkol ty) = UnifyForAllSkol (tidyType env ty) tidySkolemInfo _ info = info diff --git a/compiler/typecheck/TcPat.hs b/compiler/typecheck/TcPat.hs index 6cc6429..513eb6d 100644 --- a/compiler/typecheck/TcPat.hs +++ b/compiler/typecheck/TcPat.hs @@ -398,8 +398,7 @@ tc_pat penv (ViewPat expr pat _) overall_pat_ty thing_inside -- expr_wrap1 :: expr'_inferred "->" (inf_arg_ty -> inf_res_ty) -- check that overall pattern is more polymorphic than arg type - ; let pat_origin = GivenOrigin (SigSkol GenSigCtxt overall_pat_ty) - ; expr_wrap2 <- tcSubTypeET pat_origin overall_pat_ty inf_arg_ty + ; expr_wrap2 <- tcSubTypeET (pe_orig penv) overall_pat_ty inf_arg_ty -- expr_wrap2 :: overall_pat_ty "->" inf_arg_ty -- pattern must have inf_res_ty diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs index a7bb56a..6021735 100644 --- a/compiler/typecheck/TcRnTypes.hs +++ b/compiler/typecheck/TcRnTypes.hs @@ -2574,7 +2574,7 @@ pushErrCtxtSameOrigin err loc@(CtLoc { ctl_env = lcl }) -- b) an implication constraint is generated data SkolemInfo = SigSkol UserTypeCtxt -- A skolem that is created by instantiating - ExpType -- a programmer-supplied type signature + TcType -- a programmer-supplied type signature -- Location of the binding site is on the TyVar | PatSynSigSkol Name -- Bound by a programmer-supplied type signature of a pattern @@ -2653,7 +2653,7 @@ pprSkolInfo (PatSynSigSkol name) = text "the type signature of pattern synonym" -- For Insts, these cases should not happen pprSkolInfo UnkSkol = WARN( True, text "pprSkolInfo: UnkSkol" ) text "UnkSkol" -pprSigSkolInfo :: UserTypeCtxt -> ExpType -> SDoc +pprSigSkolInfo :: UserTypeCtxt -> TcType -> SDoc pprSigSkolInfo ctxt ty = case ctxt of FunSigCtxt f _ -> pp_sig f diff --git a/compiler/typecheck/TcUnify.hs b/compiler/typecheck/TcUnify.hs index d8f1e6a..b18671b 100644 --- a/compiler/typecheck/TcUnify.hs +++ b/compiler/typecheck/TcUnify.hs @@ -746,8 +746,7 @@ tc_sub_type_ds eq_orig inst_orig ctxt ty_actual ty_expected do { res_wrap <- tc_sub_type_ds eq_orig inst_orig ctxt act_res exp_res ; arg_wrap <- tc_sub_tc_type eq_orig (GivenOrigin - (SigSkol GenSigCtxt - (mkCheckExpType exp_arg))) + (SigSkol GenSigCtxt exp_arg)) ctxt exp_arg act_arg ; return (mkWpFun arg_wrap res_wrap exp_arg exp_res) } -- arg_wrap :: exp_arg ~ act_arg @@ -883,8 +882,7 @@ tcSkolemise ctxt expected_ty thing_inside -- Use the *instantiated* type in the SkolemInfo -- so that the names of displayed type variables line up - ; let skol_info = SigSkol ctxt (mkCheckExpType $ - mkFunTys (map varType given) rho') + ; let skol_info = SigSkol ctxt (mkFunTys (map varType given) rho') ; (ev_binds, result) <- checkConstraints skol_info tvs' given $ thing_inside tvs' rho' From git at git.haskell.org Thu Mar 31 07:02:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 07:02:02 +0000 (UTC) Subject: [commit: ghc] master: Refactor error generation for pattern synonyms (9fc65bb) Message-ID: <20160331070202.9E30F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/9fc65bb85ef3e6386e84e7f9bbe408dede1baf67/ghc >--------------------------------------------------------------- commit 9fc65bb85ef3e6386e84e7f9bbe408dede1baf67 Author: Simon Peyton Jones Date: Wed Mar 30 17:31:59 2016 +0100 Refactor error generation for pattern synonyms The result of a series of patches on type-error messages for pattern synonyms had become a bit baroque. This tidies it up a bit. Still not fantastic, but better. >--------------------------------------------------------------- 9fc65bb85ef3e6386e84e7f9bbe408dede1baf67 compiler/typecheck/TcErrors.hs | 255 ++++++++++++----------- compiler/typecheck/TcPatSyn.hs | 16 +- compiler/typecheck/TcRnTypes.hs | 20 +- compiler/typecheck/TcType.hs | 18 +- compiler/typecheck/TcValidity.hs | 8 +- testsuite/tests/patsyn/should_fail/T11039.stderr | 2 +- testsuite/tests/patsyn/should_fail/T11667.stderr | 16 +- 7 files changed, 178 insertions(+), 157 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 9fc65bb85ef3e6386e84e7f9bbe408dede1baf67 From git at git.haskell.org Thu Mar 31 08:57:55 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 08:57:55 +0000 (UTC) Subject: [commit: ghc] branch 'wip/T11770' deleted Message-ID: <20160331085755.6515E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Deleted branch: wip/T11770 From git at git.haskell.org Thu Mar 31 08:57:58 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 08:57:58 +0000 (UTC) Subject: [commit: ghc] master: Demand Analyzer: Do not set OneShot information (28fe0ee) Message-ID: <20160331085758.209AF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/28fe0eea4d161b707f67aae26fddaa2e60d8a901/ghc >--------------------------------------------------------------- commit 28fe0eea4d161b707f67aae26fddaa2e60d8a901 Author: Joachim Breitner Date: Wed Mar 30 10:05:28 2016 +0200 Demand Analyzer: Do not set OneShot information as suggested in ticket:11770#comment:1. This code was buggy (#11770), and the occurrence analyzer does the same job anyways. This also elaborates the notes in the occurrence analyzer accordingly. Differential Revision: https://phabricator.haskell.org/D2070 >--------------------------------------------------------------- 28fe0eea4d161b707f67aae26fddaa2e60d8a901 compiler/simplCore/OccurAnal.hs | 33 ++++++++++++----- compiler/stranal/DmdAnal.hs | 55 +++------------------------- testsuite/tests/stranal/should_compile/all.T | 2 +- 3 files changed, 30 insertions(+), 60 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 28fe0eea4d161b707f67aae26fddaa2e60d8a901 From git at git.haskell.org Thu Mar 31 09:47:49 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 09:47:49 +0000 (UTC) Subject: [commit: ghc] master: Revert accidental change to collectTyAndValBinders (da260a5) Message-ID: <20160331094749.DD4003A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/da260a5bddf990959f639a3551b335ee26c766f6/ghc >--------------------------------------------------------------- commit da260a5bddf990959f639a3551b335ee26c766f6 Author: Simon Peyton Jones Date: Thu Mar 31 10:47:47 2016 +0100 Revert accidental change to collectTyAndValBinders Richard accidetally introduced this change in his big kind-equality patch. The code is wrong, and potentially could cause binders to be re-ordered. Worth merging to 8.0. >--------------------------------------------------------------- da260a5bddf990959f639a3551b335ee26c766f6 compiler/coreSyn/CoreSyn.hs | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/compiler/coreSyn/CoreSyn.hs b/compiler/coreSyn/CoreSyn.hs index f06097a..7479dcd 100644 --- a/compiler/coreSyn/CoreSyn.hs +++ b/compiler/coreSyn/CoreSyn.hs @@ -1622,14 +1622,12 @@ flattenBinds (Rec prs1 : binds) = prs1 ++ flattenBinds binds flattenBinds [] = [] -- | We often want to strip off leading lambdas before getting down to --- business. This function is your friend. -collectBinders :: Expr b -> ([b], Expr b) --- | Collect type and value binders from nested lambdas, stopping --- right before any "forall"s within a non-forall. For example, --- forall (a :: *) (b :: Foo ~ Bar) (c :: *). Baz -> forall (d :: *). Blob --- will pull out the binders for a, b, c, and Baz, but not for d or anything --- within Blob. This is to coordinate with tcSplitSigmaTy. -collectTyAndValBinders :: CoreExpr -> ([TyVar], [Id], CoreExpr) +-- business. Variants are 'collectTyBinders', 'collectValBinders', +-- and 'collectTyAndValBinders' +collectBinders :: Expr b -> ([b], Expr b) +collectTyBinders :: CoreExpr -> ([TyVar], CoreExpr) +collectValBinders :: CoreExpr -> ([Id], CoreExpr) +collectTyAndValBinders :: CoreExpr -> ([TyVar], [Id], CoreExpr) collectBinders expr = go [] expr @@ -1637,16 +1635,23 @@ collectBinders expr go bs (Lam b e) = go (b:bs) e go bs e = (reverse bs, e) +collectTyBinders expr + = go [] expr + where + go tvs (Lam b e) | isTyVar b = go (b:tvs) e + go tvs e = (reverse tvs, e) + +collectValBinders expr + = go [] expr + where + go ids (Lam b e) | isId b = go (b:ids) e + go ids body = (reverse ids, body) + collectTyAndValBinders expr - = go_forall [] [] expr - where go_forall tvs ids (Lam b e) - | isTyVar b = go_forall (b:tvs) ids e - | isCoVar b = go_forall tvs (b:ids) e - go_forall tvs ids e = go_fun tvs ids e - - go_fun tvs ids (Lam b e) - | isId b = go_fun tvs (b:ids) e - go_fun tvs ids e = (reverse tvs, reverse ids, e) + = (tvs, ids, body) + where + (tvs, body1) = collectTyBinders expr + (ids, body) = collectValBinders body1 -- | Takes a nested application expression and returns the the function -- being applied and the arguments to which it is applied From git at git.haskell.org Thu Mar 31 11:22:45 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:22:45 +0000 (UTC) Subject: [commit: ghc] wip/T10613, wip/T11731: Core pretty printer: Omit wild case binders (24db5c3) Message-ID: <20160331112245.13F713A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branches: wip/T10613,wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/24db5c33aaf917dcbae3429f189ff9073266db61/ghc >--------------------------------------------------------------- commit 24db5c33aaf917dcbae3429f189ff9073266db61 Author: Joachim Breitner Date: Wed Mar 30 13:22:26 2016 +0200 Core pretty printer: Omit wild case binders as they (especially their id info with absence information) clutter the output too much. They come back with debug_on. >--------------------------------------------------------------- 24db5c33aaf917dcbae3429f189ff9073266db61 compiler/coreSyn/PprCore.hs | 28 ++++++++++++++-------- compiler/hsSyn/HsBinds.hs | 2 +- compiler/stgSyn/StgSyn.hs | 2 +- compiler/utils/Outputable.hs | 2 +- .../tests/deSugar/should_compile/T2431.stderr | 2 +- .../tests/numeric/should_compile/T7116.stdout | 16 +++++-------- .../tests/simplCore/should_compile/T3717.stderr | 4 ++-- .../tests/simplCore/should_compile/T3772.stdout | 5 ++-- .../tests/simplCore/should_compile/T4908.stderr | 8 +++---- .../tests/simplCore/should_compile/T4930.stderr | 10 ++++---- .../tests/simplCore/should_compile/T5366.stdout | 3 ++- .../tests/simplCore/should_compile/T7360.stderr | 12 +++------- .../tests/simplCore/should_compile/T7865.stdout | 4 ++-- .../simplCore/should_compile/spec-inline.stderr | 28 +++++++++------------- 14 files changed, 59 insertions(+), 67 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 24db5c33aaf917dcbae3429f189ff9073266db61 From git at git.haskell.org Thu Mar 31 11:22:47 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:22:47 +0000 (UTC) Subject: [commit: ghc] wip/T10613, wip/T11731: CSE: Do not add a "trivial_scrut -> case binder" mapping (5b8bf15) Message-ID: <20160331112247.D1E393A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branches: wip/T10613,wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/5b8bf154fefc8febb6b2c5f3360478b2d622a9eb/ghc >--------------------------------------------------------------- commit 5b8bf154fefc8febb6b2c5f3360478b2d622a9eb Author: Joachim Breitner Date: Wed Mar 30 18:00:15 2016 +0200 CSE: Do not add a "trivial_scrut -> case binder" mapping according to the existing strategy to replace, in the body of the expression "case x of y in e", occurrences of y with x (and not the other way around with non-trivial case expressions). Previously, the mapping was added to the environment, but never used, due to the exprIsTrivial guard in tryForCSE. But this is fragile if exprIsTrivial is modified, as proposed in #11731, hence the removal of this code smell. >--------------------------------------------------------------- 5b8bf154fefc8febb6b2c5f3360478b2d622a9eb compiler/simplCore/CSE.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/simplCore/CSE.hs b/compiler/simplCore/CSE.hs index b4e6e14..0a053d3 100644 --- a/compiler/simplCore/CSE.hs +++ b/compiler/simplCore/CSE.hs @@ -174,8 +174,13 @@ cseRhs :: CSEnv -> (OutBndr, InExpr) -> (CSEnv, (OutBndr, OutExpr)) cseRhs env (id',rhs) = case lookupCSEnv env rhs'' of Nothing - | always_active -> (extendCSEnv env rhs' id', (zapped_id, rhs')) - | otherwise -> (env, (id', rhs')) + | always_active -> (env', (zapped_id, rhs')) + | otherwise -> (env, (id', rhs')) + where + -- Do not add an unwanted trivial_scrut -> case binder mapping, according + -- to Note [Case binders 2]. + env' | Var {} <- rhs' = env + | otherwise = extendCSEnv env rhs' id' Just id | always_active -> (extendCSSubst env id' id_expr, (id', mkTicks ticks id_expr)) | otherwise -> (env, (id', mkTicks ticks id_expr)) From git at git.haskell.org Thu Mar 31 11:22:51 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:22:51 +0000 (UTC) Subject: [commit: ghc] wip/T10613, wip/T11731: Add a test case for #11731. (b2651a7) Message-ID: <20160331112251.045423A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branches: wip/T10613,wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/b2651a707a2f0d6c39e11a43551bcd54693b727f/ghc >--------------------------------------------------------------- commit b2651a707a2f0d6c39e11a43551bcd54693b727f Author: Joachim Breitner Date: Wed Mar 30 12:55:10 2016 +0200 Add a test case for #11731. >--------------------------------------------------------------- b2651a707a2f0d6c39e11a43551bcd54693b727f testsuite/.gitignore | 1 + testsuite/tests/simplCore/should_run/T11731.hs | 36 ++++++++++++++++++++++ testsuite/tests/simplCore/should_run/T11731.stderr | 1 + testsuite/tests/simplCore/should_run/all.T | 1 + 4 files changed, 39 insertions(+) diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 655e3da..e1f1822 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1475,6 +1475,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/simplCore/should_run/T5997 /tests/simplCore/should_run/T7101 /tests/simplCore/should_run/T7924 +/tests/simplCore/should_run/T11731 /tests/simplCore/should_run/T9128 /tests/simplCore/should_run/T9390 /tests/simplCore/should_run/runST diff --git a/testsuite/tests/simplCore/should_run/T11731.hs b/testsuite/tests/simplCore/should_run/T11731.hs new file mode 100644 index 0000000..e148507 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.hs @@ -0,0 +1,36 @@ +module Main (main ) where + +import Debug.Trace + +foo :: (a,b) -> a +foo (x,y) = x +{-# NOINLINE foo #-} + +wwMe :: Int -> (Int,Int) -> (Int, Int) +wwMe 0 p = + let a = fst p + b = snd p + -- This ensure sharing of b, as seen by the demand analyzer + + in foo p `seq` + -- This ensures that wwMe is strict in the tuple, but that the tuple + -- is preserved. + (b + a, a + b) + +wwMe n p = wwMe (n-1) (0,0) + -- ^ Make it recursive, so that it is attractive to worker-wrapper + +go :: Int -> IO () +go seed = do + let shareMeThunk = trace "Evaluated (should only happen once)" (seed + 1) + {-# NOINLINE shareMeThunk #-} + -- ^ This is the thunk that is wrongly evaluated twice. + + let (x,y) = wwMe 0 (seed,shareMeThunk) + + (x + y) `seq` return () + -- ^ Use both components +{-# NOINLINE go #-} + +main :: IO () +main = go 42 diff --git a/testsuite/tests/simplCore/should_run/T11731.stderr b/testsuite/tests/simplCore/should_run/T11731.stderr new file mode 100644 index 0000000..8d1fc60 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.stderr @@ -0,0 +1 @@ +Evaluated (should only happen once) diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T index 9c15b0f..042c097 100644 --- a/testsuite/tests/simplCore/should_run/all.T +++ b/testsuite/tests/simplCore/should_run/all.T @@ -71,3 +71,4 @@ test('T9128', normal, compile_and_run, ['']) test('T9390', normal, compile_and_run, ['']) test('T10830', extra_run_opts('+RTS -K100k -RTS'), compile_and_run, ['']) test('T11172', normal, compile_and_run, ['']) +test('T11731', expect_broken(11731), compile_and_run, ['-fspec-constr']) From git at git.haskell.org Thu Mar 31 11:22:53 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:22:53 +0000 (UTC) Subject: [commit: ghc] wip/T10613, wip/T11731: Add a final demand analyzer run right before TidyCore (cd459b8) Message-ID: <20160331112253.B6FA43A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branches: wip/T10613,wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/cd459b8cf8ae8ec79e3232321cc10ffa3b08be45/ghc >--------------------------------------------------------------- commit cd459b8cf8ae8ec79e3232321cc10ffa3b08be45 Author: Joachim Breitner Date: Thu Mar 31 10:18:15 2016 +0200 Add a final demand analyzer run right before TidyCore in order to have precise used-once information in the exported strictness signatures, as well as precise used-once information on thunks. This avoids the bad effects of #11731. >--------------------------------------------------------------- cd459b8cf8ae8ec79e3232321cc10ffa3b08be45 compiler/simplCore/SimplCore.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs index 98bcf2a..689ffbd 100644 --- a/compiler/simplCore/SimplCore.hs +++ b/compiler/simplCore/SimplCore.hs @@ -319,6 +319,11 @@ getCoreToDo dflags [simpl_phase 0 ["post-late-ww"] max_iter] ), + -- Final run of the demand_analyser, ensures that one-shot thunks are + -- really really one-shot thunks. Only needed if the demand analyser + -- has run at all. + runWhen (strictness || late_dmd_anal) CoreDoStrictness, + maybe_rule_check (Phase 0) ] From git at git.haskell.org Thu Mar 31 11:22:56 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:22:56 +0000 (UTC) Subject: [commit: ghc] wip/T10613, wip/T11731: Demand Analyser: Zap fragile used-once information (aed3780) Message-ID: <20160331112256.759853A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branches: wip/T10613,wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/aed37807505fe80cec4d685ed131d9a5f697b704/ghc >--------------------------------------------------------------- commit aed37807505fe80cec4d685ed131d9a5f697b704 Author: Joachim Breitner Date: Thu Mar 31 12:38:02 2016 +0200 Demand Analyser: Zap fragile used-once information in all runs of the demand analysis besides the last one right before CodeTidy. See #11731 for a discussion. >--------------------------------------------------------------- aed37807505fe80cec4d685ed131d9a5f697b704 compiler/basicTypes/Demand.hs | 22 +++++++++++++- compiler/basicTypes/Id.hs | 5 ++- compiler/basicTypes/IdInfo.hs | 7 ++++- compiler/coreSyn/CoreLint.hs | 2 +- compiler/simplCore/CoreMonad.hs | 4 +-- compiler/simplCore/SimplCore.hs | 14 ++++----- compiler/stranal/DmdAnal.hs | 67 +++++++++++++++++++++++++++++++++++------ 7 files changed, 99 insertions(+), 22 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc aed37807505fe80cec4d685ed131d9a5f697b704 From git at git.haskell.org Thu Mar 31 11:22:59 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:22:59 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Temporarily move regular entry counting to the COUNTING_IND (9addc7f) Message-ID: <20160331112259.470443A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/9addc7ff587743ce056757a7ed482efeaef818e9/ghc >--------------------------------------------------------------- commit 9addc7ff587743ce056757a7ed482efeaef818e9 Author: Joachim Breitner Date: Wed Mar 23 14:28:34 2016 +0100 Temporarily move regular entry counting to the COUNTING_IND >--------------------------------------------------------------- 9addc7ff587743ce056757a7ed482efeaef818e9 compiler/codeGen/StgCmmBind.hs | 8 ++++++-- rts/StgMiscClosures.cmm | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 5951175..8672273 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -609,9 +609,13 @@ thunkCode cl_info fv_details _cc node arity body -- Heap overflow check ; entryHeapCheck cl_info node' arity [] $ do - { -- Overwrite with black hole if necessary + { + -- Disabled for now, as we (temporarily unconditionally) move the + -- counting to the counting indirection + -- tickyEnterThunk cl_info + + -- Overwrite with black hole if necessary -- but *after* the heap-overflow check - ; tickyEnterThunk cl_info ; when (blackHoleOnEntry cl_info && node_points) (blackHoleIt node) diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 96b95aa..0f27fdb 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -283,6 +283,7 @@ INFO_TABLE(stg_COUNTING_IND,1,2,COUNTING_IND,"COUNTING_IND","COUNTING_IND") StgEntCounter_multi_entry_count(ent_ctr) = StgEntCounter_multi_entry_count(ent_ctr) + 1; } StgCountingInd_entries(clos) = entries + 1; + StgEntCounter_entry_count(ent_ctr) = StgEntCounter_entry_count(ent_ctr) + 1; #if defined(TICKY_TICKY) && !defined(PROFILING) /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than From git at git.haskell.org Thu Mar 31 11:23:02 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:23:02 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Evac: Do not evaluate selector thunks pointing to counting indirections (5737f05) Message-ID: <20160331112302.0A83F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/5737f0517074edcc98278578f2c6e546aa9ad4b7/ghc >--------------------------------------------------------------- commit 5737f0517074edcc98278578f2c6e546aa9ad4b7 Author: Joachim Breitner Date: Wed Mar 23 13:50:00 2016 +0100 Evac: Do not evaluate selector thunks pointing to counting indirections >--------------------------------------------------------------- 5737f0517074edcc98278578f2c6e546aa9ad4b7 rts/sm/Evac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 3b4314b..9369543 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -998,12 +998,17 @@ selector_loop: } case IND: - case COUNTING_IND: case IND_STATIC: // Again, we might need to untag a constructor. selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); goto selector_loop; + case COUNTING_IND: + // do not short cut a COUNTING_IND, as we would miss a the count + // Can we simply tick the counter here? Not really: If this selector + // thunk is not going to be used, we counted more than we wanted! + goto bale_out; + case BLACKHOLE: { StgClosure *r; From git at git.haskell.org Thu Mar 31 11:23:04 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:23:04 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (92e67ce) Message-ID: <20160331112304.CBAA03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/92e67cebc02ef072fd0171615a8536fa5720955a/ghc >--------------------------------------------------------------- commit 92e67cebc02ef072fd0171615a8536fa5720955a Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- 92e67cebc02ef072fd0171615a8536fa5720955a compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 92e67cebc02ef072fd0171615a8536fa5720955a From git at git.haskell.org Thu Mar 31 11:23:07 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:23:07 +0000 (UTC) Subject: [commit: ghc] wip/T10613: State hack hack in ticky report (fd25aed) Message-ID: <20160331112307.8068D3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/fd25aed26677ff497bc25a7b37c61a0ea83c2772/ghc >--------------------------------------------------------------- commit fd25aed26677ff497bc25a7b37c61a0ea83c2772 Author: Joachim Breitner Date: Wed Mar 23 11:10:25 2016 +0100 State hack hack in ticky report In the ticky report, do not mark a function with a State# argument as its first argument as single-entry. >--------------------------------------------------------------- fd25aed26677ff497bc25a7b37c61a0ea83c2772 compiler/codeGen/StgCmmClosure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index b467048..3b83b8e 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -234,7 +234,10 @@ mkLFReEntrant _ _ [] _ = pprPanic "mkLFReEntrant" empty mkLFReEntrant top fvs args arg_descr = LFReEntrant top os_info (length args) (null fvs) arg_descr - where os_info = idOneShotInfo (head args) + where + state_hack_hack = isStateHackType (idType (head args)) + os_info | state_hack_hack = noOneShotInfo + | otherwise = idOneShotInfo (head args) ------------- mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo From git at git.haskell.org Thu Mar 31 11:23:09 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:23:09 +0000 (UTC) Subject: [commit: ghc] wip/T10613's head updated: Temporarily move regular entry counting to the COUNTING_IND (9addc7f) Message-ID: <20160331112309.C5ACD3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T10613' now includes: 1757dd8 Don't recompute some free vars in lintCoercion 3d245bf Do not claim that -O2 does not do better than -O 973633a Comments only in Unify.hs 7aa4c52 rts/posix/Itimer.c: Handle EINTR when reading timerfd d1179c4 ghc-prim: Delay inlining of {gt,ge,lt,le}Int to phase 1 c0e3e63 Defer inlining of Ord methods 58bbb40 ghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE e9c2555 Don't require -hide-all-packages for MIN_VERSION_* macros bc953fc Add -f(no-)version-macro to explicitly control macros. 24d7615 Kill the magic of Any 8f66bac Comments only 1f68da1 Minor refactoring in mkExport 2e5e822 Comments only bdd9042 Refactor in TcMatches 174d3a5 Small refactor of TcMType.tauifyExpType 0ad2021 Make SigSkol take TcType not ExpType 9fc65bb Refactor error generation for pattern synonyms 28fe0ee Demand Analyzer: Do not set OneShot information da260a5 Revert accidental change to collectTyAndValBinders 24db5c3 Core pretty printer: Omit wild case binders 5b8bf15 CSE: Do not add a "trivial_scrut -> case binder" mapping b2651a7 Add a test case for #11731. cd459b8 Add a final demand analyzer run right before TidyCore aed3780 Demand Analyser: Zap fragile used-once information 92e67ce Rough working implementation of #10613 fd25aed State hack hack in ticky report 5737f05 Evac: Do not evaluate selector thunks pointing to counting indirections 9addc7f Temporarily move regular entry counting to the COUNTING_IND From git at git.haskell.org Thu Mar 31 11:23:12 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:23:12 +0000 (UTC) Subject: [commit: ghc] wip/T11731's head updated: Demand Analyser: Zap fragile used-once information (aed3780) Message-ID: <20160331112312.0A7CC3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T11731' now includes: 1757dd8 Don't recompute some free vars in lintCoercion 3d245bf Do not claim that -O2 does not do better than -O 973633a Comments only in Unify.hs 7aa4c52 rts/posix/Itimer.c: Handle EINTR when reading timerfd d1179c4 ghc-prim: Delay inlining of {gt,ge,lt,le}Int to phase 1 c0e3e63 Defer inlining of Ord methods 58bbb40 ghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE e9c2555 Don't require -hide-all-packages for MIN_VERSION_* macros bc953fc Add -f(no-)version-macro to explicitly control macros. 24d7615 Kill the magic of Any 8f66bac Comments only 1f68da1 Minor refactoring in mkExport 2e5e822 Comments only bdd9042 Refactor in TcMatches 174d3a5 Small refactor of TcMType.tauifyExpType 0ad2021 Make SigSkol take TcType not ExpType 9fc65bb Refactor error generation for pattern synonyms 28fe0ee Demand Analyzer: Do not set OneShot information da260a5 Revert accidental change to collectTyAndValBinders 24db5c3 Core pretty printer: Omit wild case binders 5b8bf15 CSE: Do not add a "trivial_scrut -> case binder" mapping b2651a7 Add a test case for #11731. cd459b8 Add a final demand analyzer run right before TidyCore aed3780 Demand Analyser: Zap fragile used-once information From git at git.haskell.org Thu Mar 31 11:35:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:35:17 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Add a final demand analyzer run right before TidyCore (c762111) Message-ID: <20160331113517.493E03A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/c7621119fe590eb0b7306214be65bc64f5455b6b/ghc >--------------------------------------------------------------- commit c7621119fe590eb0b7306214be65bc64f5455b6b Author: Joachim Breitner Date: Thu Mar 31 10:18:15 2016 +0200 Add a final demand analyzer run right before TidyCore in order to have precise used-once information in the exported strictness signatures, as well as precise used-once information on thunks. This avoids the bad effects of #11731. >--------------------------------------------------------------- c7621119fe590eb0b7306214be65bc64f5455b6b compiler/simplCore/SimplCore.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs index 98bcf2a..689ffbd 100644 --- a/compiler/simplCore/SimplCore.hs +++ b/compiler/simplCore/SimplCore.hs @@ -319,6 +319,11 @@ getCoreToDo dflags [simpl_phase 0 ["post-late-ww"] max_iter] ), + -- Final run of the demand_analyser, ensures that one-shot thunks are + -- really really one-shot thunks. Only needed if the demand analyser + -- has run at all. + runWhen (strictness || late_dmd_anal) CoreDoStrictness, + maybe_rule_check (Phase 0) ] From git at git.haskell.org Thu Mar 31 11:35:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:35:20 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Add a test case for #11731. (13ea9da) Message-ID: <20160331113520.6E3A73A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/13ea9dad7f292bdfac838ebc6fea8d0e16baf12a/ghc >--------------------------------------------------------------- commit 13ea9dad7f292bdfac838ebc6fea8d0e16baf12a Author: Joachim Breitner Date: Wed Mar 30 12:55:10 2016 +0200 Add a test case for #11731. >--------------------------------------------------------------- 13ea9dad7f292bdfac838ebc6fea8d0e16baf12a testsuite/.gitignore | 1 + testsuite/tests/simplCore/should_run/T11731.hs | 36 ++++++++++++++++++++++ testsuite/tests/simplCore/should_run/T11731.stderr | 1 + testsuite/tests/simplCore/should_run/all.T | 1 + 4 files changed, 39 insertions(+) diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 655e3da..e1f1822 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1475,6 +1475,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/simplCore/should_run/T5997 /tests/simplCore/should_run/T7101 /tests/simplCore/should_run/T7924 +/tests/simplCore/should_run/T11731 /tests/simplCore/should_run/T9128 /tests/simplCore/should_run/T9390 /tests/simplCore/should_run/runST diff --git a/testsuite/tests/simplCore/should_run/T11731.hs b/testsuite/tests/simplCore/should_run/T11731.hs new file mode 100644 index 0000000..e148507 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.hs @@ -0,0 +1,36 @@ +module Main (main ) where + +import Debug.Trace + +foo :: (a,b) -> a +foo (x,y) = x +{-# NOINLINE foo #-} + +wwMe :: Int -> (Int,Int) -> (Int, Int) +wwMe 0 p = + let a = fst p + b = snd p + -- This ensure sharing of b, as seen by the demand analyzer + + in foo p `seq` + -- This ensures that wwMe is strict in the tuple, but that the tuple + -- is preserved. + (b + a, a + b) + +wwMe n p = wwMe (n-1) (0,0) + -- ^ Make it recursive, so that it is attractive to worker-wrapper + +go :: Int -> IO () +go seed = do + let shareMeThunk = trace "Evaluated (should only happen once)" (seed + 1) + {-# NOINLINE shareMeThunk #-} + -- ^ This is the thunk that is wrongly evaluated twice. + + let (x,y) = wwMe 0 (seed,shareMeThunk) + + (x + y) `seq` return () + -- ^ Use both components +{-# NOINLINE go #-} + +main :: IO () +main = go 42 diff --git a/testsuite/tests/simplCore/should_run/T11731.stderr b/testsuite/tests/simplCore/should_run/T11731.stderr new file mode 100644 index 0000000..8d1fc60 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.stderr @@ -0,0 +1 @@ +Evaluated (should only happen once) diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T index 9c15b0f..042c097 100644 --- a/testsuite/tests/simplCore/should_run/all.T +++ b/testsuite/tests/simplCore/should_run/all.T @@ -71,3 +71,4 @@ test('T9128', normal, compile_and_run, ['']) test('T9390', normal, compile_and_run, ['']) test('T10830', extra_run_opts('+RTS -K100k -RTS'), compile_and_run, ['']) test('T11172', normal, compile_and_run, ['']) +test('T11731', expect_broken(11731), compile_and_run, ['-fspec-constr']) From git at git.haskell.org Thu Mar 31 11:35:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:35:23 +0000 (UTC) Subject: [commit: ghc] wip/T11731: CSE: Do not add a "trivial_scrut -> case binder" mapping (3d25033) Message-ID: <20160331113523.184AE3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/3d25033d46ab30323d868d615c0d59c377e25ea2/ghc >--------------------------------------------------------------- commit 3d25033d46ab30323d868d615c0d59c377e25ea2 Author: Joachim Breitner Date: Wed Mar 30 18:00:15 2016 +0200 CSE: Do not add a "trivial_scrut -> case binder" mapping according to the existing strategy to replace, in the body of the expression "case x of y in e", occurrences of y with x (and not the other way around with non-trivial case expressions). Previously, the mapping was added to the environment, but never used, due to the exprIsTrivial guard in tryForCSE. But this is fragile if exprIsTrivial is modified, as proposed in #11731, hence the removal of this code smell. >--------------------------------------------------------------- 3d25033d46ab30323d868d615c0d59c377e25ea2 compiler/simplCore/CSE.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/simplCore/CSE.hs b/compiler/simplCore/CSE.hs index b4e6e14..0a053d3 100644 --- a/compiler/simplCore/CSE.hs +++ b/compiler/simplCore/CSE.hs @@ -174,8 +174,13 @@ cseRhs :: CSEnv -> (OutBndr, InExpr) -> (CSEnv, (OutBndr, OutExpr)) cseRhs env (id',rhs) = case lookupCSEnv env rhs'' of Nothing - | always_active -> (extendCSEnv env rhs' id', (zapped_id, rhs')) - | otherwise -> (env, (id', rhs')) + | always_active -> (env', (zapped_id, rhs')) + | otherwise -> (env, (id', rhs')) + where + -- Do not add an unwanted trivial_scrut -> case binder mapping, according + -- to Note [Case binders 2]. + env' | Var {} <- rhs' = env + | otherwise = extendCSEnv env rhs' id' Just id | always_active -> (extendCSSubst env id' id_expr, (id', mkTicks ticks id_expr)) | otherwise -> (env, (id', mkTicks ticks id_expr)) From git at git.haskell.org Thu Mar 31 11:35:25 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:35:25 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Core pretty printer: Omit wild case binders (9ee312c) Message-ID: <20160331113525.C063E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/9ee312c1beb60175ad1c9bb600cc5e581e8937aa/ghc >--------------------------------------------------------------- commit 9ee312c1beb60175ad1c9bb600cc5e581e8937aa Author: Joachim Breitner Date: Wed Mar 30 13:22:26 2016 +0200 Core pretty printer: Omit wild case binders as they (especially their id info with absence information) clutter the output too much. They come back with debug_on. >--------------------------------------------------------------- 9ee312c1beb60175ad1c9bb600cc5e581e8937aa compiler/coreSyn/PprCore.hs | 43 +++++++++++++++++----- compiler/hsSyn/HsBinds.hs | 2 +- compiler/stgSyn/StgSyn.hs | 2 +- compiler/utils/Outputable.hs | 6 ++- .../tests/deSugar/should_compile/T2431.stderr | 2 +- .../tests/numeric/should_compile/T7116.stdout | 16 +++----- .../tests/simplCore/should_compile/T3717.stderr | 4 +- .../tests/simplCore/should_compile/T3772.stdout | 5 +-- .../tests/simplCore/should_compile/T4908.stderr | 8 ++-- .../tests/simplCore/should_compile/T4930.stderr | 10 ++--- .../tests/simplCore/should_compile/T5366.stdout | 3 +- .../tests/simplCore/should_compile/T7360.stderr | 12 ++---- .../tests/simplCore/should_compile/T7865.stdout | 4 +- .../simplCore/should_compile/spec-inline.stderr | 28 ++++++-------- 14 files changed, 78 insertions(+), 67 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 9ee312c1beb60175ad1c9bb600cc5e581e8937aa From git at git.haskell.org Thu Mar 31 11:35:28 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 11:35:28 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Demand Analyser: Zap fragile used-once information (362b677) Message-ID: <20160331113528.753973A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/362b677ab7d02fb354d38e074d7479c0eb4da751/ghc >--------------------------------------------------------------- commit 362b677ab7d02fb354d38e074d7479c0eb4da751 Author: Joachim Breitner Date: Thu Mar 31 12:38:02 2016 +0200 Demand Analyser: Zap fragile used-once information in all runs of the demand analysis besides the last one right before CodeTidy. See #11731 for a discussion. >--------------------------------------------------------------- 362b677ab7d02fb354d38e074d7479c0eb4da751 compiler/basicTypes/Demand.hs | 22 +++++++++++++- compiler/basicTypes/Id.hs | 5 ++- compiler/basicTypes/IdInfo.hs | 7 ++++- compiler/coreSyn/CoreLint.hs | 2 +- compiler/simplCore/CoreMonad.hs | 4 +-- compiler/simplCore/SimplCore.hs | 14 ++++----- compiler/stranal/DmdAnal.hs | 67 +++++++++++++++++++++++++++++++++++------ 7 files changed, 99 insertions(+), 22 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 362b677ab7d02fb354d38e074d7479c0eb4da751 From git at git.haskell.org Thu Mar 31 14:36:14 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 14:36:14 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Core pretty printer: Omit wild case binders (809ecf2) Message-ID: <20160331143614.C9F603A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/809ecf2e6b94badd078760857886bde9068780d9/ghc >--------------------------------------------------------------- commit 809ecf2e6b94badd078760857886bde9068780d9 Author: Joachim Breitner Date: Wed Mar 30 13:22:26 2016 +0200 Core pretty printer: Omit wild case binders as they (especially their id info with absence information) clutter the output too much. They come back with debug_on. >--------------------------------------------------------------- 809ecf2e6b94badd078760857886bde9068780d9 compiler/coreSyn/PprCore.hs | 43 +++++++++++++++++----- compiler/hsSyn/HsBinds.hs | 2 +- compiler/stgSyn/StgSyn.hs | 2 +- compiler/utils/Outputable.hs | 7 +++- .../tests/deSugar/should_compile/T2431.stderr | 2 +- .../tests/numeric/should_compile/T7116.stdout | 16 +++----- .../tests/simplCore/should_compile/T3717.stderr | 4 +- .../tests/simplCore/should_compile/T3772.stdout | 5 +-- .../tests/simplCore/should_compile/T4908.stderr | 8 ++-- .../tests/simplCore/should_compile/T4930.stderr | 10 ++--- .../tests/simplCore/should_compile/T5366.stdout | 3 +- .../tests/simplCore/should_compile/T7360.stderr | 12 ++---- .../tests/simplCore/should_compile/T7865.stdout | 4 +- .../simplCore/should_compile/spec-inline.stderr | 28 ++++++-------- 14 files changed, 79 insertions(+), 67 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 809ecf2e6b94badd078760857886bde9068780d9 From git at git.haskell.org Thu Mar 31 14:36:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 14:36:18 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Add a test case for #11731. (fd3c8d3) Message-ID: <20160331143618.0AE6A3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/fd3c8d31f5af455af3e76f8c640fd516b4d57e61/ghc >--------------------------------------------------------------- commit fd3c8d31f5af455af3e76f8c640fd516b4d57e61 Author: Joachim Breitner Date: Wed Mar 30 12:55:10 2016 +0200 Add a test case for #11731. >--------------------------------------------------------------- fd3c8d31f5af455af3e76f8c640fd516b4d57e61 testsuite/.gitignore | 1 + testsuite/tests/simplCore/should_run/T11731.hs | 36 ++++++++++++++++++++++ testsuite/tests/simplCore/should_run/T11731.stderr | 1 + testsuite/tests/simplCore/should_run/all.T | 1 + 4 files changed, 39 insertions(+) diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 655e3da..e1f1822 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1475,6 +1475,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/simplCore/should_run/T5997 /tests/simplCore/should_run/T7101 /tests/simplCore/should_run/T7924 +/tests/simplCore/should_run/T11731 /tests/simplCore/should_run/T9128 /tests/simplCore/should_run/T9390 /tests/simplCore/should_run/runST diff --git a/testsuite/tests/simplCore/should_run/T11731.hs b/testsuite/tests/simplCore/should_run/T11731.hs new file mode 100644 index 0000000..e148507 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.hs @@ -0,0 +1,36 @@ +module Main (main ) where + +import Debug.Trace + +foo :: (a,b) -> a +foo (x,y) = x +{-# NOINLINE foo #-} + +wwMe :: Int -> (Int,Int) -> (Int, Int) +wwMe 0 p = + let a = fst p + b = snd p + -- This ensure sharing of b, as seen by the demand analyzer + + in foo p `seq` + -- This ensures that wwMe is strict in the tuple, but that the tuple + -- is preserved. + (b + a, a + b) + +wwMe n p = wwMe (n-1) (0,0) + -- ^ Make it recursive, so that it is attractive to worker-wrapper + +go :: Int -> IO () +go seed = do + let shareMeThunk = trace "Evaluated (should only happen once)" (seed + 1) + {-# NOINLINE shareMeThunk #-} + -- ^ This is the thunk that is wrongly evaluated twice. + + let (x,y) = wwMe 0 (seed,shareMeThunk) + + (x + y) `seq` return () + -- ^ Use both components +{-# NOINLINE go #-} + +main :: IO () +main = go 42 diff --git a/testsuite/tests/simplCore/should_run/T11731.stderr b/testsuite/tests/simplCore/should_run/T11731.stderr new file mode 100644 index 0000000..8d1fc60 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.stderr @@ -0,0 +1 @@ +Evaluated (should only happen once) diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T index 9c15b0f..042c097 100644 --- a/testsuite/tests/simplCore/should_run/all.T +++ b/testsuite/tests/simplCore/should_run/all.T @@ -71,3 +71,4 @@ test('T9128', normal, compile_and_run, ['']) test('T9390', normal, compile_and_run, ['']) test('T10830', extra_run_opts('+RTS -K100k -RTS'), compile_and_run, ['']) test('T11172', normal, compile_and_run, ['']) +test('T11731', expect_broken(11731), compile_and_run, ['-fspec-constr']) From git at git.haskell.org Thu Mar 31 14:36:20 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 14:36:20 +0000 (UTC) Subject: [commit: ghc] wip/T11731: CSE: Do not add a "trivial_scrut -> case binder" mapping (fff75a8) Message-ID: <20160331143620.D3E323A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/fff75a8d5873ebdf28a38aa4a3578df1443d64d3/ghc >--------------------------------------------------------------- commit fff75a8d5873ebdf28a38aa4a3578df1443d64d3 Author: Joachim Breitner Date: Wed Mar 30 18:00:15 2016 +0200 CSE: Do not add a "trivial_scrut -> case binder" mapping according to the existing strategy to replace, in the body of the expression "case x of y in e", occurrences of y with x (and not the other way around with non-trivial case expressions). Previously, the mapping was added to the environment, but never used, due to the exprIsTrivial guard in tryForCSE. But this is fragile if exprIsTrivial is modified, as proposed in #11731, hence the removal of this code smell. >--------------------------------------------------------------- fff75a8d5873ebdf28a38aa4a3578df1443d64d3 compiler/simplCore/CSE.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/simplCore/CSE.hs b/compiler/simplCore/CSE.hs index b4e6e14..0a053d3 100644 --- a/compiler/simplCore/CSE.hs +++ b/compiler/simplCore/CSE.hs @@ -174,8 +174,13 @@ cseRhs :: CSEnv -> (OutBndr, InExpr) -> (CSEnv, (OutBndr, OutExpr)) cseRhs env (id',rhs) = case lookupCSEnv env rhs'' of Nothing - | always_active -> (extendCSEnv env rhs' id', (zapped_id, rhs')) - | otherwise -> (env, (id', rhs')) + | always_active -> (env', (zapped_id, rhs')) + | otherwise -> (env, (id', rhs')) + where + -- Do not add an unwanted trivial_scrut -> case binder mapping, according + -- to Note [Case binders 2]. + env' | Var {} <- rhs' = env + | otherwise = extendCSEnv env rhs' id' Just id | always_active -> (extendCSSubst env id' id_expr, (id', mkTicks ticks id_expr)) | otherwise -> (env, (id', mkTicks ticks id_expr)) From git at git.haskell.org Thu Mar 31 14:36:23 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 14:36:23 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Add a final demand analyzer run right before TidyCore (5932738) Message-ID: <20160331143623.8AD8E3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/593273810213a6a1b1941d4d00f815e523bfcd99/ghc >--------------------------------------------------------------- commit 593273810213a6a1b1941d4d00f815e523bfcd99 Author: Joachim Breitner Date: Thu Mar 31 10:18:15 2016 +0200 Add a final demand analyzer run right before TidyCore in order to have precise used-once information in the exported strictness signatures, as well as precise used-once information on thunks. This avoids the bad effects of #11731. >--------------------------------------------------------------- 593273810213a6a1b1941d4d00f815e523bfcd99 compiler/simplCore/SimplCore.hs | 5 +++++ compiler/stranal/DmdAnal.hs | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs index 98bcf2a..1ff0cee 100644 --- a/compiler/simplCore/SimplCore.hs +++ b/compiler/simplCore/SimplCore.hs @@ -319,6 +319,11 @@ getCoreToDo dflags [simpl_phase 0 ["post-late-ww"] max_iter] ), + -- Final run of the demand_analyser, ensures that one-shot thunks are + -- really really one-shot thunks. Only needed if the demand analyser + -- has run at all. See Note [Final Demand Analyser run] in DmdAnal + runWhen (strictness || late_dmd_anal) CoreDoStrictness, + maybe_rule_check (Phase 0) ] diff --git a/compiler/stranal/DmdAnal.hs b/compiler/stranal/DmdAnal.hs index 20f65d5..4d3fd09 100644 --- a/compiler/stranal/DmdAnal.hs +++ b/compiler/stranal/DmdAnal.hs @@ -1331,4 +1331,32 @@ of the Id, and start from "bottom". Nowadays the Id can have a current strictness, because interface files record strictness for nested bindings. To know when we are in the first iteration, we look at the ae_virgin field of the AnalEnv. + + +Note [Final Demand Analyser run] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some of the information that the demand analyser determines is not always +preserved by the simplifier, for example, the simplifier will happily rewrite + \y [Demand=1*U] let x = y in x + x +to + \y [Demand=1*U] y + y +which is quite a lie. + +The once-used information is (currently) only used by the code generator, though. So we + * do not bother keeping this information up-to-date in the simplifier, or + removing it after the demand analyser is done (keeping in mind not to + critically rely on this information in, say, the simplifier). + It should still be fine to use this as in heuristics, e.g. when deciding to + inline things, as the data will usually be correct. + * Just before TidyCore, we add a pass of the demand analyse, without + subsequent worker/wrapper and simplifier, right before TidyCore. + This way, correct information finds its way into the module interface + (strictness signatures!) and the code generator (single-entry thunks!) + +Note that the single-call information (C1(..)) can be relied upon, as the +simplifier tends to be very careful about not duplicating actual function +calls. + +Also see #11731. -} From git at git.haskell.org Thu Mar 31 16:28:00 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 16:28:00 +0000 (UTC) Subject: [commit: ghc] master: Revert "Demand Analyzer: Do not set OneShot information" (6ea42c7) Message-ID: <20160331162800.17C033A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : master Link : http://ghc.haskell.org/trac/ghc/changeset/6ea42c72dc924eddba3f2ee22fa4e514084fa5cc/ghc >--------------------------------------------------------------- commit 6ea42c72dc924eddba3f2ee22fa4e514084fa5cc Author: Joachim Breitner Date: Thu Mar 31 18:29:50 2016 +0200 Revert "Demand Analyzer: Do not set OneShot information" This reverts commit 28fe0eea4d161b707f67aae26fddaa2e60d8a901 due to various regressions. I?m not sure why my local ./validate --slow run did not catch this, though. >--------------------------------------------------------------- 6ea42c72dc924eddba3f2ee22fa4e514084fa5cc compiler/simplCore/OccurAnal.hs | 33 +++++------------ compiler/stranal/DmdAnal.hs | 55 +++++++++++++++++++++++++--- testsuite/tests/stranal/should_compile/all.T | 2 +- 3 files changed, 60 insertions(+), 30 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 6ea42c72dc924eddba3f2ee22fa4e514084fa5cc From git at git.haskell.org Thu Mar 31 20:35:27 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:35:27 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Add a test case for #11731. (5bed931) Message-ID: <20160331203527.142133A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/5bed931b774908c4852803cf37cbbd4fcff9e697/ghc >--------------------------------------------------------------- commit 5bed931b774908c4852803cf37cbbd4fcff9e697 Author: Joachim Breitner Date: Wed Mar 30 12:55:10 2016 +0200 Add a test case for #11731. >--------------------------------------------------------------- 5bed931b774908c4852803cf37cbbd4fcff9e697 testsuite/.gitignore | 1 + testsuite/tests/simplCore/should_run/T11731.hs | 36 ++++++++++++++++++++++ testsuite/tests/simplCore/should_run/T11731.stderr | 1 + testsuite/tests/simplCore/should_run/all.T | 1 + 4 files changed, 39 insertions(+) diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 655e3da..e1f1822 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1475,6 +1475,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk /tests/simplCore/should_run/T5997 /tests/simplCore/should_run/T7101 /tests/simplCore/should_run/T7924 +/tests/simplCore/should_run/T11731 /tests/simplCore/should_run/T9128 /tests/simplCore/should_run/T9390 /tests/simplCore/should_run/runST diff --git a/testsuite/tests/simplCore/should_run/T11731.hs b/testsuite/tests/simplCore/should_run/T11731.hs new file mode 100644 index 0000000..e148507 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.hs @@ -0,0 +1,36 @@ +module Main (main ) where + +import Debug.Trace + +foo :: (a,b) -> a +foo (x,y) = x +{-# NOINLINE foo #-} + +wwMe :: Int -> (Int,Int) -> (Int, Int) +wwMe 0 p = + let a = fst p + b = snd p + -- This ensure sharing of b, as seen by the demand analyzer + + in foo p `seq` + -- This ensures that wwMe is strict in the tuple, but that the tuple + -- is preserved. + (b + a, a + b) + +wwMe n p = wwMe (n-1) (0,0) + -- ^ Make it recursive, so that it is attractive to worker-wrapper + +go :: Int -> IO () +go seed = do + let shareMeThunk = trace "Evaluated (should only happen once)" (seed + 1) + {-# NOINLINE shareMeThunk #-} + -- ^ This is the thunk that is wrongly evaluated twice. + + let (x,y) = wwMe 0 (seed,shareMeThunk) + + (x + y) `seq` return () + -- ^ Use both components +{-# NOINLINE go #-} + +main :: IO () +main = go 42 diff --git a/testsuite/tests/simplCore/should_run/T11731.stderr b/testsuite/tests/simplCore/should_run/T11731.stderr new file mode 100644 index 0000000..8d1fc60 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T11731.stderr @@ -0,0 +1 @@ +Evaluated (should only happen once) diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T index 9c15b0f..042c097 100644 --- a/testsuite/tests/simplCore/should_run/all.T +++ b/testsuite/tests/simplCore/should_run/all.T @@ -71,3 +71,4 @@ test('T9128', normal, compile_and_run, ['']) test('T9390', normal, compile_and_run, ['']) test('T10830', extra_run_opts('+RTS -K100k -RTS'), compile_and_run, ['']) test('T11172', normal, compile_and_run, ['']) +test('T11731', expect_broken(11731), compile_and_run, ['-fspec-constr']) From git at git.haskell.org Thu Mar 31 20:35:29 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:35:29 +0000 (UTC) Subject: [commit: ghc] wip/T11731: Add a final demand analyzer run right before TidyCore (9b9d2ee) Message-ID: <20160331203529.B7EF33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T11731 Link : http://ghc.haskell.org/trac/ghc/changeset/9b9d2ee305625543503ff2b5cc7696609cec0fa5/ghc >--------------------------------------------------------------- commit 9b9d2ee305625543503ff2b5cc7696609cec0fa5 Author: Joachim Breitner Date: Thu Mar 31 10:18:15 2016 +0200 Add a final demand analyzer run right before TidyCore in order to have precise used-once information in the exported strictness signatures, as well as precise used-once information on thunks. This avoids the bad effects of #11731. >--------------------------------------------------------------- 9b9d2ee305625543503ff2b5cc7696609cec0fa5 compiler/simplCore/SimplCore.hs | 5 ++++ compiler/stranal/DmdAnal.hs | 28 ++++++++++++++++++++++ testsuite/tests/perf/haddock/all.T | 3 ++- .../tests/simplCore/should_compile/T4908.stderr | 6 ++--- .../simplCore/should_compile/spec-inline.stderr | 8 +++---- testsuite/tests/simplCore/should_run/all.T | 2 +- .../tests/stranal/should_compile/T10694.stderr | 2 ++ .../stranal/sigs/BottomFromInnerLambda.stderr | 7 ++++++ testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr | 14 +++++++++++ testsuite/tests/stranal/sigs/HyperStrUse.stderr | 6 +++++ testsuite/tests/stranal/sigs/StrAnalExample.stderr | 6 +++++ testsuite/tests/stranal/sigs/T8569.stderr | 9 +++++++ testsuite/tests/stranal/sigs/T8598.stderr | 6 +++++ testsuite/tests/stranal/sigs/UnsatFun.stderr | 12 ++++++++++ 14 files changed, 105 insertions(+), 9 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 9b9d2ee305625543503ff2b5cc7696609cec0fa5 From git at git.haskell.org Thu Mar 31 20:36:10 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:36:10 +0000 (UTC) Subject: [commit: ghc] wip/T10613: State hack hack in ticky report (9dceecf) Message-ID: <20160331203610.CEFCF3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/9dceecf386978a74a92d0d1893fbfa07c6ea5c5b/ghc >--------------------------------------------------------------- commit 9dceecf386978a74a92d0d1893fbfa07c6ea5c5b Author: Joachim Breitner Date: Wed Mar 23 11:10:25 2016 +0100 State hack hack in ticky report In the ticky report, do not mark a function with a State# argument as its first argument as single-entry. >--------------------------------------------------------------- 9dceecf386978a74a92d0d1893fbfa07c6ea5c5b compiler/codeGen/StgCmmClosure.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index b467048..3b83b8e 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -234,7 +234,10 @@ mkLFReEntrant _ _ [] _ = pprPanic "mkLFReEntrant" empty mkLFReEntrant top fvs args arg_descr = LFReEntrant top os_info (length args) (null fvs) arg_descr - where os_info = idOneShotInfo (head args) + where + state_hack_hack = isStateHackType (idType (head args)) + os_info | state_hack_hack = noOneShotInfo + | otherwise = idOneShotInfo (head args) ------------- mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo From git at git.haskell.org Thu Mar 31 20:36:13 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:36:13 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Rough working implementation of #10613 (adfdf5a) Message-ID: <20160331203613.8B5EB3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/adfdf5a5c4c5e9b982bb358a856ff3e767922dc8/ghc >--------------------------------------------------------------- commit adfdf5a5c4c5e9b982bb358a856ff3e767922dc8 Author: Joachim Breitner Date: Thu Mar 17 16:33:18 2016 +0100 Rough working implementation of #10613 The COUNTING_IND closure type is based on the (since removed) IND_PERM. Some of the code is rather ad-hoc and likely in need of some refactoring and clean-up before entering master (if it ever should), but it should be good enough to play around with it and obtain some numbers. >--------------------------------------------------------------- adfdf5a5c4c5e9b982bb358a856ff3e767922dc8 compiler/cmm/CLabel.hs | 5 ++- compiler/cmm/CmmType.hs | 6 +++ compiler/cmm/SMRep.hs | 11 +++++- compiler/codeGen/StgCmmBind.hs | 76 +++++++++++++++++++++++++++--------- compiler/codeGen/StgCmmClosure.hs | 8 ++++ compiler/codeGen/StgCmmHeap.hs | 20 ++++++++-- compiler/codeGen/StgCmmLayout.hs | 23 ++++++++--- compiler/codeGen/StgCmmTicky.hs | 37 ++++++++++++++++-- compiler/codeGen/StgCmmUtils.hs | 12 +++--- compiler/coreSyn/PprCore.hs | 2 +- compiler/ghci/ByteCodeItbls.hs | 4 +- includes/Cmm.h | 1 + includes/rts/Ticky.h | 9 ++++- includes/rts/storage/ClosureMacros.h | 1 + includes/rts/storage/ClosureTypes.h | 73 +++++++++++++++++----------------- includes/rts/storage/Closures.h | 7 ++++ includes/stg/MiscClosures.h | 1 + rts/CheckUnload.c | 1 + rts/ClosureFlags.c | 3 +- rts/Interpreter.c | 1 + rts/LdvProfile.c | 1 + rts/Printer.c | 10 ++++- rts/ProfHeap.c | 1 + rts/RetainerProfile.c | 6 +-- rts/RtsSymbols.c | 1 + rts/Stable.c | 1 + rts/StgMiscClosures.cmm | 43 ++++++++++++++++++++ rts/Ticky.c | 21 +++++++--- rts/sm/Compact.c | 1 + rts/sm/Evac.c | 3 ++ rts/sm/GCAux.c | 1 + rts/sm/Sanity.c | 1 + rts/sm/Scav.c | 12 ++++++ utils/deriveConstants/Main.hs | 7 ++++ utils/genapply/Main.hs | 4 +- 35 files changed, 325 insertions(+), 89 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc adfdf5a5c4c5e9b982bb358a856ff3e767922dc8 From git at git.haskell.org Thu Mar 31 20:36:16 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:36:16 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Temporarily move regular entry counting to the COUNTING_IND (9cfee59) Message-ID: <20160331203616.416953A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/9cfee59412c5867765f97f21fa430adfc0515441/ghc >--------------------------------------------------------------- commit 9cfee59412c5867765f97f21fa430adfc0515441 Author: Joachim Breitner Date: Wed Mar 23 14:28:34 2016 +0100 Temporarily move regular entry counting to the COUNTING_IND >--------------------------------------------------------------- 9cfee59412c5867765f97f21fa430adfc0515441 compiler/codeGen/StgCmmBind.hs | 8 ++++++-- rts/StgMiscClosures.cmm | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 5951175..8672273 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -609,9 +609,13 @@ thunkCode cl_info fv_details _cc node arity body -- Heap overflow check ; entryHeapCheck cl_info node' arity [] $ do - { -- Overwrite with black hole if necessary + { + -- Disabled for now, as we (temporarily unconditionally) move the + -- counting to the counting indirection + -- tickyEnterThunk cl_info + + -- Overwrite with black hole if necessary -- but *after* the heap-overflow check - ; tickyEnterThunk cl_info ; when (blackHoleOnEntry cl_info && node_points) (blackHoleIt node) diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 96b95aa..0f27fdb 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -283,6 +283,7 @@ INFO_TABLE(stg_COUNTING_IND,1,2,COUNTING_IND,"COUNTING_IND","COUNTING_IND") StgEntCounter_multi_entry_count(ent_ctr) = StgEntCounter_multi_entry_count(ent_ctr) + 1; } StgCountingInd_entries(clos) = entries + 1; + StgEntCounter_entry_count(ent_ctr) = StgEntCounter_entry_count(ent_ctr) + 1; #if defined(TICKY_TICKY) && !defined(PROFILING) /* TICKY_TICKY && !PROFILING means PERM_IND *replaces* an IND, rather than From git at git.haskell.org Thu Mar 31 20:36:18 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:36:18 +0000 (UTC) Subject: [commit: ghc] wip/T10613: Evac: Do not evaluate selector thunks pointing to counting indirections (1706987) Message-ID: <20160331203618.E15C93A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/T10613 Link : http://ghc.haskell.org/trac/ghc/changeset/170698740a5226ef2c09ed8defd7d40b5ccb813d/ghc >--------------------------------------------------------------- commit 170698740a5226ef2c09ed8defd7d40b5ccb813d Author: Joachim Breitner Date: Wed Mar 23 13:50:00 2016 +0100 Evac: Do not evaluate selector thunks pointing to counting indirections >--------------------------------------------------------------- 170698740a5226ef2c09ed8defd7d40b5ccb813d rts/sm/Evac.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index 3b4314b..9369543 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -998,12 +998,17 @@ selector_loop: } case IND: - case COUNTING_IND: case IND_STATIC: // Again, we might need to untag a constructor. selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); goto selector_loop; + case COUNTING_IND: + // do not short cut a COUNTING_IND, as we would miss a the count + // Can we simply tick the counter here? Not really: If this selector + // thunk is not going to be used, we counted more than we wanted! + goto bale_out; + case BLACKHOLE: { StgClosure *r; From git at git.haskell.org Thu Mar 31 20:36:21 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:36:21 +0000 (UTC) Subject: [commit: ghc] wip/T10613's head updated: Temporarily move regular entry counting to the COUNTING_IND (9cfee59) Message-ID: <20160331203621.1F3C83A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc Branch 'wip/T10613' now includes: 809ecf2 Core pretty printer: Omit wild case binders 5bed931 Add a test case for #11731. 9b9d2ee Add a final demand analyzer run right before TidyCore adfdf5a Rough working implementation of #10613 9dceecf State hack hack in ticky report 1706987 Evac: Do not evaluate selector thunks pointing to counting indirections 9cfee59 Temporarily move regular entry counting to the COUNTING_IND From git at git.haskell.org Thu Mar 31 20:43:15 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:43:15 +0000 (UTC) Subject: [commit: ghc] branch 'wip/cse-code-desmelling' created Message-ID: <20160331204315.0713F3A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc New branch : wip/cse-code-desmelling Referencing: df2ca2888da12b97d89672d6db581dc30b0ab9e2 From git at git.haskell.org Thu Mar 31 20:43:17 2016 From: git at git.haskell.org (git at git.haskell.org) Date: Thu, 31 Mar 2016 20:43:17 +0000 (UTC) Subject: [commit: ghc] wip/cse-code-desmelling: CSE: Code cleanup (df2ca28) Message-ID: <20160331204317.AC9C33A300@ghc.haskell.org> Repository : ssh://git at git.haskell.org/ghc On branch : wip/cse-code-desmelling Link : http://ghc.haskell.org/trac/ghc/changeset/df2ca2888da12b97d89672d6db581dc30b0ab9e2/ghc >--------------------------------------------------------------- commit df2ca2888da12b97d89672d6db581dc30b0ab9e2 Author: Simon Peyton Jones Date: Thu Mar 31 22:42:28 2016 +0200 CSE: Code cleanup Triggered by an observation by Joachim, Simon felt the urge to clean up the CSE code a bit. This is the result. (Code by Simon, Commit message and other leg-work by Joachim) >--------------------------------------------------------------- df2ca2888da12b97d89672d6db581dc30b0ab9e2 compiler/simplCore/CSE.hs | 257 ++++++++++++++++++++++++++-------------------- 1 file changed, 147 insertions(+), 110 deletions(-) Diff suppressed because of size. To see it, use: git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc df2ca2888da12b97d89672d6db581dc30b0ab9e2