[Git][ghc/ghc][wip/T23162-part2] Wibble unused variables
by Simon Peyton Jones (@simonpj) 19 Dec '25
by Simon Peyton Jones (@simonpj) 19 Dec '25
19 Dec '25
Simon Peyton Jones pushed to branch wip/T23162-part2 at Glasgow Haskell Compiler / GHC
Commits:
435c7237 by Simon Peyton Jones at 2025-12-19T08:16:59+00:00
Wibble unused variables
- - - - -
1 changed file:
- compiler/GHC/Tc/Errors/Ppr.hs
Changes:
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -4202,7 +4202,7 @@ pprTcSolverReportMsg _ (AmbiguityPreventsSolvingCt item ambigs) =
pprArising (errorItemCtLoc item) $$
text "prevents the constraint" <+> quotes (pprParendType $ errorItemPred item)
<+> text "from being solved."
-pprTcSolverReportMsg ctxt@(CEC {cec_encl = implics})
+pprTcSolverReportMsg ctxt
(CannotResolveInstance item unifiers candidates rel_binds mb_HasField_msg)
= pprWithInvisibleBits invis_bits $
vcat
@@ -4370,7 +4370,6 @@ pprTcSolverReportMsg ctxt (OverlappingInstances item matches unifiers) =
])]
where
ct_loc = errorItemCtLoc item
- orig = ctLocOrigin ct_loc
pred = errorItemPred item
(clas, tys) = getClassPredTys pred
tyCoVars = tyCoVarsOfTypesList tys
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/435c72375862a317cf386a52d643f4d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/435c72375862a317cf386a52d643f4d…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
19 Dec '25
Zubin pushed to branch ghc-9.14 at Glasgow Haskell Compiler / GHC
Commits:
ebc6d49b by Zubin Duggal at 2025-12-17T20:07:36+05:30
docs: note #26543 in known bugs
- - - - -
9589591f by Zubin Duggal at 2025-12-18T02:13:34+05:30
rel-notes: updates for final 9.14.1 release
- - - - -
902339d3 by Zubin Duggal at 2025-12-18T11:00:51+05:30
Prepare final 9.14.1 release
- - - - -
4 changed files:
- configure.ac
- docs/users_guide/9.14.1-notes.rst
- docs/users_guide/bugs.rst
- libraries/base/changelog.md
Changes:
=====================================
configure.ac
=====================================
@@ -13,7 +13,7 @@ dnl
# see what flags are available. (Better yet, read the documentation!)
#
-AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.14.0], [glasgow-haskell-bugs(a)haskell.org] [ghc-AC_PACKAGE_VERSION])
+AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.14.1], [glasgow-haskell-bugs(a)haskell.org] [ghc-AC_PACKAGE_VERSION])
# Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable
# to be useful (cf #19058). However, the version must have three components
# (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are
@@ -22,7 +22,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.14.0], [glasgow-ha
AC_CONFIG_MACRO_DIRS([m4])
# Set this to YES for a released version, otherwise NO
-: ${RELEASE=NO}
+: ${RELEASE=YES}
# The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line
# above. If this is not a released version, then we will append the
=====================================
docs/users_guide/9.14.1-notes.rst
=====================================
@@ -110,6 +110,9 @@ Language
- Explicit level import support, allowing ``import`` declarations to explicitly
state which compilation stages they are are visible to.
+- Fix handling of tabs in string gaps (:ghc-ticket:`26415`). Tabs are now
+ correctly treated as whitespace in string gaps, matching the Haskell Report.
+
Compiler
~~~~~~~~
@@ -160,6 +163,23 @@ Compiler
- Initial native code generator support for the LoongArch CPU architecture.
+- Several fixes to :extension:`DeepSubsumption` type checking, improving handling
+ of higher-rank types in various contexts (:ghc-ticket:`26225`, :ghc-ticket:`26255`,
+ :ghc-ticket:`26277`, :ghc-ticket:`26331`, :ghc-ticket:`26332`).
+
+- Fix a scoping error in the Specialiser that could cause incorrect code generation
+ with :ghc-flag:`-fpolymorphic-specialisation` (:ghc-ticket:`26329`).
+
+- Fix a long-standing bug in the coercion optimiser that could produce invalid
+ coercions for ``ForAllCo`` (:ghc-ticket:`26345`).
+
+- Fix the type-family occurs check in unification (:ghc-ticket:`26457`).
+
+- Fix solving of forall-constraints (quantified constraints) to avoid infinite
+ loops in certain cases (:ghc-ticket:`26314`, :ghc-ticket:`26315`, :ghc-ticket:`26376`).
+
+- Fix reporting of redundant constraints on default-method declarations
+ (:ghc-ticket:`25992`).
GHCi
~~~~
@@ -188,6 +208,12 @@ GHCi
debugging clients
* Internal refactorings towards making the debugger multi-thread aware (:ghc-ticket:`26064`)
+- Fix bytecode generation for unsaturated applications of data constructor
+ workers (:ghc-ticket:`23210`).
+
+- Fix bytecode to use 32 bits for breakpoint indices, allowing more breakpoints
+ in large modules (:ghc-ticket:`26325`).
+
WebAssembly backend
~~~~~~~~~~~~~~~~~~~
@@ -201,6 +227,18 @@ See the blog post on `Tweag's blog
<https://www.tweag.io/blog/2025-04-17-wasm-ghci-browser/>`_ for more
information.
+- Fix handling of forward declared ``GOT.func`` items in the wasm dynamic
+ linker (:ghc-ticket:`26430`).
+
+- Fix ``setKeepCAFs()`` to be properly called during wasm GHCi initialization
+ (:ghc-ticket:`26106`).
+
+- Fix JSFFI initialization constructor code to avoid clashing with user-defined
+ main functions.
+
+- Improve error handling in the JavaScript linker when library directories
+ are misconfigured (:ghc-ticket:`26383`).
+
Runtime system
~~~~~~~~~~~~~~
@@ -212,17 +250,44 @@ Runtime system
- Reorganise how certain symbols are linked to avoid a bootstrapping failure
with the linker shipping newer macOS versions (:ghc-ticket:`26166`)
+- Fix eager black holes handling: properly record mutated closures and fix
+ an incorrect assertion that could cause issues with multiple threads racing
+ to claim a black hole (:ghc-ticket:`26495`)
+
+- Fix the Windows runtime linker to copy DLL path strings before inserting
+ them into the cache, preventing use-after-free issues (:ghc-ticket:`26613`)
+
+- Fix lost wakeups in ``threadPaused`` for threads blocked on black holes,
+ which could cause hangs in concurrent programs (:ghc-ticket:`26324`).
+
+- Fix heap reservation logic on POSIX systems to avoid infinite loops when
+ the OS repeatedly returns low memory addresses (:ghc-ticket:`26151`).
+
+- Fix handling of ``WHITEHOLE`` closures in ``scavenge_one`` when using the
+ non-moving garbage collector (:ghc-ticket:`26204`).
+
+- Fix alignment for ``gen_workspace`` on s390x to allow bootstrap on that
+ platform (:ghc-ticket:`26334`).
+
+- Push the correct update frame type in ``stg_AP_STACK`` for eager black holes.
+
``base`` library
~~~~~~~~~~~~~~~~
- Updated to `Unicode 17.0.0 <https://www.unicode.org/versions/Unicode17.0.0>`_.
+- Removed unstable heap representation details from ``GHC.Exts`` (:ghc-ticket:`25110`).
+
``ghc-prim`` library
~~~~~~~~~~~~~~~~~~~~
``ghc-prim`` is now a legacy interface providing access to primitive operations
and types which are now also exposed via the ``ghc-experimental`` package.
+- A new primop ``annotateStack#`` has been added, allowing arbitrary data to be
+ pushed onto the call stack for later extraction when decoding stack traces
+ (:ghc-ticket:`26218`).
+
``ghc`` library
~~~~~~~~~~~~~~~
@@ -263,6 +328,16 @@ and types which are now also exposed via the ``ghc-experimental`` package.
reading of the relevant Closure attributes without reliance on incomplete
selectors.
+* Fix a race condition with profiling builds (:ghc-ticket:`15197`, :ghc-ticket:`26407`).
+
+* Fix stack decoding when using the profiled runtime (:ghc-ticket:`26507`).
+
+``ghc-internal`` library
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+* Fix ``naturalAndNot`` for the ``NB``/``NS`` (native bignum) case
+ (:ghc-ticket:`26230`).
+
``ghc-experimental`` library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=====================================
docs/users_guide/bugs.rst
=====================================
@@ -701,6 +701,9 @@ Bugs in GHC
- Because of a toolchain limitation we are unable to support full Unicode paths
on Windows. On Windows we support up to Latin-1. See :ghc-ticket:`12971` for more.
+- The typechecker might reject certain programs using the ``($)`` operator which
+ are accepted by using explicit parentheses. See :ghc-ticket:`26543` for details.
+
.. _bugs-ghci:
Bugs in GHCi (the interactive GHC)
=====================================
libraries/base/changelog.md
=====================================
@@ -1,6 +1,6 @@
# Changelog for [`base` package](http://hackage.haskell.org/package/base)
-## 4.22.0.0 *TBA*
+## 4.22.0.0 *December 2025*
* Shipped with GHC 9.14.1
* The internal `GHC.Weak.Finalize.runFinalizerBatch` function has been deprecated ([CLC proposal #342](https://github.com/haskell/core-libraries-committee/issues/342))
* Define `displayException` of `SomeAsyncException` to unwrap the exception.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85e8147dd7893db46db1868d65f4cf…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85e8147dd7893db46db1868d65f4cf…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fix-26670] 2 commits: Cleaning up trailing whitespace
by recursion-ninja (@recursion-ninja) 19 Dec '25
by recursion-ninja (@recursion-ninja) 19 Dec '25
19 Dec '25
recursion-ninja pushed to branch wip/fix-26670 at Glasgow Haskell Compiler / GHC
Commits:
2d3d798a by Recursion Ninja at 2025-12-18T20:59:28-05:00
Cleaning up trailing whitespace
- - - - -
67723c02 by Recursion Ninja at 2025-12-18T21:23:24-05:00
Improving code clarity with more decriptive 'InlineArity' constructor names and better comments throughout.
- - - - -
10 changed files:
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Types/Arity.hs
- compiler/GHC/Types/InlinePragma.hs
- compiler/GHC/Utils/Binary.hs
- libraries/exceptions
Changes:
=====================================
compiler/GHC/Core/Opt/Simplify/Iteration.hs
=====================================
@@ -657,30 +657,30 @@ tryCastWorkerWrapper env _ _ bndr rhs -- All other bindings
mkCastWrapperInlinePrag :: InlinePragma GhcRn -> InlinePragma GhcRn
-- See Note [Cast worker/wrapper]
-mkCastWrapperInlinePrag prag =
- -- Consider each field of the 'InlinePragma' constructor
- -- and deterimine what is the appropriate definition for the
- -- corresponding value used within a worker/wrapper.
- --
- -- 1. 'inl_ext': Overwrite
- setInlinePragmaArityAsNotExplicit prag
- `setInlinePragmaSource` src_txt
- --
- -- 2. 'inl_inline': *Preserve*
- -- See Note [Worker/wrapper for INLINABLE functions]
- -- in GHC.Core.Opt.WorkWrap
- -- <SKIP>
- --
- -- 3. 'inl_act': Conditionally Update
- -- See Note [Wrapper activation]
- -- in GHC.Core.Opt.WorkWrap
- `setInlinePragmaActivation` wrap_act
- --
- -- 4. 'inl_rule': *Preserve*
- -- RuleMatchInfo is (and must be) unaffected
- -- <SKIP>
- --
- -- <DONE>
+mkCastWrapperInlinePrag prag = prag
+ -- Consider each field of the 'InlinePragma' constructor
+ -- and deterimine what is the appropriate definition for the
+ -- corresponding value used within a worker/wrapper.
+ --
+ -- 1. 'inl_ext': Overwrite with defaults
+ -- > Changes <SOME>
+ `setInlinePragmaSource` src_txt
+ `setInlinePragmaArity` AnyArity
+ --
+ -- 2. 'inl_inline': *Preserve*
+ -- See Note [Worker/wrapper for INLINABLE functions]
+ -- in GHC.Core.Opt.WorkWrap
+ -- > Changes <NONE>
+ --
+ -- 3. 'inl_act': Conditionally Update
+ -- See Note [Wrapper activation]
+ -- in GHC.Core.Opt.WorkWrap
+ -- > Changes <SOME>
+ `setInlinePragmaActivation` wrap_act
+ --
+ -- 4. 'inl_rule': *Preserve*
+ -- RuleMatchInfo is (and must be) unaffected
+ -- > Changes <NONE>
where
-- See Note [Wrapper activation] in GHC.Core.Opt.WorkWrap
-- But simpler, because we don't need to disable during InitialPhase
=====================================
compiler/GHC/Core/Opt/WorkWrap.hs
=====================================
@@ -834,7 +834,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div
_ -> inl_act wrap_prag
srcTxt = SourceText $ fsLit "{-# INLINE"
- work_prag = InlinePragma { inl_ext = XInlinePragmaGhc srcTxt ArityNotExplicit
+ work_prag = InlinePragma { inl_ext = XInlinePragmaGhc srcTxt AnyArity
, inl_inline = fn_inline_spec
, inl_act = work_act
, inl_rule = FunLike }
@@ -901,7 +901,7 @@ mkStrWrapperInlinePrag :: InlinePragma (GhcPass p) -> [CoreRule] -> InlinePragma
mkStrWrapperInlinePrag (InlinePragma { inl_inline = fn_inl
, inl_act = fn_act
, inl_rule = rule_info }) rules
- = InlinePragma { inl_ext = XInlinePragmaGhc srcTxt ArityNotExplicit
+ = InlinePragma { inl_ext = XInlinePragmaGhc srcTxt AnyArity
, inl_inline = fn_inl
-- See Note [Worker/wrapper for INLINABLE functions]
=====================================
compiler/GHC/HsToCore/Binds.hs
=====================================
@@ -456,7 +456,7 @@ makeCorePair dflags gbl_id is_default_method dict_arity rhs
inline_prag = idInlinePragma gbl_id
inlinable_unf = mkInlinableUnfolding simpl_opts StableUserSrc rhs
inline_pair
- | ArityExplicitly arity <- inlinePragmaArity inline_prag
+ | AppliedToAtLeast arity <- inlinePragmaArity inline_prag
-- Add an Unfolding for an INLINE (but not for NOINLINE)
-- And eta-expand the RHS; see Note [Eta-expanding INLINE things]
, let real_arity = dict_arity + fromEnum arity
=====================================
compiler/GHC/Rename/Bind.hs
=====================================
@@ -1103,7 +1103,7 @@ renameSig ctxt sig@(SpecSig _ v tys inl)
TopSigCtxt {} -> lookupLocatedOccRn WL_TermVariable v
_ -> lookupSigOccRn ctxt sig v
; (new_ty, fvs) <- foldM do_one ([],emptyFVs) tys
- ; return (SpecSig noAnn new_v new_ty (setInlinePragmaArityAsNotExplicit inl), fvs) }
+ ; return (SpecSig noAnn new_v new_ty (inl `setInlinePragmaArity` AnyArity), fvs) }
where
do_one (tys,fvs) ty
= do { (new_ty, fvs_ty) <- rnHsSigType (SpecialiseSigCtx v) TypeLevel ty
@@ -1114,11 +1114,11 @@ renameSig _ctxt (SpecSigE _ bndrs spec_e inl)
; fn_name <- lookupOccRn WL_TermVariable fn_rdr -- Checks that the head isn't forall-bound
; bindRuleBndrs (SpecECtx fn_rdr) bndrs $ \_ bndrs' ->
do { (spec_e', fvs) <- rnLExpr spec_e
- ; return (SpecSigE fn_name bndrs' spec_e' (setInlinePragmaArityAsNotExplicit inl), fvs) } }
+ ; return (SpecSigE fn_name bndrs' spec_e' (inl `setInlinePragmaArity` AnyArity), fvs) } }
renameSig ctxt sig@(InlineSig _ v s)
= do { new_v <- lookupSigOccRn ctxt sig v
- ; return (InlineSig noAnn new_v (setInlinePragmaArityAsNotExplicit s), emptyFVs) }
+ ; return (InlineSig noAnn new_v (s `setInlinePragmaArity` AnyArity), emptyFVs) }
renameSig ctxt (FixSig _ fsig)
= do { new_fsig <- rnSrcFixityDecl ctxt fsig
=====================================
compiler/GHC/Tc/Gen/Sig.hs
=====================================
@@ -604,7 +604,7 @@ addInlinePragArity _ sig = sig
add_inl_arity :: Arity -> InlinePragma GhcRn -> InlinePragma GhcRn
add_inl_arity ar prag@(InlinePragma { inl_inline = inl_spec })
| Inline {} <- inl_spec -- Add arity only for real INLINE pragmas, not INLINABLE
- = prag `setInlinePragmaArityAsExplicitly` ar
+ = prag `setInlinePragmaArity` AppliedToAtLeast ar
| otherwise
= prag
=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -2265,7 +2265,7 @@ mkDefMethBind loc dfun_id clas sel_id dm_name dm_spec
= do { logger <- getLogger
; dm_id <- tcLookupId dm_name
; let inline_prag :: InlinePragma GhcRn
- inline_prag = idInlinePragma dm_id
+ inline_prag = idInlinePragma dm_id
inline_prags | isAnyInlinePragma inline_prag
= [noLocA (InlineSig noAnn fn inline_prag)]
| otherwise
=====================================
compiler/GHC/Types/Arity.hs
=====================================
@@ -41,21 +41,21 @@ type FullArgCount = Int
-- | The arity /at which to/ inline a function.
-- This may differ from the function's syntactic arity.
data InlineArity
- = ArityExplicitly !Word
+ = AppliedToAtLeast !Arity
-- ^ Inline only when applied to @n@ explicit
-- (non-type, non-dictionary) arguments.
- --
- -- That is, 'ArityExplicitly' describes the number of
+ --
+ -- That is, 'AppliedToAtLeast' describes the number of
-- *source-code* arguments the thing must be applied to.
- | ArityNotExplicit
+ | AnyArity
-- ^ There does not exist an explicit number of arguments
-- that the inlining process should be applied to.
deriving (Eq, Data)
instance NFData InlineArity where
- rnf (ArityExplicitly !w) = rnf w `seq` ()
- rnf !ArityNotExplicit = ()
+ rnf (AppliedToAtLeast !w) = rnf w `seq` ()
+ rnf !AnyArity = ()
-- | Representation Arity
--
=====================================
compiler/GHC/Types/InlinePragma.hs
=====================================
@@ -35,8 +35,7 @@ module GHC.Types.InlinePragma
, isOpaquePragma
-- *** Mutators
, setInlinePragmaSource
- , setInlinePragmaArityAsExplicitly
- , setInlinePragmaArityAsNotExplicit
+ , setInlinePragmaArity
, setInlinePragmaActivation
, setInlinePragmaSpec
, setInlinePragmaRuleMatchInfo
@@ -111,7 +110,7 @@ import Language.Haskell.Syntax.Extension
-- infixl so you can say (prag `set` a `set` b)
infixl 1 `setInlinePragmaActivation`,
- `setInlinePragmaArityAsExplicitly`,
+ `setInlinePragmaArity`,
`setInlinePragmaRuleMatchInfo`,
`setInlinePragmaSource`,
`setInlinePragmaSpec`
@@ -149,8 +148,8 @@ defaultInlinePragma =
let srcTxt = SourceText $ fsLit "{-# INLINE"
inlExt = case ghcPass @p of
GhcPs -> srcTxt
- GhcRn -> XInlinePragmaGhc srcTxt ArityNotExplicit
- GhcTc -> XInlinePragmaGhc srcTxt ArityNotExplicit
+ GhcRn -> XInlinePragmaGhc srcTxt AnyArity
+ GhcTc -> XInlinePragmaGhc srcTxt AnyArity
in InlinePragma
{ inl_ext = inlExt
, inl_act = AlwaysActive
@@ -185,16 +184,6 @@ setInlinePragmaArity :: forall p q. (IsPass p, XInlinePragma (GhcPass q) ~ XInli
setInlinePragmaArity prag arity =
prag { inl_ext = XInlinePragmaGhc (inlinePragmaSource prag) arity }
-setInlinePragmaArityAsExplicitly :: forall a p q. (Integral a, IsPass p, XInlinePragma (GhcPass q) ~ XInlinePragmaGhc)
- => InlinePragma (GhcPass p) -> a -> InlinePragma (GhcPass q)
-setInlinePragmaArityAsExplicitly prag intVal = prag `setInlinePragmaArity` arity
- where
- arity = ArityExplicitly . fromIntegral $ abs intVal
-
-setInlinePragmaArityAsNotExplicit :: forall p q. (IsPass p, XInlinePragma (GhcPass q) ~ XInlinePragmaGhc)
- => InlinePragma (GhcPass p) -> InlinePragma (GhcPass q)
-setInlinePragmaArityAsNotExplicit = flip setInlinePragmaArity ArityNotExplicit
-
inlinePragmaSource :: forall p. IsPass p => InlinePragma (GhcPass p) -> SourceText
inlinePragmaSource (InlinePragma { inl_ext = src }) = srcTxt
where
=====================================
compiler/GHC/Utils/Binary.hs
=====================================
@@ -2108,10 +2108,10 @@ instance Binary RuleMatchInfo where
else pure FunLike
instance Binary InlineArity where
- put_ bh ArityNotExplicit = putByte bh 0
- put_ bh (ArityExplicitly w) = putByte bh 1 *> put_ bh w
+ put_ bh AnyArity = putByte bh 0
+ put_ bh (AppliedToAtLeast w) = putByte bh 1 *> put_ bh w
get bh = do
h <- getByte bh
- if h == 0 then pure ArityNotExplicit
- else ArityExplicitly <$> get bh
+ if h == 0 then pure AnyArity
+ else AppliedToAtLeast <$> get bh
=====================================
libraries/exceptions
=====================================
@@ -1 +1 @@
-Subproject commit 81bfd6e0ca631f315658201ae02e30046678f056
+Subproject commit b6c4290124eb1138358bf04ad9f33e67f6c5c1d8
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7d47d203034f014791a2aa2cfb8fd…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7d47d203034f014791a2aa2cfb8fd…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fix-26670] Reverting semantic changes where Arity was erroneously set to 0
by recursion-ninja (@recursion-ninja) 18 Dec '25
by recursion-ninja (@recursion-ninja) 18 Dec '25
18 Dec '25
recursion-ninja pushed to branch wip/fix-26670 at Glasgow Haskell Compiler / GHC
Commits:
f7d47d20 by Recursion Ninja at 2025-12-18T18:52:11-05:00
Reverting semantic changes where Arity was erroneously set to 0
- - - - -
17 changed files:
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Instance/Typeable.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Types/Arity.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/InlinePragma.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Outputable.hs
Changes:
=====================================
compiler/GHC/Core/Opt/Simplify/Iteration.hs
=====================================
@@ -655,27 +655,39 @@ tryCastWorkerWrapper env _ _ bndr rhs -- All other bindings
, text "rhs:" <+> ppr rhs ])
; return (mkFloatBind env (NonRec bndr rhs)) }
-mkCastWrapperInlinePrag :: forall p. IsPass p => InlinePragma (GhcPass p) -> InlinePragma (GhcPass p)
+mkCastWrapperInlinePrag :: InlinePragma GhcRn -> InlinePragma GhcRn
-- See Note [Cast worker/wrapper]
-mkCastWrapperInlinePrag (InlinePragma { inl_ext = inTag, inl_inline = fn_inl, inl_act = fn_act, inl_rule = rule_info })
- = InlinePragma { inl_ext = outTag
- , inl_inline = fn_inl -- See Note [Worker/wrapper for INLINABLE functions]
- , inl_act = wrap_act -- See Note [Wrapper activation]
- , inl_rule = rule_info } -- in GHC.Core.Opt.WorkWrap
- -- RuleMatchInfo is (and must be) unaffected
+mkCastWrapperInlinePrag prag =
+ -- Consider each field of the 'InlinePragma' constructor
+ -- and deterimine what is the appropriate definition for the
+ -- corresponding value used within a worker/wrapper.
+ --
+ -- 1. 'inl_ext': Overwrite
+ setInlinePragmaArityAsNotExplicit prag
+ `setInlinePragmaSource` src_txt
+ --
+ -- 2. 'inl_inline': *Preserve*
+ -- See Note [Worker/wrapper for INLINABLE functions]
+ -- in GHC.Core.Opt.WorkWrap
+ -- <SKIP>
+ --
+ -- 3. 'inl_act': Conditionally Update
+ -- See Note [Wrapper activation]
+ -- in GHC.Core.Opt.WorkWrap
+ `setInlinePragmaActivation` wrap_act
+ --
+ -- 4. 'inl_rule': *Preserve*
+ -- RuleMatchInfo is (and must be) unaffected
+ -- <SKIP>
+ --
+ -- <DONE>
where
-- See Note [Wrapper activation] in GHC.Core.Opt.WorkWrap
-- But simpler, because we don't need to disable during InitialPhase
wrap_act | isNeverActive fn_act = activateDuringFinal
| otherwise = fn_act
-
- srcTxt = SourceText $ fsLit "{-# INLINE"
-
- outTag = case ghcPass @p of
- GhcPs -> inTag
- GhcRn -> inTag { inl_ghcrn_src = srcTxt }
- GhcTc -> inTag { inl_ghcrn_src = srcTxt }
-
+ fn_act = inlinePragmaActivation prag
+ src_txt = SourceText $ fsLit "{-# INLINE"
{- *********************************************************************
* *
=====================================
compiler/GHC/Core/Opt/Specialise.hs
=====================================
@@ -44,7 +44,7 @@ import GHC.Data.Bag
import GHC.Data.OrdList
import GHC.Data.List.SetOps
-import GHC.Hs.Extension ( GhcTc )
+import GHC.Hs.Extension ( GhcRn )
import GHC.Types.Basic
import GHC.Types.Unique.Supply
@@ -1639,6 +1639,16 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs
(rhs_bndrs, rhs_body) = collectBindersPushingCo rhs
-- See Note [Account for casts in binding]
+ -- Copy InlinePragma information from the parent Id.
+ -- So if f has INLINE[1] so does spec_fn
+ spec_inl_prag :: InlinePragma GhcRn
+ spec_inl_prag
+ | not is_local -- See Note [Specialising imported functions]
+ , isStrongLoopBreaker (idOccInfo fn) -- in GHC.Core.Opt.OccurAnal
+ = neverInlinePragma
+ | otherwise
+ = inl_prag
+
not_in_scope :: InterestingVarFun
not_in_scope v = isLocalVar v && not (v `elemInScopeSet` in_scope)
@@ -1754,20 +1764,9 @@ specCalls spec_imp env existing_rules calls_for_me fn rhs
-- See Note [Arity decrease] in GHC.Core.Opt.Simplify
join_arity_decr = length rule_lhs_args - length rule_rhs_args1
arity_decr = count isValArg rule_lhs_args - count isId rule_rhs_args1
- arity = max 0 (fn_arity - arity_decr)
-
- -- Copy InlinePragma information from the parent Id.
- -- So if f has INLINE[1] so does spec_fn
- spec_inl_prag :: InlinePragma GhcTc
- spec_inl_prag
- | not is_local -- See Note [Specialising imported functions]
- , isStrongLoopBreaker (idOccInfo fn) -- in GHC.Core.Opt.OccurAnal
- = neverInlinePragma `setInlinePragmaArity` arity
- | otherwise
- = inl_prag `setInlinePragmaArity` arity
spec_fn_info
- = vanillaIdInfo `setArityInfo` arity
+ = vanillaIdInfo `setArityInfo` max 0 (fn_arity - arity_decr)
`setInlinePragInfo` spec_inl_prag
`setUnfoldingInfo` spec_unf
=====================================
compiler/GHC/Core/Opt/WorkWrap.hs
=====================================
@@ -22,7 +22,7 @@ import GHC.Core.SimpleOpt
import GHC.Data.FastString
-import GHC.Hs.Extension (GhcPass, GhcTc)
+import GHC.Hs.Extension (GhcPass, GhcRn)
import GHC.Types.Var
import GHC.Types.Id
@@ -834,7 +834,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div
_ -> inl_act wrap_prag
srcTxt = SourceText $ fsLit "{-# INLINE"
- work_prag = InlinePragma { inl_ext = InlinePragmaGhcTag srcTxt arity
+ work_prag = InlinePragma { inl_ext = XInlinePragmaGhc srcTxt ArityNotExplicit
, inl_inline = fn_inline_spec
, inl_act = work_act
, inl_rule = FunLike }
@@ -883,7 +883,7 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div
| otherwise = topDmd
wrap_rhs = wrap_fn work_id
- wrap_prag = mkStrWrapperInlinePrag fn_inl_prag fn_rules arity
+ wrap_prag = mkStrWrapperInlinePrag fn_inl_prag fn_rules
wrap_unf = mkWrapperUnfolding simpl_opts wrap_rhs arity
wrap_id = fn_id `setIdUnfolding` wrap_unf
@@ -897,11 +897,11 @@ mkWWBindPair ww_opts fn_id fn_info fn_args fn_body work_uniq div
fn_unfolding = realUnfoldingInfo fn_info
fn_rules = ruleInfoRules (ruleInfo fn_info)
-mkStrWrapperInlinePrag :: InlinePragma (GhcPass p) -> [CoreRule] -> Arity -> InlinePragma GhcTc
+mkStrWrapperInlinePrag :: InlinePragma (GhcPass p) -> [CoreRule] -> InlinePragma GhcRn
mkStrWrapperInlinePrag (InlinePragma { inl_inline = fn_inl
, inl_act = fn_act
- , inl_rule = rule_info }) rules arity
- = InlinePragma { inl_ext = InlinePragmaGhcTag srcTxt arity
+ , inl_rule = rule_info }) rules
+ = InlinePragma { inl_ext = XInlinePragmaGhc srcTxt ArityNotExplicit
, inl_inline = fn_inl
-- See Note [Worker/wrapper for INLINABLE functions]
=====================================
compiler/GHC/CoreToIface.hs
=====================================
@@ -503,8 +503,7 @@ toIfaceIdInfo id_info
------------ Inline prag --------------
inline_prag = inlinePragInfo id_info
inline_hsinfo | isDefaultInlinePragma inline_prag = Nothing
- | otherwise = Just . HsInline $
- inline_prag `setInlinePragmaArity` arity_info
+ | otherwise = Just (HsInline inline_prag)
--------------------------
toIfUnfolding :: Bool -> Unfolding -> Maybe IfaceInfoItem
=====================================
compiler/GHC/HsToCore/Binds.hs
=====================================
@@ -324,8 +324,7 @@ dsAbsBinds dflags tyvars dicts exports
-- No SpecPrags (no dicts)
-- Can't be a default method (default methods are singletons)
= do { dsHsWrapper wrap $ \core_wrap -> do
- { return ( gbl_id `setInlinePragma`
- (defaultInlinePragma `setInlinePragmaArity` 0)
+ { return ( gbl_id `setInlinePragma` defaultInlinePragma
, core_wrap (Var lcl_id)) } }
; main_prs <- mapM mk_main exports
; let bind_prs' = map mk_aux_bind bind_prs
@@ -370,8 +369,7 @@ dsAbsBinds dflags tyvars dicts exports
mkVarApps (Var poly_tup_id) (tyvars ++ dicts)
rhs_for_spec = Let (NonRec poly_tup_id poly_tup_rhs) rhs
; (spec_binds, rules) <- dsSpecs rhs_for_spec spec_prags
- ; let global' = (global `setInlinePragma`
- (defaultInlinePragma `setInlinePragmaArity` dictArity dicts))
+ ; let global' = (global `setInlinePragma` defaultInlinePragma)
`addIdSpecialisations` rules
-- Kill the INLINE pragma because it applies to
-- the user written (local) function. The global
@@ -447,7 +445,7 @@ makeCorePair dflags gbl_id is_default_method dict_arity rhs
= (gbl_id `setIdUnfolding` mkCompulsoryUnfolding' simpl_opts rhs, rhs)
| otherwise
- = case inl_spec of
+ = case inlinePragmaSpec inline_prag of
NoUserInlinePrag -> (gbl_id, rhs)
NoInline {} -> (gbl_id, rhs)
Opaque {} -> (gbl_id, rhs)
@@ -455,16 +453,21 @@ makeCorePair dflags gbl_id is_default_method dict_arity rhs
Inline {} -> inline_pair
where
simpl_opts = initSimpleOpts dflags
- InlinePragma (InlinePragmaGhcTag _ arity) inl_spec _ _ = idInlinePragma gbl_id
+ inline_prag = idInlinePragma gbl_id
inlinable_unf = mkInlinableUnfolding simpl_opts StableUserSrc rhs
- inline_pair =
- -- Add an Unfolding for an INLINE (but not for NOINLINE)
- -- And eta-expand the RHS; see Note [Eta-expanding INLINE things]
- let real_arity = dict_arity + arity
- -- NB: The arity passed to mkInlineUnfoldingWithArity
- -- must take account of the dictionaries
- in ( gbl_id `setIdUnfolding` mkInlineUnfoldingWithArity simpl_opts StableUserSrc real_arity rhs
- , etaExpand real_arity rhs)
+ inline_pair
+ | ArityExplicitly arity <- inlinePragmaArity inline_prag
+ -- Add an Unfolding for an INLINE (but not for NOINLINE)
+ -- And eta-expand the RHS; see Note [Eta-expanding INLINE things]
+ , let real_arity = dict_arity + fromEnum arity
+ -- NB: The arity passed to mkInlineUnfoldingWithArity
+ -- must take account of the dictionaries
+ = ( gbl_id `setIdUnfolding` mkInlineUnfoldingWithArity simpl_opts StableUserSrc real_arity rhs
+ , etaExpand real_arity rhs)
+
+ | otherwise
+ = pprTrace "makeCorePair: arity missing" (ppr gbl_id) $
+ (gbl_id `setIdUnfolding` mkInlineUnfoldingNoArity simpl_opts StableUserSrc rhs, rhs)
dictArity :: [Var] -> Arity
-- Don't count coercion variables in arity
@@ -1017,7 +1020,7 @@ dsSpec_help poly_nm poly_id poly_rhs spec_inl orig_bndrs ds_call
fn_unf = realIdUnfolding poly_id
spec_unf = specUnfolding simpl_opts spec_bndrs mk_spec_body rule_lhs_args fn_unf
spec_info = vanillaIdInfo
- `setInlinePragInfo` specFunInlinePrag poly_id id_inl spec_inl
+ `setInlinePragInfo` specFunInlinePrag poly_id id_inl (demoteInlinePragmaTc spec_inl)
`setUnfoldingInfo` spec_unf
spec_id = mkLocalVar (idDetails poly_id) spec_name ManyTy spec_ty spec_info
-- Specialised binding is toplevel, hence Many.
@@ -1057,7 +1060,7 @@ dsSpec_help poly_nm poly_id poly_rhs spec_inl orig_bndrs ds_call
; dsWarnOrphanRule rule
; case checkUselessSpecPrag poly_id rule_lhs_args spec_bndrs
- no_act_spec (unsetInlinePragmaArity spec_inl) rule_act of
+ no_act_spec spec_inl rule_act of
Nothing -> return (Just result)
Just reason -> do { diagnosticDs $ DsUselessSpecialisePragma poly_nm is_dfun reason
@@ -1111,7 +1114,7 @@ decomposeCall poly_id ds_call
-- Is this SPECIALISE pragma useless?
checkUselessSpecPrag :: Id -> [CoreExpr]
- -> [Var] -> Bool -> InlinePragma GhcPs -> Activation
+ -> [Var] -> Bool -> InlinePragma (GhcPass p) -> Activation
-> Maybe UselessSpecialisePragmaReason
checkUselessSpecPrag poly_id rule_lhs_args
spec_bndrs no_act_spec spec_inl rule_act
@@ -1187,19 +1190,17 @@ getCastedVar (Var v) = Just (v, MRefl)
getCastedVar (Cast (Var v) co) = Just (v, MCo co)
getCastedVar _ = Nothing
-specFunInlinePrag :: Id -> InlinePragma GhcTc
- -> InlinePragma GhcTc -> InlinePragma GhcTc
+--specFunInlinePrag :: forall p. IsPass p => Id -> InlinePragma (GhcPass p) -> InlinePragma (GhcPass p) -> InlinePragma (GhcPass p)
+specFunInlinePrag :: Id -> InlinePragma GhcRn -> InlinePragma GhcRn -> InlinePragma GhcRn
-- See Note [Activation pragmas for SPECIALISE]
specFunInlinePrag poly_id id_inl spec_inl
| not (isDefaultInlinePragma spec_inl) = spec_inl
| isGlobalId poly_id -- See Note [Specialising imported functions]
-- in OccurAnal
- , isStrongLoopBreaker (idOccInfo poly_id) = neverInlinePragma `setInlinePragmaArity` arity
+ , isStrongLoopBreaker (idOccInfo poly_id) = neverInlinePragma
| otherwise = id_inl
-- Get the INLINE pragma from SPECIALISE declaration, or,
-- failing that, from the original Id
- where
- arity = arityInfo $ idInfo poly_id
dsWarnOrphanRule :: CoreRule -> DsM ()
dsWarnOrphanRule rule
=====================================
compiler/GHC/Rename/Bind.hs
=====================================
@@ -1103,7 +1103,7 @@ renameSig ctxt sig@(SpecSig _ v tys inl)
TopSigCtxt {} -> lookupLocatedOccRn WL_TermVariable v
_ -> lookupSigOccRn ctxt sig v
; (new_ty, fvs) <- foldM do_one ([],emptyFVs) tys
- ; return (SpecSig noAnn new_v new_ty (inl `setInlinePragmaArity` 0), fvs) } -- TODO: setting arity to 0 is likely wrong
+ ; return (SpecSig noAnn new_v new_ty (setInlinePragmaArityAsNotExplicit inl), fvs) }
where
do_one (tys,fvs) ty
= do { (new_ty, fvs_ty) <- rnHsSigType (SpecialiseSigCtx v) TypeLevel ty
@@ -1114,11 +1114,11 @@ renameSig _ctxt (SpecSigE _ bndrs spec_e inl)
; fn_name <- lookupOccRn WL_TermVariable fn_rdr -- Checks that the head isn't forall-bound
; bindRuleBndrs (SpecECtx fn_rdr) bndrs $ \_ bndrs' ->
do { (spec_e', fvs) <- rnLExpr spec_e
- ; return (SpecSigE fn_name bndrs' spec_e' ( inl `setInlinePragmaArity` 0), fvs) } } -- TODO: setting arity to 0 is likely wrong
+ ; return (SpecSigE fn_name bndrs' spec_e' (setInlinePragmaArityAsNotExplicit inl), fvs) } }
renameSig ctxt sig@(InlineSig _ v s)
= do { new_v <- lookupSigOccRn ctxt sig v
- ; return (InlineSig noAnn new_v ( s `setInlinePragmaArity` 0 ), emptyFVs) } -- TODO: setting arity to 0 is likely wrong
+ ; return (InlineSig noAnn new_v (setInlinePragmaArityAsNotExplicit s), emptyFVs) }
renameSig ctxt (FixSig _ fsig)
= do { new_fsig <- rnSrcFixityDecl ctxt fsig
=====================================
compiler/GHC/Tc/Gen/Sig.hs
=====================================
@@ -604,7 +604,7 @@ addInlinePragArity _ sig = sig
add_inl_arity :: Arity -> InlinePragma GhcRn -> InlinePragma GhcRn
add_inl_arity ar prag@(InlinePragma { inl_inline = inl_spec })
| Inline {} <- inl_spec -- Add arity only for real INLINE pragmas, not INLINABLE
- = prag `setInlinePragmaArity` ar
+ = prag `setInlinePragmaArityAsExplicitly` ar
| otherwise
= prag
@@ -620,7 +620,7 @@ addInlinePrags poly_id prags_for_me
| inl@(L _ prag) : inls <- inl_prags
= do { traceTc "addInlinePrag" (ppr poly_id $$ ppr prag)
; unless (null inls) (warn_multiple_inlines inl inls)
- ; return (poly_id `setInlinePragma` prag) }
+ ; return (poly_id `setInlinePragma` demoteInlinePragmaTc prag) }
| otherwise
= return poly_id
where
=====================================
compiler/GHC/Tc/Instance/Typeable.hs
=====================================
@@ -13,7 +13,7 @@ import GHC.Prelude
import GHC.Platform
import GHC.Types.Basic ( TypeOrConstraint(..) )
-import GHC.Types.InlinePragma ( neverInlinePragma, setInlinePragmaArity )
+import GHC.Types.InlinePragma ( neverInlinePragma )
import GHC.Types.SourceText ( SourceText(..) )
import GHC.Iface.Env( newGlobalBinder )
import GHC.Core.TyCo.Rep( Type(..), TyLit(..) )
@@ -554,8 +554,7 @@ getKindRep stuff@(Stuff {..}) in_scope = go
| otherwise
= do -- Place a NOINLINE pragma on KindReps since they tend to be quite
-- large and bloat interface files.
- let prag = neverInlinePragma `setInlinePragmaArity` 0
- rep_bndr <- (`setInlinePragma` prag)
+ rep_bndr <- (`setInlinePragma` neverInlinePragma)
<$> newSysLocalId (fsLit "$krep") ManyTy (mkTyConTy kindRepTyCon)
-- do we need to tie a knot here?
=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -70,7 +70,6 @@ import GHC.Types.Var.Env
import GHC.Types.Var.Set
import GHC.Types.Basic
import GHC.Types.Id
-import GHC.Types.Id.Info (arityInfo)
import GHC.Types.InlinePragma
import GHC.Types.SourceFile
import GHC.Types.SourceText
@@ -1429,10 +1428,9 @@ addDFunPrags :: DFunId -> [Id] -> DFunId
-- is messing with.
addDFunPrags dfun_id sc_meth_ids
= dfun_id `setIdUnfolding` mkDFunUnfolding dfun_bndrs dict_con dict_args
- `setInlinePragma` (dfunInlinePragma `setInlinePragmaArity` arity) -- NOTE: Check if this arity calculation is correct
+ `setInlinePragma` dfunInlinePragma
-- NB: mkDFunUnfolding takes care of unary classes
where
- arity = length var_apps
dict_args = map Type inst_tys ++ var_apps
var_apps = [mkVarApps (Var id) dfun_bndrs | id <- sc_meth_ids]
@@ -2267,7 +2265,7 @@ mkDefMethBind loc dfun_id clas sel_id dm_name dm_spec
= do { logger <- getLogger
; dm_id <- tcLookupId dm_name
; let inline_prag :: InlinePragma GhcRn
- inline_prag = demoteInlinePragmaRn $ idInlinePragma dm_id
+ inline_prag = idInlinePragma dm_id
inline_prags | isAnyInlinePragma inline_prag
= [noLocA (InlineSig noAnn fn inline_prag)]
| otherwise
@@ -2669,11 +2667,9 @@ tcSpecInstPrags dfun_id (InstBindings { ib_binds = binds, ib_pragmas = uprags })
tcSpecInst :: Id -> Sig GhcRn -> TcM TcSpecPrag
tcSpecInst dfun_id prag@(SpecInstSig _ hs_ty)
= addErrCtxt (SpecPragmaCtxt prag) $
- let arity = arityInfo $ idInfo dfun_id
- prag = defaultInlinePragma `setInlinePragmaArity` arity
- in do { spec_dfun_ty <- tcHsClsInstType SpecInstCtxt hs_ty
- ; co_fn <- tcSpecWrapper SpecInstCtxt (idType dfun_id) spec_dfun_ty
- ; return (SpecPrag dfun_id co_fn prag) }
+ do { spec_dfun_ty <- tcHsClsInstType SpecInstCtxt hs_ty
+ ; co_fn <- tcSpecWrapper SpecInstCtxt (idType dfun_id) spec_dfun_ty
+ ; return (SpecPrag dfun_id co_fn defaultInlinePragma) }
tcSpecInst _ _ = panic "tcSpecInst"
=====================================
compiler/GHC/Types/Arity.hs
=====================================
@@ -6,14 +6,18 @@
module GHC.Types.Arity
( Arity
- , VisArity
- , RepArity
- , JoinArity
, FullArgCount
+ , InlineArity(..)
+ , JoinArity
+ , RepArity
+ , VisArity
) where
import GHC.Prelude
+import Control.DeepSeq (NFData(..))
+import Data.Data (Data)
+
{-
************************************************************************
* *
@@ -29,9 +33,29 @@ import GHC.Prelude
-- See also Note [Definition of arity] in "GHC.Core.Opt.Arity"
type Arity = Int
--- | Syntactic (visibility) arity, i.e. the number of visible arguments.
--- See Note [Visibility and arity]
-type VisArity = Int
+-- | FullArgCount is the number of type or value arguments in an application,
+-- or the number of type or value binders in a lambda. Note: it includes
+-- both type and value arguments!
+type FullArgCount = Int
+
+-- | The arity /at which to/ inline a function.
+-- This may differ from the function's syntactic arity.
+data InlineArity
+ = ArityExplicitly !Word
+ -- ^ Inline only when applied to @n@ explicit
+ -- (non-type, non-dictionary) arguments.
+ --
+ -- That is, 'ArityExplicitly' describes the number of
+ -- *source-code* arguments the thing must be applied to.
+ | ArityNotExplicit
+ -- ^ There does not exist an explicit number of arguments
+ -- that the inlining process should be applied to.
+ deriving (Eq, Data)
+
+instance NFData InlineArity where
+
+ rnf (ArityExplicitly !w) = rnf w `seq` ()
+ rnf !ArityNotExplicit = ()
-- | Representation Arity
--
@@ -48,10 +72,9 @@ type RepArity = Int
-- are counted.
type JoinArity = Int
--- | FullArgCount is the number of type or value arguments in an application,
--- or the number of type or value binders in a lambda. Note: it includes
--- both type and value arguments!
-type FullArgCount = Int
+-- | Syntactic (visibility) arity, i.e. the number of visible arguments.
+-- See Note [Visibility and arity]
+type VisArity = Int
{- Note [Visibility and arity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=====================================
compiler/GHC/Types/Basic.hs
=====================================
@@ -1304,18 +1304,18 @@ failed Succeeded = False
failed Failed = True
{-
-data InlinePragmaGhcTag = InlinePragmaGhcTag
+data XInlinePragmaGhc = XInlinePragmaGhc
{ inl_ghcrn_src :: {-# UNPACK#-} !SourceText
, inl_ghcrn_arity :: {-# UNPACK#-} !Arity
}
deriving (Eq, Data)
-instance NFData InlinePragmaGhcTag where
- rnf (InlinePragmaGhcTag s a) = rnf s `seq` rnf a `seq` ()
+instance NFData XInlinePragmaGhc where
+ rnf (XInlinePragmaGhc s a) = rnf s `seq` rnf a `seq` ()
type instance XInlinePragma GhcPs = SourceText
-type instance XInlinePragma GhcRn = InlinePragmaGhcTag
-type instance XInlinePragma GhcTc = InlinePragmaGhcTag
+type instance XInlinePragma GhcRn = XInlinePragmaGhc
+type instance XInlinePragma GhcTc = XInlinePragmaGhc
type instance XXInlinePragma (GhcPass _) = DataConCantHappen
defaultInlinePragma, alwaysInlinePragma, neverInlinePragma, dfunInlinePragma
@@ -1339,7 +1339,7 @@ dfunInlinePragma = defaultInlinePragma { inl_act = AlwaysActive
setInlinePragmaArity :: InlinePragma GhcPs -> Arity -> InlinePragma GhcTc
setInlinePragmaArity prag@(InlinePragma { inl_ext = srcTxt }) arity =
- prag { inl_ext = InlinePragmaGhcTag srcTxt arity }
+ prag { inl_ext = XInlinePragmaGhc srcTxt arity }
inlinePragmaSource :: forall p. IsPass p => InlinePragma (GhcPass p) -> SourceText
=====================================
compiler/GHC/Types/Id.hs
=====================================
@@ -150,7 +150,7 @@ import GHC.Core.DataCon
import GHC.Core.Class
import GHC.Core.Multiplicity
-import GHC.Hs.Extension (GhcTc)
+import GHC.Hs.Extension (GhcRn)
import GHC.Types.RepType
import GHC.Types.Demand
@@ -944,13 +944,13 @@ The inline pragma tells us to be very keen to inline this Id, but it's still
OK not to if optimisation is switched off.
-}
-idInlinePragma :: Id -> InlinePragma GhcTc
+idInlinePragma :: Id -> InlinePragma GhcRn
idInlinePragma id = inlinePragInfo (idInfo id)
-setInlinePragma :: Id -> InlinePragma GhcTc -> Id
+setInlinePragma :: Id -> InlinePragma GhcRn -> Id
setInlinePragma id prag = modifyIdInfo (`setInlinePragInfo` prag) id
-modifyInlinePragma :: Id -> (InlinePragma GhcTc -> InlinePragma GhcTc) -> Id
+modifyInlinePragma :: Id -> (InlinePragma GhcRn -> InlinePragma GhcRn) -> Id
modifyInlinePragma id fn = modifyIdInfo (\info -> info `setInlinePragInfo` (fn (inlinePragInfo info))) id
idInlineActivation :: Id -> Activation
=====================================
compiler/GHC/Types/Id/Info.hs
=====================================
@@ -106,10 +106,8 @@ import GHC.Unit.Module
import GHC.Types.Demand
import GHC.Types.Cpr
import GHC.Types.InlinePragma
-import GHC.Types.SourceText
import {-# SOURCE #-} GHC.Tc.Utils.TcType ( ConcreteTyVars, noConcreteTyVars )
-
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Stg.EnforceEpt.TagSig
@@ -441,7 +439,7 @@ data IdInfo
-- See Note [Specialisations and RULES in IdInfo]
realUnfoldingInfo :: Unfolding,
-- ^ The 'Id's unfolding
- inlinePragInfo :: InlinePragma GhcTc,
+ inlinePragInfo :: InlinePragma GhcRn,
-- ^ Any inline pragma attached to the 'Id'
occInfo :: OccInfo,
-- ^ How the 'Id' occurs in the program
@@ -554,16 +552,9 @@ tagSigInfo = tagSig
setRuleInfo :: IdInfo -> RuleInfo -> IdInfo
setRuleInfo info sp = sp `seq` info { ruleInfo = sp }
---setInlinePragInfo :: IdInfo -> InlinePragma GhcTc -> IdInfo
---setInlinePragInfo info pr = pr `seq` info { inlinePragInfo = pr }
-setInlinePragInfo :: forall p. IsPass p => IdInfo -> InlinePragma (GhcPass p) -> IdInfo
-setInlinePragInfo info pr@(InlinePragma { inl_ext = src }) = pr `seq` info { inlinePragInfo = pr { inl_ext = tag } }
- where
- tag :: InlinePragmaGhcTag
- tag = case ghcPass @p of
- GhcPs -> InlinePragmaGhcTag (src :: SourceText) 0
- GhcRn -> (src :: InlinePragmaGhcTag)
- GhcTc -> (src :: InlinePragmaGhcTag)
+
+setInlinePragInfo :: IdInfo -> InlinePragma GhcRn -> IdInfo
+setInlinePragInfo info pr = pr `seq` info { inlinePragInfo = pr }
setOccInfo :: IdInfo -> OccInfo -> IdInfo
setOccInfo info oc = oc `seq` info { occInfo = oc }
@@ -630,7 +621,7 @@ vanillaIdInfo
= IdInfo {
ruleInfo = emptyRuleInfo,
realUnfoldingInfo = noUnfolding,
- inlinePragInfo = defaultInlinePragma `setInlinePragmaArity` 0,
+ inlinePragInfo = defaultInlinePragma,
occInfo = noOccInfo,
demandInfo = topDmd,
dmdSigInfo = nopSig,
=====================================
compiler/GHC/Types/Id/Make.hs
=====================================
@@ -65,7 +65,7 @@ import GHC.Core.TyCon
import GHC.Core.Class
import GHC.Core.DataCon
-import GHC.Hs.Extension (GhcPs, GhcTc)
+import GHC.Hs.Extension (GhcRn)
import GHC.Types.Literal
import GHC.Types.RepType ( countFunRepArgs, typePrimRep )
@@ -608,8 +608,8 @@ mkDataConWorkId wkr_name data_con
-- See Note [Strict fields in Core]
`setLFInfo` wkr_lf_info
- wkr_inline_prag :: InlinePragma GhcTc
- wkr_inline_prag = alwaysInlineConLikePragma `setInlinePragmaArity` wkr_arity
+ wkr_inline_prag :: InlinePragma GhcRn
+ wkr_inline_prag = alwaysInlineConLikePragma
wkr_arity = dataConRepArity data_con
wkr_sig = mkClosedDmdSig wkr_dmds topDiv
@@ -989,7 +989,7 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con
; return (unbox_fn expr) }
-dataConWrapperInlinePragma :: InlinePragma GhcPs
+dataConWrapperInlinePragma :: InlinePragma GhcRn
-- See Note [DataCon wrappers are conlike]
dataConWrapperInlinePragma = alwaysInlineConLikePragma
@@ -1950,7 +1950,7 @@ nullAddrId :: Id
-- a way to write this literal in Haskell.
nullAddrId = pcMiscPrelId nullAddrName addrPrimTy info
where
- info = noCafIdInfo `setInlinePragInfo` (alwaysInlinePragma `setInlinePragmaArity` 0 :: InlinePragma GhcTc)
+ info = noCafIdInfo `setInlinePragInfo` alwaysInlinePragma
`setUnfoldingInfo` mkCompulsoryUnfolding (Lit nullAddrLit)
------------------------------------------------
=====================================
compiler/GHC/Types/InlinePragma.hs
=====================================
@@ -6,7 +6,7 @@
(c) The GRASP/AQUA Project, Glasgow University, 1997-1998
-}
-{-# OPTIONS_GHC -Wno-orphans #-} -- Binary InlinePragmaGhcTag, Binary InlinePragma
+{-# OPTIONS_GHC -Wno-orphans #-} -- Binary XInlinePragmaGhc, Binary InlinePragma
module GHC.Types.InlinePragma
( -- * Inline Pragma Encoding
@@ -21,6 +21,7 @@ module GHC.Types.InlinePragma
, neverInlinePragma
-- *** Field accessors
, inlinePragmaActivation
+ , inlinePragmaArity
, inlinePragmaName
, inlinePragmaRuleMatchInfo
, inlinePragmaSource
@@ -33,20 +34,22 @@ module GHC.Types.InlinePragma
, isNoInlinePragma
, isOpaquePragma
-- *** Mutators
+ , setInlinePragmaSource
+ , setInlinePragmaArityAsExplicitly
+ , setInlinePragmaArityAsNotExplicit
, setInlinePragmaActivation
- , setInlinePragmaArity
+ , setInlinePragmaSpec
, setInlinePragmaRuleMatchInfo
-- *** GHC pass conversions
- , demoteInlinePragmaRn
+ , demoteInlinePragmaTc
, promoteInlinePragmaRn
- , setInlinePragmaTag
- , unsetInlinePragmaArity
-- *** Pretty-printing
, pprInline
, pprInlineDebug
-- ** Extensible record type for GhcRn & GhcTc
- , InlinePragmaGhcTag(..)
+ , XInlinePragmaGhc(..)
+ , InlineArity(..)
-- ** InlineSpec
-- *** Data-type
@@ -98,19 +101,26 @@ import {-# SOURCE #-} GHC.Hs.Extension
import GHC.Data.FastString
import GHC.Utils.Binary
import GHC.Utils.Outputable
-import GHC.Types.Arity (Arity)
-import GHC.Types.SourceText
+import GHC.Types.Arity (InlineArity(..))
+import GHC.Types.SourceText (SourceText(..))
import Control.DeepSeq (NFData(..))
-import Data.Data
+import Data.Data (Data)
import Language.Haskell.Syntax.Binds.InlinePragma
import Language.Haskell.Syntax.Extension
+-- infixl so you can say (prag `set` a `set` b)
+infixl 1 `setInlinePragmaActivation`,
+ `setInlinePragmaArityAsExplicitly`,
+ `setInlinePragmaRuleMatchInfo`,
+ `setInlinePragmaSource`,
+ `setInlinePragmaSpec`
+
data XInlinePragmaGhc = XInlinePragmaGhc
{ xinl_src :: SourceText
-- ^ See Note [Pragma source text]
- , xinl_sat :: Maybe Arity
- -- ^ @Just n@ <=> Inline only when applied to @n@ explicit
+ , xinl_sat :: InlineArity
+ -- ^ Inline only when applied to @n@ explicit
-- (non-type, non-dictionary) arguments.
--
-- That is, 'xinl_sat' describes the number of *source-code*
@@ -120,33 +130,48 @@ data XInlinePragmaGhc = XInlinePragmaGhc
}
deriving (Eq, Data)
-instance NFData InlinePragmaGhcTag where
- rnf (InlinePragmaGhcTag s a) = rnf s `seq` rnf a `seq` ()
+instance NFData XInlinePragmaGhc where
+ rnf (XInlinePragmaGhc s a) = rnf s `seq` rnf a `seq` ()
type instance XInlinePragma GhcPs = SourceText
-type instance XInlinePragma GhcRn = InlinePragmaGhcTag
-type instance XInlinePragma GhcTc = InlinePragmaGhcTag
+type instance XInlinePragma GhcRn = XInlinePragmaGhc
+type instance XInlinePragma GhcTc = XInlinePragmaGhc
type instance XXInlinePragma (GhcPass _) = DataConCantHappen
-defaultInlinePragma, alwaysInlinePragma, neverInlinePragma, dfunInlinePragma
- :: InlinePragma GhcPs
-defaultInlinePragma = InlinePragma { inl_ext = SourceText $ fsLit "{-# INLINE"
- , inl_act = AlwaysActive
- , inl_rule = FunLike
- , inl_inline = NoUserInlinePrag }
-
-alwaysInlinePragma = defaultInlinePragma { inl_inline = Inline }
-neverInlinePragma = defaultInlinePragma { inl_act = NeverActive }
-
-alwaysInlineConLikePragma :: InlinePragma GhcPs
-alwaysInlineConLikePragma = alwaysInlinePragma { inl_rule = ConLike }
+-- | The default 'InlinePragma' definition for GHC.
+-- The type and value of 'inl_ext' provided will differ
+-- between the passes of GHC. Consequently, it may be
+-- necessary to apply type annotation at the call site
+-- to help the type checker disambiguate the correct
+-- type of 'inl_ext'.
+defaultInlinePragma :: forall p. IsPass p => InlinePragma (GhcPass p)
+defaultInlinePragma =
+ let srcTxt = SourceText $ fsLit "{-# INLINE"
+ inlExt = case ghcPass @p of
+ GhcPs -> srcTxt
+ GhcRn -> XInlinePragmaGhc srcTxt ArityNotExplicit
+ GhcTc -> XInlinePragmaGhc srcTxt ArityNotExplicit
+ in InlinePragma
+ { inl_ext = inlExt
+ , inl_act = AlwaysActive
+ , inl_rule = FunLike
+ , inl_inline = NoUserInlinePrag }
+
+-- | The default 'InlinePragma' definition for the "parser pass" of GHC.
+alwaysInlinePragma, neverInlinePragma, alwaysInlineConLikePragma, dfunInlinePragma
+ :: forall p. IsPass p => InlinePragma (GhcPass p)
+
+
+alwaysInlinePragma = (defaultInlinePragma @p) { inl_inline = Inline }
+neverInlinePragma = (defaultInlinePragma @p) { inl_act = NeverActive }
+alwaysInlineConLikePragma = (alwaysInlinePragma @p) { inl_rule = ConLike }
-- A DFun has an always-active inline activation so that
-- exprIsConApp_maybe can "see" its unfolding
-- (However, its actual Unfolding is a DFunUnfolding, which is
-- never inlined other than via exprIsConApp_maybe.)
-dfunInlinePragma = defaultInlinePragma { inl_act = AlwaysActive
- , inl_rule = ConLike }
+dfunInlinePragma = (defaultInlinePragma @p) { inl_act = AlwaysActive
+ , inl_rule = ConLike }
isDefaultInlinePragma :: InlinePragma p -> Bool
isDefaultInlinePragma (XInlinePragma _) = False
@@ -155,28 +180,38 @@ isDefaultInlinePragma (InlinePragma { inl_act = activation
, inl_inline = inline })
= noUserInlineSpec inline && isAlwaysActive activation && isFunLike match_info
-setInlinePragmaArity :: forall p q. (IsPass p, XInlinePragma (GhcPass q) ~ InlinePragmaGhcTag)
- => InlinePragma (GhcPass p) -> Arity -> InlinePragma (GhcPass q)
+setInlinePragmaArity :: forall p q. (IsPass p, XInlinePragma (GhcPass q) ~ XInlinePragmaGhc)
+ => InlinePragma (GhcPass p) -> InlineArity -> InlinePragma (GhcPass q)
setInlinePragmaArity prag arity =
- prag { inl_ext = InlinePragmaGhcTag (inlinePragmaSource prag) arity }
+ prag { inl_ext = XInlinePragmaGhc (inlinePragmaSource prag) arity }
+
+setInlinePragmaArityAsExplicitly :: forall a p q. (Integral a, IsPass p, XInlinePragma (GhcPass q) ~ XInlinePragmaGhc)
+ => InlinePragma (GhcPass p) -> a -> InlinePragma (GhcPass q)
+setInlinePragmaArityAsExplicitly prag intVal = prag `setInlinePragmaArity` arity
+ where
+ arity = ArityExplicitly . fromIntegral $ abs intVal
-unsetInlinePragmaArity :: forall p. IsPass p => InlinePragma (GhcPass p) -> InlinePragma GhcPs
-unsetInlinePragmaArity prag =
- prag { inl_ext = inlinePragmaSource prag }
+setInlinePragmaArityAsNotExplicit :: forall p q. (IsPass p, XInlinePragma (GhcPass q) ~ XInlinePragmaGhc)
+ => InlinePragma (GhcPass p) -> InlinePragma (GhcPass q)
+setInlinePragmaArityAsNotExplicit = flip setInlinePragmaArity ArityNotExplicit
inlinePragmaSource :: forall p. IsPass p => InlinePragma (GhcPass p) -> SourceText
inlinePragmaSource (InlinePragma { inl_ext = src }) = srcTxt
where
srcTxt = case ghcPass @p of
GhcPs -> src
- GhcRn -> inl_ghcrn_src src
- GhcTc -> inl_ghcrn_src src
+ GhcRn -> xinl_src src
+ GhcTc -> xinl_src src
+
+inlinePragmaArity :: forall p. (XInlinePragma (GhcPass p) ~ XInlinePragmaGhc)
+ => InlinePragma (GhcPass p) -> InlineArity
+inlinePragmaArity = xinl_sat . inl_ext
promoteInlinePragmaRn :: InlinePragma GhcRn -> InlinePragma GhcTc
promoteInlinePragmaRn prag@(InlinePragma { inl_ext = src }) = prag { inl_ext = src }
-demoteInlinePragmaRn :: InlinePragma GhcTc -> InlinePragma GhcRn
-demoteInlinePragmaRn prag@(InlinePragma { inl_ext = src }) = prag { inl_ext = src }
+demoteInlinePragmaTc :: InlinePragma GhcTc -> InlinePragma GhcRn
+demoteInlinePragmaTc prag@(InlinePragma { inl_ext = src }) = prag { inl_ext = src }
inlinePragmaSpec :: InlinePragma p -> InlineSpec
inlinePragmaSpec = inl_inline
@@ -187,8 +222,18 @@ inlinePragmaActivation (InlinePragma { inl_act = activation }) = activation
inlinePragmaRuleMatchInfo :: InlinePragma (GhcPass p) -> RuleMatchInfo
inlinePragmaRuleMatchInfo (InlinePragma { inl_rule = info }) = info
-setInlinePragmaTag :: InlinePragma (GhcPass p) -> XInlinePragma (GhcPass q) -> InlinePragma (GhcPass q)
-setInlinePragmaTag prag tag = prag { inl_ext = tag }
+setInlinePragmaSource :: forall p. IsPass p
+ => InlinePragma (GhcPass p) -> SourceText -> InlinePragma (GhcPass p)
+setInlinePragmaSource prag srcTxt = prag { inl_ext = newExt }
+ where
+ oldExt = inl_ext prag
+ newExt = case ghcPass @p of
+ GhcPs -> srcTxt
+ GhcRn -> oldExt { xinl_src = srcTxt }
+ GhcTc -> oldExt { xinl_src = srcTxt }
+
+setInlinePragmaSpec :: InlinePragma (GhcPass p) -> InlineSpec -> InlinePragma (GhcPass p)
+setInlinePragmaSpec prag spec = prag { inl_inline = spec }
setInlinePragmaActivation :: InlinePragma (GhcPass p) -> Activation -> InlinePragma (GhcPass p)
setInlinePragmaActivation prag activation = prag { inl_act = activation }
@@ -360,15 +405,15 @@ no harm.
modules once TTG has progressed and the Language.Haskell.Syntax.Types module
no longer depends on importing GHC.Hs.Doc.
-}
-instance Binary InlinePragmaGhcTag where
- put_ bh (InlinePragmaGhcTag s a) = do
+instance Binary XInlinePragmaGhc where
+ put_ bh (XInlinePragmaGhc s a) = do
put_ bh s
put_ bh a
get bh = do
s <- get bh
a <- get bh
- return (InlinePragmaGhcTag s a)
+ return (XInlinePragmaGhc s a)
instance forall p. IsPass p => Binary (InlinePragma (GhcPass p)) where
put_ bh (InlinePragma s a b c) = do
=====================================
compiler/GHC/Utils/Binary.hs
=====================================
@@ -125,6 +125,7 @@ import GHC.Data.FastString
import GHC.Data.TrieMap
import GHC.Utils.Exception
import GHC.Utils.Panic.Plain
+import GHC.Types.Arity (InlineArity(..))
import GHC.Types.Unique.FM
import GHC.Data.FastMutInt
import GHC.Utils.Fingerprint
@@ -2064,28 +2065,21 @@ instance Binary FFIType where
FFIUInt64 -> 11
instance Binary Activation where
- put_ bh NeverActive =
- putByte bh 0
- put_ bh FinalActive = do
- putByte bh 1
- put_ bh AlwaysActive =
- putByte bh 2
- put_ bh (ActiveBefore aa) = do
- putByte bh 3
- put_ bh aa
- put_ bh (ActiveAfter ab) = do
- putByte bh 4
- put_ bh ab
+ put_ bh = \case
+ NeverActive -> putByte bh 0
+ FinalActive -> putByte bh 1
+ AlwaysActive -> putByte bh 2
+ ActiveBefore aa -> putByte bh 3 *> put_ bh aa
+ ActiveAfter ab -> putByte bh 4 *> put_ bh ab
+
get bh = do
- h <- getByte bh
- case h of
- 0 -> return NeverActive
- 1 -> return FinalActive
- 2 -> return AlwaysActive
- 3 -> do aa <- get bh
- return (ActiveBefore aa)
- _ -> do ab <- get bh
- return (ActiveAfter ab)
+ h <- getByte bh
+ case h of
+ 0 -> pure NeverActive
+ 1 -> pure FinalActive
+ 2 -> pure AlwaysActive
+ 3 -> ActiveBefore <$> get bh
+ _ -> ActiveAfter <$> get bh
instance Binary InlineSpec where
put_ bh = putByte bh . \case
@@ -2095,18 +2089,29 @@ instance Binary InlineSpec where
NoInline -> 3
Opaque -> 4
- get bh = do h <- getByte bh
- return $ case h of
- 0 -> NoUserInlinePrag
- 1 -> Inline
- 2 -> Inlinable
- 3 -> NoInline
- _ -> Opaque
+ get bh = do
+ h <- getByte bh
+ return $ case h of
+ 0 -> NoUserInlinePrag
+ 1 -> Inline
+ 2 -> Inlinable
+ 3 -> NoInline
+ _ -> Opaque
instance Binary RuleMatchInfo where
put_ bh FunLike = putByte bh 0
put_ bh ConLike = putByte bh 1
+
+ get bh = do
+ h <- getByte bh
+ if h == 1 then pure ConLike
+ else pure FunLike
+
+instance Binary InlineArity where
+ put_ bh ArityNotExplicit = putByte bh 0
+ put_ bh (ArityExplicitly w) = putByte bh 1 *> put_ bh w
+
get bh = do
- h <- getByte bh
- if h == 1 then return ConLike
- else return FunLike
+ h <- getByte bh
+ if h == 0 then pure ArityNotExplicit
+ else ArityExplicitly <$> get bh
=====================================
compiler/GHC/Utils/Outputable.hs
=====================================
@@ -112,6 +112,7 @@ module GHC.Utils.Outputable (
) where
import Language.Haskell.Syntax.Binds.InlinePragma
+import Language.Haskell.Syntax.Extension ( dataConCantHappen )
import Language.Haskell.Syntax.Module.Name ( ModuleName(..) )
import {-# SOURCE #-} GHC.Hs.Extension
@@ -2025,7 +2026,15 @@ pprInlineDebug = pprInline' False
pprInline' :: Bool -- True <=> do not display the inl_inline field
-> InlinePragma (GhcPass p)
-> SDoc
-pprInline' _ (XInlinePragma ext) = dataConCantHappen ext
+-- TODO: Revise this definition for XInlinePragma constructor.
+-- The proper defintion is:
+-- > pprInline' _ (XInlinePragma ext) = dataConCantHappen ext
+-- We cannot add this proper definition until this module imports
+-- 'GHC.Types.InlinePragma', instead of the other way around.
+-- Until then, the type family definition of XInlinePragma (GhcPass _)
+-- will not be in scope and the type-checker cannot determine that
+-- the binding 'ext' is in fact a 'DataConCantHappen' value.
+pprInline' _ (XInlinePragma ext) = error "XInlinePragma = dataConCantHappen"
pprInline' emptyInline (InlinePragma
{ inl_inline = inline,
inl_act = activation,
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7d47d203034f014791a2aa2cfb8fd2…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7d47d203034f014791a2aa2cfb8fd2…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
18 Dec '25
Cheng Shao pushed new branch wip/cleanup-win32-tarballs at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/cleanup-win32-tarballs
You're receiving this email because of your account on gitlab.haskell.org.
1
0
18 Dec '25
Cheng Shao pushed new branch wip/split-sections-scc at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/split-sections-scc
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/terrorjack/asan] 21 commits: X86 CodeGen: fix assign_eax_sse_regs
by Cheng Shao (@TerrorJack) 18 Dec '25
by Cheng Shao (@TerrorJack) 18 Dec '25
18 Dec '25
Cheng Shao pushed to branch wip/terrorjack/asan at Glasgow Haskell Compiler / GHC
Commits:
fca9cd7c by sheaf at 2025-12-18T13:18:18-05:00
X86 CodeGen: fix assign_eax_sse_regs
We must set %al to the number of SSE2 registers that contain arguments
(in case we are dealing with a varargs function). The logic for counting
how many arguments reside in SSE2 registers was incorrect, as it used
'isFloatFormat', which incorrectly ignores vector registers.
We now instead do case analysis on the register class:
is_sse_reg r =
case targetClassOfReg platform r of
RcFloatOrVector -> True
RcInteger -> False
This change is necessary to prevent segfaults in T20030_test1j, because
subsequent commits change the format calculations, resulting in vector
formats more often.
- - - - -
53150617 by sheaf at 2025-12-18T13:18:19-05:00
X86 regUsageOfInstr: fix format for IMUL
When used with 8-bit operands, the IMUL instruction returns the result
in the lower 16 bits of %rax (also known as %ax). This is different
than for the other sizes, where an input at 16, 32 or 64 bits will
result in 16, 32 or 64 bits of output in both %rax and %rdx.
This doesn't affect the behaviour of the compiler, because we don't
allow partial writes at sub-word sizes. The rationale is explained
in Wrinkle [Don't allow scalar partial writes] in Note [Register formats in liveness analysis],
in GHC.CmmToAsm.Reg.Liveness.
- - - - -
c7a56dd1 by sheaf at 2025-12-18T13:18:19-05:00
Liveness analysis: consider register formats
This commit updates the register allocator to be a bit more careful in
situations in which a single register is used at multiple different
formats, e.g. when xmm1 is used both to store a Double# and a DoubleX2#.
This is done by introducing the 'Regs' newtype around 'UniqSet RegWithFormat',
for which the combining operations take the larger of the two formats
instead of overriding the format.
Operations on 'Regs' are defined in 'GHC.CmmToAsm.Reg.Regs'. There is
a modest compile-time cost for the additional overhead for tracking
register formats, which causes the metric increases of this commit.
The subtle aspects of the implementation are outlined in
Note [Register formats in liveness analysis] in GHC.CmmToAsm.Reg.Liveness.
Fixes #26411 #26611
-------------------------
Metric Increase:
T12707
T26425
T3294
-------------------------
- - - - -
c2e83339 by sheaf at 2025-12-18T13:18:19-05:00
Register allocator: reload at same format as spill
This commit ensures that if we spill a register onto the stack at a
given format, we then always reload the register at this same format.
This ensures we don't end up in a situation where we spill F64x2 but end
up only reloading the lower F64. This first reload would make us believe
the whole data is in a register, thus silently losing the upper 64 bits
of the spilled register's contents.
Fixes #26526
- - - - -
55ab583b by sheaf at 2025-12-18T13:18:19-05:00
Register allocation: writes redefine format
As explained in Note [Allocated register formats] in GHC.CmmToAsm.Reg.Linear,
we consider all writes to redefine the format of the register.
This ensures that in a situation such as
movsd .Ln6m(%rip),%v1
shufpd $0,%v1,%v1
we properly consider the broadcast operation to change the format of %v1
from F64 to F64x2.
This completes the fix to #26411 (test in T26411b).
- - - - -
951402ed by Vladislav Zavialov at 2025-12-18T13:19:05-05:00
Parser: improve mkModuleImpExp, remove checkImportSpec
1. The `mkModuleImpExp` helper now knows whether it is processing an import or
export list item, and uses this information to produce a more accurate error
message for `import M (T(..,x))` with PatternSynonyms disabled.
The old message incorrectly referred to this case as an export form.
2. The `checkImportSpec` helper is removed in favor of more comprehensive error
checking in `mkModuleImpExp`.
3. Additionaly, the invariants of `ImpExpList` and `ImpExpAllWith` have been
made more explicit in the comments and assertions (calls to 'panic').
Test case: import-syntax-no-ext
- - - - -
47d83d96 by Vladislav Zavialov at 2025-12-18T13:19:06-05:00
Subordinate namespace-specified wildcards (#25901)
Add support for subordinate namespace-specified wildcards
`X(type ..)` and `X(data ..)` to import and export lists.
Examples:
import M (Cls(type ..)) -- imports Cls and all its associated types
import M (Cls(data ..)) -- imports Cls and all its methods
module M (R(data ..), C(type ..)) where
-- exports R and all its data constructors and record fields;
-- exports C and all its associated types, but not its methods
The scope of this change is limited to the case where the wildcard is the only
subordinate import/export item, whereas the more complex forms `X(type .., f)`
or `X(type .., data ..)` are unsupported and raise the newly introduced
PsErrUnsupportedExplicitNamespace error. This restriction may be lifted later.
Summary of the changes:
1. Refactor IEThingAll to store its extension field XIEThingAll as a record
IEThingAllExt instead of a tuple.
2. Extend the AST by adding a NamespaceSpecifier field to IEThingAllExt,
representing an optional namespace specifier `type` or `data` in front
of a subordinate wildcard `X(..)`.
3. Extend the grammar in Parser.y with productions for `type ..` and `data ..`
in subordinate import/export items.
4. Introduce `filterByNamespaceGREs` to filter [GlobalRdrElt] by a
NamespaceSpecifier; use it in `filterImports` and `exports_from_avail`
to account for the namespace specifier in IEThingAll.
5. Improve diagnostics by storing more information in DodgyImportsEmptyParent
and DodgyExportsEmptyParent.
Test cases:
T25901_sub_e T25901_sub_f T25901_sub_g T25901_sub_a
T25901_sub_b T25901_sub_c T25901_sub_d T25901_sub_w
DodgyImports02 DodgyImports03 DodgyImports04
- - - - -
eac418bb by Recursion Ninja at 2025-12-18T13:19:48-05:00
Removing the 'Data' instance for 'InstEnv'.
The 'Data' instance is blocking work on Trees that Grow, and the
'Data' instance seem to have been added without a clear purpose.
- - - - -
e920e038 by Recursion Ninja at 2025-12-18T13:19:48-05:00
'Decouple Language.Haskell.Syntax.Decls' from 'GHC.Unit.Module.Warnings'
- - - - -
bd38b76c by Cheng Shao at 2025-12-18T13:20:31-05:00
testsuite: improve coverage of foundation test
This patch refactors the `foundation` test a bit to improve coverage:
- Instead of using a hard-coded seed, a random seed is now taken from
the command line, and printed upon test failure. This improves test
coverage over many future CI runs, and shall a failure occur, the
seed is available in the CI log for local reproduction.
- The iterations count is bumped to 1000 instead of 100, similar to
the bump in `test-primops`. Runtime timeout is bumped 2x just to be
safe.
- Improve `newLCGGen` by using non-atomic loads/stores on a
`MutableByteArray#` for storing mutable `Word64`, this test doesn't
use parallelism in the first place
- Fixed a few compiler warnings and removed redundant pragmas and
imports
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
3995187c by Sylvain Henry at 2025-12-18T13:21:45-05:00
Doc: document -pgmi "" (#26634)
- - - - -
5729418c by Cheng Shao at 2025-12-18T13:22:29-05:00
rts: use __builtin_mul_overflow for hs_mulIntMayOflo
This patch uses `__builtin_mul_overflow` to implement
`hs_mulIntMayOflo`. This is a GNU C checked arithmetic builtin
function supported by gcc/clang, is type-generic so works for both
32-bit/64-bit, and makes the code both more efficient and easier to
read/maintain than the previous hand rolled logic.
- - - - -
1ca4b49a by Cheng Shao at 2025-12-18T13:23:11-05:00
compiler/rts: fix ABI mismatch in barf() invocations
This patch fixes a long-standing issue of ABI mismatch in `barf()`
invocations, both in compiler-emitted code and in hand written Cmm
code:
- In RTS, we have `barf()` which reports a fatal internal error
message and exits the program.
- `barf()` is a variadic C function! When used as a callee of a
foreign call with `ccall` calling convention instead of `capi`,
there is an ABI mismatch between the caller and the callee!
- Unfortunately, both the compiler and the Cmm sources contain many
places where we call `barf()` via `ccall` convention!! Like, when
you write `foreign "C" barf("foo object (%p) entered!", R1)`, it
totally doesn't do what you think it'll do at all!! The second
argument `R1` is not properly passed in `va_list`, and the behavior
is completely undefined!!
- Even more unfortunately, this issue has been sitting around long
enough because the ABI mismatch is subtle enough on normie platforms
like x64 and arm64.
- But there are platforms like wasm32 that are stricter about ABI, and
the broken `barf()` invocations already causes trouble for wasm
backend: we had to use ugly hacks like `barf(errmsg, NULL)` to make
`wasm-ld` happy, and even with this band-aid, compiler-generated
`barf()` invocations are still broken, resulting in regressions in
certain debug-related functionality, e.g. `-dtag-inference-checks`
is broken on wasm32 (#22882).
This patch properly fixes the issue:
- We add non-variadic `barf` wrappers in the RTS that can be used as
`ccall` callees
- Both the compiler `emitBarf` logic and the hand-written Cmm are
changed to call these wrappers
- `emitBarf` now also properly annotates the foreign call as
`CmmNeverReturns` to indicate it's a noreturn call to enable more
efficient code generation
`-dtag-inference-checks` now works on wasm. Closes #22882.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
b3dd23b9 by Vilim Lendvaj at 2025-12-18T13:23:57-05:00
Remove outdated comment
The Traversable instance for ZipList is no longer in
GHC.Internal.Data.Traversable. In fact, it is right below this very comment.
- - - - -
9a9c2f03 by Cheng Shao at 2025-12-18T13:24:39-05:00
compiler: remove unused OtherSection logic
This patch removes the OtherSection logic in Cmm, given it's never
actually used by any of our backends.
- - - - -
f52e9541 by Cheng Shao at 2025-12-18T19:57:45+01:00
rts: workaround -Werror=maybe-uninitialized false positives
In some cases gcc might report -Werror=maybe-uninitialized that we
know are false positives, but need to workaround it to make validate
builds with -Werror pass.
- - - - -
9d897f8e by Cheng Shao at 2025-12-18T19:57:45+01:00
rts: add is-valid-utf8.c to .ubsan-suppressions
A minor one in `bytestring` that might surface when building with
+ubsan using clang.
- - - - -
4620a7c3 by Cheng Shao at 2025-12-18T20:44:16+01:00
hadrian: add support for building with AddressSanitizer
This patch adds a +asan flavour transformer to hadrian to build all
stage1+ C/C++ code with AddressBehaviorSanitizer. This is particularly
useful to catch potential out-of-bounds and use-after-free bugs in the
RTS codebase.
- - - - -
f94985be by Cheng Shao at 2025-12-18T20:44:21+01:00
ci: add ubsan+asan job
We now have a `x86_64-linux-fedora43-validate+debug_info+ubsan+asan`
validate/nightly job with both UBSan/ASan enabled.
- - - - -
62b20ad5 by Cheng Shao at 2025-12-18T20:44:22+01:00
rts: add ASAN instrumentation to mblock allocator
- - - - -
26339689 by Cheng Shao at 2025-12-18T20:44:22+01:00
rts: add ASAN instrumentation to per-Task InCall free list
- - - - -
133 changed files:
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/Builtin/Utils.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- compiler/GHC/CmmToAsm/LA64/Ppr.hs
- compiler/GHC/CmmToAsm/PPC/Ppr.hs
- compiler/GHC/CmmToAsm/Ppr.hs
- compiler/GHC/CmmToAsm/RV64/Ppr.hs
- compiler/GHC/CmmToAsm/Reg/Graph.hs
- compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs
- compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs
- compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs
- compiler/GHC/CmmToAsm/Reg/Linear.hs
- compiler/GHC/CmmToAsm/Reg/Linear/Base.hs
- compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs
- compiler/GHC/CmmToAsm/Reg/Liveness.hs
- + compiler/GHC/CmmToAsm/Reg/Regs.hs
- compiler/GHC/CmmToAsm/Reg/Target.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm/Data.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Warnings.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/StgToCmm/Bind.hs
- compiler/GHC/StgToCmm/Utils.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Types/DefaultEnv.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Unique/Set.hs
- compiler/GHC/Unit/Module/Warnings.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- docs/users_guide/phases.rst
- hadrian/doc/flavours.md
- hadrian/src/Flavour.hs
- libraries/ghc-internal/src/GHC/Internal/Functor/ZipList.hs
- rts/.ubsan-suppressions
- rts/Apply.cmm
- rts/Compact.cmm
- rts/ContinuationOps.cmm
- rts/Exception.cmm
- rts/Jumps.h
- rts/PrimOps.cmm
- rts/RtsMessages.c
- rts/StgMiscClosures.cmm
- rts/StgStartup.cmm
- rts/Task.c
- rts/include/Stg.h
- + rts/include/rts/ASANUtils.h
- rts/include/rts/Messages.h
- rts/linker/InitFini.c
- rts/prim/mulIntMayOflo.c
- rts/rts.cabal
- rts/sm/MBlock.c
- rts/sm/Sanity.c
- testsuite/driver/testglobals.py
- testsuite/driver/testlib.py
- testsuite/tests/diagnostic-codes/codes.stdout
- testsuite/tests/ffi/should_run/all.T
- testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
- testsuite/tests/numeric/should_run/all.T
- testsuite/tests/numeric/should_run/foundation.hs
- testsuite/tests/numeric/should_run/foundation.stdout
- testsuite/tests/patsyn/should_fail/all.T
- + testsuite/tests/patsyn/should_fail/import-syntax-no-ext.hs
- + testsuite/tests/patsyn/should_fail/import-syntax-no-ext.stderr
- + testsuite/tests/rename/should_compile/T25901_sub_e.hs
- + testsuite/tests/rename/should_compile/T25901_sub_f.hs
- + testsuite/tests/rename/should_compile/T25901_sub_f.stderr
- + testsuite/tests/rename/should_compile/T25901_sub_g.hs
- + testsuite/tests/rename/should_compile/T25901_sub_g.stderr
- + testsuite/tests/rename/should_compile/T25901_sub_g_helper.hs
- testsuite/tests/rename/should_compile/all.T
- testsuite/tests/rename/should_fail/T23570b.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_a.hs
- + testsuite/tests/rename/should_fail/T25901_sub_a.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_b.hs
- + testsuite/tests/rename/should_fail/T25901_sub_b.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_c.hs
- + testsuite/tests/rename/should_fail/T25901_sub_c.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_c_helper.hs
- + testsuite/tests/rename/should_fail/T25901_sub_d.hs
- + testsuite/tests/rename/should_fail/T25901_sub_d.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_d_helper.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/rts/T18623/all.T
- testsuite/tests/rts/all.T
- + testsuite/tests/simd/should_run/T26411.hs
- + testsuite/tests/simd/should_run/T26411.stdout
- + testsuite/tests/simd/should_run/T26411b.hs
- + testsuite/tests/simd/should_run/T26411b.stdout
- testsuite/tests/simd/should_run/all.T
- testsuite/tests/simplStg/should_compile/all.T
- testsuite/tests/warnings/should_compile/DodgyExports03.stderr
- testsuite/tests/warnings/should_compile/DodgyImports.stderr
- + testsuite/tests/warnings/should_compile/DodgyImports02.hs
- + testsuite/tests/warnings/should_compile/DodgyImports02.stderr
- + testsuite/tests/warnings/should_compile/DodgyImports03.hs
- + testsuite/tests/warnings/should_compile/DodgyImports03.stderr
- + testsuite/tests/warnings/should_compile/DodgyImports03_helper.hs
- + testsuite/tests/warnings/should_compile/DodgyImports04.hs
- + testsuite/tests/warnings/should_compile/DodgyImports04.stderr
- testsuite/tests/warnings/should_compile/DodgyImports_hiding.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
- utils/genapply/Main.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc23bc7a1802526d1cb30cfb86f135…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bc23bc7a1802526d1cb30cfb86f135…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/fix-26670] Apply 1 suggestion(s) to 1 file(s)
by recursion-ninja (@recursion-ninja) 18 Dec '25
by recursion-ninja (@recursion-ninja) 18 Dec '25
18 Dec '25
recursion-ninja pushed to branch wip/fix-26670 at Glasgow Haskell Compiler / GHC
Commits:
74ac93ee by recursion-ninja at 2025-12-18T19:01:51+00:00
Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: sheaf <sam.derbyshire(a)gmail.com>
- - - - -
1 changed file:
- compiler/GHC/Types/InlinePragma.hs
Changes:
=====================================
compiler/GHC/Types/InlinePragma.hs
=====================================
@@ -106,9 +106,17 @@ import Data.Data
import Language.Haskell.Syntax.Binds.InlinePragma
import Language.Haskell.Syntax.Extension
-data InlinePragmaGhcTag = InlinePragmaGhcTag
- { inl_ghcrn_src :: {-# UNPACK#-} !SourceText
- , inl_ghcrn_arity :: {-# UNPACK#-} !Arity
+data XInlinePragmaGhc = XInlinePragmaGhc
+ { xinl_src :: SourceText
+ -- ^ See Note [Pragma source text]
+ , xinl_sat :: Maybe Arity
+ -- ^ @Just n@ <=> Inline only when applied to @n@ explicit
+ -- (non-type, non-dictionary) arguments.
+ --
+ -- That is, 'xinl_sat' describes the number of *source-code*
+ -- arguments the thing must be applied to. We add on the
+ -- number of implicit, dictionary arguments when making
+ -- the Unfolding, and don't look at inl_sat further
}
deriving (Eq, Data)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ac93ee37f1c8e390ca84b1b296698…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ac93ee37f1c8e390ca84b1b296698…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 18 commits: X86 CodeGen: fix assign_eax_sse_regs
by Marge Bot (@marge-bot) 18 Dec '25
by Marge Bot (@marge-bot) 18 Dec '25
18 Dec '25
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
fca9cd7c by sheaf at 2025-12-18T13:18:18-05:00
X86 CodeGen: fix assign_eax_sse_regs
We must set %al to the number of SSE2 registers that contain arguments
(in case we are dealing with a varargs function). The logic for counting
how many arguments reside in SSE2 registers was incorrect, as it used
'isFloatFormat', which incorrectly ignores vector registers.
We now instead do case analysis on the register class:
is_sse_reg r =
case targetClassOfReg platform r of
RcFloatOrVector -> True
RcInteger -> False
This change is necessary to prevent segfaults in T20030_test1j, because
subsequent commits change the format calculations, resulting in vector
formats more often.
- - - - -
53150617 by sheaf at 2025-12-18T13:18:19-05:00
X86 regUsageOfInstr: fix format for IMUL
When used with 8-bit operands, the IMUL instruction returns the result
in the lower 16 bits of %rax (also known as %ax). This is different
than for the other sizes, where an input at 16, 32 or 64 bits will
result in 16, 32 or 64 bits of output in both %rax and %rdx.
This doesn't affect the behaviour of the compiler, because we don't
allow partial writes at sub-word sizes. The rationale is explained
in Wrinkle [Don't allow scalar partial writes] in Note [Register formats in liveness analysis],
in GHC.CmmToAsm.Reg.Liveness.
- - - - -
c7a56dd1 by sheaf at 2025-12-18T13:18:19-05:00
Liveness analysis: consider register formats
This commit updates the register allocator to be a bit more careful in
situations in which a single register is used at multiple different
formats, e.g. when xmm1 is used both to store a Double# and a DoubleX2#.
This is done by introducing the 'Regs' newtype around 'UniqSet RegWithFormat',
for which the combining operations take the larger of the two formats
instead of overriding the format.
Operations on 'Regs' are defined in 'GHC.CmmToAsm.Reg.Regs'. There is
a modest compile-time cost for the additional overhead for tracking
register formats, which causes the metric increases of this commit.
The subtle aspects of the implementation are outlined in
Note [Register formats in liveness analysis] in GHC.CmmToAsm.Reg.Liveness.
Fixes #26411 #26611
-------------------------
Metric Increase:
T12707
T26425
T3294
-------------------------
- - - - -
c2e83339 by sheaf at 2025-12-18T13:18:19-05:00
Register allocator: reload at same format as spill
This commit ensures that if we spill a register onto the stack at a
given format, we then always reload the register at this same format.
This ensures we don't end up in a situation where we spill F64x2 but end
up only reloading the lower F64. This first reload would make us believe
the whole data is in a register, thus silently losing the upper 64 bits
of the spilled register's contents.
Fixes #26526
- - - - -
55ab583b by sheaf at 2025-12-18T13:18:19-05:00
Register allocation: writes redefine format
As explained in Note [Allocated register formats] in GHC.CmmToAsm.Reg.Linear,
we consider all writes to redefine the format of the register.
This ensures that in a situation such as
movsd .Ln6m(%rip),%v1
shufpd $0,%v1,%v1
we properly consider the broadcast operation to change the format of %v1
from F64 to F64x2.
This completes the fix to #26411 (test in T26411b).
- - - - -
951402ed by Vladislav Zavialov at 2025-12-18T13:19:05-05:00
Parser: improve mkModuleImpExp, remove checkImportSpec
1. The `mkModuleImpExp` helper now knows whether it is processing an import or
export list item, and uses this information to produce a more accurate error
message for `import M (T(..,x))` with PatternSynonyms disabled.
The old message incorrectly referred to this case as an export form.
2. The `checkImportSpec` helper is removed in favor of more comprehensive error
checking in `mkModuleImpExp`.
3. Additionaly, the invariants of `ImpExpList` and `ImpExpAllWith` have been
made more explicit in the comments and assertions (calls to 'panic').
Test case: import-syntax-no-ext
- - - - -
47d83d96 by Vladislav Zavialov at 2025-12-18T13:19:06-05:00
Subordinate namespace-specified wildcards (#25901)
Add support for subordinate namespace-specified wildcards
`X(type ..)` and `X(data ..)` to import and export lists.
Examples:
import M (Cls(type ..)) -- imports Cls and all its associated types
import M (Cls(data ..)) -- imports Cls and all its methods
module M (R(data ..), C(type ..)) where
-- exports R and all its data constructors and record fields;
-- exports C and all its associated types, but not its methods
The scope of this change is limited to the case where the wildcard is the only
subordinate import/export item, whereas the more complex forms `X(type .., f)`
or `X(type .., data ..)` are unsupported and raise the newly introduced
PsErrUnsupportedExplicitNamespace error. This restriction may be lifted later.
Summary of the changes:
1. Refactor IEThingAll to store its extension field XIEThingAll as a record
IEThingAllExt instead of a tuple.
2. Extend the AST by adding a NamespaceSpecifier field to IEThingAllExt,
representing an optional namespace specifier `type` or `data` in front
of a subordinate wildcard `X(..)`.
3. Extend the grammar in Parser.y with productions for `type ..` and `data ..`
in subordinate import/export items.
4. Introduce `filterByNamespaceGREs` to filter [GlobalRdrElt] by a
NamespaceSpecifier; use it in `filterImports` and `exports_from_avail`
to account for the namespace specifier in IEThingAll.
5. Improve diagnostics by storing more information in DodgyImportsEmptyParent
and DodgyExportsEmptyParent.
Test cases:
T25901_sub_e T25901_sub_f T25901_sub_g T25901_sub_a
T25901_sub_b T25901_sub_c T25901_sub_d T25901_sub_w
DodgyImports02 DodgyImports03 DodgyImports04
- - - - -
eac418bb by Recursion Ninja at 2025-12-18T13:19:48-05:00
Removing the 'Data' instance for 'InstEnv'.
The 'Data' instance is blocking work on Trees that Grow, and the
'Data' instance seem to have been added without a clear purpose.
- - - - -
e920e038 by Recursion Ninja at 2025-12-18T13:19:48-05:00
'Decouple Language.Haskell.Syntax.Decls' from 'GHC.Unit.Module.Warnings'
- - - - -
bd38b76c by Cheng Shao at 2025-12-18T13:20:31-05:00
testsuite: improve coverage of foundation test
This patch refactors the `foundation` test a bit to improve coverage:
- Instead of using a hard-coded seed, a random seed is now taken from
the command line, and printed upon test failure. This improves test
coverage over many future CI runs, and shall a failure occur, the
seed is available in the CI log for local reproduction.
- The iterations count is bumped to 1000 instead of 100, similar to
the bump in `test-primops`. Runtime timeout is bumped 2x just to be
safe.
- Improve `newLCGGen` by using non-atomic loads/stores on a
`MutableByteArray#` for storing mutable `Word64`, this test doesn't
use parallelism in the first place
- Fixed a few compiler warnings and removed redundant pragmas and
imports
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
3995187c by Sylvain Henry at 2025-12-18T13:21:45-05:00
Doc: document -pgmi "" (#26634)
- - - - -
5729418c by Cheng Shao at 2025-12-18T13:22:29-05:00
rts: use __builtin_mul_overflow for hs_mulIntMayOflo
This patch uses `__builtin_mul_overflow` to implement
`hs_mulIntMayOflo`. This is a GNU C checked arithmetic builtin
function supported by gcc/clang, is type-generic so works for both
32-bit/64-bit, and makes the code both more efficient and easier to
read/maintain than the previous hand rolled logic.
- - - - -
1ca4b49a by Cheng Shao at 2025-12-18T13:23:11-05:00
compiler/rts: fix ABI mismatch in barf() invocations
This patch fixes a long-standing issue of ABI mismatch in `barf()`
invocations, both in compiler-emitted code and in hand written Cmm
code:
- In RTS, we have `barf()` which reports a fatal internal error
message and exits the program.
- `barf()` is a variadic C function! When used as a callee of a
foreign call with `ccall` calling convention instead of `capi`,
there is an ABI mismatch between the caller and the callee!
- Unfortunately, both the compiler and the Cmm sources contain many
places where we call `barf()` via `ccall` convention!! Like, when
you write `foreign "C" barf("foo object (%p) entered!", R1)`, it
totally doesn't do what you think it'll do at all!! The second
argument `R1` is not properly passed in `va_list`, and the behavior
is completely undefined!!
- Even more unfortunately, this issue has been sitting around long
enough because the ABI mismatch is subtle enough on normie platforms
like x64 and arm64.
- But there are platforms like wasm32 that are stricter about ABI, and
the broken `barf()` invocations already causes trouble for wasm
backend: we had to use ugly hacks like `barf(errmsg, NULL)` to make
`wasm-ld` happy, and even with this band-aid, compiler-generated
`barf()` invocations are still broken, resulting in regressions in
certain debug-related functionality, e.g. `-dtag-inference-checks`
is broken on wasm32 (#22882).
This patch properly fixes the issue:
- We add non-variadic `barf` wrappers in the RTS that can be used as
`ccall` callees
- Both the compiler `emitBarf` logic and the hand-written Cmm are
changed to call these wrappers
- `emitBarf` now also properly annotates the foreign call as
`CmmNeverReturns` to indicate it's a noreturn call to enable more
efficient code generation
`-dtag-inference-checks` now works on wasm. Closes #22882.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
b3dd23b9 by Vilim Lendvaj at 2025-12-18T13:23:57-05:00
Remove outdated comment
The Traversable instance for ZipList is no longer in
GHC.Internal.Data.Traversable. In fact, it is right below this very comment.
- - - - -
9a9c2f03 by Cheng Shao at 2025-12-18T13:24:39-05:00
compiler: remove unused OtherSection logic
This patch removes the OtherSection logic in Cmm, given it's never
actually used by any of our backends.
- - - - -
54f74e4b by Wolfgang Jeltsch at 2025-12-18T13:57:28-05:00
Remove unused known-key and name variables for generics
This removes the known-key and corresponding name variables for `K1`,
`M1`, `R`, `D`, `C`, `S`, and `URec` from `GHC.Generics`, as they are
apparently nowhere used in GHC’s source code.
- - - - -
e1e2adce by Wolfgang Jeltsch at 2025-12-18T13:57:30-05:00
Remove unused known keys and names for generics classes
This removes the known-key and corresponding name variables for
`Datatype`, `Constructor`, and `Selector` from `GHC.Generics`, as they
are apparently nowhere used in GHC’s source code.
- - - - -
d02245f6 by Cheng Shao at 2025-12-18T13:57:32-05:00
wasm: fix handling of ByteArray#/MutableByteArray# arguments in JSFFI imports
This patch fixes the handling of ByteArray#/MutableByteArray#
arguments in JSFFI imports, see the amended note and manual for
explanation. Also adds a test to witness the fix.
Co-authored-by: Codex <codex(a)openai.com>
- - - - -
125 changed files:
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Utils.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- compiler/GHC/CmmToAsm/LA64/Ppr.hs
- compiler/GHC/CmmToAsm/PPC/Ppr.hs
- compiler/GHC/CmmToAsm/Ppr.hs
- compiler/GHC/CmmToAsm/RV64/Ppr.hs
- compiler/GHC/CmmToAsm/Reg/Graph.hs
- compiler/GHC/CmmToAsm/Reg/Graph/Coalesce.hs
- compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs
- compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs
- compiler/GHC/CmmToAsm/Reg/Linear.hs
- compiler/GHC/CmmToAsm/Reg/Linear/Base.hs
- compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs
- compiler/GHC/CmmToAsm/Reg/Liveness.hs
- + compiler/GHC/CmmToAsm/Reg/Regs.hs
- compiler/GHC/CmmToAsm/Reg/Target.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm/Data.hs
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Foreign/Wasm.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Warnings.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/StgToCmm/Bind.hs
- compiler/GHC/StgToCmm/Utils.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Utils.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Types/DefaultEnv.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Unique/Set.hs
- compiler/GHC/Unit/Module/Warnings.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- compiler/Language/Haskell/Syntax/Extension.hs
- compiler/ghc.cabal.in
- docs/users_guide/phases.rst
- docs/users_guide/wasm.rst
- libraries/ghc-internal/src/GHC/Internal/Functor/ZipList.hs
- rts/Apply.cmm
- rts/Compact.cmm
- rts/ContinuationOps.cmm
- rts/Exception.cmm
- rts/Jumps.h
- rts/PrimOps.cmm
- rts/RtsMessages.c
- rts/StgMiscClosures.cmm
- rts/StgStartup.cmm
- rts/include/Stg.h
- rts/include/rts/Messages.h
- rts/prim/mulIntMayOflo.c
- testsuite/tests/diagnostic-codes/codes.stdout
- testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr
- testsuite/tests/jsffi/all.T
- + testsuite/tests/jsffi/bytearrayarg.hs
- + testsuite/tests/jsffi/bytearrayarg.mjs
- + testsuite/tests/jsffi/bytearrayarg.stdout
- testsuite/tests/numeric/should_run/all.T
- testsuite/tests/numeric/should_run/foundation.hs
- testsuite/tests/numeric/should_run/foundation.stdout
- testsuite/tests/patsyn/should_fail/all.T
- + testsuite/tests/patsyn/should_fail/import-syntax-no-ext.hs
- + testsuite/tests/patsyn/should_fail/import-syntax-no-ext.stderr
- testsuite/tests/perf/should_run/all.T
- + testsuite/tests/rename/should_compile/T25901_sub_e.hs
- + testsuite/tests/rename/should_compile/T25901_sub_f.hs
- + testsuite/tests/rename/should_compile/T25901_sub_f.stderr
- + testsuite/tests/rename/should_compile/T25901_sub_g.hs
- + testsuite/tests/rename/should_compile/T25901_sub_g.stderr
- + testsuite/tests/rename/should_compile/T25901_sub_g_helper.hs
- testsuite/tests/rename/should_compile/all.T
- testsuite/tests/rename/should_fail/T23570b.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_a.hs
- + testsuite/tests/rename/should_fail/T25901_sub_a.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_b.hs
- + testsuite/tests/rename/should_fail/T25901_sub_b.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_c.hs
- + testsuite/tests/rename/should_fail/T25901_sub_c.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_c_helper.hs
- + testsuite/tests/rename/should_fail/T25901_sub_d.hs
- + testsuite/tests/rename/should_fail/T25901_sub_d.stderr
- + testsuite/tests/rename/should_fail/T25901_sub_d_helper.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w.hs
- + testsuite/tests/rename/should_fail/T25901_sub_w.stderr
- testsuite/tests/rename/should_fail/all.T
- + testsuite/tests/simd/should_run/T26411.hs
- + testsuite/tests/simd/should_run/T26411.stdout
- + testsuite/tests/simd/should_run/T26411b.hs
- + testsuite/tests/simd/should_run/T26411b.stdout
- testsuite/tests/simd/should_run/all.T
- testsuite/tests/simplStg/should_compile/all.T
- testsuite/tests/warnings/should_compile/DodgyExports03.stderr
- testsuite/tests/warnings/should_compile/DodgyImports.stderr
- + testsuite/tests/warnings/should_compile/DodgyImports02.hs
- + testsuite/tests/warnings/should_compile/DodgyImports02.stderr
- + testsuite/tests/warnings/should_compile/DodgyImports03.hs
- + testsuite/tests/warnings/should_compile/DodgyImports03.stderr
- + testsuite/tests/warnings/should_compile/DodgyImports03_helper.hs
- + testsuite/tests/warnings/should_compile/DodgyImports04.hs
- + testsuite/tests/warnings/should_compile/DodgyImports04.stderr
- testsuite/tests/warnings/should_compile/DodgyImports_hiding.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
- utils/genapply/Main.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Create.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c8309bcf3f2a3faa31522c0eb0b08…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c8309bcf3f2a3faa31522c0eb0b08…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc] Pushed new branch wip/jeltsch/known-key-removals/type-representations
by Wolfgang Jeltsch (@jeltsch) 18 Dec '25
by Wolfgang Jeltsch (@jeltsch) 18 Dec '25
18 Dec '25
Wolfgang Jeltsch pushed new branch wip/jeltsch/known-key-removals/type-representations at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/jeltsch/known-key-removals/ty…
You're receiving this email because of your account on gitlab.haskell.org.
1
0