1. 31 Jan, 2018 6 commits
  2. 30 Jan, 2018 1 commit
  3. 29 Jan, 2018 2 commits
  4. 27 Jan, 2018 1 commit
  5. 26 Jan, 2018 16 commits
    • U-Maokai\andi's avatar
      cmm: Use two equality checks for two alt switch with default · 7ff60235
      U-Maokai\andi authored
      For code like:
      f 1 = e1
      f 7 = e2
      f _ = e3
      
      We can treat it as a sparse jump table, check if we are outside of the
      range in one direction first and then start checking the values.
      
      GHC currently does this by checking for x>7, then x <= 7 and at last x
      == 1.
      
      This patch changes this such that we only compare for equality against
      the two values and jump to the default if non are equal.
      
      The resulting code is both faster and smaller.
      wheel-sieve1 improves by 4-8% depending on problem size.
      
      This implements the idea from #14644
      
      Reviewers: bgamari, simonmar, simonpj, nomeata
      
      Reviewed By: simonpj, nomeata
      
      Subscribers: nomeata, simonpj, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4294
      7ff60235
    • Ryan Scott's avatar
      Fix #14719 by using the setting the right SrcSpan · 59fa7b32
      Ryan Scott authored
      Currently, error messages that germane to GADT constructors
      put the source span at only the first character in the constructor,
      leading to insufficient caret diagnostics. This can be easily fixed
      by using a source span that spans the entire constructor, instead of
      just the first character.
      
      Test Plan: make test TEST=T14719
      
      Reviewers: alanz, bgamari, simonpj
      
      Reviewed By: alanz, simonpj
      
      Subscribers: simonpj, goldfire, rwbarton, thomie, carter
      
      GHC Trac Issues: #14719
      
      Differential Revision: https://phabricator.haskell.org/D4344
      59fa7b32
    • Tamar Christina's avatar
      Fix Windows stack allocations. · a55d581f
      Tamar Christina authored
      On Windows we use the function `win32AllocStack` to do stack
      allocations in 4k blocks and insert a stack check afterwards
      to ensure the allocation returned a valid block.
      
      The problem is this function does something that by C semantics
      is pointless. The stack allocated value can never escape the
      function, and the stack isn't used so the compiler just optimizes
      away the entire function body.
      
      After considering a bunch of other possibilities I think the simplest
      fix is to just disable optimizations for the function.
      
      Alternatively inline assembly is an option but the stack check function
      doesn't have a very portable name as it relies on e.g. `libgcc`.
      
      Thanks to Sergey Vinokurov for helping diagnose and test.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14669
      
      Differential Revision: https://phabricator.haskell.org/D4343
      a55d581f
    • Alec Theriault's avatar
      Option for LINE pragmas to get lexed into tokens · 9a57cfeb
      Alec Theriault authored
      This adds a parser-level switch to have 'LINE' and 'COLUMN'
      pragmas lexed into actual tokens (as opposed to updating the
      position information in the parser).
      
      'lexTokenStream' is the only place where this option is enabled.
      
      Reviewers: bgamari, alexbiehl, mpickering
      
      Reviewed By: mpickering
      
      Subscribers: alanz, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4336
      9a57cfeb
    • Michal Terepeta's avatar
      Remove Hoopl.Unique · bd58e290
      Michal Terepeta authored
      
      
      Reasons to remove:
      - It's confusing - we already have a widely used `Unique` module in
        `basicTypes/` that defines a newtype called `Unique`
      - `Hoopl.Unique` is not actually used much
      
      I've also moved the `Unique{Map,Set}` from `Hoopl.Unique` to
      `Hoopl.Collections` to keep things together. But that module is also a
      bit funny - it defines two type-classes that have only one instance
      each. So we should probably either remove them or use them more
      widely... In any case, that will be a separate change.
      Signed-off-by: Michal Terepeta's avatarMichal Terepeta <michal.terepeta@gmail.com>
      
      Test Plan: ./validate
      
      Reviewers: bgamari, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: kavon, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4331
      bd58e290
    • Ömer Sinan Ağacan's avatar
      Linker: ignore empty paths in addEnvPaths · cacba075
      Ömer Sinan Ağacan authored
      Previously `splitEnv` worked like this:
      
          > splitEnv "foo:::bar::baz:"
          ["foo","","","bar","","baz",""]
      
      with this patch:
      
          > splitEnv working_dir "foo:::bar:baz:"
          ["foo",working_dir,working_dir"bar","baz",working_dir]
      
      This fixes #14695, where having a trailing `:` in the env variable
      caused ghci to pass empty `-B` parameter to `gcc`, which in turned
      caused the next parameter (`--print-file-name`) to be considered as the
      argument to `-B`. As a result ghci did not work.
      
      The `working_dir` argument is to have a similar behavior with POSIX:
      according to chapter 8.3 zero-length prefix means current working
      directory.
      
      Reviewers: hvr, bgamari, AndreasK, simonmar
      
      Reviewed By: bgamari, AndreasK, simonmar
      
      Subscribers: AndreasK, rwbarton, thomie, carter
      
      GHC Trac Issues: #14695
      
      Differential Revision: https://phabricator.haskell.org/D4330
      cacba075
    • Matthías Páll Gissurarson's avatar
      Sort valid substitutions for typed holes by "relevance" · cbdea959
      Matthías Páll Gissurarson authored
      This is an initial attempt at tackling the issue of how to order the
      suggestions provided by the valid substitutions checker, by sorting
      them by creating a graph of how they subsume each other. We'd like to
      order them in such a manner that the most "relevant" suggestions are
      displayed first, so that the suggestion that the user might be looking
      for is displayed before more far-fetched suggestions (and thus also
      displayed when they'd otherwise be cut-off by the
      `-fmax-valid-substitutions` limit). The previous ordering was based on
      the order in which the elements appear in the list of imports, which I
      believe is less correlated with relevance than this ordering.
      
      A drawback of this approach is that, since we now want to sort the
      elements, we can no longer "bail out early" when we've hit the
      `-fmax-valid-substitutions` limit.
      
      Reviewers: bgamari, dfeuer
      
      Reviewed By: dfeuer
      
      Subscribers: dfeuer, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4326
      cbdea959
    • Herbert Valerio Riedel's avatar
      Add ptr-eq short-cut to `compareByteArrays#` primitive · 31c260f3
      Herbert Valerio Riedel authored
      This is an obvious optimisation whose overhead is neglectable but
      which significantly simplifies the common uses of `compareByteArrays#`
      which would otherwise require to make *careful* use of
      `reallyUnsafePtrEquality#` or (equally fragile) `byteArrayContents#`
      which can result in less optimal assembler code being generated.
      
      Test Plan: carefully examined generated cmm/asm code; validate via phab
      
      Reviewers: alexbiehl, bgamari, simonmar
      
      Reviewed By: bgamari, simonmar
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4319
      31c260f3
    • Andreas Klebinger's avatar
      Add ability to parse likely flags for ifs in Cmm. · e7dcc708
      Andreas Klebinger authored
      Adding the ability to parse likely flags in Cmm allows better codegen
      for cmm files.
      
      Test Plan: ci
      
      Reviewers: bgamari, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14672
      
      Differential Revision: https://phabricator.haskell.org/D4316
      e7dcc708
    • Andreas Klebinger's avatar
      Handle the likely:True case in CmmContFlowOpt · 52dfb25c
      Andreas Klebinger authored
      It's better to fall through to the likely case than to jump to it.
      
      We optimize for this in CmmContFlowOpt when likely:False.
      This commit extends the logic there to handle cases with likely:True
      as well.
      
      Test Plan: ci
      
      Reviewers: bgamari, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: simonmar, alexbiehl, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4306
      52dfb25c
    • Ben Gamari's avatar
      base: Refactor Show ErrorCall instance into proper ShowS style · 302aee52
      Ben Gamari authored
      Test Plan: Validate
      
      Reviewers: hvr, dfeuer
      
      Reviewed By: dfeuer
      
      Subscribers: dfeuer, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4304
      302aee52
    • Alec Theriault's avatar
      Haddock needs to pass visible modules for instance filtering · 66961dc8
      Alec Theriault authored
      The GHC-side `getNameToInstancesIndex` filters out incorrectly some
      instances because it is not aware of what modules are visible. Using
      `runTcInteractive` means that `ie_visible` gets initialized to a one
      module set containing some dummy GHCi module. This is clearly not the
      module set we want to check against to see if a given orphan instance
      is visible or not.
      
      In fact, GHC has no way of knowing what we want that module set to be
      since it doesn't know ahead of time which modules Haddock is making its
      docs for. The fix is just to pass that set in as an argument.
      
      Bumps haddock submodule.
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: duog, alexbiehl, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4290
      66961dc8
    • Ben Gamari's avatar
      testsuite: Add testcase for #12158 · 983e4919
      Ben Gamari authored
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4334
      983e4919
    • Joachim Breitner's avatar
      Turn EvTerm (almost) into CoreExpr (#14691) · 0e022e56
      Joachim Breitner authored
      Ideally, I'd like to do
      
          type EvTerm = CoreExpr
      
      and the type checker builds the evidence terms as it goes. This failed,
      becuase the evidence for `Typeable` refers to local identifiers that are
      added *after* the typechecker solves constraints. Therefore, `EvTerm`
      stays a data type with two constructors: `EvExpr` for `CoreExpr`
      evidence, and `EvTypeable` for the others.
      
      Delted `Note [Memoising typeOf]`, its reference (and presumably
      relevance) was removed in 8fa4bf9a.
      
      Differential Revision: https://phabricator.haskell.org/D4341
      0e022e56
    • Ben Gamari's avatar
    • Ben Gamari's avatar
      Bump terminfo submodule · d6e0338b
      Ben Gamari authored
      d6e0338b
  6. 25 Jan, 2018 4 commits
    • Simon Peyton Jones's avatar
      Fix the lone-variable case in callSiteInline · 06366890
      Simon Peyton Jones authored
      See Note [Lone variables] in CoreUnfold and
      Note [exprIsExpandable] in CoreUtils.
      
      Helpfully pointed out by Matthew Pickering in Trac #14688
      
      Nofib results are good:
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs   Runtime   Elapsed  TotalMem
      --------------------------------------------------------------------------------
                 anna          +0.1%     +0.3%     0.151     0.151      0.0%
               awards          +0.0%     -0.2%     0.001     0.001      0.0%
            compress2          +0.6%     -0.7%     -4.8%     -5.0%     -4.0%
                eliza          +0.0%     -2.4%     0.001     0.001      0.0%
               fulsom          +0.4%    -13.3%     -7.6%     -7.6%   +190.0%
               gamteb          +0.0%     -0.6%     0.062     0.062      0.0%
                   gg          +0.1%     -0.4%     0.016     0.016      0.0%
                  ida          +0.1%     +0.3%     0.110     0.110      0.0%
                kahan          +0.0%     -0.7%     -0.9%     -0.9%      0.0%
                 mate          +0.1%     -5.2%     -4.9%     -4.9%      0.0%
               n-body          +0.0%     -0.2%     -0.3%     -3.0%      0.0%
               pretty          +0.0%     -2.8%     0.000     0.000      0.0%
                  scs          +0.0%     -0.2%     +1.6%     +2.4%      0.0%
               simple          +0.4%     -0.2%     -2.3%     -2.3%     -3.4%
              veritas          +0.4%     -1.0%     0.003     0.003      0.0%
                 wang          +0.0%     -1.6%     0.165     0.165      0.0%
      --------------------------------------------------------------------------------
                  Min          -0.0%    -13.3%    -16.2%    -18.8%     -4.0%
                  Max          +0.6%     +0.3%     +4.9%     +4.9%   +190.0%
       Geometric Mean          +0.1%     -0.3%     -1.7%     -2.4%     +0.9%
      06366890
    • Simon Peyton Jones's avatar
      Comments only · 2a2e6a8f
      Simon Peyton Jones authored
      2a2e6a8f
    • Simon Peyton Jones's avatar
      Remove dead code: mkNthCoRole · 076bdb36
      Simon Peyton Jones authored
      076bdb36
    • Simon Peyton Jones's avatar
      Comments about CoercionHoles · d36ae5d6
      Simon Peyton Jones authored
      Richard was confused; I hope these comments help.
      d36ae5d6
  7. 23 Jan, 2018 1 commit
    • niteria's avatar
      Allocate less in plus_mod_dep · f00ddea9
      niteria authored
      This gives a 10% allocation improvement on MultiLayerModules.
      The idea is to reuse existing tuples, instead of constantly
      constructing new ones.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: rwbarton, thomie, simonmar, carter
      
      Differential Revision: https://phabricator.haskell.org/D4332
      f00ddea9
  8. 22 Jan, 2018 4 commits
    • Ryan Scott's avatar
      Pass -dsuppress-uniques when running T14507 · 452dee3f
      Ryan Scott authored
      Not doing so resulted in different uniques being printed on different
      environments, as shown in #14703.
      452dee3f
    • Simon Peyton Jones's avatar
      a3cde5fd
    • Ben Gamari's avatar
      Bump transformers submodule to 0.5.5.0 · 24e56ebd
      Ben Gamari authored
      24e56ebd
    • Oleg Grenrus's avatar
      Update Cabal submodule · 2671cccd
      Oleg Grenrus authored
      - Cabal-2.2 uses SPDX license identifiers, so I had to update
        `cabal-version: 2.1` packages `license: BSD3` to `license: BSD-3-Clause`
      - `ghc-cabal` used old ReadP parsec, now it uses `parsec` too
      - InstalledPackageInfo pretty-printing have changed a little,
        fields with default values aren't printed. This can be changed in
        `Cabal` still, but I haven't found problems with omitting them.
      
      Note: `BSD-3-Clause` is parsed as "name = BSD, version = 3" by old
      parser (because 3-Clause looks like version 3 with tag Clause).
      If you see *"BSD-3" is not a valid license*, then something is using
      old parser still.
      
      Fixes #9885.
      2671cccd
  9. 21 Jan, 2018 5 commits
    • Ben Gamari's avatar
      SysTools: Add detection support for LLD linker · 6c0db98b
      Ben Gamari authored
      I noticed while trying to test against LLVM 5.0 that GHC would throw "Couldn't
      figure out linker information" warnings due to LLD being chosen by configure.
      Adding detection support to silence these is simple enough, let's just do it.
      6c0db98b
    • niteria's avatar
      Use IntSet in Dataflow · 88297438
      niteria authored
      Before this change, a list was used as a substitute for a heap.
      This led to quadratic behavior on a simple program (see new
      test case).
      
      This change replaces it with IntSet in effect reverting
      5a1a2633. @simonmar said it's fine to revert as long as nofib
      results are good.
      
      Test Plan:
      new test case:
      
      20% improvement
      3x improvement when N=10000
      
      nofib:
      
      I run it twice for before and after because the compile time
      results are noisy.
      
      - Compile Allocations:
      
      ```
                before    before re-run    after     after re-run
      -1 s.d.   -----     -0.0%            -0.1%     -0.1%
      +1 s.d.   -----     +0.0%            +0.1%     +0.1%
      Average   -----     +0.0%            -0.0%     -0.0%
      ```
      - Compile Time:
      
      ```
                before    before re-run    after     after re-run
      -1 s.d.   -----     -0.1%            -2.3%     -2.6%
      +1 s.d.   -----     +5.2%            +3.7%     +4.4%
      Average   -----     +2.5%            +0.7%     +0.8%
      
      ```
      I checked each case and couldn't find consistent slow-down/speed-up on
      compile time. Full results here: P173
      
      Reviewers: simonpj, simonmar, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter, simonmar
      
      GHC Trac Issues: #14667
      
      Differential Revision: https://phabricator.haskell.org/D4329
      88297438
    • Takenobu Tani's avatar
      Implement underscores in numeric literals (NumericUnderscores extension) · 4a13c5b1
      Takenobu Tani authored
      Implement the proposal of underscores in numeric literals.
      Underscores in numeric literals are simply ignored.
      
      The specification of the feature is available here:
      https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/000
      9-numeric-underscores.rst
      
      For a discussion of the various choices:
      https://github.com/ghc-proposals/ghc-proposals/pull/76
      
      Implementation detail:
      
      * Added dynamic flag
        * `NumericUnderscores` extension flag is added for this feature.
      
      * Alex "Regular expression macros" in Lexer.x
        * Add `@numspc` (numeric spacer) macro to represent multiple
          underscores.
        * Modify `@decimal`, `@decimal`, `@binary`, `@octal`, `@hexadecimal`,
          `@exponent`, and `@bin_exponent` macros to include `@numspc`.
      
      * Alex "Rules" in Lexer.x
        * To be simpler, we have only the definitions with underscores.
          And then we have a separate function (`tok_integral` and `tok_frac`)
          that validates the literals.
      
      * Validation functions in Lexer.x
        * `tok_integral` and `tok_frac` functions validate
          whether contain underscores or not.
          If `NumericUnderscores` extensions are not enabled,
          check that there are no underscores.
        * `tok_frac` function is created by merging `strtoken` and
          `init_strtoken`.
        * `init_strtoken` is deleted. Because it is no longer used.
      
      * Remove underscores from target literal string
        * `parseUnsignedInteger`, `readRational__`, and `readHexRational} use
          the customized `span'` function to remove underscores.
      
      * Added Testcase
        * testcase for NumericUnderscores enabled.
            NumericUnderscores0.hs and NumericUnderscores1.hs
        * testcase for NumericUnderscores disabled.
            NoNumericUnderscores0.hs and NoNumericUnderscores1.hs
        * testcase to invalid pattern for NumericUnderscores enabled.
            NumericUnderscoresFail0.hs and NumericUnderscoresFail1.hs
      
      Test Plan: `validate` including the above testcase
      
      Reviewers: goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: carter, rwbarton, thomie
      
      GHC Trac Issues: #14473
      
      Differential Revision: https://phabricator.haskell.org/D4235
      4a13c5b1
    • Douglas Wilson's avatar
      [rts] Adjust whitehole_spin · 180ca65f
      Douglas Wilson authored
      Rename to whitehole_gc_spin, in preparation for adding stats for the
      whitehole busy-loop in SMPClosureOps.
      
      Make whitehole_gc_spin volatile, and move it to be defined and
      statically initialised in GC.c. This saves some #ifs, and I'm pretty
      sure it should be volatile.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4300
      180ca65f
    • Alp Mestanogullari's avatar
      tentative improvement to callstack docs · 5edb18a9
      Alp Mestanogullari authored
      This is an attempt at clarifying the docs for HasCallStack in both the
      user guide and libraries/base/GHC/Stack/Types.hs. The example used right
      now is built around an hypothetical 'error' function that doesn't itself
      print call stacks, and the fact that this doesn't hold makes it all
      confusing, see #14635.
      
      Reviewers: hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14635
      
      Differential Revision: https://phabricator.haskell.org/D4317
      5edb18a9