[commit: ghc] master: Fix StgLint bound id check, generalize StgLint (04caa93)

git at git.haskell.org git at git.haskell.org
Sat Dec 8 05:05:20 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/04caa935ac22bd2bd1a254f26df9dca4ee6abdd1/ghc

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

commit 04caa935ac22bd2bd1a254f26df9dca4ee6abdd1
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Fri Dec 7 23:23:10 2018 -0500

    Fix StgLint bound id check, generalize StgLint
    
    StgLint was incorrectly using isLocalId for bound id check to see
    whether an id is imported (in which case we don't expect it to be bound)
    or local.  The problem with isLocalId is that its semantics changes
    after Core, as explained in the note: (last line)
    
        Note [GlobalId/LocalId]
        ~~~~~~~~~~~~~~~~~~~~~~~
        A GlobalId is
          * always a constant (top-level)
          * imported, or data constructor, or primop, or record selector
          * has a Unique that is globally unique across the whole
            GHC invocation (a single invocation may compile multiple
            modules)
          * never treated as a candidate by the free-variable finder;
                it's a constant!
    
        A LocalId is
          * bound within an expression (lambda, case, local let(rec))
          * or defined at top level in the module being compiled
          * always treated as a candidate by the free-variable finder
    
        After CoreTidy, top-level LocalIds are turned into GlobalIds
    
    We now pass current module as a parameter to StgLint, which uses it to
    see if an id should be bound (defined in the current module) or not
    (imported).
    
    Other changes:
    
    - Generalized StgLint to make it work on both StgTopBinding and
      CgStgTopBinding.
    - Bring all top-level binders into scope before linting top-level
      bindings to allow uses before definitions.
    
    TODO: We should remove the binder from local vars when checking RHSs of
    non-recursive bindings.
    
    Test Plan: This validates.
    
    Reviewers: simonpj, bgamari, sgraf
    
    Reviewed By: simonpj, sgraf
    
    Subscribers: rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5370


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

04caa935ac22bd2bd1a254f26df9dca4ee6abdd1
 compiler/main/HscMain.hs      |   2 +-
 compiler/simplStg/SimplStg.hs |  18 ++++--
 compiler/stgSyn/StgLint.hs    | 133 +++++++++++++++++++++++++++---------------
 compiler/stgSyn/StgSyn.hs     |  13 +++--
 testsuite/mk/test.mk          |   3 +-
 5 files changed, 109 insertions(+), 60 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 04caa935ac22bd2bd1a254f26df9dca4ee6abdd1


More information about the ghc-commits mailing list