[Git][ghc/ghc][wip/T26772] 5 commits: PPC NCG: Use libcall for 64-bit cmpxchg on 32-bit PowerPC
by Simon Peyton Jones (@simonpj) 30 Jan '26
by Simon Peyton Jones (@simonpj) 30 Jan '26
30 Jan '26
Simon Peyton Jones pushed to branch wip/T26772 at Glasgow Haskell Compiler / GHC
Commits:
ce2d62fb by Jessica Clarke at 2026-01-29T19:48:51-05:00
PPC NCG: Use libcall for 64-bit cmpxchg on 32-bit PowerPC
There is no native instruction for this, and even if there were a
register pair version we could use, the implementation here is assuming
the values fit in a single register, and we end up only using / defining
the low halves of the registers.
Fixes: b4d39adbb5 ("PrimOps: Add CAS op for all int sizes")
Fixes: #23969
- - - - -
43d97761 by Michael Karcher at 2026-01-29T19:49:43-05:00
NCG for PPC: add pattern for CmmRegOff to iselExpr64
Closes #26828
- - - - -
eea3ecd1 by Simon Peyton Jones at 2026-01-30T09:27:40+00:00
Fix subtle bug in GHC.Core.Utils.mkTick
This patch fixes a decade-old bug in `mkTick`, which
could generate type-incorrect code! See the diagnosis
in #26772.
The new code is simpler and easier to understand.
(As #26772 says, I think it could be improved further.)
- - - - -
f24081f7 by Simon Peyton Jones at 2026-01-30T09:27:40+00:00
Modify a debug-trace in the Simplifier
...just to show a bit more information.
- - - - -
355626a5 by Simon Peyton Jones at 2026-01-30T09:27:40+00:00
Fix long-standing interaction between ticks and casts
The code for Note [Eliminate Identity Cases] was simply wrong when
ticks and casts interacted. This patch fixes the interaction.
It was shown up when validating #26772, although it's not the exactly
the bug that's reported by #26772. Nor is it easy to reproduce, hence
no regression test.
- - - - -
10 changed files:
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Types/Evidence.hs
- testsuite/tests/ghci.debugger/scripts/T26042b.stdout
- testsuite/tests/ghci.debugger/scripts/T26042c.stdout
- testsuite/tests/ghci.debugger/scripts/T26042d2.stdout
- testsuite/tests/ghci.debugger/scripts/T26042f2.stdout
Changes:
=====================================
compiler/GHC/CmmToAsm/PPC/CodeGen.hs
=====================================
@@ -180,7 +180,7 @@ stmtToInstrs stmt = do
format = cmmTypeFormat ty
CmmUnsafeForeignCall target result_regs args
- -> genCCall target result_regs args
+ -> genCCall platform target result_regs args
CmmBranch id -> genBranch id
CmmCondBranch arg true false prediction -> do
@@ -338,6 +338,8 @@ iselExpr64 (CmmReg (CmmLocal local_reg)) = do
let Reg64 hi lo = localReg64 local_reg
return (RegCode64 nilOL hi lo)
+iselExpr64 regoff@(CmmRegOff _ _) = iselExpr64 $ mangleIndexTree regoff
+
iselExpr64 (CmmLit (CmmInt i _)) = do
Reg64 rhi rlo <- getNewReg64
let
@@ -1183,24 +1185,25 @@ genCondJump id bool prediction = do
-- @get_arg@, which moves the arguments to the correct registers/stack
-- locations. Apart from that, the code is easy.
-genCCall :: ForeignTarget -- function to call
+genCCall :: Platform
+ -> ForeignTarget -- function to call
-> [CmmFormal] -- where to put the result
-> [CmmActual] -- arguments (of mixed type)
-> NatM InstrBlock
-genCCall (PrimTarget MO_AcquireFence) _ _
+genCCall _ (PrimTarget MO_AcquireFence) _ _
= return $ unitOL LWSYNC
-genCCall (PrimTarget MO_ReleaseFence) _ _
+genCCall _ (PrimTarget MO_ReleaseFence) _ _
= return $ unitOL LWSYNC
-genCCall (PrimTarget MO_SeqCstFence) _ _
+genCCall _ (PrimTarget MO_SeqCstFence) _ _
= return $ unitOL HWSYNC
-genCCall (PrimTarget MO_Touch) _ _
+genCCall _ (PrimTarget MO_Touch) _ _
= return $ nilOL
-genCCall (PrimTarget (MO_Prefetch_Data _)) _ _
+genCCall _ (PrimTarget (MO_Prefetch_Data _)) _ _
= return $ nilOL
-genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n]
+genCCall _ (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n]
= do let fmt = intFormat width
reg_dst = getLocalRegReg dst
(instr, n_code) <- case amop of
@@ -1250,7 +1253,7 @@ genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n]
(n_reg, n_code) <- getSomeReg n
return (op dst dst (RIReg n_reg), n_code)
-genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr]
+genCCall _ (PrimTarget (MO_AtomicRead width _)) [dst] [addr]
= do let fmt = intFormat width
reg_dst = getLocalRegReg dst
form = if widthInBits width == 64 then DS else D
@@ -1277,12 +1280,12 @@ genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr]
-- This is also what gcc does.
-genCCall (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do
+genCCall _ (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do
code <- assignMem_IntCode (intFormat width) addr val
return $ unitOL HWSYNC `appOL` code
-genCCall (PrimTarget (MO_Cmpxchg width)) [dst] [addr, old, new]
- | width == W32 || width == W64
+genCCall platform (PrimTarget (MO_Cmpxchg width)) [dst] [addr, old, new]
+ | width == W32 || (width == W64 && not (target32Bit platform))
= do
(old_reg, old_code) <- getSomeReg old
(new_reg, new_code) <- getSomeReg new
@@ -1311,9 +1314,8 @@ genCCall (PrimTarget (MO_Cmpxchg width)) [dst] [addr, old, new]
format = intFormat width
-genCCall (PrimTarget (MO_Clz width)) [dst] [src]
- = do platform <- getPlatform
- let reg_dst = getLocalRegReg dst
+genCCall platform (PrimTarget (MO_Clz width)) [dst] [src]
+ = do let reg_dst = getLocalRegReg dst
if target32Bit platform && width == W64
then do
RegCode64 code vr_hi vr_lo <- iselExpr64 src
@@ -1361,9 +1363,8 @@ genCCall (PrimTarget (MO_Clz width)) [dst] [src]
let cntlz = unitOL (CNTLZ format reg_dst reg)
return $ s_code `appOL` pre `appOL` cntlz `appOL` post
-genCCall (PrimTarget (MO_Ctz width)) [dst] [src]
- = do platform <- getPlatform
- let reg_dst = getLocalRegReg dst
+genCCall platform (PrimTarget (MO_Ctz width)) [dst] [src]
+ = do let reg_dst = getLocalRegReg dst
if target32Bit platform && width == W64
then do
let format = II32
@@ -1425,9 +1426,8 @@ genCCall (PrimTarget (MO_Ctz width)) [dst] [src]
, SUBFC dst r' (RIImm (ImmInt (format_bits)))
]
-genCCall target dest_regs argsAndHints
- = do platform <- getPlatform
- case target of
+genCCall platform target dest_regs argsAndHints
+ = do case target of
PrimTarget (MO_S_QuotRem width) -> divOp1 True width
dest_regs argsAndHints
PrimTarget (MO_U_QuotRem width) -> divOp1 False width
=====================================
compiler/GHC/Core/Opt/Simplify/Iteration.hs
=====================================
@@ -1713,6 +1713,7 @@ simplCast env body co0 cont0
, sc_hole_ty = coercionLKind co }) }
-- NB! As the cast goes past, the
-- type of the hole changes (#16312)
+
-- (f |> co) e ===> (f (e |> co1)) |> co2
-- where co :: (s1->s2) ~ (t1->t2)
-- co1 :: t1 ~ s1
@@ -1838,7 +1839,7 @@ simpl_lam env bndr body (ApplyToVal { sc_arg = arg, sc_env = arg_se
, not ( isSimplified dup && -- See (SR2) in Note [Avoiding simplifying repeatedly]
not (exprIsTrivial arg) &&
not (isDeadOcc (idOccInfo bndr)) )
- -> do { simplTrace "SimplBindr:inline-uncond3" (ppr bndr) $
+ -> do { simplTrace "SimplBindr:inline-uncond3" (ppr bndr <+> text ":=" <+> ppr arg $$ ppr (seIdSubst env)) $
tick (PreInlineUnconditionally bndr)
; simplLam env' body cont }
=====================================
compiler/GHC/Core/Opt/Simplify/Utils.hs
=====================================
@@ -72,6 +72,7 @@ import GHC.Types.Tickish
import GHC.Types.Demand
import GHC.Types.Var.Set
import GHC.Types.Basic
+import GHC.Types.Name.Env
import GHC.Data.OrdList ( isNilOL )
import GHC.Data.FastString ( fsLit )
@@ -81,9 +82,9 @@ import GHC.Utils.Monad
import GHC.Utils.Outputable
import GHC.Utils.Panic
-import Control.Monad ( when )
+import Control.Monad ( guard, when )
import Data.List ( sortBy )
-import GHC.Types.Name.Env
+import Data.Maybe
import Data.Graph
{- *********************************************************************
@@ -2543,7 +2544,27 @@ Note [Eliminate Identity Case]
True -> True;
False -> False
-and similar friends.
+and similar friends. There are some tricky wrinkles:
+
+(EIC1) Casts. We've seen this:
+ case e of x { _ -> x `cast` c }
+ And we definitely want to eliminate this case, to give
+ e `cast` c
+(EIC2) Ticks. Similarly
+ case e of x { _ -> Tick t x }
+ At least if the tick is 'floatable' we want to eliminate the case
+ to give
+ Tick t e
+
+So `check_eq` strips off enclosing casts and ticks from the RHS of the
+alternative, returning a wrapper function that will rebuild them around
+the scrutinee if case-elim is successful.
+
+(EIC3) What if there are many alternatives, all identities. If casts
+ are involved they must be the same cast, to make the types line up.
+ In principle there could be different ticks in each RHS, but we just
+ pick the ticks from the first alternative. (In the common case there
+ is only one alternative.)
Note [Scrutinee Constant Folding]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2737,45 +2758,47 @@ mkCase mode scrut outer_bndr alts_ty alts
-- See Note [Eliminate Identity Case]
--------------------------------------------------
-mkCase1 _mode scrut case_bndr _ alts@(Alt _ _ rhs1 : alts') -- Identity case
- | all identity_alt alts
+mkCase1 _mode scrut case_bndr _ (alt1 : alts) -- Identity case
+ | Just wrap <- identity_alt alt1 -- `wrap`: see (EIC1) and (EIC2)
+ , all (isJust . identity_alt) alts -- See (EIC3) in Note [Eliminate Identity Case]
= do { tick (CaseIdentity case_bndr)
- ; return (mkTicks ticks $ re_cast scrut rhs1) }
+ ; return (wrap scrut) }
where
- ticks = concatMap (\(Alt _ _ rhs) -> stripTicksT tickishFloatable rhs) alts'
- identity_alt (Alt con args rhs) = check_eq rhs con args
-
- check_eq (Cast rhs co) con args -- See Note [RHS casts]
- = not (any (`elemVarSet` tyCoVarsOfCo co) args) && check_eq rhs con args
- check_eq (Tick t e) alt args
- = tickishFloatable t && check_eq e alt args
-
- check_eq (Lit lit) (LitAlt lit') _ = lit == lit'
- check_eq (Var v) _ _ | v == case_bndr = True
- check_eq (Var v) (DataAlt con) args
- | null arg_tys, null args = v == dataConWorkId con
- -- Optimisation only
- check_eq rhs (DataAlt con) args = cheapEqExpr' tickishFloatable rhs $
- mkConApp2 con arg_tys args
- check_eq _ _ _ = False
+ identity_alt :: CoreAlt -> Maybe (CoreExpr -> CoreExpr)
+ identity_alt (Alt con args rhs) = check_eq con args rhs
+
+ check_eq :: AltCon -> [Var] -> CoreExpr -> Maybe (CoreExpr -> CoreExpr)
+ -- (check_eq con args e) return True if
+ -- e looks like (Tick (Cast (Tick (con args))))
+ -- where (con args) is the LHS of the alternative
+ -- In that case it returns (\e. Tick (Cast (Tick e))),
+ -- a wrapper function that can rebuild the tick/cast stuff
+ -- See (EIC1) and (EIC2) in Note [Eliminate Identity Case]
+ check_eq alt_con args (Cast e co) -- See (EIC1)
+ = do { guard (not (any (`elemVarSet` tyCoVarsOfCo co) args))
+ ; wrap <- check_eq alt_con args e
+ ; return (flip mkCast co . wrap) }
+ check_eq alt_con args (Tick t e) -- See (EIC2)
+ = do { guard (tickishFloatable t)
+ ; wrap <- check_eq alt_con args e
+ ; return (Tick t . wrap) }
+ check_eq alt_con args e
+ | is_id alt_con args e = Just (\e -> e)
+ | otherwise = Nothing
+
+ is_id :: AltCon -> [Var] -> CoreExpr -> Bool
+ is_id _ _ (Var v) | v == case_bndr = True
+ is_id (LitAlt lit') _ (Lit lit) = lit == lit'
+ is_id (DataAlt con) args rhs
+ | Var v <- rhs -- Optimisation only
+ , null arg_tys
+ , null args = v == dataConWorkId con
+ | otherwise = cheapEqExpr' tickishFloatable rhs $
+ mkConApp2 con arg_tys args
+ is_id _ _ _ = False
arg_tys = tyConAppArgs (idType case_bndr)
- -- Note [RHS casts]
- -- ~~~~~~~~~~~~~~~~
- -- We've seen this:
- -- case e of x { _ -> x `cast` c }
- -- And we definitely want to eliminate this case, to give
- -- e `cast` c
- -- So we throw away the cast from the RHS, and reconstruct
- -- it at the other end. All the RHS casts must be the same
- -- if (all identity_alt alts) holds.
- --
- -- Don't worry about nested casts, because the simplifier combines them
-
- re_cast scrut (Cast rhs co) = Cast (re_cast scrut rhs) co
- re_cast scrut _ = scrut
-
mkCase1 mode scrut bndr alts_ty alts = mkCase2 mode scrut bndr alts_ty alts
=====================================
compiler/GHC/Core/Utils.hs
=====================================
@@ -252,7 +252,7 @@ applyTypeToArgs op_ty args
mkCastMCo :: CoreExpr -> MCoercionR -> CoreExpr
mkCastMCo e MRefl = e
-mkCastMCo e (MCo co) = Cast e co
+mkCastMCo e (MCo co) = mkCast e co
-- We are careful to use (MCo co) only when co is not reflexive
-- Hence (Cast e co) rather than (mkCast e co)
@@ -305,40 +305,41 @@ mkCast expr co
-- | Wraps the given expression in the source annotation, dropping the
-- annotation if possible.
mkTick :: CoreTickish -> CoreExpr -> CoreExpr
-mkTick t orig_expr = mkTick' id id orig_expr
+mkTick t orig_expr = mkTick' id orig_expr
where
-- Some ticks (cost-centres) can be split in two, with the
-- non-counting part having laxer placement properties.
canSplit = tickishCanSplit t && tickishPlace (mkNoCount t) /= tickishPlace t
+
-- mkTick' handles floating of ticks *into* the expression.
- -- In this function, `top` is applied after adding the tick, and `rest` before.
- -- This will result in applications that look like (top $ Tick t $ rest expr).
- -- If we want to push the tick deeper, we pre-compose `top` with a function
- -- adding the tick.
- mkTick' :: (CoreExpr -> CoreExpr) -- apply after adding tick (float through)
- -> (CoreExpr -> CoreExpr) -- apply before adding tick (float with)
- -> CoreExpr -- current expression
+ mkTick' :: (CoreExpr -> CoreExpr) -- Apply before adding tick (float with)
+ -- Always a composition of (Tick t) wrappers
+ -> CoreExpr -- Current expression
-> CoreExpr
- mkTick' top rest expr = case expr of
+ -- So in the call (mkTick' rest e), the expression
+ -- (rest e)
+ -- has the same type as e
+ -- Returns an expression equivalent to (Tick t (rest e))
+ mkTick' rest expr = case expr of
-- Float ticks into unsafe coerce the same way we would do with a cast.
Case scrut bndr ty alts@[Alt ac abs _rhs]
| Just rhs <- isUnsafeEqualityCase scrut bndr alts
- -> top $ mkTick' (\e -> Case scrut bndr ty [Alt ac abs e]) rest rhs
+ -> Case scrut bndr ty [Alt ac abs (mkTick' rest rhs)]
-- Cost centre ticks should never be reordered relative to each
-- other. Therefore we can stop whenever two collide.
Tick t2 e
- | ProfNote{} <- t2, ProfNote{} <- t -> top $ Tick t $ rest expr
+ | ProfNote{} <- t2, ProfNote{} <- t -> Tick t $ rest expr
-- Otherwise we assume that ticks of different placements float
-- through each other.
- | tickishPlace t2 /= tickishPlace t -> mkTick' (top . Tick t2) rest e
+ | tickishPlace t2 /= tickishPlace t -> Tick t2 $ mkTick' rest e
-- For annotations this is where we make sure to not introduce
-- redundant ticks.
- | tickishContains t t2 -> mkTick' top rest e
- | tickishContains t2 t -> orig_expr
- | otherwise -> mkTick' top (rest . Tick t2) e
+ | tickishContains t t2 -> mkTick' rest e -- Drop t2
+ | tickishContains t2 t -> rest e -- Drop t
+ | otherwise -> mkTick' (rest . Tick t2) e
-- Ticks don't care about types, so we just float all ticks
-- through them. Note that it's not enough to check for these
@@ -346,14 +347,14 @@ mkTick t orig_expr = mkTick' id id orig_expr
-- expressions below ticks, such constructs can be the result of
-- unfoldings. We therefore make an effort to put everything into
-- the right place no matter what we start with.
- Cast e co -> mkTick' (top . flip Cast co) rest e
- Coercion co -> Coercion co
+ Cast e co -> mkCast (mkTick' rest e) co
+ Coercion co -> Tick t $ rest (Coercion co)
Lam x e
-- Always float through type lambdas. Even for non-type lambdas,
-- floating is allowed for all but the most strict placement rule.
| not (isRuntimeVar x) || tickishPlace t /= PlaceRuntime
- -> mkTick' (top . Lam x) rest e
+ -> Lam x $ mkTick' rest e
-- If it is both counting and scoped, we split the tick into its
-- two components, often allowing us to keep the counting tick on
@@ -362,25 +363,25 @@ mkTick t orig_expr = mkTick' id id orig_expr
-- floated, and the lambda may then be in a position to be
-- beta-reduced.
| canSplit
- -> top $ Tick (mkNoScope t) $ rest $ Lam x $ mkTick (mkNoCount t) e
+ -> Tick (mkNoScope t) $ rest $ Lam x $ mkTick (mkNoCount t) e
App f arg
-- Always float through type applications.
| not (isRuntimeArg arg)
- -> mkTick' (top . flip App arg) rest f
+ -> App (mkTick' rest f) arg
-- We can also float through constructor applications, placement
-- permitting. Again we can split.
| isSaturatedConApp expr && (tickishPlace t==PlaceCostCentre || canSplit)
-> if tickishPlace t == PlaceCostCentre
- then top $ rest $ tickHNFArgs t expr
- else top $ Tick (mkNoScope t) $ rest $ tickHNFArgs (mkNoCount t) expr
+ then rest $ tickHNFArgs t expr
+ else Tick (mkNoScope t) $ rest $ tickHNFArgs (mkNoCount t) expr
Var x
| notFunction && tickishPlace t == PlaceCostCentre
- -> orig_expr
+ -> rest expr -- Drop t
| notFunction && canSplit
- -> top $ Tick (mkNoScope t) $ rest expr
+ -> Tick (mkNoScope t) $ rest expr
where
-- SCCs can be eliminated on variables provided the variable
-- is not a function. In these cases the SCC makes no difference:
@@ -392,10 +393,10 @@ mkTick t orig_expr = mkTick' id id orig_expr
Lit{}
| tickishPlace t == PlaceCostCentre
- -> orig_expr
+ -> rest expr -- Drop t
-- Catch-all: Annotate where we stand
- _any -> top $ Tick t $ rest expr
+ _any -> Tick t $ rest expr
mkTicks :: [CoreTickish] -> CoreExpr -> CoreExpr
mkTicks ticks expr = foldr mkTick expr ticks
=====================================
compiler/GHC/Tc/Instance/Class.hs
=====================================
@@ -49,6 +49,7 @@ import GHC.Core.Make ( mkCharExpr, mkNaturalExpr, mkStringExprFS, mkCoreLams )
import GHC.Core.DataCon
import GHC.Core.TyCon
import GHC.Core.Class
+import GHC.Core.Utils( mkCast )
import GHC.Core ( Expr(..), mkConApp )
import GHC.StgToCmm.Closure ( isSmallFamily )
@@ -455,7 +456,7 @@ matchWithDict [cls_ty, mty]
= mkCoreLams [ runtimeRep1TyVar, openAlphaTyVar, sv, k ] $
Var k `App` (evUnaryDictAppE cls dict_args meth_arg)
where
- meth_arg = Var sv `Cast` mkSubCo (evExprCoercion ev_expr)
+ meth_arg = Var sv `mkCast` mkSubCo (evExprCoercion ev_expr)
; let mk_ev [c] = evDictApp wd_cls [cls_ty, mty] [evWithDict c]
mk_ev e = pprPanic "matchWithDict" (ppr e)
@@ -657,7 +658,7 @@ matchDataToTag dataToTagClass [levity, dty] = do
(mkReflCo Representational intPrimTy)
-> do { addUsedDataCons rdr_env repTyCon -- See wrinkles DTW2 and DTW3
; let mk_ev _ = evDictApp dataToTagClass [levity, dty] $
- [methodRep `Cast` methodCo]
+ [methodRep `mkCast` methodCo]
; pure (OneInst { cir_new_theta = [] -- (Ignore stupid theta.)
, cir_mk_ev = mk_ev
, cir_canonical = EvCanonical
=====================================
compiler/GHC/Tc/Types/Evidence.hs
=====================================
@@ -59,6 +59,7 @@ import GHC.Tc.Utils.TcType
import GHC.Core
import GHC.Core.Coercion.Axiom
import GHC.Core.Coercion
+import GHC.Core.Utils( mkCast )
import GHC.Core.Ppr () -- Instance OutputableBndr TyVar
import GHC.Core.Predicate
import GHC.Core.Type
@@ -930,7 +931,7 @@ evCastE ee co
| assertPpr (coercionRole co == Representational)
(vcat [text "Coercion of wrong role passed to evCastE:", ppr ee, ppr co]) $
isReflCo co = ee
- | otherwise = Cast ee co
+ | otherwise = mkCast ee co
evDFunApp :: DFunId -> [Type] -> [EvExpr] -> EvTerm
-- Dictionary instance application, including when the "dictionary function"
=====================================
testsuite/tests/ghci.debugger/scripts/T26042b.stdout
=====================================
@@ -22,30 +22,18 @@ _result ::
-> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
Int #) = _
Stopped in Main.foo, T26042b.hs:14:3-18
-_result ::
- GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld
- -> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
- Int #) = _
+_result :: IO Int = _
13 y = 4
14 n <- bar (x + y)
^^^^^^^^^^^^^^^^
15 return n
-_result ::
- GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld
- -> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
- Int #) = _
+_result :: IO Int = _
Stopped in Main.main, T26042b.hs:5:3-26
-_result ::
- GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld
- -> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
- () #) = _
+_result :: IO () = _
4 main = do
5 a <- foo False undefined
^^^^^^^^^^^^^^^^^^^^^^^^
6 print a
-_result ::
- GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld
- -> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
- () #) = _
+_result :: IO () = _
14
14
=====================================
testsuite/tests/ghci.debugger/scripts/T26042c.stdout
=====================================
@@ -1,18 +1,12 @@
Breakpoint 0 activated at T26042c.hs:10:15-22
Stopped in Main.foo, T26042c.hs:10:15-22
-_result ::
- GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld
- -> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
- Int #) = _
+_result :: IO Int = _
9 foo :: Bool -> Int -> IO Int
10 foo True i = return i
^^^^^^^^
11 foo False _ = do
Stopped in Main.main, T26042c.hs:5:3-26
-_result ::
- GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld
- -> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
- () #) = _
+_result :: IO () = _
4 main = do
5 a <- foo False undefined
^^^^^^^^^^^^^^^^^^^^^^^^
=====================================
testsuite/tests/ghci.debugger/scripts/T26042d2.stdout
=====================================
@@ -1,10 +1,7 @@
Breakpoint 0 activated at T26042d2.hs:11:3-21
hello1
Stopped in Main.f, T26042d2.hs:11:3-21
-_result ::
- GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld
- -> (# GHC.Internal.Prim.State# GHC.Internal.Prim.RealWorld,
- () #) = _
+_result :: IO () = _
10 f = do
11 putStrLn "hello2.1"
^^^^^^^^^^^^^^^^^^^
=====================================
testsuite/tests/ghci.debugger/scripts/T26042f2.stdout
=====================================
@@ -1,6 +1,6 @@
Breakpoint 0 activated at T26042f.hs:(20,7)-(21,14)
Stopped in T8.t, T26042f.hs:(20,7)-(21,14)
-_result :: Int = _
+_result :: Identity Int = _
x :: Int = 450
19 t :: Int -> Identity Int
vv
@@ -18,12 +18,12 @@ _result :: Identity Int = _
^^^^^^^^^^^^
15 n <- pure (a+a)
Stopped in T8.f, T26042f.hs:8:3-14
-_result :: Identity Int = _
+_result :: Int = _
x :: Int = 15
7 f x = do
8 b <- g (x*x)
^^^^^^^^^^^^
9 y <- pure (b+b)
x :: Int = 15
-_result :: Identity Int = _
+_result :: Int = _
7248
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed30e6b8700c1f412cc0ef53b24800…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed30e6b8700c1f412cc0ef53b24800…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][master] NCG for PPC: add pattern for CmmRegOff to iselExpr64
by Marge Bot (@marge-bot) 30 Jan '26
by Marge Bot (@marge-bot) 30 Jan '26
30 Jan '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
43d97761 by Michael Karcher at 2026-01-29T19:49:43-05:00
NCG for PPC: add pattern for CmmRegOff to iselExpr64
Closes #26828
- - - - -
1 changed file:
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
Changes:
=====================================
compiler/GHC/CmmToAsm/PPC/CodeGen.hs
=====================================
@@ -338,6 +338,8 @@ iselExpr64 (CmmReg (CmmLocal local_reg)) = do
let Reg64 hi lo = localReg64 local_reg
return (RegCode64 nilOL hi lo)
+iselExpr64 regoff@(CmmRegOff _ _) = iselExpr64 $ mangleIndexTree regoff
+
iselExpr64 (CmmLit (CmmInt i _)) = do
Reg64 rhi rlo <- getNewReg64
let
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43d977619de65c0cf87695fa5d86f1a…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43d977619de65c0cf87695fa5d86f1a…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][master] PPC NCG: Use libcall for 64-bit cmpxchg on 32-bit PowerPC
by Marge Bot (@marge-bot) 30 Jan '26
by Marge Bot (@marge-bot) 30 Jan '26
30 Jan '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
ce2d62fb by Jessica Clarke at 2026-01-29T19:48:51-05:00
PPC NCG: Use libcall for 64-bit cmpxchg on 32-bit PowerPC
There is no native instruction for this, and even if there were a
register pair version we could use, the implementation here is assuming
the values fit in a single register, and we end up only using / defining
the low halves of the registers.
Fixes: b4d39adbb5 ("PrimOps: Add CAS op for all int sizes")
Fixes: #23969
- - - - -
1 changed file:
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
Changes:
=====================================
compiler/GHC/CmmToAsm/PPC/CodeGen.hs
=====================================
@@ -180,7 +180,7 @@ stmtToInstrs stmt = do
format = cmmTypeFormat ty
CmmUnsafeForeignCall target result_regs args
- -> genCCall target result_regs args
+ -> genCCall platform target result_regs args
CmmBranch id -> genBranch id
CmmCondBranch arg true false prediction -> do
@@ -1183,24 +1183,25 @@ genCondJump id bool prediction = do
-- @get_arg@, which moves the arguments to the correct registers/stack
-- locations. Apart from that, the code is easy.
-genCCall :: ForeignTarget -- function to call
+genCCall :: Platform
+ -> ForeignTarget -- function to call
-> [CmmFormal] -- where to put the result
-> [CmmActual] -- arguments (of mixed type)
-> NatM InstrBlock
-genCCall (PrimTarget MO_AcquireFence) _ _
+genCCall _ (PrimTarget MO_AcquireFence) _ _
= return $ unitOL LWSYNC
-genCCall (PrimTarget MO_ReleaseFence) _ _
+genCCall _ (PrimTarget MO_ReleaseFence) _ _
= return $ unitOL LWSYNC
-genCCall (PrimTarget MO_SeqCstFence) _ _
+genCCall _ (PrimTarget MO_SeqCstFence) _ _
= return $ unitOL HWSYNC
-genCCall (PrimTarget MO_Touch) _ _
+genCCall _ (PrimTarget MO_Touch) _ _
= return $ nilOL
-genCCall (PrimTarget (MO_Prefetch_Data _)) _ _
+genCCall _ (PrimTarget (MO_Prefetch_Data _)) _ _
= return $ nilOL
-genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n]
+genCCall _ (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n]
= do let fmt = intFormat width
reg_dst = getLocalRegReg dst
(instr, n_code) <- case amop of
@@ -1250,7 +1251,7 @@ genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n]
(n_reg, n_code) <- getSomeReg n
return (op dst dst (RIReg n_reg), n_code)
-genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr]
+genCCall _ (PrimTarget (MO_AtomicRead width _)) [dst] [addr]
= do let fmt = intFormat width
reg_dst = getLocalRegReg dst
form = if widthInBits width == 64 then DS else D
@@ -1277,12 +1278,12 @@ genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr]
-- This is also what gcc does.
-genCCall (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do
+genCCall _ (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do
code <- assignMem_IntCode (intFormat width) addr val
return $ unitOL HWSYNC `appOL` code
-genCCall (PrimTarget (MO_Cmpxchg width)) [dst] [addr, old, new]
- | width == W32 || width == W64
+genCCall platform (PrimTarget (MO_Cmpxchg width)) [dst] [addr, old, new]
+ | width == W32 || (width == W64 && not (target32Bit platform))
= do
(old_reg, old_code) <- getSomeReg old
(new_reg, new_code) <- getSomeReg new
@@ -1311,9 +1312,8 @@ genCCall (PrimTarget (MO_Cmpxchg width)) [dst] [addr, old, new]
format = intFormat width
-genCCall (PrimTarget (MO_Clz width)) [dst] [src]
- = do platform <- getPlatform
- let reg_dst = getLocalRegReg dst
+genCCall platform (PrimTarget (MO_Clz width)) [dst] [src]
+ = do let reg_dst = getLocalRegReg dst
if target32Bit platform && width == W64
then do
RegCode64 code vr_hi vr_lo <- iselExpr64 src
@@ -1361,9 +1361,8 @@ genCCall (PrimTarget (MO_Clz width)) [dst] [src]
let cntlz = unitOL (CNTLZ format reg_dst reg)
return $ s_code `appOL` pre `appOL` cntlz `appOL` post
-genCCall (PrimTarget (MO_Ctz width)) [dst] [src]
- = do platform <- getPlatform
- let reg_dst = getLocalRegReg dst
+genCCall platform (PrimTarget (MO_Ctz width)) [dst] [src]
+ = do let reg_dst = getLocalRegReg dst
if target32Bit platform && width == W64
then do
let format = II32
@@ -1425,9 +1424,8 @@ genCCall (PrimTarget (MO_Ctz width)) [dst] [src]
, SUBFC dst r' (RIImm (ImmInt (format_bits)))
]
-genCCall target dest_regs argsAndHints
- = do platform <- getPlatform
- case target of
+genCCall platform target dest_regs argsAndHints
+ = do case target of
PrimTarget (MO_S_QuotRem width) -> divOp1 True width
dest_regs argsAndHints
PrimTarget (MO_U_QuotRem width) -> divOp1 False width
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce2d62fba69d2ea0c74c46c50628feb…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce2d62fba69d2ea0c74c46c50628feb…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T26503] 2 commits: Unify HsString + HsMultilineString
by Brandon Chinn (@brandonchinn178) 30 Jan '26
by Brandon Chinn (@brandonchinn178) 30 Jan '26
30 Jan '26
Brandon Chinn pushed to branch wip/T26503 at Glasgow Haskell Compiler / GHC
Commits:
40968332 by Brandon Chinn at 2026-01-29T15:32:18-08:00
Unify HsString + HsMultilineString
- - - - -
769c384e by Brandon Chinn at 2026-01-29T15:45:00-08:00
Implement QualifiedStrings (#26503)
See Note [Implementation of QualifiedStrings]
- - - - -
72 changed files:
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/String.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error/Codes.hs
- + compiler/GHC/Types/StringMeta.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/Language/Haskell/Syntax/Lit.hs
- compiler/ghc.cabal.in
- docs/users_guide/9.16.1-notes.rst
- + docs/users_guide/exts/qualified_strings.rst
- libraries/ghc-boot-th/GHC/Boot/TH/Ppr.hs
- libraries/ghc-internal/src/GHC/Internal/LanguageExtensions.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
- libraries/template-haskell/Language/Haskell/TH/Lib.hs
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/driver/T4437.hs
- testsuite/tests/ghc-api/annotations-literals/literals.stdout
- testsuite/tests/ghc-api/annotations-literals/parsed.hs
- testsuite/tests/ghc-api/annotations-literals/parsed.stdout
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr
- + testsuite/tests/qualified-strings/Makefile
- + testsuite/tests/qualified-strings/should_compile/Example/Length.hs
- + testsuite/tests/qualified-strings/should_compile/all.T
- + testsuite/tests/qualified-strings/should_compile/qstrings_redundant_pattern.hs
- + testsuite/tests/qualified-strings/should_compile/qstrings_redundant_pattern.stderr
- + testsuite/tests/qualified-strings/should_fail/Example/Length.hs
- + testsuite/tests/qualified-strings/should_fail/Makefile
- + testsuite/tests/qualified-strings/should_fail/all.T
- + testsuite/tests/qualified-strings/should_fail/qstrings_bad_expr.hs
- + testsuite/tests/qualified-strings/should_fail/qstrings_bad_expr.stderr
- + testsuite/tests/qualified-strings/should_fail/qstrings_bad_pat.hs
- + testsuite/tests/qualified-strings/should_fail/qstrings_bad_pat.stderr
- + testsuite/tests/qualified-strings/should_fail/qstrings_multiline_no_ext.hs
- + testsuite/tests/qualified-strings/should_fail/qstrings_multiline_no_ext.stderr
- + testsuite/tests/qualified-strings/should_run/Example/ByteStringAscii.hs
- + testsuite/tests/qualified-strings/should_run/Example/ByteStringUtf8.hs
- + testsuite/tests/qualified-strings/should_run/Example/Text.hs
- + testsuite/tests/qualified-strings/should_run/Makefile
- + testsuite/tests/qualified-strings/should_run/all.T
- + testsuite/tests/qualified-strings/should_run/qstrings_expr.hs
- + testsuite/tests/qualified-strings/should_run/qstrings_expr.stdout
- + testsuite/tests/qualified-strings/should_run/qstrings_pat.hs
- + testsuite/tests/qualified-strings/should_run/qstrings_pat.stdout
- + testsuite/tests/qualified-strings/should_run/qstrings_th.hs
- + testsuite/tests/qualified-strings/should_run/qstrings_th.stdout
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c811b1db19a5c693266c24afcd1cea…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c811b1db19a5c693266c24afcd1cea…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
30 Jan '26
Andreas Klebinger pushed to branch wip/andreask/linker_fix at Glasgow Haskell Compiler / GHC
Commits:
3809f281 by Andreas Klebinger at 2026-01-29T23:08:53+01:00
wobble
- - - - -
1 changed file:
- rts/linker/MachO.c
Changes:
=====================================
rts/linker/MachO.c
=====================================
@@ -175,7 +175,7 @@ resolveImports(
int
ocAllocateExtras_MachO(ObjectCode* oc)
{
- IF_DEBUG(linker, DEBUG_LOG("ocAllocateExtras_MachO: start\n"));
+ IF_DEBUG(linker, debugBelch("ocAllocateExtras_MachO: start\n"));
if (NULL != oc->info->symCmd) {
IF_DEBUG(linker,
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3809f2819423fbb5e732d38573b1dda…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3809f2819423fbb5e732d38573b1dda…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/26699] Decouple `L.S.H.Decls` from importing `GHC.Types.Basic`
by recursion-ninja (@recursion-ninja) 30 Jan '26
by recursion-ninja (@recursion-ninja) 30 Jan '26
30 Jan '26
recursion-ninja pushed to branch wip/26699 at Glasgow Haskell Compiler / GHC
Commits:
6995cc5f by Recursion Ninja at 2026-01-29T16:38:40-05:00
Decouple `L.S.H.Decls` from importing `GHC.Types.Basic`
Data-types within `GHC.Types.Basic` which describe components of
the AST are migrated to `Language.Haskell.Syntax.Basic`. Related
function definitions are also moved.
Migrated types:
* TopLevelFlag
* RuleName
* TyConFlavour
* TypeOrData
* NewOrData
Migrated instances:
* `Outputable` instances moved to in `GHC.Utils.Outputable`
* `Binary` instance of `Boxity` moved to to `GHC.Utils.Binary`
* Other `Binary` instances are orphans to be migrated later.
The `OverlapMode` data-type is given a TTG extension point.
The `OverlapFlag` data-type, which depends on `OverlapMode`,
is updated to support `OverlapMode` with a GHC "pass" type paramerter.
In order to avoid module import cycles, `OverlapMode` and `OverlapFlag`
are migrated to new modules (no way around this).
* Migrated `OverlapMode` to new module `Language.Haskell.Syntax.Overlap`
* Migrated `OverlapFlag` to new module `GHC.Hs.Decls.Overlap`
Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Rodrigo Mesquita <rodrigo.m.mesquita(a)gmail.com>
- - - - -
37 changed files:
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Hs/Decls.hs
- + compiler/GHC/Hs/Decls/Overlap.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Parser.y
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Unit/Types.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax/Basic.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- + compiler/Language/Haskell/Syntax/Decls/Overlap.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6995cc5fca4473fff52e050ea993557…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6995cc5fca4473fff52e050ea993557…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/26699] Apply 1 suggestion(s) to 1 file(s)
by recursion-ninja (@recursion-ninja) 30 Jan '26
by recursion-ninja (@recursion-ninja) 30 Jan '26
30 Jan '26
recursion-ninja pushed to branch wip/26699 at Glasgow Haskell Compiler / GHC
Commits:
5e2da544 by recursion-ninja at 2026-01-29T21:28:03+00:00
Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Rodrigo Mesquita <rodrigo.m.mesquita(a)gmail.com>
- - - - -
1 changed file:
- compiler/GHC/Hs/Decls/Overlap.hs
Changes:
=====================================
compiler/GHC/Hs/Decls/Overlap.hs
=====================================
@@ -5,8 +5,7 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
{- Necessary for the following instances:
* (type class): Binary OverlapMode
- * (type family): XOverlapMode (GhcPass p)
- * (type family): XXOverlapMode (GhcPass p)
+ * (type class): NFData OverlapMode
-}
{- |
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e2da544b21f800b1dfd3b8605153aa…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e2da544b21f800b1dfd3b8605153aa…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/26699] Add TTG extension point to 'OverlapMode'
by recursion-ninja (@recursion-ninja) 30 Jan '26
by recursion-ninja (@recursion-ninja) 30 Jan '26
30 Jan '26
recursion-ninja pushed to branch wip/26699 at Glasgow Haskell Compiler / GHC
Commits:
76bbbe23 by Recursion Ninja at 2026-01-29T16:01:16-05:00
Add TTG extension point to 'OverlapMode'
Migrate OverlapMode to new module Language.Haskell.Syntax.Overlap
Migrate OverlapFlag to new module GHC.Hs.Decls.Overlap
- - - - -
26 changed files:
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Hs/Decls.hs
- + compiler/GHC/Hs/Decls/Overlap.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Parser.y
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Unit/Types.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax/Basic.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- + compiler/Language/Haskell/Syntax/Decls/Overlap.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
Changes:
=====================================
compiler/GHC/Core/InstEnv.hs
=====================================
@@ -10,7 +10,7 @@ The bits common to GHC.Tc.TyCl.Instance and GHC.Tc.Deriv.
module GHC.Core.InstEnv (
DFunId, InstMatch, ClsInstLookupResult,
CanonicalEvidence(..), PotentialUnifiers(..), getCoherentUnifiers, nullUnifiers,
- OverlapFlag(..), OverlapMode(..), setOverlapModeMaybe,
+ OverlapFlag(..), OverlapMode(..),
ClsInst(..), DFunInstType, pprInstance, pprInstanceHdr, pprDFunId, pprInstances,
instanceWarning, instanceHead, instanceSig, mkLocalClsInst, mkImportedClsInst,
instanceDFunId, updateClsInstDFuns, updateClsInstDFun,
@@ -40,6 +40,7 @@ import GHC.Core.RoughMap
import GHC.Core.Class
import GHC.Core.Unify
import GHC.Core.FVs( orphNamesOfTypes, orphNamesOfType )
+import GHC.Hs.Decls.Overlap
import GHC.Hs.Extension
import GHC.Unit.Module.Env
@@ -50,7 +51,6 @@ import GHC.Types.Unique.DSet
import GHC.Types.Var.Set
import GHC.Types.Name
import GHC.Types.Name.Set
-import GHC.Types.Basic
import GHC.Types.Id
import GHC.Generics (Generic)
import Data.List.NonEmpty ( NonEmpty (..), nonEmpty )
=====================================
compiler/GHC/Hs/Decls.hs
=====================================
@@ -100,13 +100,17 @@ module GHC.Hs.Decls (
-- friends:
import GHC.Prelude
+import Language.Haskell.Syntax.Binds
import Language.Haskell.Syntax.Decls
+import Language.Haskell.Syntax.Decls.Overlap (OverlapMode(..))
import Language.Haskell.Syntax.Extension
-import {-# SOURCE #-} GHC.Hs.Expr ( pprExpr, pprUntypedSplice )
+import {-# SOURCE #-} GHC.Hs.Expr (pprExpr, pprUntypedSplice)
-- Because Expr imports Decls via HsBracket
-import GHC.Hs.Binds
+import GHC.Hs.Binds (ActivationAnn(..),
+ emptyValBindsIn, emptyValBindsOut, isEmptyValBinds,
+ plusHsValBinds, pprDeclList, pprLHsBindsForUser)
import GHC.Hs.Type
import GHC.Hs.Doc
import GHC.Types.Basic
@@ -1061,7 +1065,7 @@ ppDerivStrategy mb =
Nothing -> empty
Just (L _ ds) -> ppr ds
-ppOverlapPragma :: Maybe (LocatedP OverlapMode) -> SDoc
+ppOverlapPragma :: Maybe (LocatedP (OverlapMode (GhcPass p))) -> SDoc
ppOverlapPragma mb =
case mb of
Nothing -> empty
@@ -1489,7 +1493,7 @@ type instance Anno (ClsInstDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (InstDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (DocDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (DerivDecl (GhcPass p)) = SrcSpanAnnA
-type instance Anno OverlapMode = SrcSpanAnnP
+type instance Anno (OverlapMode (GhcPass p)) = SrcSpanAnnP
type instance Anno (DerivStrategy (GhcPass p)) = EpAnnCO
type instance Anno (DefaultDecl (GhcPass p)) = SrcSpanAnnA
type instance Anno (ForeignDecl (GhcPass p)) = SrcSpanAnnA
=====================================
compiler/GHC/Hs/Decls/Overlap.hs
=====================================
@@ -0,0 +1,108 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE UndecidableInstances #-} -- XOverlapMode, XXOverlapMode
+
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+{- Necessary for the following instances:
+ * (type class): Binary OverlapMode
+ * (type family): XOverlapMode (GhcPass p)
+ * (type family): XXOverlapMode (GhcPass p)
+-}
+
+{- |
+Data-types describing the overlap annotations for instances as well as
+interpreting the instances usage within the Safe Haskell context.
+-}
+module GHC.Hs.Decls.Overlap (
+ -- * OverlapFlag
+ -- ** Data-type
+ OverlapFlag(..),
+
+ -- * OverlapMode
+ -- ** Data-type
+ OverlapMode(..),
+ -- ** Queries
+ hasOverlappableFlag,
+ hasOverlappingFlag,
+ hasIncoherentFlag,
+ hasNonCanonicalFlag,
+ ) where
+
+import GHC.Prelude
+
+import GHC.Hs.Extension
+
+import Language.Haskell.Syntax.Decls.Overlap
+import Language.Haskell.Syntax.Extension
+
+import GHC.Types.SourceText
+import GHC.Utils.Binary
+import GHC.Utils.Outputable
+
+import Control.DeepSeq (NFData(..))
+
+{-
+************************************************************************
+* *
+ Instance overlap flag
+* *
+************************************************************************
+-}
+
+-- | The semantics allowed for overlapping instances for a particular
+-- instance. See Note [Safe Haskell isSafeOverlap] in GHC.Core.InstEnv for a
+-- explanation of the `isSafeOverlap` field.
+data OverlapFlag = OverlapFlag
+ { isSafeOverlap :: Bool
+ , overlapMode :: OverlapMode GhcTc
+ } deriving (Eq)
+
+instance Binary OverlapFlag where
+ put_ bh flag = do put_ bh (overlapMode flag)
+ put_ bh (isSafeOverlap flag)
+ get bh = do
+ h <- get bh
+ b <- get bh
+ return OverlapFlag { isSafeOverlap = b, overlapMode = h }
+
+instance NFData OverlapFlag where
+ rnf (OverlapFlag mode safe) = rnf mode `seq` rnf safe
+
+instance Outputable OverlapFlag where
+ ppr flag = ppr (overlapMode flag) <+> pprSafeOverlap (isSafeOverlap flag)
+
+type instance XOverlapMode (GhcPass _) = SourceText
+
+type instance XXOverlapMode (GhcPass _) = DataConCantHappen
+
+instance NFData (OverlapMode (GhcPass p)) where
+ rnf = \case
+ NoOverlap s -> rnf s
+ Overlappable s -> rnf s
+ Overlapping s -> rnf s
+ Overlaps s -> rnf s
+ Incoherent s -> rnf s
+ NonCanonical s -> rnf s
+
+instance Binary (OverlapMode (GhcPass p)) where
+ put_ bh = \case
+ NoOverlap s -> putByte bh 0 >> put_ bh s
+ Overlaps s -> putByte bh 1 >> put_ bh s
+ Incoherent s -> putByte bh 2 >> put_ bh s
+ Overlapping s -> putByte bh 3 >> put_ bh s
+ Overlappable s -> putByte bh 4 >> put_ bh s
+ NonCanonical s -> putByte bh 5 >> put_ bh s
+
+ get bh = do
+ h <- getByte bh
+ case h of
+ 0 -> get bh >>= \s -> return $ NoOverlap s
+ 1 -> get bh >>= \s -> return $ Overlaps s
+ 2 -> get bh >>= \s -> return $ Incoherent s
+ 3 -> get bh >>= \s -> return $ Overlapping s
+ 4 -> get bh >>= \s -> return $ Overlappable s
+ _ -> get bh >>= \s -> return $ NonCanonical s
+
+pprSafeOverlap :: Bool -> SDoc
+pprSafeOverlap True = text "[safe]"
+pprSafeOverlap False = empty
=====================================
compiler/GHC/Hs/Instances.hs
=====================================
@@ -33,6 +33,7 @@ import GHC.Types.Name.Reader (WithUserRdr(..))
import GHC.Types.InlinePragma (ActivationGhc)
import GHC.Data.BooleanFormula (BooleanFormula(..))
import Language.Haskell.Syntax.Decls
+import Language.Haskell.Syntax.Decls.Overlap (OverlapMode(..))
import Language.Haskell.Syntax.Extension (Anno)
import Language.Haskell.Syntax.Binds.InlinePragma (ActivationX(..), InlinePragma(..))
@@ -642,3 +643,8 @@ deriving instance Data ActivationGhc
deriving instance Data (InlinePragma GhcPs)
deriving instance Data (InlinePragma GhcRn)
deriving instance Data (InlinePragma GhcTc)
+
+-- deriving instance Data (OverlapMode p)
+deriving instance Data (OverlapMode GhcPs)
+deriving instance Data (OverlapMode GhcRn)
+deriving instance Data (OverlapMode GhcTc)
=====================================
compiler/GHC/HsToCore/Quote.hs
=====================================
@@ -37,6 +37,7 @@ import GHC.HsToCore.Binds
import qualified GHC.Boot.TH.Syntax as TH
import GHC.Hs
+import GHC.Hs.Decls.Overlap ( OverlapMode(..) )
import GHC.Tc.Utils.TcType
import GHC.Tc.Types.Evidence
@@ -68,7 +69,6 @@ import qualified GHC.Data.List.NonEmpty as NE
import GHC.Types.SrcLoc as SrcLoc
import GHC.Types.Unique
-import GHC.Types.Basic
import GHC.Types.ForeignCall
import GHC.Types.Var
import GHC.Types.Id
@@ -2731,7 +2731,7 @@ repNewtypeStrategy = rep2 newtypeStrategyName []
repViaStrategy :: Core (M TH.Type) -> MetaM (Core (M TH.DerivStrategy))
repViaStrategy (MkC t) = rep2 viaStrategyName [t]
-repOverlap :: Maybe OverlapMode -> MetaM (Core (Maybe TH.Overlap))
+repOverlap :: Maybe (OverlapMode GhcRn) -> MetaM (Core (Maybe TH.Overlap))
repOverlap mb =
case mb of
Nothing -> nothing
=====================================
compiler/GHC/Iface/Ext/Ast.hs
=====================================
@@ -1718,7 +1718,7 @@ instance ToHie (RScoped (LocatedAn NoEpAnns (DerivStrategy GhcRn))) where
NewtypeStrategy _ -> []
ViaStrategy s -> [ toHie (TS (ResolvedScopes [sc]) s) ]
-instance ToHie (LocatedP OverlapMode) where
+instance ToHie (LocatedP (OverlapMode GhcRn)) where
toHie (L span _) = locOnly (locA span)
instance ToHie (LocatedA (ConDecl GhcRn)) where
=====================================
compiler/GHC/Iface/Syntax.hs
=====================================
@@ -85,6 +85,7 @@ import GHC.Builtin.Types ( constraintKindTyConName )
import GHC.Stg.EnforceEpt.TagSig
import GHC.Parser.Annotation (noLocA)
import GHC.Hs.Extension ( GhcRn )
+import GHC.Hs.Decls.Overlap ( OverlapFlag )
import GHC.Hs.Doc ( WithHsDocIdentifiers(..) )
import GHC.Utils.Lexeme (isLexSym)
=====================================
compiler/GHC/Parser.y
=====================================
@@ -43,6 +43,7 @@ import qualified Data.List.NonEmpty as NE
import qualified Prelude -- for happy-generated code
import GHC.Hs
+import GHC.Hs.Decls.Overlap ( OverlapMode(..) )
import GHC.Driver.Backpack.Syntax
@@ -1443,7 +1444,7 @@ inst_decl :: { LInstDecl GhcPs }
(fmap reverse $7)
(AnnDataDefn [] [] NoEpTok tnewtype tdata (epTok $2) dcolon twhere oc cc NoEpTok)}}
-overlap_pragma :: { Maybe (LocatedP OverlapMode) }
+overlap_pragma :: { Maybe (LocatedP (OverlapMode GhcPs)) }
: '{-# OVERLAPPABLE' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlappable (getOVERLAPPABLE_PRAGs $1)))
(AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
| '{-# OVERLAPPING' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlapping (getOVERLAPPING_PRAGs $1)))
=====================================
compiler/GHC/Rename/Module.hs
=====================================
@@ -1,3 +1,4 @@
+{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE TypeFamilies #-}
@@ -21,6 +22,7 @@ import {-# SOURCE #-} GHC.Rename.Expr( rnLExpr )
import {-# SOURCE #-} GHC.Rename.Splice ( rnSpliceDecl, rnTopSpliceDecls )
import GHC.Hs
+import GHC.Hs.Decls.Overlap ( OverlapMode(..) )
import GHC.Rename.HsType
import GHC.Rename.Bind
@@ -582,7 +584,7 @@ rnClsInstDecl :: ClsInstDecl GhcPs -> RnM (ClsInstDecl GhcRn, FreeVars)
rnClsInstDecl (ClsInstDecl { cid_ext = (inst_warn_ps, _, _)
, cid_poly_ty = inst_ty, cid_binds = mbinds
, cid_sigs = uprags, cid_tyfam_insts = ats
- , cid_overlap_mode = oflag
+ , cid_overlap_mode = omode
, cid_datafam_insts = adts })
= do { rec { let ctxt = ClassInstanceCtx head_ty'
; checkInferredVars ctxt inst_ty
@@ -656,13 +658,14 @@ rnClsInstDecl (ClsInstDecl { cid_ext = (inst_warn_ps, _, _)
; (adts', adt_fvs) <- rnATInstDecls rnDataFamInstDecl cls ktv_names adts
; return ( (ats', adts'), at_fvs `plusFV` adt_fvs) }
+ ; let omode' = rnOverlapMode omode
; let all_fvs = meth_fvs `plusFV` more_fvs
`plusFV` inst_fvs
; inst_warn_rn <- mapM rnLWarningTxt inst_warn_ps
; return (ClsInstDecl { cid_ext = inst_warn_rn
, cid_poly_ty = inst_ty', cid_binds = mbinds'
, cid_sigs = uprags', cid_tyfam_insts = ats'
- , cid_overlap_mode = oflag
+ , cid_overlap_mode = omode'
, cid_datafam_insts = adts' },
all_fvs) }
-- We return the renamed associated data type declarations so
@@ -685,6 +688,18 @@ rnClsInstDecl (ClsInstDecl { cid_ext = (inst_warn_ps, _, _)
addErrAt l $ TcRnWithHsDocContext ctxt err_msg
pure $ mkUnboundName (mkTcOccFS (fsLit "<class>"))
+rnOverlapMode :: Maybe (XRec GhcPs (OverlapMode GhcPs))
+ -> Maybe (XRec GhcRn (OverlapMode GhcRn))
+rnOverlapMode =
+ let advancePass = \case
+ NoOverlap s -> NoOverlap s
+ Overlappable s -> Overlappable s
+ Overlapping s -> Overlapping s
+ Overlaps s -> Overlaps s
+ Incoherent s -> Incoherent s
+ NonCanonical s -> NonCanonical s
+ in fmap (fmap advancePass)
+
rnFamEqn :: HsDocContext
-> AssocTyFamInfo
-> FamEqn GhcPs rhs
@@ -1167,7 +1182,8 @@ rnSrcDerivDecl (DerivDecl (inst_warn_ps, ann) ty mds overlap)
NFC_StandaloneDerivedInstanceHead
(getLHsInstDeclHead $ dropWildCards ty')
; inst_warn_rn <- mapM rnLWarningTxt inst_warn_ps
- ; return (DerivDecl (inst_warn_rn, ann) ty' mds' overlap, fvs) }
+ ; let overlap' = rnOverlapMode overlap
+ ; return (DerivDecl (inst_warn_rn, ann) ty' mds' overlap', fvs) }
where
ctxt = DerivDeclCtx
nowc_ty = dropWildCards ty
=====================================
compiler/GHC/Tc/Deriv.hs
=====================================
@@ -763,7 +763,7 @@ deriveStandalone (L loc (DerivDecl (warn, _) deriv_ty mb_lderiv_strat overlap_mo
then do warnUselessTypeable
return Nothing
else do early_deriv_spec <-
- mkEqnHelp (fmap unLoc overlap_mode)
+ mkEqnHelp (fmap (tcOverlapMode . unLoc) overlap_mode)
tvs' cls inst_tys'
deriv_ctxt' mb_deriv_strat'
(fmap unLoc warn)
@@ -773,6 +773,16 @@ deriveStandalone (L loc (DerivDecl (warn, _) deriv_ty mb_lderiv_strat overlap_mo
early_deriv_spec
pure (Just early_deriv_spec) }
+
+tcOverlapMode :: OverlapMode GhcRn -> OverlapMode GhcTc
+tcOverlapMode = \case
+ NoOverlap s -> NoOverlap s
+ Overlappable s -> Overlappable s
+ Overlapping s -> Overlapping s
+ Overlaps s -> Overlaps s
+ Incoherent s -> Incoherent s
+ NonCanonical s -> NonCanonical s
+
-- Typecheck the type in a standalone deriving declaration.
--
-- This may appear dense, but it's mostly huffing and puffing to recognize
@@ -1218,7 +1228,7 @@ instance (at least from the user's perspective), the amount of engineering
required to obtain the latter instance just isn't worth it.
-}
-mkEqnHelp :: Maybe OverlapMode
+mkEqnHelp :: Maybe (OverlapMode GhcTc)
-> [TyVar]
-> Class -> [Type]
-> DerivContext
=====================================
compiler/GHC/Tc/Deriv/Utils.hs
=====================================
@@ -112,7 +112,7 @@ mkDerivOrigin standalone = DerivOrigin standalone
-- determining what its @EarlyDerivSpec@ should be.
-- See @Note [DerivEnv and DerivSpecMechanism]@.
data DerivEnv = DerivEnv
- { denv_overlap_mode :: Maybe OverlapMode
+ { denv_overlap_mode :: Maybe (OverlapMode GhcTc)
-- ^ Is this an overlapping instance?
, denv_tvs :: [TyVar]
-- ^ Universally quantified type variables in the instance. If the
@@ -167,7 +167,7 @@ data DerivSpec theta = DS { ds_loc :: SrcSpan
, ds_tys :: [Type]
, ds_skol_info :: SkolemInfo
, ds_user_ctxt :: UserTypeCtxt
- , ds_overlap :: Maybe OverlapMode
+ , ds_overlap :: Maybe (OverlapMode GhcTc)
, ds_standalone_wildcard :: Maybe SrcSpan
-- See Note [Inferring the instance context]
-- in GHC.Tc.Deriv.Infer
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -70,6 +70,7 @@ import GHC.CoreToIface
import GHC.Driver.Flags
import GHC.Driver.Backend
import GHC.Hs hiding (HoleError)
+import GHC.Hs.Decls.Overlap
import GHC.Tc.Errors.Types
import GHC.Tc.Errors.Types.PromotionErr (pprTermLevelUseCtxt)
=====================================
compiler/GHC/Tc/Utils/Instantiate.hs
=====================================
@@ -912,7 +912,7 @@ hasFixedRuntimeRepRes std_nm user_expr ty = mapM_ do_check mb_arity
************************************************************************
-}
-getOverlapFlag :: Maybe OverlapMode -- User pragma if any
+getOverlapFlag :: Maybe (OverlapMode (GhcPass p)) -- User pragma if any
-> TcM OverlapFlag
-- Construct the OverlapFlag from the global module flags,
-- but if the overlap_mode argument is (Just m),
@@ -946,18 +946,25 @@ getOverlapFlag overlap_mode_prag
-- See GHC.Core.InstEnv Note [Coherence and specialisation: overview]
final_overlap_mode
| Incoherent s <- overlap_mode
- , noncanonical_incoherence = NonCanonical s
- | otherwise = overlap_mode
+ , noncanonical_incoherence = NonCanonical s
+ | otherwise = overlap_mode
- ; return (OverlapFlag { isSafeOverlap = safeLanguageOn dflags
- , overlapMode = final_overlap_mode }) }
+ final_overlap_flag = OverlapFlag (safeLanguageOn dflags) $
+ case final_overlap_mode of
+ NoOverlap s -> NoOverlap s
+ Overlappable s -> Overlappable s
+ Overlapping s -> Overlapping s
+ Overlaps s -> Overlaps s
+ Incoherent s -> Incoherent s
+ NonCanonical s -> NonCanonical s
+ ; return $ final_overlap_flag }
tcGetInsts :: TcM [ClsInst]
-- Gets the local class instances.
tcGetInsts = fmap tcg_insts getGblEnv
-newClsInst :: Maybe OverlapMode -- User pragma
+newClsInst :: Maybe (OverlapMode (GhcPass p)) -- User pragma
-> Name -> [TyVar] -> ThetaType
-> Class -> [Type] -> Maybe (WarningTxt GhcRn) -> TcM ClsInst
newClsInst overlap_mode dfun_name tvs theta clas tys warn
=====================================
compiler/GHC/ThToHs.hs
=====================================
@@ -38,6 +38,7 @@ import GHC.Core.Type as Hs
import qualified GHC.Core.Coercion as Coercion ( Role(..) )
import GHC.Builtin.Types
import GHC.Builtin.Types.Prim( fUNTyCon )
+import GHC.Hs.Decls.Overlap as Hs
import GHC.Types.Basic as Hs
import GHC.Types.InlinePragma as Hs
import GHC.Types.ForeignCall
=====================================
compiler/GHC/Types/Basic.hs
=====================================
@@ -14,7 +14,14 @@ types that
\end{itemize}
-}
-{-# OPTIONS_GHC -Wno-orphans #-} -- Outputable PromotionFlag, Binary PromotionFlag, Outputable Boxity, Binay Boxity
+{-# OPTIONS_GHC -Wno-orphans #-}
+{-
+Above flag is necessary for these instances:
+ * Binary Boxity
+ * Binary PromotionFlag
+ * Outputable Boxity
+ * Outputable PromotionFlag
+-}
{-# LANGUAGE DerivingVia #-}
module GHC.Types.Basic (
@@ -40,9 +47,6 @@ module GHC.Types.Basic (
TopLevelFlag(..), isTopLevel, isNotTopLevel,
- OverlapFlag(..), OverlapMode(..), setOverlapModeMaybe,
- hasOverlappingFlag, hasOverlappableFlag, hasIncoherentFlag, hasNonCanonicalFlag,
-
Boxity(..), isBoxed,
CbvMark(..), isMarkedCbv,
@@ -107,13 +111,13 @@ import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Utils.Binary
import GHC.Types.Arity
-import GHC.Types.SourceText
+
import qualified GHC.LanguageExtensions as LangExt
import {-# SOURCE #-} Language.Haskell.Syntax.Type (PromotionFlag(..), isPromoted)
import {-# SOURCE #-} Language.Haskell.Syntax.Expr (HsDoFlavour)
import Language.Haskell.Syntax.Basic
-import Language.Haskell.Syntax.ImpExp
+import Language.Haskell.Syntax.ImpExp (ImportDeclLevel(..), ImportDeclLevelStyle(..))
import Control.DeepSeq ( NFData(..) )
import Data.Data
@@ -592,178 +596,6 @@ of whether we should do pattern-match checks; see the calls of the requiresPMC
function (e.g. isMatchContextPmChecked and needToRunPmCheck in GHC.HsToCore.Pmc.Utils).
-}
-{-
-************************************************************************
-* *
- Instance overlap flag
-* *
-************************************************************************
--}
-
--- | The semantics allowed for overlapping instances for a particular
--- instance. See Note [Safe Haskell isSafeOverlap] in GHC.Core.InstEnv for a
--- explanation of the `isSafeOverlap` field.
---
-
-data OverlapFlag = OverlapFlag
- { overlapMode :: OverlapMode
- , isSafeOverlap :: Bool
- } deriving (Eq, Data)
-
-setOverlapModeMaybe :: OverlapFlag -> Maybe OverlapMode -> OverlapFlag
-setOverlapModeMaybe f Nothing = f
-setOverlapModeMaybe f (Just m) = f { overlapMode = m }
-
-hasIncoherentFlag :: OverlapMode -> Bool
-hasIncoherentFlag mode =
- case mode of
- Incoherent _ -> True
- NonCanonical _ -> True
- _ -> False
-
-hasOverlappableFlag :: OverlapMode -> Bool
-hasOverlappableFlag mode =
- case mode of
- Overlappable _ -> True
- Overlaps _ -> True
- Incoherent _ -> True
- NonCanonical _ -> True
- _ -> False
-
-hasOverlappingFlag :: OverlapMode -> Bool
-hasOverlappingFlag mode =
- case mode of
- Overlapping _ -> True
- Overlaps _ -> True
- Incoherent _ -> True
- NonCanonical _ -> True
- _ -> False
-
-hasNonCanonicalFlag :: OverlapMode -> Bool
-hasNonCanonicalFlag = \case
- NonCanonical{} -> True
- _ -> False
-
-data OverlapMode -- See Note [Rules for instance lookup] in GHC.Core.InstEnv
- = NoOverlap SourceText
- -- See Note [Pragma source text]
- -- ^ This instance must not overlap another `NoOverlap` instance.
- -- However, it may be overlapped by `Overlapping` instances,
- -- and it may overlap `Overlappable` instances.
-
-
- | Overlappable SourceText
- -- See Note [Pragma source text]
- -- ^ Silently ignore this instance if you find a
- -- more specific one that matches the constraint
- -- you are trying to resolve
- --
- -- Example: constraint (Foo [Int])
- -- instance Foo [Int]
- -- instance {-# OVERLAPPABLE #-} Foo [a]
- --
- -- Since the second instance has the Overlappable flag,
- -- the first instance will be chosen (otherwise
- -- its ambiguous which to choose)
-
-
- | Overlapping SourceText
- -- See Note [Pragma source text]
- -- ^ Silently ignore any more general instances that may be
- -- used to solve the constraint.
- --
- -- Example: constraint (Foo [Int])
- -- instance {-# OVERLAPPING #-} Foo [Int]
- -- instance Foo [a]
- --
- -- Since the first instance has the Overlapping flag,
- -- the second---more general---instance will be ignored (otherwise
- -- it is ambiguous which to choose)
-
-
- | Overlaps SourceText
- -- See Note [Pragma source text]
- -- ^ Equivalent to having both `Overlapping` and `Overlappable` flags.
-
- | Incoherent SourceText
- -- See Note [Pragma source text]
- -- ^ Behave like Overlappable and Overlapping, and in addition pick
- -- an arbitrary one if there are multiple matching candidates, and
- -- don't worry about later instantiation
- --
- -- Example: constraint (Foo [b])
- -- instance {-# INCOHERENT -} Foo [Int]
- -- instance Foo [a]
- -- Without the Incoherent flag, we'd complain that
- -- instantiating 'b' would change which instance
- -- was chosen. See also Note [Incoherent instances] in "GHC.Core.InstEnv"
-
- | NonCanonical SourceText
- -- ^ Behave like Incoherent, but the instance choice is observable
- -- by the program behaviour. See Note [Coherence and specialisation: overview].
- --
- -- We don't have surface syntax for the distinction between
- -- Incoherent and NonCanonical instances; instead, the flag
- -- `-f{no-}specialise-incoherents` (on by default) controls
- -- whether `INCOHERENT` instances are regarded as Incoherent or
- -- NonCanonical.
-
- deriving (Eq, Data)
-
-
-instance Outputable OverlapFlag where
- ppr flag = ppr (overlapMode flag) <+> pprSafeOverlap (isSafeOverlap flag)
-
-instance NFData OverlapFlag where
- rnf (OverlapFlag mode safe) = rnf mode `seq` rnf safe
-
-instance Outputable OverlapMode where
- ppr (NoOverlap _) = empty
- ppr (Overlappable _) = text "[overlappable]"
- ppr (Overlapping _) = text "[overlapping]"
- ppr (Overlaps _) = text "[overlap ok]"
- ppr (Incoherent _) = text "[incoherent]"
- ppr (NonCanonical _) = text "[noncanonical]"
-
-instance NFData OverlapMode where
- rnf (NoOverlap s) = rnf s
- rnf (Overlappable s) = rnf s
- rnf (Overlapping s) = rnf s
- rnf (Overlaps s) = rnf s
- rnf (Incoherent s) = rnf s
- rnf (NonCanonical s) = rnf s
-
-instance Binary OverlapMode where
- put_ bh (NoOverlap s) = putByte bh 0 >> put_ bh s
- put_ bh (Overlaps s) = putByte bh 1 >> put_ bh s
- put_ bh (Incoherent s) = putByte bh 2 >> put_ bh s
- put_ bh (Overlapping s) = putByte bh 3 >> put_ bh s
- put_ bh (Overlappable s) = putByte bh 4 >> put_ bh s
- put_ bh (NonCanonical s) = putByte bh 5 >> put_ bh s
- get bh = do
- h <- getByte bh
- case h of
- 0 -> (get bh) >>= \s -> return $ NoOverlap s
- 1 -> (get bh) >>= \s -> return $ Overlaps s
- 2 -> (get bh) >>= \s -> return $ Incoherent s
- 3 -> (get bh) >>= \s -> return $ Overlapping s
- 4 -> (get bh) >>= \s -> return $ Overlappable s
- 5 -> (get bh) >>= \s -> return $ NonCanonical s
- _ -> panic ("get OverlapMode" ++ show h)
-
-
-instance Binary OverlapFlag where
- put_ bh flag = do put_ bh (overlapMode flag)
- put_ bh (isSafeOverlap flag)
- get bh = do
- h <- get bh
- b <- get bh
- return OverlapFlag { overlapMode = h, isSafeOverlap = b }
-
-pprSafeOverlap :: Bool -> SDoc
-pprSafeOverlap True = text "[safe]"
-pprSafeOverlap False = empty
-
{-
************************************************************************
* *
=====================================
compiler/GHC/Types/Name.hs
=====================================
@@ -105,10 +105,11 @@ import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.OldList (intersperse)
+import Language.Haskell.Syntax.Basic (Boxity(Boxed, Unboxed))
+
import Control.DeepSeq
import Data.Data
import qualified Data.Semigroup as S
-import GHC.Types.Basic (Boxity(Boxed, Unboxed))
import GHC.Builtin.Uniques ( isTupleTyConUnique, isCTupleTyConUnique,
isSumTyConUnique, isTupleDataConLikeUnique )
=====================================
compiler/GHC/Unit/Types.hs
=====================================
@@ -99,7 +99,7 @@ import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS.Char8
import Language.Haskell.Syntax.Module.Name
-import Language.Haskell.Syntax.ImpExp (IsBootInterface(..))
+import Language.Haskell.Syntax.ImpExp.IsBoot (IsBootInterface(..))
---------------------------------------------------------------------
-- MODULES
=====================================
compiler/GHC/Utils/Outputable.hs
=====================================
@@ -114,6 +114,7 @@ import {-# SOURCE #-} GHC.Types.Name.Occurrence( OccName )
import Language.Haskell.Syntax.Basic
import Language.Haskell.Syntax.Binds.InlinePragma
+import Language.Haskell.Syntax.Decls.Overlap ( OverlapMode(..) )
import Language.Haskell.Syntax.Module.Name ( ModuleName(..) )
import GHC.Prelude.Basic
@@ -2026,3 +2027,12 @@ instance Outputable RuleMatchInfo where
instance Outputable TopLevelFlag where
ppr TopLevel = text "<TopLevel>"
ppr NotTopLevel = text "<NotTopLevel>"
+
+instance Outputable (OverlapMode p) where
+ ppr (NoOverlap _) = empty
+ ppr (Overlappable _) = text "[overlappable]"
+ ppr (Overlapping _) = text "[overlapping]"
+ ppr (Overlaps _) = text "[overlap ok]"
+ ppr (Incoherent _) = text "[incoherent]"
+ ppr (NonCanonical _) = text "[noncanonical]"
+ ppr (XOverlapMode _) = text "[user TTG extension]"
=====================================
compiler/Language/Haskell/Syntax/Basic.hs
=====================================
@@ -1,6 +1,8 @@
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
+
module Language.Haskell.Syntax.Basic where
+import Control.DeepSeq
import Data.Data (Data)
import Data.Eq
import Data.Ord
@@ -8,7 +10,6 @@ import Data.Bool
import Prelude
import GHC.Data.FastString (FastString)
-import Control.DeepSeq
{-
************************************************************************
=====================================
compiler/Language/Haskell/Syntax/Decls.hs
=====================================
@@ -88,18 +88,18 @@ module Language.Haskell.Syntax.Decls (
-- friends:
import {-# SOURCE #-} Language.Haskell.Syntax.Expr
- ( HsExpr, HsUntypedSplice )
+ (HsExpr, HsUntypedSplice)
-- Because Expr imports Decls via HsBracket
-import Language.Haskell.Syntax.Basic (TopLevelFlag, RuleName)
+import Language.Haskell.Syntax.Basic
+ (LexicalFixity, Role, RuleName, TopLevelFlag)
import Language.Haskell.Syntax.Binds
import Language.Haskell.Syntax.Binds.InlinePragma (Activation)
+import Language.Haskell.Syntax.Decls.Overlap (OverlapMode)
import Language.Haskell.Syntax.Extension
-import Language.Haskell.Syntax.Type
-import Language.Haskell.Syntax.Basic (Role, LexicalFixity)
import Language.Haskell.Syntax.Specificity (Specificity)
+import Language.Haskell.Syntax.Type
-import GHC.Types.Basic (OverlapMode)
import GHC.Types.ForeignCall (CType, CCallConv, Safety, Header, CLabelString, CCallTarget, CExportSpec)
import GHC.Data.FastString (FastString)
@@ -119,7 +119,7 @@ import Prelude (Show)
import Data.Foldable
import Data.Traversable
import Data.List.NonEmpty (NonEmpty (..))
-import GHC.Generics ( Generic )
+import GHC.Generics (Generic)
{-
@@ -1261,7 +1261,7 @@ data ClsInstDecl pass
, cid_sigs :: [LSig pass] -- User-supplied pragmatic info
, cid_tyfam_insts :: [LTyFamInstDecl pass] -- Type family instances
, cid_datafam_insts :: [LDataFamInstDecl pass] -- Data family instances
- , cid_overlap_mode :: Maybe (XRec pass OverlapMode)
+ , cid_overlap_mode :: Maybe (XRec pass (OverlapMode pass))
}
| XClsInstDecl !(XXClsInstDecl pass)
@@ -1310,7 +1310,7 @@ data DerivDecl pass = DerivDecl
-- See Note [Inferring the instance context] in GHC.Tc.Deriv.Infer.
, deriv_strategy :: Maybe (LDerivStrategy pass)
- , deriv_overlap_mode :: Maybe (XRec pass OverlapMode)
+ , deriv_overlap_mode :: Maybe (XRec pass (OverlapMode pass))
}
| XDerivDecl !(XXDerivDecl pass)
=====================================
compiler/Language/Haskell/Syntax/Decls/Overlap.hs
=====================================
@@ -0,0 +1,123 @@
+{-# LANGUAGE GeneralisedNewtypeDeriving #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE OverlappingInstances #-}
+{-# LANGUAGE UndecidableInstances #-} -- Eq XOverlapMode, NFData OverlapMode
+
+{- |
+Data-type describing the overlap annotations for instances.
+-}
+module Language.Haskell.Syntax.Decls.Overlap where
+
+import Control.DeepSeq
+import Data.Eq
+import Prelude
+
+import Language.Haskell.Syntax.Extension
+
+-- | The status of overlapping instances /(including no overlap)/ for a type.
+data OverlapMode pass -- See Note [Rules for instance lookup] in GHC.Core.InstEnv
+ = NoOverlap (XOverlapMode pass)
+ -- ^ This instance must not overlap another `NoOverlap` instance.
+ -- However, it may be overlapped by `Overlapping` instances,
+ -- and it may overlap `Overlappable` instances.
+
+
+ | Overlappable (XOverlapMode pass)
+ -- ^ Silently ignore this instance if you find a
+ -- more specific one that matches the constraint
+ -- you are trying to resolve
+ --
+ -- Example: constraint (Foo [Int])
+ -- instance Foo [Int]
+ -- instance {-# OVERLAPPABLE #-} Foo [a]
+ --
+ -- Since the second instance has the Overlappable flag,
+ -- the first instance will be chosen (otherwise
+ -- its ambiguous which to choose)
+
+ | Overlapping (XOverlapMode pass)
+ -- ^ Silently ignore any more general instances that may be
+ -- used to solve the constraint.
+ --
+ -- Example: constraint (Foo [Int])
+ -- instance {-# OVERLAPPING #-} Foo [Int]
+ -- instance Foo [a]
+ --
+ -- Since the first instance has the Overlapping flag,
+ -- the second---more general---instance will be ignored (otherwise
+ -- it is ambiguous which to choose)
+
+ | Overlaps (XOverlapMode pass)
+ -- ^ Equivalent to having both `Overlapping` and `Overlappable` flags.
+
+ | Incoherent (XOverlapMode pass)
+ -- ^ Behave like Overlappable and Overlapping, and in addition pick
+ -- an arbitrary one if there are multiple matching candidates, and
+ -- don't worry about later instantiation
+ --
+ -- Example: constraint (Foo [b])
+ -- instance {-# INCOHERENT -} Foo [Int]
+ -- instance Foo [a]
+ -- Without the Incoherent flag, we'd complain that
+ -- instantiating 'b' would change which instance
+ -- was chosen. See also Note [Incoherent instances] in "GHC.Core.InstEnv"
+
+ | NonCanonical (XOverlapMode pass)
+ -- ^ Behave like Incoherent, but the instance choice is observable
+ -- by the program behaviour. See Note [Coherence and specialisation: overview].
+ --
+ -- We don't have surface syntax for the distinction between
+ -- Incoherent and NonCanonical instances; instead, the flag
+ -- `-f{no-}specialise-incoherents` (on by default) controls
+ -- whether `INCOHERENT` instances are regarded as Incoherent or
+ -- NonCanonical.
+
+ | XOverlapMode !(XXOverlapMode pass)
+ -- ^ The /Trees That Grow/ extension point constructor.
+
+deriving instance ( Eq (XOverlapMode pass)
+ , Eq (XXOverlapMode pass)
+ ) => Eq (OverlapMode pass)
+
+instance ( NFData (XOverlapMode pass)
+ , NFData (XXOverlapMode pass)
+ ) => NFData (OverlapMode pass) where
+ rnf = \case
+ NoOverlap s -> rnf s
+ Overlappable s -> rnf s
+ Overlapping s -> rnf s
+ Overlaps s -> rnf s
+ Incoherent s -> rnf s
+ NonCanonical s -> rnf s
+ XOverlapMode s -> rnf s
+
+
+hasIncoherentFlag :: OverlapMode p -> Bool
+hasIncoherentFlag mode =
+ case mode of
+ Incoherent _ -> True
+ NonCanonical _ -> True
+ _ -> False
+
+hasOverlappableFlag :: OverlapMode p -> Bool
+hasOverlappableFlag mode =
+ case mode of
+ Overlappable _ -> True
+ Overlaps _ -> True
+ Incoherent _ -> True
+ NonCanonical _ -> True
+ _ -> False
+
+hasOverlappingFlag :: OverlapMode p -> Bool
+hasOverlappingFlag mode =
+ case mode of
+ Overlapping _ -> True
+ Overlaps _ -> True
+ Incoherent _ -> True
+ NonCanonical _ -> True
+ _ -> False
+
+hasNonCanonicalFlag :: OverlapMode p -> Bool
+hasNonCanonicalFlag = \case
+ NonCanonical{} -> True
+ _ -> False
=====================================
compiler/Language/Haskell/Syntax/Extension.hs
=====================================
@@ -359,6 +359,11 @@ type family XDataFamInstD x
type family XTyFamInstD x
type family XXInstDecl x
+-- -------------------------------------
+-- OverlapMode type families
+type family XOverlapMode x
+type family XXOverlapMode x
+
-- -------------------------------------
-- DerivDecl type families
type family XCDerivDecl x
=====================================
compiler/ghc.cabal.in
=====================================
@@ -546,6 +546,7 @@ Library
GHC.Hs.Basic
GHC.Hs.Binds
GHC.Hs.Decls
+ GHC.Hs.Decls.Overlap
GHC.Hs.Doc
GHC.Hs.DocString
GHC.Hs.Dump
@@ -1024,6 +1025,7 @@ Library
Language.Haskell.Syntax.Binds.InlinePragma
Language.Haskell.Syntax.BooleanFormula
Language.Haskell.Syntax.Decls
+ Language.Haskell.Syntax.Decls.Overlap
Language.Haskell.Syntax.Expr
Language.Haskell.Syntax.Extension
Language.Haskell.Syntax.ImpExp
=====================================
utils/check-exact/ExactPrint.hs
=====================================
@@ -45,8 +45,8 @@ import GHC.Base (NonEmpty(..))
import qualified GHC.Data.BooleanFormula as BF
import GHC.Data.FastString
import qualified GHC.Data.Strict as Strict
+import GHC.Hs.Decls.Overlap (OverlapMode(..))
import GHC.TypeLits
-import GHC.Types.Basic hiding (EP)
import GHC.Types.ForeignCall
import GHC.Types.InlinePragma (ActivationGhc, inlinePragmaActivation, inlinePragmaSource)
import GHC.Types.Name.Reader
@@ -2263,7 +2263,7 @@ instance ExactPrint (TyFamInstDecl GhcPs) where
-- ---------------------------------------------------------------------
-instance ExactPrint (LocatedP OverlapMode) where
+instance Typeable p => ExactPrint (LocatedP (OverlapMode (GhcPass p))) where
getAnnotationEntry = entryFromLocatedA
setAnnotationAnchor = setAnchorAn
=====================================
utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
=====================================
@@ -37,6 +37,7 @@ import GHC hiding (NoLink, HsTypeGhcPsExt (..))
import GHC.Builtin.Types (eqTyCon_RDR, tupleDataConName, tupleTyConName)
import GHC.Core.TyCon (tyConResKind)
import GHC.Driver.DynFlags (getDynFlags)
+import GHC.Hs.Decls.Overlap (OverlapMode(..))
import GHC.Types.Basic (TupleSort (..))
import GHC.Types.Name
import GHC.Types.Name.Reader (RdrName (Exact))
@@ -860,10 +861,19 @@ renameDerivD
{ deriv_ext = noExtField
, deriv_type = ty'
, deriv_strategy = strat'
- , deriv_overlap_mode = omode
+ , deriv_overlap_mode = fmap convertOverlapMode <$> omode
}
)
+convertOverlapMode :: OverlapMode GhcRn -> OverlapMode DocNameI
+convertOverlapMode = \case
+ NoOverlap _ -> NoOverlap NoExtField
+ Overlappable _ -> Overlappable NoExtField
+ Overlapping _ -> Overlapping NoExtField
+ Overlaps _ -> Overlaps NoExtField
+ Incoherent _ -> Incoherent NoExtField
+ NonCanonical _ -> NonCanonical NoExtField
+
renameDerivStrategy :: DerivStrategy GhcRn -> RnM (DerivStrategy DocNameI)
renameDerivStrategy (StockStrategy a) = pure (StockStrategy a)
renameDerivStrategy (AnyclassStrategy a) = pure (AnyclassStrategy a)
@@ -885,7 +895,7 @@ renameClsInstD
return
( ClsInstDecl
{ cid_ext = noExtField
- , cid_overlap_mode = omode
+ , cid_overlap_mode = fmap convertOverlapMode <$> omode
, cid_poly_ty = ltype'
, cid_binds = []
, cid_sigs = []
=====================================
utils/haddock/haddock-api/src/Haddock/Types.hs
=====================================
@@ -56,6 +56,7 @@ import GHC.Data.BooleanFormula (BooleanFormula)
import GHC.Driver.Session (Language)
import qualified GHC.LanguageExtensions as LangExt
import GHC.Core.InstEnv (is_dfun_name)
+import GHC.Hs.Decls.Overlap (OverlapMode)
import GHC.Types.Name (stableNameCmp)
import GHC.Types.Name.Occurrence
import GHC.Types.Name.Reader (RdrName (..))
@@ -829,6 +830,7 @@ type instance Anno (FamilyResultSig DocNameI) = EpAnn NoEpAnns
type instance Anno (HsOuterTyVarBndrs Specificity DocNameI) = SrcSpanAnnA
type instance Anno (HsSigType DocNameI) = SrcSpanAnnA
type instance Anno (BooleanFormula DocNameI) = SrcSpanAnnL
+type instance Anno (OverlapMode DocNameI) = EpAnn AnnPragma
type XRecCond a =
( XParTy a ~ (EpToken "(", EpToken ")")
@@ -960,8 +962,10 @@ type instance XClassDecl DocNameI = NoExtField
type instance XDataDecl DocNameI = NoExtField
type instance XSynDecl DocNameI = NoExtField
type instance XFamDecl DocNameI = NoExtField
+type instance XOverlapMode DocNameI = NoExtField
type instance XXHsDataDefn DocNameI = DataConCantHappen
type instance XXFamilyDecl DocNameI = DataConCantHappen
+type instance XXOverlapMode DocNameI = DataConCantHappen
type instance XXTyClDecl DocNameI = DataConCantHappen
type instance XHsWC DocNameI _ = NoExtField
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76bbbe232482d9808d6c83185f50b16…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76bbbe232482d9808d6c83185f50b16…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/jeltsch/stability-risk-1-and-2-module-deprecation] Amend error output of `T21336`
by Wolfgang Jeltsch (@jeltsch) 30 Jan '26
by Wolfgang Jeltsch (@jeltsch) 30 Jan '26
30 Jan '26
Wolfgang Jeltsch pushed to branch wip/jeltsch/stability-risk-1-and-2-module-deprecation at Glasgow Haskell Compiler / GHC
Commits:
c7493f8e by Wolfgang Jeltsch at 2026-01-29T22:52:27+02:00
Amend error output of `T21336`
- - - - -
2 changed files:
- libraries/base/tests/IO/T21336/T21336b.stderr
- + libraries/base/tests/IO/T21336/T21336c.stderr
Changes:
=====================================
libraries/base/tests/IO/T21336/T21336b.stderr
=====================================
@@ -1 +1,5 @@
+FinalizerExceptionHandler.hs:7:1: warning: [GHC-15328] [-Wdeprecations (in -Wextended-warnings)]
+ Module ‘GHC.Exception’ is deprecated:
+ "GHC.Exception is deprecated and will be removed in GHC 10.02. Please use Control.Exception where possible and the ghc-internal package otherwise."
+
Exception during weak pointer finalization (ignored): <stdout>: hFlush: resource exhausted (No space left on device)
=====================================
libraries/base/tests/IO/T21336/T21336c.stderr
=====================================
@@ -0,0 +1,3 @@
+FinalizerExceptionHandler.hs:7:1: warning: [GHC-15328] [-Wdeprecations (in -Wextended-warnings)]
+ Module ‘GHC.Exception’ is deprecated:
+ "GHC.Exception is deprecated and will be removed in GHC 10.02. Please use Control.Exception where possible and the ghc-internal package otherwise."
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7493f8e63444d07166f66f5a41c050…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7493f8e63444d07166f66f5a41c050…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/26699] 19 commits: ci: remove duplicate keys in .gitlab-ci.yml
by recursion-ninja (@recursion-ninja) 30 Jan '26
by recursion-ninja (@recursion-ninja) 30 Jan '26
30 Jan '26
recursion-ninja pushed to branch wip/26699 at Glasgow Haskell Compiler / GHC
Commits:
414b9593 by Cheng Shao at 2026-01-24T07:11:51-05:00
ci: remove duplicate keys in .gitlab-ci.yml
This patch removes accidentally duplicate keys in `.gitlab-ci.yml`.
The YAML spec doesn't allow duplicate keys in the first place, and
according to GitLab docs
(https://docs.gitlab.com/ci/yaml/yaml_optimization/#anchors) the
latest key overrides the earlier entries.
- - - - -
e5cb5491 by Cheng Shao at 2026-01-24T07:12:34-05:00
hadrian: drop obsolete configure/make builder logic for libffi
This patch drops obsolete hadrian logic around `Configure
libffiPath`/`Make libffiPath` builders, they are no longer needed
after libffi-clib has landed. Closes #26815.
- - - - -
2d160222 by Simon Hengel at 2026-01-24T07:13:17-05:00
Fix typo in roles.rst
- - - - -
56db94f7 by Peter Trommler at 2026-01-26T11:26:18+01:00
PPC NCG: Generate clear right insn at arch width
The clear right immediate (clrrxi) is only available in word and
doubleword width. Generate clrrxi instructions at architecture
width for all MachOp widths.
Fixes #24145
- - - - -
5957a8ad by Wolfgang Jeltsch at 2026-01-27T06:11:40-05:00
Add operations for obtaining operating-system handles
This contribution implements CLC proposal #369. It adds operations for
obtaining POSIX file descriptors and Windows handles that underlie
Haskell handles. Those operating system handles can also be obtained
without such additional operations, but this is more involved and, more
importantly, requires using internals.
- - - - -
86a0510c by Greg Steuck at 2026-01-27T06:12:34-05:00
Move flags to precede patterns for grep and read files directly
This makes the tests pass with non-GNU (i.e. POSIX-complicant) tools.
There's no reason to use cat and pipe where direct file argument works.
- - - - -
50761451 by Cheng Shao at 2026-01-27T21:51:23-05:00
ci: update darwin boot ghc to 9.10.3
This patch updates darwin boot ghc to 9.10.3, along with other related
updates, and pays off some technical debt here:
- Update `nixpkgs` and use the `nixpkgs-25.05-darwin` channel.
- Update the `niv` template.
- Update LLVM to 21 and update `llvm-targets` to reflect LLVM 21
layout changes for arm64/x86_64 darwin targets.
- Use `stdenvNoCC` to prevent nix packaged apple sdk from being used
by boot ghc, and manually set `DEVELOPER_DIR`/`SDKROOT` to enforce
the usage of system-wide command line sdk for macos.
- When building nix derivation for boot ghc, run `configure` via the
`arch` command so that `configure` and its subprocesses pick up the
manually specified architecture.
- Remove the previous horrible hack that obliterates `configure` to
make autoconf test result in true. `configure` now properly does its
job.
- Remove the now obsolete configure args and post install settings
file patching logic.
- Use `scheme-small` for texlive to avoid build failures in certain
unused texlive packages, especially on x86_64-darwin.
- - - - -
94dcd15e by Matthew Pickering at 2026-01-27T21:52:05-05:00
Evaluate backtraces for "error" exceptions at the moment they are thrown
See Note [Capturing the backtrace in throw] and
Note [Hiding precise exception signature in throw] which explain the
implementation.
This commit makes `error` and `throw` behave the same with regard to
backtraces. Previously, exceptions raised by `error` would not contain
useful IPE backtraces.
I did try and implement `error` in terms of `throw` but it started to
involve putting diverging functions into hs-boot files, which seemed to
risky if the compiler wouldn't be able to see if applying a function
would diverge.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/383
Fixes #26751
- - - - -
ef35e3ea by Teo Camarasu at 2026-01-27T21:52:46-05:00
ghc-internal: move all Data instances to Data.Data
Most instances of Data are defined in GHC.Internal.Data.Data.
Let's move all remaining instance there.
This moves other modules down in the dependency hierarchy allowing for
more parallelism, and it decreases the likelihood that we would need to
load this heavy .hi file if we don't actually need it.
Resolves #26830
Metric Decrease:
T12227
T16875
- - - - -
5e0ec555 by sheaf at 2026-01-28T06:56:38-05:00
Add test case for #25679
This commit adds the T25679 test case. The test now passes, thanks to
commit 1e53277af36d3f0b6ad5491f70ffc5593a49dcfd.
Fixes #25679
- - - - -
f1cd1611 by sheaf at 2026-01-28T06:56:38-05:00
Improve defaulting of representational equalities
This commit makes the defaulting of representational equalities, introduced
in 1e53277a, a little bit more robust. Now, instead of calling the eager
unifier, it calls the full-blown constraint solver, which means that it can
handle some subtle situations, e.g. involving functional dependencies and
type-family injectivity annotations, such as:
type family F a = r | r -> a
type instance F Int = Bool
[W] F beta ~R Bool
- - - - -
25edf516 by sheaf at 2026-01-28T06:56:38-05:00
Improve errors for unsolved representational equalities
This commit adds a new field of CtLoc, CtExplanations, which allows the
typechecker to leave some information about what it has done. For the moment,
it is only used to improve error messages for unsolved representational
equalities. The typechecker will now accumulate, when unifying at
representational role:
- out-of-scope newtype constructors,
- type constructors that have nominal role in a certain argument,
- over-saturated type constructors,
- AppTys, e.g. `c a ~R# c b`, to report that we must assume that 'c' has
nominal role in its parameters,
- data family applications that do not reduce, potentially preventing
newtype unwrapping.
Now, instead of having to re-construct the possible errors after the fact,
we simply consult the CtExplanations field.
Additionally, this commit modifies the typechecker error messages that
concern out-of-scope newtype constructors. The error message now depends
on whether we have an import suggestion to provide to the user:
- If we have an import suggestion for the newtype constructor,
the message will be of the form:
The data constructor MkN of the newtype N is out of scope
Suggested fix: add 'MkN' to the import list in the import of 'M'
- If we don't have any import suggestions, the message will be
of the form:
NB: The type 'N' is an opaque newtype, whose constructor is hidden
Fixes #15850, #20289, #20468, #23731, #25949, #26137
- - - - -
4d0e6da1 by Simon Peyton Jones at 2026-01-28T06:57:19-05:00
Fix two bugs in short-cut constraint solving
There are two main changes here:
* Use `isSolvedWC` rather than `isEmptyWC` in `tryShortCutSolver`
The residual constraint may have some fully-solved, but
still-there implications, and we don't want them to abort short
cut solving! That bug caused #26805.
* In the short-cut solver, we abandon the fully-solved residual
constraint; but we may thereby lose track of Givens that are
needed, and either report them as redundant or prune evidence
bindings that are in fact needed.
This bug stopped the `constraints` package from compiling;
see the trail in !15389.
The second bug led me to (another) significant refactoring
of the mechanism for tracking needed EvIds. See the new
Note [Tracking needed EvIds] in GHC.Tc.Solver.Solve
It's simpler and much less head-scratchy now.
Some particulars:
* An EvBindsVar now tracks NeededEvIds
* We deal with NeededEvIds for an implication only when it is
fully solved. Much simpler!
* `tryShortCutTcS` now takes a `TcM WantedConstraints` rather than
`TcM Bool`, so that is can plumb the needed EvIds correctly.
* Remove `ic_need` and `ic_need_implic` from Implication (hooray),
and add `ics_dm` and `ics_non_dm` to `IC_Solved`.
Pure refactor
* Shorten data constructor `CoercionHole` to `CH`, following
general practice in GHC.
* Rename `EvBindMap` to `EvBindsMap` for consistency
- - - - -
662480b7 by Cheng Shao at 2026-01-28T06:58:00-05:00
ci: use debian validate bindists instead of fedora release bindists in testing stage
This patch changes the `abi-test`, `hadrian-multi` and `perf` jobs in
the full-ci pipeline testing stage to use debian validate bindists
instead of fedora release bindists, to increase pipeline level
parallelism and allow full-ci pipelines to complete earlier. Closes #26818.
- - - - -
39581ec6 by Cheng Shao at 2026-01-28T06:58:40-05:00
ci: run perf test with -j$cores
This patch makes the perf ci job compile Cabal with -j$cores to speed
up the job.
- - - - -
607b287b by Wolfgang Jeltsch at 2026-01-28T15:41:53+02:00
Remove `GHC.Desugar` from `base`
`GHC.Desugar` was deprecated and should have been removed in GHC 9.14.
However, the removal was forgotten, although there was a code block that
was intended to trigger a compilation error when the GHC version in use
was 9.14 or later. This code sadly didn’t work, because the
`__GLASGOW_HASKELL__` macro was misspelled as `__GLASGOW_HASKELL`.
- - - - -
e8f5a45d by sterni at 2026-01-29T04:19:18-05:00
users_guide: fix runtime error during build with Sphinx 9.1.0
Appears that pathto is stricter about what it accepts now.
Tested Sphinx 8.2.3 and 9.1.0 on the ghc-9.10 branch.
Resolves #26810.
Co-authored-by: Martin Weinelt <hexa(a)darmstadt.ccc.de>
- - - - -
8957432a by Recursion Ninja at 2026-01-29T14:20:53-05:00
Migrating the simplest types required for Trees That Grow progress
from GHC.Types.Basic to Language.Haskell.Syntax.Basic. Related
function definitions were also moved. Outputable type-class instances
are defined in GHC.Utils.Outputable. Binary instance of Boxity was
moved to GHC.Utils.Binary.
Migrated types:
* TopLevelFlag
* RuleName
* TyConFlavour
* TypeOrData
* NewOrData
- - - - -
c2ddef60 by Recursion Ninja at 2026-01-29T14:51:34-05:00
Add TTG extension point to 'OverlapMode'
Migrate OverlapMode to new module Language.Haskell.Syntax.Overlap
Migrate OverlapFlag to new module GHC.Hs.Decls.Overlap
- - - - -
172 changed files:
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/darwin/nix/sources.json
- .gitlab/darwin/toolchain.nix
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/TyCo/Tidy.hs
- compiler/GHC/Core/TyCon/RecWalk.hs
- compiler/GHC/Data/Maybe.hs
- compiler/GHC/Hs/Decls.hs
- + compiler/GHC/Hs/Decls/Overlap.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Parser.y
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Default.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/CtLoc.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Types/RepType.hs
- compiler/GHC/Types/Var.hs
- compiler/GHC/Unit/Types.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Monad.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/GHC/Utils/Trace.hs
- compiler/Language/Haskell/Syntax/Basic.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- + compiler/Language/Haskell/Syntax/Decls/Overlap.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- docs/users_guide/exts/roles.rst
- docs/users_guide/rtd-theme/layout.html
- hadrian/src/Context.hs
- hadrian/src/Settings/Builders/Configure.hs
- hadrian/src/Settings/Builders/Make.hs
- libraries/base/base.cabal.in
- libraries/base/changelog.md
- − libraries/base/src/GHC/Desugar.hs
- + libraries/base/src/System/IO/OS.hs
- libraries/base/tests/IO/all.T
- + libraries/base/tests/IO/osHandles001FileDescriptors.hs
- + libraries/base/tests/IO/osHandles001FileDescriptors.stdout
- + libraries/base/tests/IO/osHandles001WindowsHandles.hs
- + libraries/base/tests/IO/osHandles001WindowsHandles.stdout
- + libraries/base/tests/IO/osHandles002FileDescriptors.hs
- + libraries/base/tests/IO/osHandles002FileDescriptors.stderr
- + libraries/base/tests/IO/osHandles002FileDescriptors.stdin
- + libraries/base/tests/IO/osHandles002FileDescriptors.stdout
- + libraries/base/tests/IO/osHandles002WindowsHandles.hs
- + libraries/base/tests/IO/osHandles002WindowsHandles.stderr
- + libraries/base/tests/IO/osHandles002WindowsHandles.stdin
- + libraries/base/tests/IO/osHandles002WindowsHandles.stdout
- libraries/base/tests/T23454.stderr
- libraries/base/tests/perf/Makefile
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/Data/Data.hs
- libraries/ghc-internal/src/GHC/Internal/Err.hs
- libraries/ghc-internal/src/GHC/Internal/Exts.hs
- libraries/ghc-internal/src/GHC/Internal/Functor/ZipList.hs
- + libraries/ghc-internal/src/GHC/Internal/System/IO/OS.hs
- libraries/ghc-internal/tests/stack-annotation/all.T
- + libraries/ghc-internal/tests/stack-annotation/ann_frame005.hs
- + libraries/ghc-internal/tests/stack-annotation/ann_frame005.stdout
- llvm-targets
- + testsuite/tests/default/T25825.hs
- testsuite/tests/default/all.T
- testsuite/tests/deriving/should_fail/T1496.stderr
- testsuite/tests/deriving/should_fail/T4846.stderr
- testsuite/tests/deriving/should_fail/T5498.stderr
- testsuite/tests/deriving/should_fail/T6147.stderr
- testsuite/tests/deriving/should_fail/T7148.stderr
- testsuite/tests/deriving/should_fail/T7148a.stderr
- testsuite/tests/deriving/should_fail/T8984.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail4.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail5.stderr
- testsuite/tests/driver/T16318/Makefile
- testsuite/tests/driver/T18125/Makefile
- testsuite/tests/gadt/CasePrune.stderr
- testsuite/tests/ghci.debugger/scripts/T8487.stdout
- testsuite/tests/ghci.debugger/scripts/break011.stdout
- testsuite/tests/ghci.debugger/scripts/break017.stdout
- testsuite/tests/ghci.debugger/scripts/break025.stdout
- testsuite/tests/indexed-types/should_fail/T9580.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/linear/should_fail/LinearRole.stderr
- testsuite/tests/roles/should_fail/RolesIArray.stderr
- + testsuite/tests/simplCore/should_compile/T26805.hs
- + testsuite/tests/simplCore/should_compile/T26805.stderr
- testsuite/tests/simplCore/should_compile/all.T
- + testsuite/tests/typecheck/should_compile/T26805a.hs
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_fail/T10285.stderr
- testsuite/tests/typecheck/should_fail/T10534.stderr
- testsuite/tests/typecheck/should_fail/T10715b.stderr
- testsuite/tests/typecheck/should_fail/T11347.stderr
- testsuite/tests/typecheck/should_fail/T15801.stderr
- + testsuite/tests/typecheck/should_fail/T15850.hs
- + testsuite/tests/typecheck/should_fail/T15850.stderr
- + testsuite/tests/typecheck/should_fail/T15850_Lib.hs
- + testsuite/tests/typecheck/should_fail/T20289.hs
- + testsuite/tests/typecheck/should_fail/T20289.stderr
- + testsuite/tests/typecheck/should_fail/T20289_A.hs
- testsuite/tests/typecheck/should_fail/T22645.stderr
- testsuite/tests/typecheck/should_fail/T22924a.stderr
- + testsuite/tests/typecheck/should_fail/T23731.hs
- + testsuite/tests/typecheck/should_fail/T23731.stderr
- + testsuite/tests/typecheck/should_fail/T23731b.hs
- + testsuite/tests/typecheck/should_fail/T23731b.stderr
- + testsuite/tests/typecheck/should_fail/T23731b_aux.hs
- + testsuite/tests/typecheck/should_fail/T25679.hs
- + testsuite/tests/typecheck/should_fail/T25679.stderr
- + testsuite/tests/typecheck/should_fail/T25949.hs
- + testsuite/tests/typecheck/should_fail/T25949.stderr
- + testsuite/tests/typecheck/should_fail/T25949_aux.hs
- + testsuite/tests/typecheck/should_fail/T26137.hs
- + testsuite/tests/typecheck/should_fail/T26137.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail3.stderr
- testsuite/tests/typecheck/should_fail/all.T
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ebe1815552f2d5edf28b0fd06140c0…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ebe1815552f2d5edf28b0fd06140c0…
You're receiving this email because of your account on gitlab.haskell.org.
1
0