From 538cf5105b079fa779b612c6154db2bb4febb586 Mon Sep 17 00:00:00 2001 From: simonpj Date: Wed, 25 Jun 2003 08:20:22 +0000 Subject: [PATCH] [project @ 2003-06-25 08:20:20 by simonpj] * Remove -ffoldr-build-on Add -rrules-off Document the change * Document -fwarn-simple-patterns more --- ghc/compiler/deSugar/DsListComp.lhs | 13 +++++++++---- ghc/compiler/main/CmdLineOpts.lhs | 9 +++------ ghc/compiler/main/DriverState.hs | 3 +-- ghc/compiler/simplCore/SimplMonad.lhs | 4 +++- ghc/docs/users_guide/flags.sgml | 6 +++--- ghc/docs/users_guide/using.sgml | 14 ++++++++++++++ 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/ghc/compiler/deSugar/DsListComp.lhs b/ghc/compiler/deSugar/DsListComp.lhs index e9c455d..713d026 100644 --- a/ghc/compiler/deSugar/DsListComp.lhs +++ b/ghc/compiler/deSugar/DsListComp.lhs @@ -22,7 +22,7 @@ import CoreSyn import DsMonad -- the monadery used in the desugarer import DsUtils -import CmdLineOpts ( opt_FoldrBuildOn ) +import CmdLineOpts ( opt_IgnoreIfacePragmas, opt_RulesOff ) import CoreUtils ( exprType, mkIfThenElse ) import Id ( idType ) import Var ( Id ) @@ -51,11 +51,16 @@ dsListComp :: [TypecheckedStmt] -> DsM CoreExpr dsListComp quals elt_ty - | not opt_FoldrBuildOn -- Be boring - || isParallelComp quals + | opt_RulesOff || opt_IgnoreIfacePragmas -- Either rules are switched off, or + -- we are ignoring what there are; + -- Either way foldr/build won't happen, so + -- use the more efficient Wadler-style desugaring + || isParallelComp quals -- Foldr-style desugaring can't handle + -- parallel list comprehensions = deListComp quals (mkNilExpr elt_ty) - | otherwise -- foldr/build lives! + | otherwise -- Foldr/build should be enabled, so desugar + -- into foldrs and builds = newTyVarsDs [alphaTyVar] `thenDs` \ [n_tyvar] -> let n_ty = mkTyVarTy n_tyvar diff --git a/ghc/compiler/main/CmdLineOpts.lhs b/ghc/compiler/main/CmdLineOpts.lhs index ed8e99b..6cf2f3d 100644 --- a/ghc/compiler/main/CmdLineOpts.lhs +++ b/ghc/compiler/main/CmdLineOpts.lhs @@ -73,11 +73,11 @@ module CmdLineOpts ( -- optimisation opts opt_NoMethodSharing, opt_DoSemiTagging, - opt_FoldrBuildOn, opt_LiberateCaseThreshold, opt_StgDoLetNoEscapes, opt_UnfoldCasms, opt_CprOff, + opt_RulesOff, opt_UnboxStrictFields, opt_SimplNoPreInlining, opt_SimplDoEtaReduction, @@ -107,7 +107,6 @@ module CmdLineOpts ( opt_NoHiCheck, opt_OmitBlackHoling, opt_OmitInterfacePragmas, - opt_NoPruneTyDecls, opt_NoPruneDecls, opt_Static, opt_Unregisterised, @@ -586,8 +585,8 @@ opt_Flatten = lookUp FSLIT("-fflatten") -- optimisation opts opt_NoMethodSharing = lookUp FSLIT("-fno-method-sharing") opt_DoSemiTagging = lookUp FSLIT("-fsemi-tagging") -opt_FoldrBuildOn = lookUp FSLIT("-ffoldr-build-on") opt_CprOff = lookUp FSLIT("-fcpr-off") +opt_RulesOff = lookUp FSLIT("-frules-off") -- Switch off CPR analysis in the new demand analyser opt_LiberateCaseThreshold = lookup_def_int "-fliberate-case-threshold" (10::Int) opt_StgDoLetNoEscapes = lookUp FSLIT("-flet-no-escape") @@ -636,7 +635,6 @@ opt_UF_CheapOp = ( 1 :: Int) -- Only one instruction; and the args are charged opt_UF_DearOp = ( 4 :: Int) opt_NoPruneDecls = lookUp FSLIT("-fno-prune-decls") -opt_NoPruneTyDecls = lookUp FSLIT("-fno-prune-tydecls") opt_Static = lookUp FSLIT("-static") opt_Unregisterised = lookUp FSLIT("-funregisterised") opt_EmitExternalCore = lookUp FSLIT("-fext-core") @@ -665,7 +663,6 @@ isStaticHscFlag f = "fsmp", "fflatten", "fsemi-tagging", - "ffoldr-build-on", "flet-no-escape", "funfold-casms-in-hi-file", "funbox-strict-fields", @@ -686,11 +683,11 @@ isStaticHscFlag f = "fexcess-precision", "funfolding-update-in-place", "fno-prune-decls", - "fno-prune-tydecls", "static", "funregisterised", "fext-core", "frule-check", + "frules-off", "fcpr-off" ] || any (flip prefixMatch f) [ diff --git a/ghc/compiler/main/DriverState.hs b/ghc/compiler/main/DriverState.hs index 0e22c01..c24e569 100644 --- a/ghc/compiler/main/DriverState.hs +++ b/ghc/compiler/main/DriverState.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverState.hs,v 1.93 2003/06/24 12:56:44 stolz Exp $ +-- $Id: DriverState.hs,v 1.94 2003/06/25 08:20:21 simonpj Exp $ -- -- Settings for the driver -- @@ -213,7 +213,6 @@ hsc_minusNoO_flags = hsc_minusO_flags = [ "-fignore-asserts", - "-ffoldr-build-on", "-fdo-eta-reduction", "-fdo-lambda-eta-expansion", "-fcase-merge", diff --git a/ghc/compiler/simplCore/SimplMonad.lhs b/ghc/compiler/simplCore/SimplMonad.lhs index 09c8916..afe7289 100644 --- a/ghc/compiler/simplCore/SimplMonad.lhs +++ b/ghc/compiler/simplCore/SimplMonad.lhs @@ -77,7 +77,7 @@ import BasicTypes ( TopLevelFlag, isTopLevel, isLoopBreaker, ) import CmdLineOpts ( SimplifierSwitch(..), SimplifierMode(..), DynFlags, DynFlag(..), dopt, - opt_PprStyle_Debug, opt_HistorySize, opt_SimplNoPreInlining, + opt_PprStyle_Debug, opt_HistorySize, opt_SimplNoPreInlining, opt_RulesOff ) import Unique ( Unique ) import Outputable @@ -926,6 +926,8 @@ activeInline env id occ activeRule :: SimplEnv -> Maybe (Activation -> Bool) -- Nothing => No rules at all activeRule env + | opt_RulesOff = Nothing + | otherwise = case getMode env of SimplGently -> Just isAlwaysActive -- Used to be Nothing (no rules in gentle mode) diff --git a/ghc/docs/users_guide/flags.sgml b/ghc/docs/users_guide/flags.sgml index 8a1f164..afd7622 100644 --- a/ghc/docs/users_guide/flags.sgml +++ b/ghc/docs/users_guide/flags.sgml @@ -728,10 +728,10 @@ - - Enable foldr-build optimisation + + Switch off all rewrite rules static - + diff --git a/ghc/docs/users_guide/using.sgml b/ghc/docs/users_guide/using.sgml index d3d205a..e1222c0 100644 --- a/ghc/docs/users_guide/using.sgml +++ b/ghc/docs/users_guide/using.sgml @@ -1066,6 +1066,20 @@ f "2" = 2 patterns that can fail, eg. \(x:xs)->.... Normally, these aren't treated as incomplete patterns by . + ``Lambda-bound patterns'' includes all places where there is a single pattern, + including list comprehensions and do-notation. In these cases, a pattern-match + failure is quite legitimate, and triggers filtering (list comprehensions) or + the monad fail operation (monads). For example: + + f :: [Maybe a] -> [a] + f xs = [y | Just y <- xs] + + Switching on will elicit warnings about + these probably-innocent cases, which is why the flag is off by default. + The deriving( Read ) mechanism produces monadic code with + pattern matches, so you will also get misleading warnings about the compiler-generated + code. (This is arguably a Bad Thing, but it's awkward to fix.) + -- 1.7.10.4