Simon Jakobi pushed to branch wip/sjakobi/T27628-rebox-warning at Glasgow Haskell Compiler / GHC Commits: 83433a7d by Simon Jakobi at 2026-08-24T09:59:37+02:00 Tighten the reboxing warning's fact column, fix "user's guide" The value column was still aligned for a longer label from an earlier draft of the fact block. Its longest label is now "call patterns:", so move the column from 23 to 16, which also lets previously wrapped "-- reboxes" tags fit on one line. Assisted-by: Claude Fable 5 - - - - - 634390dc by Simon Jakobi at 2026-08-24T17:34:52+02:00 Add the mrs field to the changelog entry !7 is the draft MR on my fork (https://gitlab.haskell.org/sjakobi/ghc/-/merge_requests/7). The number needs updating when the ghc/ghc MR exists. Assisted-by: Claude Fable 5 - - - - - 1ec581aa by Simon Jakobi at 2026-08-24T18:14:23+02:00 Show each specialisation's signature in reboxing warnings To assess the damage behind a reboxing warning, the reader wants to inspect the specialisation in a Core dump, but the warning offered no way to find it there: the spec's final name is invented during tidying, and the "SC:" rules don't survive to the dump when the original binder is local. What is stable is the spec binder's occurrence name and type at creation, so each call pattern now shows the signature of the specialisation made for it: call patterns: go (A _) (I# _) -- reboxes ‘A’ -- as ‘$sgo :: Int -> GHC.Internal.Prim.Int# -> Int’ The patterns block now hangs below its label, freeing width for the types, and the fact column tightens accordingly. Caveats of the signature as a pointer — the occurrence name is a substring of the tidied name, and a spec can be renamed by late worker/wrapper, inlined, or merged — are in the amended Note [Reboxing warning]. Part of #27628. Assisted-by: Claude Fable 5 - - - - - 15d14c01 by Simon Jakobi at 2026-08-24T22:07:26+02:00 docs: List -fspec-constr-threshold among the reboxing remedies A per-module threshold below the offending function's body size is the remedy 556db2f32f5 used for the reboxing in GHC.Tc.Solver.Rewrite, but the -Wspec-constr-reboxing docs did not mention it. Part of #27628. Assisted-by: Claude Fable 5 - - - - - ba495af1 by Simon Jakobi at 2026-08-24T22:28:02+02:00 Don't double-qualify constructors in reboxing warnings The warning prefixes imported constructors with their defining module, but printed the constructor with plain ppr, which the ambient qual policy qualifies too when the name is not in unqualified scope: "T27628h_M.M.Bin", or "GHC.Internal.Types.GHC.Internal.Types.I#" for the wired-in I#. Print just the OccName after the manual prefix. The existing tests all had the constructor in unqualified scope, where the ambient policy adds nothing, so the doubling never showed. T27628m imports the defining module qualified to pin the fixed rendering. Context: #27628 Assisted-by: Claude Fable 5 - - - - - 15 changed files: - changelog.d/27628 - compiler/GHC/Core/Opt/SpecConstr.hs - docs/users_guide/using-warnings.rst - testsuite/tests/simplCore/should_compile/T27628.stderr - testsuite/tests/simplCore/should_compile/T27628b.stderr - testsuite/tests/simplCore/should_compile/T27628f.stderr - testsuite/tests/simplCore/should_compile/T27628g.stderr - testsuite/tests/simplCore/should_compile/T27628h.stderr - testsuite/tests/simplCore/should_compile/T27628i.stderr - testsuite/tests/simplCore/should_compile/T27628j.stderr - testsuite/tests/simplCore/should_compile/T27628k.stderr - testsuite/tests/simplCore/should_compile/T27628l.stderr - + testsuite/tests/simplCore/should_compile/T27628m.hs - + testsuite/tests/simplCore/should_compile/T27628m.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== changelog.d/27628 ===================================== @@ -7,3 +7,4 @@ description: re-allocates the constructor ("reboxing"). Reboxing can increase allocation and defeat sharing schemes based on pointer equality. issues: #27628 +mrs: !7 ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -827,9 +827,9 @@ specConstrProgram guts -- Merge warnings that would render identically: same occurrence -- name, type, parent, displayed location, recursivity, and - -- patterns. The reader could not tell them apart, so printing - -- both is noise; see Note [Reboxing warning]. Callers are - -- aggregated, not compared. + -- patterns (with their spec signatures). The reader could not + -- tell them apart, so printing both is noise; see + -- Note [Reboxing warning]. Callers are aggregated, not compared. same_render (SpecReboxed fn1 ty1 p1 r1 pats1 _) (SpecReboxed fn2 ty2 p2 r2 pats2 _) = getOccName fn1 == getOccName fn2 && p1 == p2 && nameSrcSpan (rebox_loc_name fn1 p1) == nameSrcSpan (rebox_loc_name fn2 p2) @@ -840,7 +840,11 @@ specConstrProgram guts (sortBy cmpReboxedPat pats2)) same_render _ _ = False - same_pat p1 p2 = cmpReboxedPat p1 p2 == EQ + -- Spec signatures of merge candidates are alpha-equivalent copies, + -- so eqType; a mismatch just leaves two warnings unmerged + same_pat p1@(ReboxedPat _ _ occ1 sty1) p2@(ReboxedPat _ _ occ2 sty2) + = cmpReboxedPat p1 p2 == EQ + && occ1 == occ2 && sty1 `eqType` sty2 -- Recursivity as displayed: siblings compare by occurrence name, -- so span-less copies of one mutual group still merge @@ -863,25 +867,25 @@ specConstrProgram guts rebox_msg w@(SpecFailForcedArgCount {}) = pprPanic "rebox_msg" (ppr w) rebox_msg (SpecReboxed fn ty mb_parent recur pats callers) = vcat [ hang (text "SpecConstr specialised") 2 - (quotes (ppr fn <+> dcolon <+> pp_ty)) + (quotes (ppr fn <+> dcolon <+> pp_ty ty)) , nest 2 $ vcat $ catMaybes [ Just (fact "source:" pp_source) , Just (fact "recursivity:" pp_recur) , fact "called from:" <$> pp_callers - , Just (fact pats_label pp_pats) ] + , Just (text pats_label $$ nest 2 pp_pats) ] , pp_trailer - , text "See -Wspec-constr-reboxing in the users guide for possible remedies." ] + , text "See -Wspec-constr-reboxing in the user's guide for possible remedies." ] where -- Aligned label column; $$ overlaps, so a multi-line value keeps -- its lines aligned under the first - fact l v = text l $$ nest 23 v + fact l v = text l $$ nest 14 v -- Truncate only pathologically large types - pp_ty = sdocWithContext $ \ctx -> - case splitAt 10000 (showSDocOneLine ctx pp_tidy) of - (_, []) -> pp_tidy - (prefix, _) -> text prefix <> text "..." - where pp_tidy = pprSigmaType (tidyTopType ty) + pp_ty t = sdocWithContext $ \ctx -> + case splitAt 10000 (showSDocOneLine ctx pp_tidy) of + (_, []) -> pp_tidy + (prefix, _) -> text prefix <> text "..." + where pp_tidy = pprSigmaType (tidyTopType t) -- pprSigmaType: suppress the printed forall -- A name with no source span reached this module in an interface @@ -920,19 +924,25 @@ specConstrProgram guts pp_pats = vcat (map pp_pat (sortBy cmpReboxedPat pats)) - pp_pat (ReboxedPat shapes cons) - = hang (hang (ppr fn) 2 (fsep (map pprPatShape shapes))) 2 - (text "-- reboxes" <+> - pprWithCommas pp_con (sortBy stableNameCmp cons)) + -- "-- reboxes" and "-- as" have equal width, aligning the + -- payloads; a wrapping signature continues under the type's start + pp_pat (ReboxedPat shapes cons spec_occ spec_ty) + = hang (hang (ppr fn) 2 (fsep (map pprPatShape shapes))) 2 $ vcat + [ text "-- reboxes" <+> + pprWithCommas pp_con (sortBy stableNameCmp cons) + , text "-- as" <+> + quotes (ppr spec_occ <+> dcolon <+> pp_ty spec_ty) ] -- Qualify imported constructors: they identify the package to - -- follow up with when the function itself has no location + -- follow up with when the function itself has no location. + -- OccName only: the ambient qual policy may qualify 'ppr con' too, + -- doubling the prefix pp_con con | Just m <- nameModule_maybe con, m /= mg_module guts - = quotes (ppr m <> dot <> ppr con) + = quotes (ppr m <> dot <> ppr (getOccName con)) | otherwise = quotes (ppr con) - all_cons = nub [ con | ReboxedPat _ cons <- pats, con <- cons ] + all_cons = nub [ con | ReboxedPat _ cons _ _ <- pats, con <- cons ] pp_trailer = fsep $ map text $ words $ case all_cons of [_] -> "This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing." @@ -1583,15 +1593,40 @@ that decision bites, without changing which specialisations are made: -Wspec-constr-reboxing (off by default). * One warning per function, listing each call pattern the function was - specialised for — the constructor skeletons of the call's arguments, - e.g. `go (_ : _) (BMap _) -- reboxes ‘BMap’` — alongside that - pattern's reboxed constructors. The shapes show where in the - argument each reboxed constructor sits, and picture what SpecConstr - did: it made a copy of + specialised for — the constructor skeletons of the call's arguments — + together with that pattern's reboxed constructors and the signature of + the specialisation made for it: + + call patterns: + go (_ : _) (BMap _) + -- reboxes ‘BMap’ + -- as ‘$sgo :: Int -> Map Int Bool -> Bool’ + + The shapes show where in the argument each reboxed constructor sits, + and picture what SpecConstr did: it made a copy of the function for calls of exactly that shape. The warning also shows the function's type: names like `go1` say nothing, and for span-less functions (last bullet below) the type is the main identifying clue. +* The spec signature lets the reader find the specialisation in a Core + dump and assess the reboxing there. (The "SC:" RULEs are no pointer: + they are attached to the *original* binder, and for a local original — + the common inlined-library-loop case — Core Tidy drops them.) Both + parts of the signature are approximate: + + - The name is the spec's occurrence name at creation ($s<fn>); tidying + can prefix the parent and suffix a digit (`$sgo` may end up as + `go_$sgo1`), so it is a substring of the final name. + + - The type is the spec binder's type at creation. It normally survives + to the final program — the default pipeline runs no worker/wrapper + after SpecConstr — but under -flate-dmd-anal the spec can reappear as + a `$w$s<fn>` worker with a different type. + + - A listed spec can still be inlined or CSE'd away, and the specs for + different patterns can collapse into one, so the signatures are + advice, not a 1-1 contract with the final program. + "Per function" means per (parent, function) *pair*: the function's Name alone is ambiguous, because distinct top-level bindings can bind distinct locals that share a unique. That happens when several @@ -2217,12 +2252,6 @@ specialise env recur bind_calls (RI { ri_fn = fn, ri_lam_bndrs = arg_bndrs <- callsToNewPats env fn spec_info arg_occs all_calls ; let n_pats = length new_pats - -- Warn about committed specialisations that will rebox; - -- see Note [Reboxing warning] - rebox_ws = [ SpecReboxed (idName fn) (idType fn) (sc_top_fn env) - recur [ReboxedPat (patShapes p) (cp_rebox p)] - (cp_callers p) - | p <- new_pats, not (null (cp_rebox p)) ] -- ; when (not (null new_pats) || isJust mb_unspec) $ -- pprTraceM "specialise" (vcat [ ppr fn <+> text "with" <+> int n_pats <+> text "good patterns" -- , text "boring_call:" <+> ppr boring_call @@ -2242,6 +2271,17 @@ specialise env recur bind_calls (RI { ri_fn = fn, ri_lam_bndrs = arg_bndrs ; let spec_usg = combineUsages spec_usgs + -- Warn about committed specialisations that will rebox, + -- naming the specialisation just made for each pattern + -- (new_specs is 1-1 with new_pats); see Note [Reboxing warning] + rebox_ws = [ SpecReboxed (idName fn) (idType fn) (sc_top_fn env) + recur + [ReboxedPat (patShapes p) (cp_rebox p) + (getOccName spec_id) (idType spec_id)] + (cp_callers p) + | (p, OS { os_id = spec_id }) <- new_pats `zip` new_specs + , not (null (cp_rebox p)) ] + unspec_rhs_needed = pats_discarded || boring_call || isExportedId fn -- If there were any boring calls among the seeds (= all_calls), then those @@ -2804,9 +2844,10 @@ instance Outputable CallPat where , text "cp_callers = " <> ppr callers ]) -- | One call pattern as displayed by the reboxing warning: the shapes of --- the pattern's arguments, and the reboxed constructors among them. +-- the pattern's arguments, the reboxed constructors among them, and the +-- occurrence name and type of the specialisation made for the pattern. -- See Note [Reboxing warning] -data ReboxedPat = ReboxedPat [PatShape] [Name] +data ReboxedPat = ReboxedPat [PatShape] [Name] OccName Type -- | The constructor skeleton of one call-pattern argument, as displayed -- by the reboxing warning @@ -2830,10 +2871,12 @@ patShapes (CP { cp_args = args }) = mapMaybe arg_shape args | otherwise = Just ShapeWild --- | Stable comparison, used both to merge identically-rendering warnings --- and to order a warning's patterns deterministically +-- | Stable comparison on the shapes and constructors, used to order a +-- warning's patterns deterministically. The merge equality additionally +-- compares the spec signatures (Type has no stable Ordering); see +-- same_pat in specConstrProgram. cmpReboxedPat :: ReboxedPat -> ReboxedPat -> Ordering -cmpReboxedPat (ReboxedPat ss1 cs1) (ReboxedPat ss2 cs2) +cmpReboxedPat (ReboxedPat ss1 cs1 _ _) (ReboxedPat ss2 cs2 _ _) = cmpListBy cmpShape ss1 ss2 `mappend` cmpListBy stableNameCmp (sortBy stableNameCmp cs1) (sortBy stableNameCmp cs2) @@ -2902,7 +2945,7 @@ instance Outputable SpecConstrWarning where ppr (SpecReboxed fn _ty mb_parent _recur pats _callers) = ppr fn <+> parens (pprWithCommas ppr dcs) <+> pp_defn where - dcs = [ dc | ReboxedPat _ cons <- pats, dc <- cons ] + dcs = [ dc | ReboxedPat _ cons _ _ <- pats, dc <- cons ] -- A local fn often has no useful location; point at its -- enclosing top-level binder instead pp_defn = case mb_parent of ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -532,7 +532,9 @@ of ``-W(no-)*``. Possible remedies include excluding the type from SpecConstr with an ``{-# ANN type T NoSpecConstr #-}`` pragma, hiding the constructor from the call-pattern analysis by wrapping the argument in ``GHC.Exts.lazy`` - at the call site, or :ghc-flag:`-fno-spec-constr`. + at the call site, lowering :ghc-flag:`-fspec-constr-threshold=⟨n⟩` in + the affected module below the function's body size, or + :ghc-flag:`-fno-spec-constr`. The warning shows the specialised function's type, which is often the clearest clue to its identity when its name carries no meaning, @@ -545,13 +547,31 @@ of ``-W(no-)*``. ``called from:`` — the top-level bindings containing the specialised calls; ``call patterns:`` — the calls the function was specialised for, shown as the constructor skeletons of their arguments, each - alongside the constructors that the specialisation reboxes (for - example ``go (_ : _) (Bin _ _ _) -- reboxes ‘Bin’``). One warning is emitted per + followed by the constructors that the specialisation reboxes and by + the name and type the specialisation was created with:: + + call patterns: + go (_ : _) (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$sgo :: Int -> Int -> Map Int Bool -> Bool’ + + One warning is emitted per specialised function, and warnings that would read identically are merged into one. Specialisations on nullary constructors are not reported, since "reboxing" a nullary constructor simply references its shared static closure. + The ``as`` signature is a guide for finding the specialisation in a + Core dump (:ghc-flag:`-ddump-simpl`), for example to judge how much + reboxing survives optimisation. Later passes may rename the binder — + typically to ``<parent>_$s<function>``, possibly with a digit appended + — so search for the shown name as a substring; the type normally + survives unchanged. A specialisation can also be inlined, or merged + with another one, and then appears in no dump. The calls rewritten to + use specialisations can be traced with + :ghc-flag:`-ddump-rule-firings`; the rewrite rules are named + ``SC:<function><n>``. + A ``source:`` reading ``inlined from another module (no source location)`` concerns a function that reached the module being compiled through another module's unfolding; interface files record no source ===================================== testsuite/tests/simplCore/should_compile/T27628.stderr ===================================== @@ -4,11 +4,18 @@ T27628.hs: warning: [-Wspec-constr-reboxing] -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Int#’ - source: T27628.hs:17:1 - recursivity: self-recursive - called from: ‘f’ - call pattern: $wgo (LC _ _) -- reboxes ‘LC’ + source: T27628.hs:17:1 + recursivity: self-recursive + called from: ‘f’ + call pattern: + $wgo (LC _ _) + -- reboxes ‘LC’ + -- as ‘$s$wgo :: Int + -> Int + -> GHC.Internal.Prim.Int# + -> GHC.Internal.Prim.Int# + -> GHC.Internal.Prim.Int#’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628b.stderr ===================================== @@ -1,10 +1,13 @@ T27628b.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘merge :: T -> T -> T’ - source: T27628b.hs:10:1 - recursivity: self-recursive - called from: ‘f’ - call pattern: merge (Bin _ _ _) -- reboxes ‘Bin’ + source: T27628b.hs:10:1 + recursivity: self-recursive + called from: ‘f’ + call pattern: + merge (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$smerge :: Int -> T -> T -> T -> T’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628f.stderr ===================================== @@ -1,10 +1,13 @@ T27628f.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘merge :: T -> T -> T’ - source: ‘f’ at T27628f.hs:12:5 - recursivity: self-recursive - called from: ‘f’ - call pattern: merge (Bin _ _ _) -- reboxes ‘Bin’ + source: ‘f’ at T27628f.hs:12:5 + recursivity: self-recursive + called from: ‘f’ + call pattern: + merge (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$smerge :: Int -> T -> T -> T -> T’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628g.stderr ===================================== @@ -1,10 +1,13 @@ T27628g.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘poly_merge :: T a -> T a -> T a’ - source: T27628g.hs:11:5 - recursivity: self-recursive - called from: ‘f’ - call pattern: poly_merge (Bin _ _ _) -- reboxes ‘Bin’ + source: T27628g.hs:11:5 + recursivity: self-recursive + called from: ‘f’ + call pattern: + poly_merge (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$spoly_merge :: a -> T a -> T a -> T a -> T a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628h.stderr ===================================== @@ -1,20 +1,26 @@ ./T27628h_M.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘poly_merge :: T a -> T a -> T a’ - source: T27628h_M.hs:11:5 - recursivity: self-recursive - called from: ‘f’ - call pattern: poly_merge (Bin _ _ _) -- reboxes ‘Bin’ + source: T27628h_M.hs:11:5 + recursivity: self-recursive + called from: ‘f’ + call pattern: + poly_merge (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$spoly_merge :: a -> T a -> T a -> T a -> T a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628h.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘merge :: T Int -> T Int -> T Int’ - source: inlined from another module (no source location) - recursivity: self-recursive - called from: ‘g’ - call pattern: merge (Bin _ _ _) -- reboxes ‘T27628h_M.Bin’ + source: inlined from another module (no source location) + recursivity: self-recursive + called from: ‘g’ + call pattern: + merge (Bin _ _ _) + -- reboxes ‘T27628h_M.Bin’ + -- as ‘$smerge :: Int -> T Int -> T Int -> T Int -> T Int’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628i.stderr ===================================== @@ -1,51 +1,65 @@ ./T27628i_M.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘poly_merge :: T a -> T a -> T a’ - source: T27628i_M.hs:36:5 - recursivity: self-recursive - called from: ‘f3’ - call pattern: poly_merge (Bin _ _ _) -- reboxes ‘Bin’ + source: T27628i_M.hs:36:5 + recursivity: self-recursive + called from: ‘f3’ + call pattern: + poly_merge (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$spoly_merge :: a -> T a -> T a -> T a -> T a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ./T27628i_M.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘poly_merge :: S a -> S a -> S a’ - source: T27628i_M.hs:24:5 - recursivity: self-recursive - called from: ‘f2’ - call pattern: poly_merge (Node _ _ _) -- reboxes ‘Node’ + source: T27628i_M.hs:24:5 + recursivity: self-recursive + called from: ‘f2’ + call pattern: + poly_merge (Node _ _ _) + -- reboxes ‘Node’ + -- as ‘$spoly_merge :: a -> S a -> S a -> S a -> S a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ./T27628i_M.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘poly_merge :: T a -> T a -> T a’ - source: T27628i_M.hs:14:5 - recursivity: self-recursive - called from: ‘f1’ - call pattern: poly_merge (Bin _ _ _) -- reboxes ‘Bin’ + source: T27628i_M.hs:14:5 + recursivity: self-recursive + called from: ‘f1’ + call pattern: + poly_merge (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$spoly_merge :: a -> T a -> T a -> T a -> T a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628i.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘merge :: T Int -> T Int -> T Int’ - source: inlined from another module (no source location) - recursivity: self-recursive - called from: ‘g1’, ‘g3’ - call pattern: merge (Bin _ _ _) -- reboxes ‘T27628i_M.Bin’ + source: inlined from another module (no source location) + recursivity: self-recursive + called from: ‘g1’, ‘g3’ + call pattern: + merge (Bin _ _ _) + -- reboxes ‘T27628i_M.Bin’ + -- as ‘$smerge :: Int -> T Int -> T Int -> T Int -> T Int’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628i.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘merge :: S Int -> S Int -> S Int’ - source: inlined from another module (no source location) - recursivity: self-recursive - called from: ‘g2’ - call pattern: merge (Node _ _ _) - -- reboxes ‘T27628i_M.Node’ + source: inlined from another module (no source location) + recursivity: self-recursive + called from: ‘g2’ + call pattern: + merge (Node _ _ _) + -- reboxes ‘T27628i_M.Node’ + -- as ‘$smerge :: Int -> S Int -> S Int -> S Int -> S Int’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628j.stderr ===================================== @@ -1,10 +1,13 @@ T27628j.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘mergeB :: T -> T -> T’ - source: T27628j.hs:17:1 - recursivity: mutually recursive with ‘mergeA’ - called from: ‘g’ - call pattern: mergeB (Bin _ _ _) -- reboxes ‘Bin’ + source: T27628j.hs:17:1 + recursivity: mutually recursive with ‘mergeA’ + called from: ‘g’ + call pattern: + mergeB (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$smergeB :: Int -> T -> T -> T -> T’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628k.stderr ===================================== @@ -1,11 +1,16 @@ T27628k.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘go :: T -> Int -> Int’ - source: T27628k.hs:17:1 - recursivity: self-recursive - call patterns: go (A _) (I# _) -- reboxes ‘A’ - go (B _) (I# _) -- reboxes ‘B’ + source: T27628k.hs:17:1 + recursivity: self-recursive + call patterns: + go (A _) (I# _) + -- reboxes ‘A’ + -- as ‘$sgo :: Int -> GHC.Internal.Prim.Int# -> Int’ + go (B _) (I# _) + -- reboxes ‘B’ + -- as ‘$sgo :: Int -> GHC.Internal.Prim.Int# -> Int’ These constructor arguments are also used boxed, so the specialisations may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628l.stderr ===================================== @@ -1,66 +1,78 @@ T27628l.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘go1 :: [Max a] -> Max a -> Max a’ - source: ‘$cmconcat’ at T27628l.hs:22:5 - recursivity: self-recursive - called from: ‘$cmconcat’ - call pattern: go1 _ (Just _) - -- reboxes ‘GHC.Internal.Maybe.Just’ + source: ‘$cmconcat’ at T27628l.hs:22:5 + recursivity: self-recursive + called from: ‘$cmconcat’ + call pattern: + go1 _ (Just _) + -- reboxes ‘GHC.Internal.Maybe.Just’ + -- as ‘$sgo1 :: [Max a] -> a -> Max a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628l.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘exit :: Max a -> b -> Max a’ - source: ‘$cstimes’ at T27628l.hs:12:10 - recursivity: non-recursive (a join point) - called from: ‘$cstimes’ - call pattern: exit (Just _) _ - -- reboxes ‘GHC.Internal.Maybe.Just’ + source: ‘$cstimes’ at T27628l.hs:12:10 + recursivity: non-recursive (a join point) + called from: ‘$cstimes’ + call pattern: + exit (Just _) _ + -- reboxes ‘GHC.Internal.Maybe.Just’ + -- as ‘$sexit :: a -> b -> Max a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628l.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘g :: Max a -> b -> Max a -> Max a’ - source: ‘$cstimes’ at T27628l.hs:12:10 - recursivity: self-recursive - called from: ‘$cstimes’ - call pattern: g (Just _) _ _ - -- reboxes ‘GHC.Internal.Maybe.Just’ + source: ‘$cstimes’ at T27628l.hs:12:10 + recursivity: self-recursive + called from: ‘$cstimes’ + call pattern: + g (Just _) _ _ + -- reboxes ‘GHC.Internal.Maybe.Just’ + -- as ‘$sg :: a -> b -> Max a -> Max a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628l.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘go1 :: [Min a] -> Min a -> Min a’ - source: ‘$cmconcat’ at T27628l.hs:37:5 - recursivity: self-recursive - called from: ‘$cmconcat’ - call pattern: go1 _ (Just _) - -- reboxes ‘GHC.Internal.Maybe.Just’ + source: ‘$cmconcat’ at T27628l.hs:37:5 + recursivity: self-recursive + called from: ‘$cmconcat’ + call pattern: + go1 _ (Just _) + -- reboxes ‘GHC.Internal.Maybe.Just’ + -- as ‘$sgo1 :: [Min a] -> a -> Min a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628l.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘exit :: Min a -> b -> Min a’ - source: ‘$cstimes’ at T27628l.hs:27:10 - recursivity: non-recursive (a join point) - called from: ‘$cstimes’ - call pattern: exit (Just _) _ - -- reboxes ‘GHC.Internal.Maybe.Just’ + source: ‘$cstimes’ at T27628l.hs:27:10 + recursivity: non-recursive (a join point) + called from: ‘$cstimes’ + call pattern: + exit (Just _) _ + -- reboxes ‘GHC.Internal.Maybe.Just’ + -- as ‘$sexit :: a -> b -> Min a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. T27628l.hs: warning: [-Wspec-constr-reboxing] SpecConstr specialised ‘g :: Min a -> b -> Min a -> Min a’ - source: ‘$cstimes’ at T27628l.hs:27:10 - recursivity: self-recursive - called from: ‘$cstimes’ - call pattern: g (Just _) _ _ - -- reboxes ‘GHC.Internal.Maybe.Just’ + source: ‘$cstimes’ at T27628l.hs:27:10 + recursivity: self-recursive + called from: ‘$cstimes’ + call pattern: + g (Just _) _ _ + -- reboxes ‘GHC.Internal.Maybe.Just’ + -- as ‘$sg :: a -> b -> Min a -> Min a’ This constructor argument is also used boxed, so the specialisation may increase allocation and defeat pointer-equality-based sharing. - See -Wspec-constr-reboxing in the users guide for possible remedies. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/T27628m.hs ===================================== @@ -0,0 +1,10 @@ +-- Like T27628h, but the constructor is in scope only qualified (M.Bin), +-- so the ambient qual policy qualifies it in the warning. The warning's +-- own module prefix must not stack on top: expect ‘T27628h_M.Bin’, not +-- ‘T27628h_M.M.Bin’. +module T27628m where + +import qualified T27628h_M as M + +g :: Int -> M.T Int -> M.T Int +g x t = M.f x (M.f x t) ===================================== testsuite/tests/simplCore/should_compile/T27628m.stderr ===================================== @@ -0,0 +1,26 @@ +./T27628h_M.hs: warning: [-Wspec-constr-reboxing] + SpecConstr specialised ‘poly_merge :: T a -> T a -> T a’ + source: T27628h_M.hs:11:5 + recursivity: self-recursive + called from: ‘f’ + call pattern: + poly_merge (Bin _ _ _) + -- reboxes ‘Bin’ + -- as ‘$spoly_merge :: a -> T a -> T a -> T a -> T a’ + This constructor argument is also used boxed, so the specialisation + may increase allocation and defeat pointer-equality-based sharing. + See -Wspec-constr-reboxing in the user's guide for possible remedies. + +T27628m.hs: warning: [-Wspec-constr-reboxing] + SpecConstr specialised ‘merge :: M.T Int -> M.T Int -> M.T Int’ + source: inlined from another module (no source location) + recursivity: self-recursive + called from: ‘g’ + call pattern: + merge (Bin _ _ _) + -- reboxes ‘T27628h_M.Bin’ + -- as ‘$smerge :: Int + -> M.T Int -> M.T Int -> M.T Int -> M.T Int’ + This constructor argument is also used boxed, so the specialisation + may increase allocation and defeat pointer-equality-based sharing. + See -Wspec-constr-reboxing in the user's guide for possible remedies. ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -625,3 +625,4 @@ test('T27628i', [extra_files(['T27628i_M.hs'])], multimod_compile, ['T27628i', ' test('T27628j', normal, compile, ['-O2 -Wspec-constr-reboxing']) test('T27628k', normal, compile, ['-O2 -Wspec-constr-reboxing']) test('T27628l', normal, compile, ['-O2 -Wspec-constr-reboxing -dsuppress-uniques']) +test('T27628m', [extra_files(['T27628h_M.hs'])], multimod_compile, ['T27628m', '-v0 -O2 -Wspec-constr-reboxing -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/147702b050c6af5394f49026d4621c1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/147702b050c6af5394f49026d4621c1... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help