1. 22 May, 2020 1 commit
    • Sylvain Henry's avatar
      Utils: new_worktree script · 34004f76
      Sylvain Henry authored
      This script makes it faster/easier to create a new GIT worktree by
      copying submodules. It avoids downloading them again.
      34004f76
  2. 21 May, 2020 30 commits
    • Sylvain Henry's avatar
      Move isDynLinkName into GHC.Types.Name · 566cc73f
      Sylvain Henry authored
      It doesn't belong into GHC.Unit.State
      566cc73f
    • Krzysztof Gogolewski's avatar
      Sort deterministically metric output · 8a816e5f
      Krzysztof Gogolewski authored
      Previously, we sorted according to the test name and way,
      but the metrics (max_bytes_used/peak_megabytes_allocated etc.)
      were appearing in nondeterministic order.
      8a816e5f
    • Krzysztof Gogolewski's avatar
      Add a regression test for #11506 · a1275081
      Krzysztof Gogolewski authored
      The testcase works now.
      See explanation in #11506 (comment 273202)
      a1275081
    • Andreas Klebinger's avatar
      Don't variable-length encode magic iface constant. · 4ca0c8a1
      Andreas Klebinger authored
      We changed to use variable length encodings for many types by default,
      including Word32. This makes sense for numbers but not when Word32 is
      meant to represent four bytes.
      
      I added a FixedLengthEncoding newtype to Binary who's instances
      interpret their argument as a collection of bytes instead of a number.
      
      We then use this when writing/reading magic numbers to the iface file.
      
      I also took the libery to remove the dummy iface field.
      
      This fixes #18180.
      4ca0c8a1
    • Alexey Kuleshevich's avatar
      Fix wording in primops documentation to reflect the correct reasoning: · 1b508a9e
      Alexey Kuleshevich authored
      * Besides resizing functions, shrinking ones also mutate the
        size of a mutable array and because of those two `sizeofMutabeByteArray`
        and `sizeofSmallMutableArray` are now deprecated
      * Change reference in documentation to the newer functions `getSizeof*`
        instead of `sizeof*` for shrinking functions
      * Fix incorrect mention of "byte" instead of "small"
      1b508a9e
    • Galen Huntington's avatar
      d3d055b8
    • Sebastian Graf's avatar
      Make `Int`'s `mod` and `rem` strict in their first arguments · a95bbd0b
      Sebastian Graf authored
      They used to be strict until 4d2ac2d4 (9 years ago).
      
      It's obviously better to be strict for performance reasons.
      It also blocks #18067.
      
      NoFib results:
      
      ```
      --------------------------------------------------------------------------------
              Program         Allocs    Instrs
      --------------------------------------------------------------------------------
              integer          -1.1%     +0.4%
         wheel-sieve2         +21.2%    +20.7%
      --------------------------------------------------------------------------------
                  Min          -1.1%     -0.0%
                  Max         +21.2%    +20.7%
       Geometric Mean          +0.2%     +0.2%
      ```
      
      The regression in `wheel-sieve2` is due to reboxing that likely will go
      away with the resolution of #18067. See !3282 for details.
      
      Fixes #18187.
      a95bbd0b
    • Richard Eisenberg's avatar
      MR template should ask for key part · 2b363ebb
      Richard Eisenberg authored
      2b363ebb
    • Vilem-Benjamin Liepelt's avatar
    • Vilem-Benjamin Liepelt's avatar
      Piggyback on Enum Word methods for Word64 · e7480063
      Vilem-Benjamin Liepelt authored
      If we are on a 64 bit platform, we can use the efficient Enum Word
      methods for the Enum Word64 instance.
      e7480063
    • Vilem-Benjamin Liepelt's avatar
      Add INLINABLE pragmas to Enum list producers · b552e531
      Vilem-Benjamin Liepelt authored
      The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in
      the interface file so we can do list fusion at usage sites.
      
      Related tickets: #15185, #8763, #18178.
      b552e531
    • Vilem-Benjamin Liepelt's avatar
      Fix spelling mistakes and typos · 3451584f
      Vilem-Benjamin Liepelt authored
      3451584f
    • John Ericson's avatar
      6890c38d
    • John Ericson's avatar
      Tiny cleaup eta-reduce away a function argument · cb4231db
      John Ericson authored
      In GHC, not in the code being compiled!
      cb4231db
    • John Ericson's avatar
      510e0451
    • John Ericson's avatar
      More judiciously panic in `ts_pat` · 5108e84a
      John Ericson authored
      5108e84a
    • John Ericson's avatar
      Use `Checker` for `tc_lpat` and `tc_lpats` · b797aa42
      John Ericson authored
      b797aa42
    • John Ericson's avatar
      Use `Checker` for `tc_pat` · 964d3ea2
      John Ericson authored
      964d3ea2
    • Tuan Le's avatar
    • Stefan Holdermans's avatar
      Update documentation for GHCi :script · cf566330
      Stefan Holdermans authored
      This patch adds the fixes that allow for file names containing spaces to
      be passed to GHCi's ':script' command to the release notes for 8.12 and
      expands the user-guide documentation for ':script' by mentioning how
      such file names can be passed.
      
      Related to #18027.
      cf566330
    • Stefan Holdermans's avatar
      Allow GHCi :script file names in double quotes · a0b79e1b
      Stefan Holdermans authored
      This patch updates the user interface of GHCi so that file names passed
      to the ':script' command can be wrapped in double quotes.
      
      For example:
      
        :script "foo bar.script"
      
      The implementation uses a modified version of 'words' that treats
      character sequences enclosed in double quotes as single words.
      
      Fixes #18027.
      a0b79e1b
    • Stefan Holdermans's avatar
      Add extra tests for GHCi :script syntax checks · 82663959
      Stefan Holdermans authored
      The syntax for GHCi's ":script" command allows for only a single file
      name to be passed as an argument. This patch adds a test for the cases
      in which a file name is missing or multiple file names are passed.
      
      Related to #T18027.
      82663959
    • Stefan Holdermans's avatar
      Allow spaces in GHCi :script file names · a8c27cf6
      Stefan Holdermans authored
      This patch updates the user interface of GHCi so that file names passed
      to the ':script' command may contain spaces escaped with a backslash.
      
      For example:
      
        :script foo\ bar.script
      
      The implementation uses a modified version of 'words' that does not
      break on escaped spaces.
      
      Fixes #18027.
      a8c27cf6
    • Gleb Popov's avatar
      gitlab-ci: Set locale to C.UTF-8. · b7a6b2f4
      Gleb Popov authored
      b7a6b2f4
    • Andreas Klebinger's avatar
      NCG: Codelayout: Distinguish conditional and other branches. · edc2cc58
      Andreas Klebinger authored
      In #18053 we ended up with a suboptimal code layout because
      the code layout algorithm didn't distinguish between conditional
      and unconditional control flow.
      
      We can completely eliminate unconditional control flow instructions
      by placing blocks next to each other, not so much for conditionals.
      
      In terms of implementation we simply give conditional branches less
      weight before computing the layout.
      
      Fixes #18053
      edc2cc58
    • Andreas Klebinger's avatar
      Refactor linear reg alloc to remember past assignments. · 13f6c9d0
      Andreas Klebinger authored
      When assigning registers we now first try registers we
      assigned to in the past, instead of picking the "first"
      one.
      
      This is in extremely helpful when dealing with loops for
      which variables are dead for part of the loop.
      
      This is important for patterns like this:
      
              foo = arg1
          loop:
              use(foo)
              ...
              foo = getVal()
              goto loop;
      
      There we:
      * assign foo to the register of arg1.
      * use foo, it's dead after this use as it's overwritten after.
      * do other things.
      * look for a register to put foo in.
      
      If we pick an arbitrary one it might differ from the register the
      start of the loop expect's foo to be in.
      To fix this we simply look for past register assignments for
      the given variable. If we find one and the register is free we
      use that register.
      
      This reduces the need for fixup blocks which match the register
      assignment between blocks. In the example above between the end
      and the head of the loop.
      
      This patch also moves branch weight estimation ahead of register
      allocation and adds a flag to control it (cmm-static-pred).
      * It means the linear allocator is more likely to assign the hotter
        code paths first.
      * If it assign these first we are:
        + Less likely to spill on the hot path.
        + Less likely to introduce fixup blocks on the hot path.
      
      These two measure combined are surprisingly effective. Based on nofib
      we get in the mean:
      
      * -0.9% instructions executed
      * -0.1% reads/writes
      * -0.2% code size.
      * -0.1% compiler allocations.
      * -0.9% compile time.
      * -0.8% runtime.
      
      Most of the benefits are simply a result of removing redundant moves
      and spills.
      
      Reduced compiler allocations likely are the result of less code being
      generated. (The added lookup is mostly non-allocating).
      13f6c9d0
    • Ben Gamari's avatar
      nonmoving: Optimise the write barrier · 78c6523c
      Ben Gamari authored
      78c6523c
    • Ben Price's avatar
      Lint should say when it is checking a rule · 24e61aad
      Ben Price authored
      It is rather confusing that when lint finds an error in a rule attached
      to a binder, it reports the error as in the RHS, not the rule:
        ...
        In the RHS of foo
      
      We add a clarifying line:
        ...
        In the RHS of foo
        In a rule attached to foo
      
      The implication that the rule lives inside the RHS is a bit odd, but
      this niggle is already present for unfoldings, whose pattern we are
      following.
      24e61aad
    • Gert-Jan Bottu's avatar
      Explicit Specificity · a9311cd5
      Gert-Jan Bottu authored
      Implementation for Ticket #16393.
      Explicit specificity allows users to manually create inferred type variables,
      by marking them with braces.
      This way, the user determines which variables can be instantiated through
      visible type application.
      
      The additional syntax is included in the parser, allowing users to write
      braces in type variable binders (type signatures, data constructors etc).
      This information is passed along through the renamer and verified in the
      type checker.
      The AST for type variable binders, data constructors, pattern synonyms,
      partial signatures and Template Haskell has been updated to include the
      specificity of type variables.
      
      Minor notes:
      - Bumps haddock submodule
      - Disables pattern match checking in GHC.Iface.Type with GHC 8.8
      a9311cd5
    • Fumiaki Kinoshita's avatar
      base: Add Generic instances to various datatypes under GHC.* · 55f0e783
      Fumiaki Kinoshita authored
      * GHC.Fingerprint.Types: Fingerprint
      * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags
      * GHC.Stats: RTSStats and GCStats
      * GHC.ByteOrder: ByteOrder
      * GHC.Unicode: GeneralCategory
      * GHC.Stack.Types: SrcLoc
      
      Metric Increase:
          haddock.base
      55f0e783
  3. 17 May, 2020 1 commit
    • Ryan Scott's avatar
      Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr · 5bcf8606
      Ryan Scott authored
      There are two different Notes named `[When to print foralls]`. The
      most up-to-date one is in `GHC.Iface.Type`, but there is a second
      one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was
      written before GHC switched over to using ifaces to pretty-print
      types. I decided to just remove the latter and replace it with a
      reference to the former.
      
      [ci skip]
      5bcf8606
  4. 15 May, 2020 2 commits
    • Ben Gamari's avatar
      GHC.Cmm.Opt: Handle MO_XX_Conv · 568d7279
      Ben Gamari authored
      This MachOp was introduced by 2c959a18
      but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't
      handled. Ideally we would eliminate the match but this appears to be a
      larger task.
      
      Fixes #18141.
      568d7279
    • Sebastian Graf's avatar
      DmdAnal: Improve handling of precise exceptions · 9bd20e83
      Sebastian Graf authored
      This patch does two things: Fix possible unsoundness in what was called
      the "IO hack" and implement part 2.1 of the "fixing precise exceptions"
      plan in
      https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions,
      which, in combination with !2956, supersedes !3014 and !2525.
      
      **IO hack**
      
      The "IO hack" (which is a fallback to preserve precise exceptions
      semantics and thus soundness, rather than some smart thing that
      increases precision) is called `exprMayThrowPreciseException` now.
      I came up with two testcases exemplifying possible unsoundness (if
      twisted enough) in the old approach:
      
      - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting
                   to manual state token threading and direct use of primops.
                   More details below.
      - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have
                   Nested CPR. Not currently relevant, as we don't have Nested
                   CPR yet.
      - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI
                   calls.
      
      Basically, the IO hack assumed that precise exceptions can only be
      thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I
      couldn't come up with a program using the `IO` abstraction that violates
      this assumption. But it's easy to do so via manual state token threading
      and direct use of primops, see `T13380d`. Also similar code might be
      generated by Nested CPR in the (hopefully not too) distant future, see
      `T13380e`. Hence, we now have a more careful test in `forcesRealWorld`
      that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR).
      
      **Precise exceptions**
      
      In #13380 and #17676 we saw that we didn't preserve precise exception
      semantics in demand analysis. We fixed that with minimal changes in
      !2956, but that was terribly unprincipled.
      
      That unprincipledness resulted in a loss of precision, which is tracked
      by these new test cases:
      
      - `T13380b`: Regression in dead code elimination, because !2956 was too
                   syntactic about `raiseIO#`
      - `T13380c`: No need to apply the "IO hack" when the IO action may not
                   throw a precise exception (and the existing IO hack doesn't
                   detect that)
      
      Fixing both issues in !3014 turned out to be too complicated and had
      the potential to regress in the future. Hence we decided to only fix
      `T13380b` and augment the `Divergence` lattice with a new middle-layer
      element, `ExnOrDiv`, which means either `Diverges` (, throws an
      imprecise exception) or throws a *precise* exception.
      
      See the wiki page on Step 2.1 for more implementational details:
      https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21
      9bd20e83
  5. 14 May, 2020 6 commits