summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorSebastian Graf <sgraf1337@gmail.com>2019-09-18 17:56:35 +0000
committerSebastian Graf <sgraf1337@gmail.com>2019-09-24 14:00:29 +0000
commit1922416f69edd55545a155c1d5abdb4b371e1612 (patch)
tree35b0168e6f89f2418b614af26777ba095e36668b /compiler/main
parent68ddb43c44065d0d3a8a6893f7f8e87f15ee9c1e (diff)
downloadhaskell-wip/pmcheck-limit-deltas.tar.gz
PmCheck: Only ever check constantly many models against a single patternwip/pmcheck-limit-deltas
Introduces a new flag `-fmax-pmcheck-deltas` to achieve that. Deprecates the old `-fmax-pmcheck-iter` mechanism in favor of this new flag. From the user's guide: Pattern match checking can be exponential in some cases. This limit makes sure we scale polynomially in the number of patterns, by forgetting refined information gained from a partially successful match. For example, when matching `x` against `Just 4`, we split each incoming matching model into two sub-models: One where `x` is not `Nothing` and one where `x` is `Just y` but `y` is not `4`. When the number of incoming models exceeds the limit, we continue checking the next clause with the original, unrefined model. This also retires the incredibly hard to understand "maximum number of refinements" mechanism, because the current mechanism is more general and should catch the same exponential cases like PrelRules at the same time. ------------------------- Metric Decrease: T11822 -------------------------
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/DynFlags.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index c2d0322cd9..b2c927fffb 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -974,7 +974,6 @@ data DynFlags = DynFlags {
debugLevel :: Int, -- ^ How much debug information to produce
simplPhases :: Int, -- ^ Number of simplifier phases
maxSimplIterations :: Int, -- ^ Max simplifier iterations
- maxPmCheckIterations :: Int, -- ^ Max no iterations for pm checking
ruleCheck :: Maybe String,
inlineCheck :: Maybe String, -- ^ A prefix to report inlining decisions about
strictnessBefore :: [Int], -- ^ Additional demand analysis
@@ -998,6 +997,10 @@ data DynFlags = DynFlags {
-- error messages
maxUncoveredPatterns :: Int, -- ^ Maximum number of unmatched patterns to show
-- in non-exhaustiveness warnings
+ maxPmCheckModels :: Int, -- ^ Soft limit on the number of models
+ -- the pattern match checker checks
+ -- a pattern against. A safe guard
+ -- against exponential blow-up.
simplTickFactor :: Int, -- ^ Multiplier for simplifier ticks
specConstrThreshold :: Maybe Int, -- ^ Threshold for SpecConstr
specConstrCount :: Maybe Int, -- ^ Max number of specialisations for any one function
@@ -1926,7 +1929,6 @@ defaultDynFlags mySettings (myLlvmTargets, myLlvmPasses) =
debugLevel = 0,
simplPhases = 2,
maxSimplIterations = 4,
- maxPmCheckIterations = 2000000,
ruleCheck = Nothing,
inlineCheck = Nothing,
binBlobThreshold = 500000, -- 500K is a good default (see #16190)
@@ -1935,6 +1937,7 @@ defaultDynFlags mySettings (myLlvmTargets, myLlvmPasses) =
maxRefHoleFits = Just 6,
refLevelHoleFits = Nothing,
maxUncoveredPatterns = 4,
+ maxPmCheckModels = 100,
simplTickFactor = 100,
specConstrThreshold = Just 2000,
specConstrCount = Just 3,
@@ -3599,12 +3602,16 @@ dynamic_flags_deps = [
"vectors registers are now passed in registers by default."
, make_ord_flag defFlag "fmax-uncovered-patterns"
(intSuffix (\n d -> d { maxUncoveredPatterns = n }))
+ , make_ord_flag defFlag "fmax-pmcheck-models"
+ (intSuffix (\n d -> d { maxPmCheckModels = n }))
, make_ord_flag defFlag "fsimplifier-phases"
(intSuffix (\n d -> d { simplPhases = n }))
, make_ord_flag defFlag "fmax-simplifier-iterations"
(intSuffix (\n d -> d { maxSimplIterations = n }))
- , make_ord_flag defFlag "fmax-pmcheck-iterations"
- (intSuffix (\n d -> d{ maxPmCheckIterations = n }))
+ , (Deprecated, defFlag "fmax-pmcheck-iterations"
+ (intSuffixM (\_ d ->
+ do { deprecate $ "use -fmax-pmcheck-models instead"
+ ; return d })))
, make_ord_flag defFlag "fsimpl-tick-factor"
(intSuffix (\n d -> d { simplTickFactor = n }))
, make_ord_flag defFlag "fspec-constr-threshold"