Commit f766da17 authored by simonpj@microsoft.com's avatar simonpj@microsoft.com

Make SpecConstr more informative output when there are too many specialisations

It now says something like

  SpecConstr
    Function `happyDoAction'
      has 17 call pattterns, but the limit is 3
    Use -fspec-constr-count=n to set the bound
    Use -dppr-debug to see specialisations

Previously it just silently did no specialisation
parent c75d5fc8
......@@ -1097,20 +1097,24 @@ specialise env force_spec bind_calls (fn, arg_bndrs, body, arg_occs)
, notNull arg_bndrs -- Only specialise functions
, Just all_calls <- lookupVarEnv bind_calls fn
= do { (boring_call, pats) <- callsToPats env specs arg_occs all_calls
-- ; pprTrace "specialise" (vcat [ppr fn <+> ppr arg_occs,
-- text "calls" <+> ppr all_calls,
-- text "good pats" <+> ppr pats]) $
-- ; pprTrace "specialise" (vcat [ ppr fn <+> text "with" <+> int (length pats) <+> text "good patterns"
-- , text "arg_occs" <+> ppr arg_occs,
-- , text "calls" <+> ppr all_calls,
-- , text "good pats" <+> ppr pats]) $
-- return ()
-- Bale out if too many specialisations
-- Rather a hacky way to do so, but it'll do for now
; let spec_count' = length pats + spec_count
; let n_pats = length pats
spec_count' = length pats + spec_count
; case sc_count env of
Just max | not force_spec && spec_count' > max
-> WARN( True, msg ) return (nullUsage, spec_info)
-> pprTrace "SpecConstr" msg $
return (nullUsage, spec_info)
where
msg = vcat [ sep [ ptext (sLit "SpecConstr: specialisation of") <+> quotes (ppr fn)
, nest 2 (ptext (sLit "limited by bound of")) <+> int max ]
msg = vcat [ sep [ ptext (sLit "Function") <+> quotes (ppr fn)
, nest 2 (ptext (sLit "has") <+> int n_pats <+>
ptext (sLit "call pattterns, but the limit is") <+> int max) ]
, ptext (sLit "Use -fspec-constr-count=n to set the bound")
, extra ]
extra | not opt_PprStyle_Debug = ptext (sLit "Use -dppr-debug to see specialisations")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment