[commit: ghc] wip/gadtpm: Added a new flag (-guard-reasoning={simple, try, try-quiet, do}) (1ed992d)

git at git.haskell.org git at git.haskell.org
Mon Dec 21 10:55:14 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/gadtpm
Link       : http://ghc.haskell.org/trac/ghc/changeset/1ed992d03456c2be3e15ee3ad9fd2b2e2104df7c/ghc

>---------------------------------------------------------------

commit 1ed992d03456c2be3e15ee3ad9fd2b2e2104df7c
Author: George Karachalias <george.karachalias at gmail.com>
Date:   Mon Dec 21 00:19:55 2015 +0100

    Added a new flag (-guard-reasoning={simple,try,try-quiet,do})
    
    Summary:
    Options:
    ~~~~~~~
      simple    : Like old times (see only `otherwise`)
      try       : Default: If guards>20, bail. Issue waring below.
      try-quiet : If too many guards, skip check, issue no warning
      do        : Run the check fully (but may use up all resources)
    
    Warning:
    ~~~~~~~
    Pattern match checking omitted for an equation for `opt_trans_rule'
    because it may be non-performant (too many guards)
    Use: -guard-reasoning=simple
           for a more efficient (but less expressive) pattern guard checking
         -guard-reasoning=try-quiet
           to suppress this warning for inefficiently checked matches
         -guard-reasoning=do
           to fully check the match (may run out of memory)
    
    If the guards are too many, the suggested strategy is the following:
    
    1) First try -guard-reasoning=simple. The simple version of the checker
       may still be able to emit the correct warnings.
    
    2) If you still get some warnings but you are confident that there
       shouldn't be any, try -guard-reasoning=do.
    
    3) If the compilation takes too long but you are sure that your match
       is exhaustive and nothing is redundant, you can either:
       * Disable the check for matches with many guards with
         -guard-reasoning=try-quiet (useful if you compile with -Werror) or
       * Do nothing, just keep the warning as a reminder.
    
    With the current state of GHC, the above warning is emitted only for:
    
    libraries/base/Foreign/C/Error.hs:472:5:      function `errType'
    compiler/nativeGen/Dwarf/Constants.hs:170:18: (case expression)
    compiler/ghci/RtClosureInspect.hs:497:4:      function `rep'
    (And would have been for compiler/types/OptCoercion.hs, for which the
    check is currently disabled)
    
    Note that for Error.hs, Constants.hs and RtClosureInspect.hs we can
    safely enable "-guard-reasoning=do". For OptCoercion.hs the full
    check takes forever to complete (and uses up all the memory) but with
    "-guard-reasoning=simple" we can both have it checked and in reasonable
    time.
    
    ("-guard-reasoning=do" not enabled in Error.hs because it is in a
    submodule. Left it to the library maintainer)
    
    Turn datatype `PmPat' into a GADT
    
    Use the same type (PmPat) for both patterns and value abstractions.
    This way, we can get rid of constructors `NonGuard' and `VA' (less
    obscure and slightly more performant).
    
    Change the flags + eliminate some warnings
    
    Test Plan: validate
    
    Reviewers: bgamari, austin, hvr, goldfire
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1676
    
    GHC Trac Issues: #11195


>---------------------------------------------------------------

1ed992d03456c2be3e15ee3ad9fd2b2e2104df7c
 compiler/deSugar/Check.hs             | 53 ++++++++++++++++++-----------------
 compiler/deSugar/Match.hs             | 37 +++++++++---------------
 compiler/ghci/RtClosureInspect.hs     |  2 +-
 compiler/main/DynFlags.hs             | 27 +++++-------------
 compiler/nativeGen/Dwarf/Constants.hs |  2 +-
 compiler/types/OptCoercion.hs         |  2 +-
 6 files changed, 50 insertions(+), 73 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 1ed992d03456c2be3e15ee3ad9fd2b2e2104df7c


More information about the ghc-commits mailing list