diff options
author | David Feuer <david.feuer@gmail.com> | 2017-05-19 18:09:43 -0400 |
---|---|---|
committer | David Feuer <David.Feuer@gmail.com> | 2017-05-19 18:09:44 -0400 |
commit | 40210c3637d7ac066e0d98c33612b57725708216 (patch) | |
tree | 8cd07f5f33d6ac8aa27375aa7c8e00de8d63f616 | |
parent | 4e0e120bcbda6c5351d7c5aa01f7298e2198d457 (diff) | |
download | haskell-40210c3637d7ac066e0d98c33612b57725708216.tar.gz |
Improve error msg for simplifier tick exhaustion
Simplifier tick exhaustion is not necessarily "impossible", and
isn't even always a GHC bug, per se. Improve the error message.
Furthermore, the simplifier code has access to `IO`, so we can
throw a proper `IO` exception instead of panicking.
Reviewers: austin, bgamari, angerman
Reviewed By: angerman
Subscribers: angerman, rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3597
-rw-r--r-- | compiler/simplCore/SimplMonad.hs | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/compiler/simplCore/SimplMonad.hs b/compiler/simplCore/SimplMonad.hs index 8f20637ed6..015ee5c786 100644 --- a/compiler/simplCore/SimplMonad.hs +++ b/compiler/simplCore/SimplMonad.hs @@ -33,6 +33,7 @@ import Outputable import FastString import MonadUtils import ErrUtils +import Panic (throwGhcExceptionIO, GhcException (..)) import BasicTypes ( IntWithInf, treatZeroAsInf, mkIntWithInf ) import Control.Monad ( when, liftM, ap ) @@ -211,16 +212,30 @@ tick t = SM (\st_env us sc -> let sc' = doSimplTick (st_flags st_env) t sc checkedTick :: Tick -> SimplM () -- Try to take a tick, but fail if too many checkedTick t - = SM (\st_env us sc -> if st_max_ticks st_env <= mkIntWithInf (simplCountN sc) - then pprPanic "Simplifier ticks exhausted" (msg sc) - else let sc' = doSimplTick (st_flags st_env) t sc - in sc' `seq` return ((), us, sc')) + = SM (\st_env us sc -> + if st_max_ticks st_env <= mkIntWithInf (simplCountN sc) + then throwGhcExceptionIO $ + PprProgramError "Simplifier ticks exhausted" (msg sc) + else let sc' = doSimplTick (st_flags st_env) t sc + in sc' `seq` return ((), us, sc')) where - msg sc = vcat [ text "When trying" <+> ppr t - , text "To increase the limit, use -fsimpl-tick-factor=N (default 100)" - , text "If you need to do this, let GHC HQ know, and what factor you needed" - , pp_details sc - , pprSimplCount sc ] + msg sc = vcat + [ text "When trying" <+> ppr t + , text "To increase the limit, use -fsimpl-tick-factor=N (default 100)." + , space + , text "If you need to increase the limit substantially, please file a" + , text "bug report and indicate the factor you needed." + , space + , text "If GHC was unable to complete compilation even" + <+> text "with a very large factor" + , text "(a thousand or more), please consult the" + <+> doubleQuotes (text "Known bugs or infelicities") + , text "section in the Users Guide before filing a report. There are a" + , text "few situations unlikely to occur in practical programs for which" + , text "simplifier non-termination has been judged acceptable." + , space + , pp_details sc + , pprSimplCount sc ] pp_details sc | hasDetailedCounts sc = empty | otherwise = text "To see detailed counts use -ddump-simpl-stats" |