1. 12 Nov, 2019 1 commit
  2. 07 Nov, 2019 1 commit
  3. 23 Oct, 2019 1 commit
    • Andreas Klebinger's avatar
      Make dynflag argument for withTiming pure. · 6beea836
      Andreas Klebinger authored
      19 times out of 20 we already have dynflags in scope.
      
      We could just always use `return dflags`. But this is in fact not free.
      When looking at some STG code I noticed that we always allocate a
      closure for this expression in the heap. Clearly a waste in these cases.
      
      For the other cases we can either just modify the callsite to
      get dynflags or use the _D variants of withTiming I added which
      will use getDynFlags under the hood.
      6beea836
  4. 22 Oct, 2019 1 commit
    • Stefan Schulze Frielinghaus's avatar
      Implement s390x LLVM backend. · fd8b666a
      Stefan Schulze Frielinghaus authored
      This patch adds support for the s390x architecture for the LLVM code
      generator. The patch includes a register mapping of STG registers onto
      s390x machine registers which enables a registerised build.
      fd8b666a
  5. 07 Oct, 2019 1 commit
    • Ben Gamari's avatar
      Refactor, document, and optimize LLVM configuration loading · b2577081
      Ben Gamari authored
      As described in the new Note [LLVM Configuration] in SysTools, we now
      load llvm-targets and llvm-passes lazily to avoid the overhead of doing
      so when -fllvm isn't used (also known as "the common case").
      
      Noticed in #17003.
      
      Metric Decrease:
          T12234
          T12150
      b2577081
  6. 09 Sep, 2019 1 commit
    • Sylvain Henry's avatar
      Module hierarchy: StgToCmm (#13009) · 447864a9
      Sylvain Henry authored
      Add StgToCmm module hierarchy. Platform modules that are used in several
      other places (NCG, LLVM codegen, Cmm transformations) are put into
      GHC.Platform.
      447864a9
  7. 29 Aug, 2019 1 commit
    • Ömer Sinan Ağacan's avatar
      Fix LLVM version check yet again · bf9dfe1c
      Ömer Sinan Ağacan authored
      There were two problems with LLVM version checking:
      
      - The parser would only parse x and x.y formatted versions. E.g. 1.2.3
        would be rejected.
      
      - The version check was too strict and would reject x.y formatted
        versions. E.g. when we support version 7 it'd reject 7.0 ("LLVM
        version 7.0") and only accept 7 ("LLVM version 7").
      
      We now parse versions with arbitrarily deep minor numbering (x.y.z.t...)
      and accept versions as long as the major version matches the supported
      version (e.g. 7.1, 7.1.2, 7.1.2.3 ...).
      bf9dfe1c
  8. 28 Aug, 2019 1 commit
    • Ömer Sinan Ağacan's avatar
      Return results of Cmm streams in backends · 1c7ec449
      Ömer Sinan Ağacan authored
      This generalizes code generators (outputAsm, outputLlvm, outputC, and
      the call site codeOutput) so that they'll return the return values of
      the passed Cmm streams.
      
      This allows accumulating data during Cmm generation and returning it to
      the call site in HscMain.
      
      Previously the Cmm streams were assumed to return (), so the code
      generators returned () as well.
      
      This change is required by !1304 and !1530.
      
      Skipping CI as this was tested before and I only updated the commit
      message.
      
      [skip ci]
      1c7ec449
  9. 23 Aug, 2019 1 commit
    • Ömer Sinan Ağacan's avatar
      Make non-streaming LLVM and C backends streaming · a8300520
      Ömer Sinan Ağacan authored
      This adds a Stream.consume function, uses it in LLVM and C code
      generators, and removes the use of Stream.collect function which was
      used to collect streaming Cmm generation results into a list.
      
      LLVM and C backends now properly use streamed Cmm generation, instead of
      collecting Cmm groups into a list before generating LLVM/C code.
      a8300520
  10. 16 Jul, 2019 1 commit
  11. 14 Jul, 2019 1 commit
  12. 03 Jul, 2019 1 commit
  13. 28 Jun, 2019 1 commit
    • Travis Whitaker's avatar
      Correct closure observation, construction, and mutation on weak memory machines. · 11bac115
      Travis Whitaker authored
      Here the following changes are introduced:
          - A read barrier machine op is added to Cmm.
          - The order in which a closure's fields are read and written is changed.
          - Memory barriers are added to RTS code to ensure correctness on
            out-or-order machines with weak memory ordering.
      
      Cmm has a new CallishMachOp called MO_ReadBarrier. On weak memory machines, this
      is lowered to an instruction that ensures memory reads that occur after said
      instruction in program order are not performed before reads coming before said
      instruction in program order. On machines with strong memory ordering properties
      (e.g. X86, SPARC in TSO mode) no such instruction is necessary, so
      MO_ReadBarrier is simply erased. However, such an instruction is necessary on
      weakly ordered machines, e.g. ARM and PowerPC.
      
      Weam memory ordering has consequences for how closures are observed and mutated.
      For example, consider a closure that needs to be updated to an indirection. In
      order for the indirection to be safe for concurrent observers to enter, said
      observers must read the indirection's info table before they read the
      indirectee. Furthermore, the entering observer makes assumptions about the
      closure based on its info table contents, e.g. an INFO_TYPE of IND imples the
      closure has an indirectee pointer that is safe to follow.
      
      When a closure is updated with an indirection, both its info table and its
      indirectee must be written. With weak memory ordering, these two writes can be
      arbitrarily reordered, and perhaps even interleaved with other threads' reads
      and writes (in the absence of memory barrier instructions). Consider this
      example of a bad reordering:
      
      - An updater writes to a closure's info table (INFO_TYPE is now IND).
      - A concurrent observer branches upon reading the closure's INFO_TYPE as IND.
      - A concurrent observer reads the closure's indirectee and enters it. (!!!)
      - An updater writes the closure's indirectee.
      
      Here the update to the indirectee comes too late and the concurrent observer has
      jumped off into the abyss. Speculative execution can also cause us issues,
      consider:
      
      - An observer is about to case on a value in closure's info table.
      - The observer speculatively reads one or more of closure's fields.
      - An updater writes to closure's info table.
      - The observer takes a branch based on the new info table value, but with the
        old closure fields!
      - The updater writes to the closure's other fields, but its too late.
      
      Because of these effects, reads and writes to a closure's info table must be
      ordered carefully with respect to reads and writes to the closure's other
      fields, and memory barriers must be placed to ensure that reads and writes occur
      in program order. Specifically, updates to a closure must follow the following
      pattern:
      
      - Update the closure's (non-info table) fields.
      - Write barrier.
      - Update the closure's info table.
      
      Observing a closure's fields must follow the following pattern:
      
      - Read the closure's info pointer.
      - Read barrier.
      - Read the closure's (non-info table) fields.
      
      This patch updates RTS code to obey this pattern. This should fix long-standing
      SMP bugs on ARM (specifically newer aarch64 microarchitectures supporting
      out-of-order execution) and PowerPC. This fixes issue #15449.
      Co-Authored-By: Ben Gamari's avatarBen Gamari <ben@well-typed.com>
      11bac115
  14. 24 Jun, 2019 1 commit
    • Erik de Castro Lopo's avatar
      Fixes for LLVM 7 · 71aca77c
      Erik de Castro Lopo authored
      LLVM version numberinf changed recently. Previously, releases were numbered
      4.0, 5.0 and 6.0 but with version 7, they dropped the redundant ".0".
      
      Fix requires for Llvm detection and some code.
      71aca77c
  15. 20 Jun, 2019 1 commit
    • John Ericson's avatar
      Move 'Platform' to ghc-boot · bff2f24b
      John Ericson authored
      ghc-pkg needs to be aware of platforms so it can figure out which
      subdire within the user package db to use. This is admittedly
      roundabout, but maybe Cabal could use the same notion of a platform as
      GHC to good affect too.
      bff2f24b
  16. 12 Jun, 2019 1 commit
  17. 09 Jun, 2019 1 commit
  18. 14 May, 2019 1 commit
    • John Ericson's avatar
      Remove all target-specific portions of Config.hs · e529c65e
      John Ericson authored
      1. If GHC is to be multi-target, these cannot be baked in at compile
         time.
      
      2. Compile-time flags have a higher maintenance than run-time flags.
      
      3. The old way makes build system implementation (various bootstrapping
         details) with the thing being built. E.g. GHC doesn't need to care
         about which integer library *will* be used---this is purely a crutch
         so the build system doesn't need to pass flags later when using that
         library.
      
      4. Experience with cross compilation in Nixpkgs has shown things work
         nicer when compiler's can *optionally* delegate the bootstrapping the
         package manager. The package manager knows the entire end-goal build
         plan, and thus can make top-down decisions on bootstrapping. GHC can
         just worry about GHC, not even core library like base and ghc-prim!
      e529c65e
  19. 15 Apr, 2019 1 commit
    • Gabor Greif's avatar
      asm-emit-time IND_STATIC elimination · be05bd81
      Gabor Greif authored
      When a new closure identifier is being established to a
      local or exported closure already emitted into the same
      module, refrain from adding an IND_STATIC closure, and
      instead emit an assembly-language alias.
      
      Inter-module IND_STATIC objects still remain, and need to be
      addressed by other measures.
      
      Binary-size savings on nofib are around 0.1%.
      be05bd81
  20. 11 Apr, 2019 1 commit
    • Carter Schonwald's avatar
      removing x87 register support from native code gen · 42504f4a
      Carter Schonwald authored
      * simplifies registers to have GPR, Float and Double, by removing the SSE2 and X87 Constructors
      * makes -msse2 assumed/default for x86 platforms, fixing a long standing nondeterminism in rounding
      behavior in 32bit haskell code
      * removes the 80bit floating point representation from the supported float sizes
      * theres still 1 tiny bit of x87 support needed,
      for handling float and double return values in FFI calls  wrt the C ABI on x86_32,
      but this one piece does not leak into the rest of NCG.
      * Lots of code thats not been touched in a long time got deleted as a
      consequence of all of this
      
      all in all, this change paves the way towards a lot of future further
      improvements in how GHC handles floating point computations, along with
      making the native code gen more accessible to a larger pool of contributors.
      42504f4a
  21. 01 Apr, 2019 1 commit
  22. 15 Mar, 2019 1 commit
  23. 31 Jan, 2019 1 commit
  24. 18 Jan, 2019 1 commit
  25. 14 Dec, 2018 1 commit
  26. 22 Nov, 2018 5 commits
    • David Eichmann's avatar
      Fix unused-import warnings · 6353efc7
      David Eichmann authored
      This patch fixes a fairly long-standing bug (dating back to 2015) in
      RdrName.bestImport, namely
      
         commit 9376249b
         Author: Simon Peyton Jones <simonpj@microsoft.com>
         Date:   Wed Oct 28 17:16:55 2015 +0000
      
         Fix unused-import stuff in a better way
      
      In that patch got the sense of the comparison back to front, and
      thereby failed to implement the unused-import rules described in
        Note [Choosing the best import declaration] in RdrName
      
      This led to Trac #13064 and #15393
      
      Fixing this bug revealed a bunch of unused imports in libraries;
      the ones in the GHC repo are part of this commit.
      
      The two important changes are
      
      * Fix the bug in bestImport
      
      * Modified the rules by adding (a) in
           Note [Choosing the best import declaration] in RdrName
        Reason: the previosu rules made Trac #5211 go bad again.  And
        the new rule (a) makes sense to me.
      
      In unravalling this I also ended up doing a few other things
      
      * Refactor RnNames.ImportDeclUsage to use a [GlobalRdrElt] for the
        things that are used, rather than [AvailInfo]. This is simpler
        and more direct.
      
      * Rename greParentName to greParent_maybe, to follow GHC
        naming conventions
      
      * Delete dead code RdrName.greUsedRdrName
      
      Bumps a few submodules.
      
      Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27
      
      Subscribers: rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5312
      6353efc7
    • Gabor Greif's avatar
      llvmGen: Eliminate duplicate definition · d0fc7618
      Gabor Greif authored
      remove local
      d0fc7618
    • Sylvain Henry's avatar
      Rename literal constructors · 13bb4bf4
      Sylvain Henry authored
      In a previous patch we replaced some built-in literal constructors
      (MachInt, MachWord, etc.) with a single LitNumber constructor.
      
      In this patch we replace the `Mach` prefix of the remaining constructors
      with `Lit` for consistency (e.g., LitChar, LitLabel, etc.).
      
      Sadly the name `LitString` was already taken for a kind of FastString
      and it would become misleading to have both `LitStr` (literal
      constructor renamed after `MachStr`) and `LitString` (FastString
      variant). Hence this patch renames the FastString variant `PtrString`
      (which is more accurate) and the literal string constructor now uses the
      least surprising `LitString` name.
      
      Both `Literal` and `LitString/PtrString` have recently seen breaking
      changes so doing this kind of renaming now shouldn't harm much.
      
      Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27, tdammers
      
      Subscribers: tdammers, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4881
      13bb4bf4
    • Gabor Greif's avatar
      Minor performance optimisation · 8707911a
      Gabor Greif authored
      only concat once
      8707911a
    • Gabor Greif's avatar
      another minor refactoring · 4343d5af
      Gabor Greif authored
      4343d5af
  27. 07 Nov, 2018 3 commits
  28. 02 Nov, 2018 1 commit
    • Michal Terepeta's avatar
      Add Int8# and Word8# · 2c959a18
      Michal Terepeta authored
      This is the first step of implementing:
      https://github.com/ghc-proposals/ghc-proposals/pull/74
      
      The main highlights/changes:
      
          primops.txt.pp gets two new sections for two new primitive types for
          signed and unsigned 8-bit integers (Int8# and Word8 respectively) along
          with basic arithmetic and comparison operations. PrimRep/RuntimeRep get
          two new constructors for them. All of the primops translate into the
          existing MachOPs.
      
          For CmmCalls the codegen will now zero-extend the values at call
          site (so that they can be moved to the right register) and then truncate
          them back their original width.
      
          x86 native codegen needed some updates, since it wasn't able to deal
          with the new widths, but all the changes are quite localized. LLVM
          backend seems to just work.
      
      This is the second attempt at merging this, after the first attempt in
      D4475 had to be backed out due to regressions on i386.
      
      Bumps binary submodule.
      Signed-off-by: Michal Terepeta's avatarMichal Terepeta <michal.terepeta@gmail.com>
      
      Test Plan: ./validate (on both x86-{32,64})
      
      Reviewers: bgamari, hvr, goldfire, simonmar
      
      Subscribers: rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5258
      2c959a18
  29. 28 Oct, 2018 1 commit
    • Kavon Farvardin's avatar
      Fix for T14251 on ARM · d8495549
      Kavon Farvardin authored
      We now calculate the SSE register padding needed to fix the calling
      convention in LLVM in a robust way: grouping them by whether
      registers in that class overlap (with the same class overlapping
      itself).
      
      My prior patch assumed that no matter the platform, physical
      register Fx aliases with Dx, etc, for our calling convention.
      
      This is unfortunately not the case for any platform except x86-64.
      
      Test Plan:
      Only know how to test on x86-64, but it should be tested on ARM with:
      
      `make test WAYS=llvm && make test WAYS=optllvm`
      
      Reviewers: bgamari, angerman
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15780, #14251, #15747
      
      Differential Revision: https://phabricator.haskell.org/D5254
      d8495549
  30. 09 Oct, 2018 1 commit
    • Ben Gamari's avatar
      Revert "Add Int8# and Word8#" · d728c3c5
      Ben Gamari authored
      This unfortunately broke i386 support since it introduced references to
      byte-sized registers that don't exist on that architecture.
      
      Reverts binary submodule
      
      This reverts commit 5d5307f9.
      d728c3c5
  31. 07 Oct, 2018 1 commit
    • Michal Terepeta's avatar
      Add Int8# and Word8# · 5d5307f9
      Michal Terepeta authored
      This is the first step of implementing:
      https://github.com/ghc-proposals/ghc-proposals/pull/74
      
      The main highlights/changes:
      
      - `primops.txt.pp` gets two new sections for two new primitive types
        for signed and unsigned 8-bit integers (`Int8#` and `Word8`
        respectively) along with basic arithmetic and comparison
        operations. `PrimRep`/`RuntimeRep` get two new constructors for
        them. All of the primops translate into the existing `MachOP`s.
      
      - For `CmmCall`s the codegen will now zero-extend the values at call
        site (so that they can be moved to the right register) and then
        truncate them back their original width.
      
      - x86 native codegen needed some updates, since it wasn't able to deal
        with the new widths, but all the changes are quite localized. LLVM
        backend seems to just work.
      
      Bumps binary submodule.
      Signed-off-by: Michal Terepeta's avatarMichal Terepeta <michal.terepeta@gmail.com>
      
      Test Plan: ./validate with new tests
      
      Reviewers: hvr, goldfire, bgamari, simonmar
      
      Subscribers: Abhiroop, dfeuer, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4475
      5d5307f9
  32. 05 Oct, 2018 1 commit
    • Kavon Farvardin's avatar
      Multiple fixes / improvements for LLVM backend · adcb5fb4
      Kavon Farvardin authored
      - Fix for #13904 -- stop "trashing" callee-saved registers, since it is
        not actually doing anything useful.
      
      - Fix for #14251 -- fixes the calling convention for functions passing
        raw SSE-register values by adding padding as needed to get the values
        in the right registers. This problem cropped up when some args were
        unused an dropped from the live list.
      
      - Fixed a typo in 'readnone' attribute
      
      - Added 'lower-expect' pass to level 0 LLVM optimization passes to
        improve block layout in LLVM for stack checks, etc.
      
      Test Plan: `make test WAYS=optllvm` and `make test WAYS=llvm`
      
      Reviewers: bgamari, simonmar, angerman
      
      Reviewed By: angerman
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #13904, #14251
      
      Differential Revision: https://phabricator.haskell.org/D5190
      adcb5fb4
  33. 21 Aug, 2018 1 commit
  34. 07 Aug, 2018 1 commit
    • Herbert Valerio Riedel's avatar
      Turn on MonadFail desugaring by default · aab8656b
      Herbert Valerio Riedel authored
      Summary:
      This contains two commits:
      
      ----
      
      Make GHC's code-base compatible w/ `MonadFail`
      
      There were a couple of use-sites which implicitly used pattern-matches
      in `do`-notation even though the underlying `Monad` didn't explicitly
      support `fail`
      
      This refactoring turns those use-sites into explicit case
      discrimations and adds an `MonadFail` instance for `UniqSM`
      (`UniqSM` was the worst offender so this has been postponed for a
      follow-up refactoring)
      
      ---
      
      Turn on MonadFail desugaring by default
      
      This finally implements the phase scheduled for GHC 8.6 according to
      
      https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail#Transitionalstrategy
      
      This also preserves some tests that assumed MonadFail desugaring to be
      active; all ghc boot libs were already made compatible with this
      `MonadFail` long ago, so no changes were needed there.
      
      Test Plan: Locally performed ./validate --fast
      
      Reviewers: bgamari, simonmar, jrtc27, RyanGlScott
      
      Reviewed By: bgamari
      
      Subscribers: bgamari, RyanGlScott, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D5028
      aab8656b