1. 13 Jun, 2016 1 commit
    • Simon Peyton Jones's avatar
      Improve typechecking of let-bindings · 15b9bf4b
      Simon Peyton Jones authored
      This major commit was initially triggered by #11339, but it spiraled
      into a major review of the way in which type signatures for bindings
      are handled, especially partial type signatures.  On the way I fixed a
      number of other bugs, namely
         #12069
         #12033
         #11700
         #11339
         #11670
      
      The main change is that I completely reorganised the way in which type
      signatures in bindings are handled. The new story is in TcSigs
      Note [Overview of type signatures].  Some specific:
      
      * Changes in the data types for signatures in TcRnTypes:
        TcIdSigInfo and new TcIdSigInst
      
      * New module TcSigs deals with typechecking type signatures
        and pragmas. It contains code mostly moved from TcBinds,
        which is already too big
      
      * HsTypes: I swapped the nesting of HsWildCardBndrs
        and HsImplicitBndsrs, so that the wildcards are on the
        oustide not the insidde in a LHsSigWcType.  This is just
        a matter of convenient, nothing deep.
      
      There are a host of other changes as knock-on effects, and
      it all took FAR longer than I anticipated :-).  But it is
      a significant improvement, I think.
      
      Lots of error messages changed slightly, some just variants but
      some modest improvements.
      
      New tests
      
      * typecheck/should_compile
          * SigTyVars: a scoped-tyvar test
          * ExPat, ExPatFail: existential pattern bindings
          * T12069
          * T11700
          * T11339
      
      * partial-sigs/should_compile
          * T12033
          * T11339a
          * T11670
      
      One thing to check:
      
      * Small change to output from ghc-api/landmines.
        Need to check with Alan Zimmerman
      15b9bf4b
  2. 12 Jun, 2016 3 commits
    • Tamar Christina's avatar
      Disable T12031 on linux · 29e14643
      Tamar Christina authored
      29e14643
    • Tamar Christina's avatar
      Fix incorrect calculated relocations on Windows x86_64 · b40e1b4c
      Tamar Christina authored
      Summary:
      See #12031 for analysis, but essentially what happens is:
      
      To sum up the issue, the reason this seems to go wrong is because
      of how we initialize the `.bss` section for Windows in the runtime linker.
      
      The first issue is where we calculate the zero space for the section:
      
      ```
      zspace = stgCallocBytes(1, bss_sz, "ocGetNames_PEi386(anonymous bss)");
      sectab_i->PointerToRawData = ((UChar*)zspace) - ((UChar*)(oc->image));
      ```
      
      Where
      ```
      UInt32 PointerToRawData;
      ```
      
      This means we're stuffing a `64-bit` value into a `32-bit` one. Also `zspace`
      can be larger than `oc->image`. In which case it'll overflow and
      then get truncated in the cast.
      
      The address of a value in the `.bss` section is then calculated as:
      
      ```
      addr = ((UChar*)(oc->image))
           + (sectabent->PointerToRawData
           + symtab_i->Value);
      ```
      
      If it does truncate then this calculation won't be correct (which is what is happening).
      
      We then later use the value of `addr` as the `S` (Symbol) value for the relocations
      
      ```
      S = (size_t) lookupSymbol_( (char*)symbol );
      ```
      
      Now the majority of the relocations are `R_X86_64_PC32` etc.
      e.g. They are guaranteed to fit in a `32-bit` value.
      
      The `R_X86_64_64` introduced for these pseudo-relocations so they can use
      the full `48-bit` addressing space isn't as lucky.
      As for why it sometimes work has to do on whether the value is truncated or not.
      
      `PointerToRawData` can't be changed because it's size is fixed by the PE specification.
      
      Instead just like with the other platforms, we now use `section` on Windows as well.
      This gives us a `start` parameter of type `void*` which solves the issue.
      
      This refactors the code to use `section.start` and to fix the issues.
      
      Test Plan: ./validate and new test added T12031
      
      Reviewers: RyanGlScott, erikd, bgamari, austin, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2316
      
      GHC Trac Issues: #12031, #11317
      b40e1b4c
    • Matthew Pickering's avatar
      Skip retc001 on OSX · 91308679
      Matthew Pickering authored
      See #11204, this test sometimes fails and sometimes passes on OSX
      which causes intermittent validate failures if it is run.
      91308679
  3. 10 Jun, 2016 2 commits
    • Simon Marlow's avatar
      NUMA support · 9e5ea67e
      Simon Marlow authored
      Summary:
      The aim here is to reduce the number of remote memory accesses on
      systems with a NUMA memory architecture, typically multi-socket servers.
      
      Linux provides a NUMA API for doing two things:
      * Allocating memory local to a particular node
      * Binding a thread to a particular node
      
      When given the +RTS --numa flag, the runtime will
      * Determine the number of NUMA nodes (N) by querying the OS
      * Assign capabilities to nodes, so cap C is on node C%N
      * Bind worker threads on a capability to the correct node
      * Keep a separate free lists in the block layer for each node
      * Allocate the nursery for a capability from node-local memory
      * Allocate blocks in the GC from node-local memory
      
      For example, using nofib/parallel/queens on a 24-core 2-socket machine:
      
      ```
      $ ./Main 15 +RTS -N24 -s -A64m
        Total   time  173.960s  (  7.467s elapsed)
      
      $ ./Main 15 +RTS -N24 -s -A64m --numa
        Total   time  150.836s  (  6.423s elapsed)
      ```
      
      The biggest win here is expected to be allocating from node-local
      memory, so that means programs using a large -A value (as here).
      
      According to perf, on this program the number of remote memory accesses
      were reduced by more than 50% by using `--numa`.
      
      Test Plan:
      * validate
      * There's a new flag --debug-numa=<n> that pretends to do NUMA without
        actually making the OS calls, which is useful for testing the code
        on non-NUMA systems.
      * TODO: I need to add some unit tests
      
      Reviewers: erikd, austin, rwbarton, ezyang, bgamari, hvr, niteria
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2199
      9e5ea67e
    • sgillespie's avatar
      Fix #12099: Remove bogus flags · bcb419a4
      sgillespie authored
      Remove -fwarn- and -fno-warn- from flagsForCompletion
      
      Testcase: Fix linter error on T12099
      
      For Issue #12099
      
      Reviewers: austin, thomie, bgamari
      
      Reviewed By: austin, thomie, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2281
      
      GHC Trac Issues: #12099
      bcb419a4
  4. 09 Jun, 2016 4 commits
    • Facundo Domínguez's avatar
      Improve the error messages for static forms. · e9dfb6e5
      Facundo Domínguez authored
      Now the message explains why closed variables are not closed when
      encountered in the body of (static ...).
      
      This required adding to the local environment the free variables of
      the local bindings in scope. Thus we can analyze and explain why a
      variable is not closed when encountered.
      
      Test Plan: ./validate
      
      Reviewers: austin, simonpj, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: mboes, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2167
      
      GHC Trac Issues: #12003
      e9dfb6e5
    • Tamar Christina's avatar
      Fix Ticky histogram on Windows · b020db2a
      Tamar Christina authored
      Summary:
      The histogram types are defined in `Ticky.c` as `StgInt` values.
      
      ```
      EXTERN StgInt RET_NEW_hst[TICKY_BIN_COUNT] INIT({0});
      EXTERN StgInt RET_OLD_hst[TICKY_BIN_COUNT] INIT({0});
      EXTERN StgInt RET_UNBOXED_TUP_hst[TICKY_BIN_COUNT] INIT({0});
      ```
      
      which means they'll be `32-bits` on `x86` and `64-bits` on `x86_64`.
      
      However the `bumpHistogram` in `StgCmmTicky` is incrementing them as if
      they're a `cLong`. A long on Windows `x86_64` is `32-bit`.
      
      As such when then value for the `_hst_1` is being set what it's actually doing
      is setting the value of the high bits of the first entry.
      
      This ends up giving us `0b‭100000000000000000000000000000000‬` or `4294967296`
      as is displayed in the ticket on #8308.
      
      Since `StgInt` is defined using the `WORD` size. Just use that directly in
      `bumpHistogram`.
      
      Also since `cLong` is no longer used after this commit it will also be dropped.
      
      Test Plan: make TEST=T8308
      
      Reviewers: mlen, jstolarek, bgamari, thomie, goldfire, simonmar, austin
      
      Reviewed By: bgamari, thomie
      
      Subscribers: #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2318
      
      GHC Trac Issues: #8308
      b020db2a
    • Edward Z. Yang's avatar
      Fix #12076 by inlining trivial expressions in CorePrep. · 11ff1df8
      Edward Z. Yang authored
      
      
      Summary:
      This mostly follows the plan detailed by the discussion
      Simon and I had, with one difference: instead of grabbing
      the free variables of the trivial expressions to get the
      embedded Ids, we just use getIdFromTrivialExpr_maybe to extract
      out the Id.  If there is no Id, the expression cannot
      refer to a function (as there are no literal functions)
      and thus we do not need to saturate.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2309
      
      GHC Trac Issues: #12076
      11ff1df8
    • Edward Z. Yang's avatar
      Fix #12064 by making IfaceClass typechecking more lazy. · 8f6d2927
      Edward Z. Yang authored
      
      
      Summary:
      Comes with a test based off of prog006.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2221
      
      GHC Trac Issues: #12064
      8f6d2927
  5. 08 Jun, 2016 2 commits
    • Ömer Sinan Ağacan's avatar
      Show sources of cost centers in .prof · d7933cbc
      Ömer Sinan Ağacan authored
      This fixes the problem with duplicate cost-centre names that was
      reported a couple of times before. When a module implements a typeclass
      multiple times for different types, methods of different implementations
      get same cost-centre names and are reported like this:
      
          COST CENTRE MODULE            %time %alloc
      
          CAF         GHC.IO.Handle.FD    0.0   32.8
          CAF         GHC.Read            0.0    1.0
          CAF         GHC.IO.Encoding     0.0    1.8
          showsPrec   Main                0.0    1.2
          readPrec    Main                0.0   19.4
          readPrec    Main                0.0   20.5
          main        Main                0.0   20.2
      
                                                  individual      inherited
          COST CENTRE  MODULE  no.     entries  %time %alloc   %time %alloc
      
          MAIN         MAIN     53          0    0.0    0.2     0.0  100.0
           CAF         Main    105          0    0.0    0.3     0.0   62.5
            readPrec   Main    109          1    0.0    0.6     0.0    0.6
            readPrec   Main    107          1    0.0    0.6     0.0    0.6
            main       Main    106          1    0.0   20.2     0.0   61.0
             ==        Main    114          1    0.0    0.0     0.0    0.0
             ==        Main    113          1    0.0    0.0     0.0    0.0
             showsPrec Main    112          2    0.0    1.2     0.0    1.2
             showsPrec Main    111          2    0.0    0.9     0.0    0.9
             readPrec  Main    110          0    0.0   18.8     0.0   18.8
             readPrec  Main    108          0    0.0   19.9     0.0   19.9
      
      It's not possible to tell from the report which `==` took how long. This
      patch adds one more column at the cost of making outputs wider. The
      report now looks like this:
      
          COST CENTRE MODULE           SRC                       %time %alloc
      
          CAF         GHC.IO.Handle.FD <entire-module>             0.0   32.9
          CAF         GHC.IO.Encoding  <entire-module>             0.0    1.8
          CAF         GHC.Read         <entire-module>             0.0    1.0
          showsPrec   Main             Main_1.hs:7:19-22           0.0    1.2
          readPrec    Main             Main_1.hs:7:13-16           0.0   19.5
          readPrec    Main             Main_1.hs:4:13-16           0.0   20.5
          main        Main             Main_1.hs:(10,1)-(20,20)    0.0   20.2
      
                                                                             individual      inherited
          COST CENTRE  MODULE        SRC                      no. entries  %time %alloc   %time %alloc
      
          MAIN         MAIN          <built-in>                53      0    0.0    0.2     0.0  100.0
           CAF         Main          <entire-module>          105      0    0.0    0.3     0.0   62.5
            readPrec   Main          Main_1.hs:7:13-16        109      1    0.0    0.6     0.0    0.6
            readPrec   Main          Main_1.hs:4:13-16        107      1    0.0    0.6     0.0    0.6
            main       Main          Main_1.hs:(10,1)-(20,20) 106      1    0.0   20.2     0.0   61.0
             ==        Main          Main_1.hs:7:25-26        114      1    0.0    0.0     0.0    0.0
             ==        Main          Main_1.hs:4:25-26        113      1    0.0    0.0     0.0    0.0
             showsPrec Main          Main_1.hs:7:19-22        112      2    0.0    1.2     0.0    1.2
             showsPrec Main          Main_1.hs:4:19-22        111      2    0.0    0.9     0.0    0.9
             readPrec  Main          Main_1.hs:7:13-16        110      0    0.0   18.8     0.0   18.8
             readPrec  Main          Main_1.hs:4:13-16        108      0    0.0   19.9     0.0   19.9
           CAF         Text.Read.Lex <entire-module>          102      0    0.0    0.5     0.0    0.5
      
      To fix failing test cases because of different orderings of cost centres
      (e.g. optimized and non-optimized build printing in different order),
      with this patch we also start sorting cost centres before printing. The
      order depends on 1) entries (more entered cost centres come first) 2)
      names (using strcmp() on cost centre names).
      
      Reviewers: simonmar, austin, erikd, bgamari
      
      Reviewed By: simonmar, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2282
      
      GHC Trac Issues: #11543, #8473, #7105
      d7933cbc
    • niteria's avatar
      Add some determinism tests · d4b548ef
      niteria authored
      These are the tests that I accumulated fixing real issues.
      Each test is a separate thing that was broken and they are
      relatively small.
      
      GHC Trac: #4012
      d4b548ef
  6. 07 Jun, 2016 3 commits
  7. 06 Jun, 2016 2 commits
    • Alan Zimmerman's avatar
      Merge MatchFixity and HsMatchContext · a13cb279
      Alan Zimmerman authored
      Summary:
      MatchFixity was introduced to facilitate use of API Annotations.
      
      HsMatchContext does the same thing with more detail, but is chased
      through all over the place to provide context when processing a Match.
      
      Since we already have MatchFixity in the Match, it may as well provide
      the full context.
      
      updates submodule haddock
      
      Test Plan: ./validate
      
      Reviewers: austin, goldfire, bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2271
      
      GHC Trac Issues: #12105
      
      (cherry picked from commit 306ecad591951521ac3f5888ca8be85bf749d271)
      a13cb279
    • niteria's avatar
      Desugar ApplicativeDo and RecDo deterministically · e684f546
      niteria authored
      This fixes a problem described in
      Note [Deterministic ApplicativeDo and RecursiveDo desugaring].
      
      Test Plan: ./validate + new testcase
      
      Reviewers: simonpj, bgamari, austin, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2287
      
      GHC Trac Issues: #4012
      e684f546
  8. 05 Jun, 2016 2 commits
  9. 04 Jun, 2016 4 commits
  10. 03 Jun, 2016 2 commits
    • Tamar Christina's avatar
      Refactored SymbolInfo to lower memory usage in RTS · 37473722
      Tamar Christina authored
      Previously as part of #11223 a new struct `SymbolInfo` was introduced to
      keep track it the weak symbol status of a symbol.
      
      This structure also kept a copy of the calculated address of the symbol
      which turns out was useful in ignoring non-weak zero-valued symbols.
      
      The information was kept in an array so it means for every symbol two
      extra bytes were kept even though the vast majority of symbols are
      non-weak and non-zero valued.
      
      This changes the array into a sparse map keeping this information only
      for the symbols that are weak or zero-valued. This allows for a
      reduction in the amount of information needed to be kept while giving up
      a small (negligable) hit in performance as this information now has to
      be looked up in hashmaps.
      
      Test Plan: ./validate on all platforms that use the runtime linker.
      
      For unix platforms please ensure `DYNAMIC_GHC_PROGRAMS=NO` is added to
      your validate file.
      
      Reviewers: simonmar, austin, erikd, bgamari
      
      Reviewed By: simonmar, bgamari
      
      Subscribers: thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2184
      
      GHC Trac Issues: #11816
      37473722
    • Peter Trommler's avatar
      testsuite: Mark broken tests on powerpc64le · 1dadd9a9
      Peter Trommler authored
      Mark all failing tests that have a ticket for powerpc64 as broken. Most
      of these failures are due to the lack of linker support in the runtime
      system.
      
      Test Plan: validate on powerpc and AIX
      
      Reviewers: erikd, bgamari, simonmar, hvr, austin
      
      Reviewed By: austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2289
      
      GHC Trac Issues: #11261, #11259, #11260, #11323
      1dadd9a9
  11. 27 May, 2016 1 commit
  12. 26 May, 2016 2 commits
    • Simon Peyton Jones's avatar
      Reduce special-casing for nullary unboxed tuple · e9e61f18
      Simon Peyton Jones authored
      When we built the kind of a nullary unboxed tuple, we said, in
      TysWiredIn.mk_tuple:
      
          res_rep | arity == 0 = voidRepDataConTy
                        -- See Note [Nullary unboxed tuple] in Type
                  | otherwise  = unboxedTupleRepDataConTy
      
      But this is bogus.  The Note deals with what the 'unarise' transformation
      does, and up to that point it's simpler and more uniform to treat
      nullary unboxed tuples the same as all the others.
      
      Nicer now.  And it fixes the Lint error in Trac #12115
      e9e61f18
    • Simon Peyton Jones's avatar
      Fix bytecode gen to deal with rep-polymorphism · 0f1e315b
      Simon Peyton Jones authored
      When faced runtime-rep-polymorphic code from a pattern-synonym
      matcher, the bytecode generator was treating the result as lifted,
      which it isn't.  The fix is just to treat those rep-polymorphic
      continuations like unlifted types, and add a dummy arg.
      
      Trac #12007 is a case in point.
      0f1e315b
  13. 25 May, 2016 3 commits
  14. 24 May, 2016 5 commits
    • thomie's avatar
      Testsuite: delete drvfail015.stderr-7.0 [skip ci] · 31f18043
      thomie authored
      Running the testsuite with ghc-7.0 is not supported.
      31f18043
    • seraphime's avatar
      Fix: #12084 deprecate old profiling flags · 1956cbf1
      seraphime authored
      Change help message so it doesn't specify -auto-all.
      Make old profiling flags deprecated as they are no longer
      documented.
      Update Makefile and documentation accordingly.
      Update release notes for ghc 8.2
      
      Test Plan:
      ./verify; `ghc --help` shouldn't specify the -auto-all
      flag. Furthermore `ghc -fprof -auto-all` should emit a warning
      
      Reviewed By: thomie, austin
      
      Differential Revision: https://phabricator.haskell.org/D2257
      
      GHC Trac Issues: #12084
      
      Update submodule nofib
      1956cbf1
    • niteria's avatar
      Make Arrow desugaring deterministic · 9d06ef1a
      niteria authored
      This kills two instances of varSetElems that turned out to be
      nondeterministic. I've tried to untangle this before, but it's
      a bit hard with the fixDs in the middle. Fortunately I now have
      a test case that proves that we need determinism here.
      
      Test Plan: ./validate, new testcase
      
      Reviewers: simonpj, simonmar, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2258
      
      GHC Trac Issues: #4012
      9d06ef1a
    • Josh Price's avatar
      Add support for unicode TH quotes (#11743) · 8f7d0163
      Josh Price authored
      I've also added cases for `IToparenbar` and `ITcparenbar` (aka banana
      brackets) to `isUnicode`.
      
      Document unicode TH quote alternatives (#11743)
      
      Test Plan: ./validate
      
      Reviewers: austin, goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2185
      
      GHC Trac Issues: #11743
      8f7d0163
    • Simon Peyton Jones's avatar
      Don't split the arg types in a PatSyn signature · 03d89603
      Simon Peyton Jones authored
      This patch fixes Trac #11977, and #12108, rather satisfactorily
      maily by deleting code!
      
        pattern P :: Eq a => a -> a -> Int
      
      The idea is simply /not/ to split the bit after the '=>' into the
      pattern argument types, but to keep the (a->a->Int) part
      un-decomposed, in the patsig_body_ty field of a TcPatSynInfo.
      
      There is one awkward wrinkle, which is that we can't split the
      implicitly-bound type variables into existential and universal until
      we know which types are arguments and which are part of the result.
      So we postpone the decision until we have the declaration in hand.
      See TcPatSyn Note [The pattern-synonym signature splitting rule]
      03d89603
  15. 23 May, 2016 2 commits
  16. 21 May, 2016 2 commits
    • Andrew Farmer's avatar
      Fix deriving Ord when RebindableSyntax is enabled · 527ed724
      Andrew Farmer authored
      Deriving clauses (Ord especially) generated if-expressions with nlHsIf
      which were subject to RebindableSyntax. This changes nlHsIf to generate
      concrete if-expressions.
      
      There was also an error about calling tagToEnum# at a polymorphic type,
      which is not allowed. Fixing nlHsIf didn't fix this for some reason, so
      I generated a type ascription around the call to tagToEnum#. Not sure
      why the typechecker could not figure this out.
      
      Test Plan: Added a test, ran validate.
      
      Reviewers: simonpj, simonmar, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2247
      
      GHC Trac Issues: #12080
      527ed724
    • thomie's avatar
      Testsuite: mark T8761 expect_broken #12077 · 8e929744
      thomie authored
      8e929744