1. 07 Oct, 2019 1 commit
  2. 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
  3. 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
  4. 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
  5. 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
  6. 14 Jul, 2019 1 commit
  7. 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
  8. 15 Mar, 2019 1 commit
  9. 22 Nov, 2018 1 commit
  10. 19 Sep, 2017 1 commit
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
  11. 06 Sep, 2017 1 commit
    • Moritz Angermann's avatar
      Clean up opt and llc · 22733532
      Moritz Angermann authored
      The LLVM backend shells out to LLVMs `opt` and `llc` tools. This clean
      up introduces a shared data structure to carry the arguments we pass to
      each tool so that corresponding flags are next to each other. It drops
      the hard coded data layouts in favor of using `-mtriple` and have LLVM
      infer them. Furthermore we add `clang` as a proper tool, so we don't
      rely on assuming that `clang` is called `clang` on the `PATH` when using
      `clang` as the assembler.  Finally this diff also changes the type of
      `optLevel` from `Int` to `Word`, as we do not have negative optimization
      levels.
      
      Reviewers: erikd, hvr, austin, rwbarton, bgamari, kavon
      
      Reviewed By: kavon
      
      Subscribers: michalt, Ericson2314, ryantrinkle, dfeuer, carter, simonpj,
      kavon, simonmar, thomie, erikd, snowleopard
      
      Differential Revision: https://phabricator.haskell.org/D3352
      22733532
  12. 23 Jun, 2017 1 commit
    • Michal Terepeta's avatar
      Hoopl: remove dependency on Hoopl package · 42eee6ea
      Michal Terepeta authored
      This copies the subset of Hoopl's functionality needed by GHC to
      `cmm/Hoopl` and removes the dependency on the Hoopl package.
      
      The main motivation for this change is the confusing/noisy interface
      between GHC and Hoopl:
      - Hoopl has `Label` which is GHC's `BlockId` but different than
        GHC's `CLabel`
      - Hoopl has `Unique` which is different than GHC's `Unique`
      - Hoopl has `Unique{Map,Set}` which are different than GHC's
        `Uniq{FM,Set}`
      - GHC has its own specialized copy of `Dataflow`, so `cmm/Hoopl` is
        needed just to filter the exposed functions (filter out some of the
        Hoopl's and add the GHC ones)
      With this change, we'll be able to simplify this significantly.
      It'll also be much easier to do invasive changes (Hoopl is a public
      package on Hackage with users that depend on the current behavior)
      
      This should introduce no changes in functionality - it merely
      copies the relevant code.
      Signed-off-by: Michal Terepeta's avatarMichal Terepeta <michal.terepeta@gmail.com>
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari, simonmar
      
      Reviewed By: bgamari, simonmar
      
      Subscribers: simonpj, kavon, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3616
      42eee6ea
  13. 15 Jan, 2017 1 commit
    • Erik de Castro Lopo's avatar
      LLVM: Tweak TBAA metadata codegen · 9d67f04d
      Erik de Castro Lopo authored
      This change is requred for llvm 4.0. GHC doesn't use that version yet,
      but this change is just as valid for versions eariler than 4.0.
      
      Two changes needed:
      
      * Previously, GHC defined a `topN` node in the TBAA heiarchy and some IR
        instructions referenced that node. With LLVM 4.0 the root node can no
        longer be referenced by IR instructions, so we introduce a new element
        `rootN` and make `topN` a child of that.
      
      * Previously the root TBAA node was rendered as "!0 = !{!"root", null}".
        With LLVM 4.0 that needs to be "!0 = !{!"root"}" which is also
        accepted by earlier versions.
      
      Test Plan: Build with quick-llvm BuildFlavor and run tests
      
      Reviewers: bgamari, drbo, austin, angerman, michalt, DemiMarie
      
      Reviewed By: DemiMarie
      
      Subscribers: mpickering, DemiMarie, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2975
      9d67f04d
  14. 18 Jun, 2016 1 commit
  15. 24 Mar, 2016 1 commit
    • Ben Gamari's avatar
      ErrUtils: Add timings to compiler phases · 8048d51b
      Ben Gamari authored
      This adds timings and allocation figures to the compiler's output when
      run with `-v2` in an effort to ease performance analysis.
      
      Todo:
        * Documentation
        * Where else should we add these?
        * Perhaps we should remove some of the now-arguably-redundant
          `showPass` occurrences where they are
        * Must we force more?
        * Perhaps we should place this behind a `-ftimings` instead of `-v2`
      
      Test Plan: `ghc -v2 Test.hs`, look at the output
      
      Reviewers: hvr, goldfire, simonmar, austin
      
      Reviewed By: simonmar
      
      Subscribers: angerman, michalt, niteria, ezyang, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1959
      8048d51b
  16. 12 Mar, 2016 1 commit
    • Erik de Castro Lopo's avatar
      LlvmCodeGen: Fix generation of malformed LLVM blocks · 92821ec9
      Erik de Castro Lopo authored
      Commit 673efccb uncovered a bug in LLVM code generation that produced
      LLVM code that the LLVM compiler refused to compile:
      
          {
          clpH:
            br label %clpH
          }
      
      This may well be a bug in LLVM itself. The solution is to keep the
      existing entry label and rewrite the function as:
      
          {
          clpH:
            br label %nPV
          nPV:
            br label %nPV
          }
      
      Thanks to Ben Gamari for pointing me in the right direction on this
      one.
      
      Test Plan: Build GHC with BuildFlavour=quick-llvm
      
      Reviewers: hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1996
      
      GHC Trac Issues: #11649
      92821ec9
  17. 18 Dec, 2015 1 commit
    • Ömer Sinan Ağacan's avatar
      LLVM backend: Show expected LLVM version in warnings/errors · 0e9a331f
      Ömer Sinan Ağacan authored
      Summary:
      Before:
      
          [1 of 1] Compiling Main             ( Main.hs, Main.o )
          You are using a new version of LLVM that hasn't been tested yet!
          We will try though...
      
      After:
      
          [1 of 1] Compiling Main             ( Main.hs, Main.o )
          You are using an unsupported version of LLVM!
          Currently only 3.7 is supported.
          We will try though...
      
      Before:
      
          [1 of 1] Compiling Main             ( Main.hs, Main.o )
      
          <no location info>:
              Warning: Couldn't figure out LLVM version!
                       Make sure you have installed LLVM
          ghc: could not execute: opt
      
      After:
      
          [1 of 1] Compiling Main             ( Main.hs, Main.o )
      
          <no location info>: error:
              Warning: Couldn't figure out LLVM version!
                       Make sure you have installed LLVM 3.7
          ghc-stage1: could not execute: opt
      
      Reviewers: austin, rwbarton, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1658
      0e9a331f
  18. 13 Oct, 2015 1 commit
    • Erik de Castro Lopo's avatar
      Switch to LLVM version 3.7 · 29310b62
      Erik de Castro Lopo authored
      Before this commit, GHC only supported LLVM 3.6. Now it only supports
      LLVM 3.7 which was released in August 2015. LLVM version 3.6 and earlier
      do not work on AArch64/Arm64, but 3.7 does.
      
      Also:
      * Add CC_Ghc constructor to LlvmCallConvention.
      * Replace `maxSupportLlvmVersion`/`minSupportLlvmVersion` with
        a single `supportedLlvmVersion` variable.
      * Get `supportedLlvmVersion` from version specified in configure.ac.
      * Drop llvmVersion field from DynFlags (no longer needed because only
        one version is supported).
      
      Test Plan: Validate on x86_64 and arm
      
      Reviewers: bgamari, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1320
      
      GHC Trac Issues: #10953
      29310b62
  19. 09 Oct, 2015 2 commits
  20. 10 Feb, 2015 1 commit
    • Ben Gamari's avatar
      llvmGen: move to LLVM 3.6 exclusively · 5d5abdca
      Ben Gamari authored
      Summary:
      Rework llvmGen to use LLVM 3.6 exclusively. The plans for the 7.12 release are to ship LLVM alongside GHC in the interests of user (and developer) sanity.
      
      Along the way, refactor TNTC support to take advantage of the new `prefix` data support in LLVM 3.6. This allows us to drop the section-reordering component of the LLVM mangler.
      
      Test Plan: Validate, look at emitted code
      
      Reviewers: dterei, austin, scpmw
      
      Reviewed By: austin
      
      Subscribers: erikd, awson, spacekitteh, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D530
      
      GHC Trac Issues: #10074
      5d5abdca
  21. 21 Nov, 2014 1 commit
    • Ben Gamari's avatar
      llvmGen: Compatibility with LLVM 3.5 (re #9142) · e16a342d
      Ben Gamari authored
      Due to changes in LLVM 3.5 aliases now may only refer to definitions.
      Previously to handle symbols defined outside of the current commpilation
      unit GHC would emit both an `external` declaration, as well as an alias
      pointing to it, e.g.,
      
          @stg_BCO_info = external global i8
          @stg_BCO_info$alias = alias private i8* @stg_BCO_info
      
      Where references to `stg_BCO_info` will use the alias
      `stg_BCO_info$alias`. This is not permitted under the new alias
      behavior, resulting in errors resembling,
      
          Alias must point to a definition
          i8* @"stg_BCO_info$alias"
      
      To fix this, we invert the naming relationship between aliases and
      definitions. That is, now the symbol definition takes the name
      `@stg_BCO_info$def` and references use the actual name, `@stg_BCO_info`.
      This means the external symbols can be handled by simply emitting an
      `external` declaration,
      
          @stg_BCO_info = external global i8
      
      Whereas in the case of a forward declaration we emit,
      
          @stg_BCO_info = alias private i8* @stg_BCO_info$def
      
      Reviewed By: austin
      
      Differential Revision: https://phabricator.haskell.org/D155
      e16a342d
  22. 15 May, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Add LANGUAGE pragmas to compiler/ source files · 23892440
      Herbert Valerio Riedel authored
      In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
      reorganized, while following the convention, to
      
      - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
        any `{-# OPTIONS_GHC #-}`-lines.
      
      - Moreover, if the list of language extensions fit into a single
        `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
        line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
        individual language extension. In both cases, try to keep the
        enumeration alphabetically ordered.
        (The latter layout is preferable as it's more diff-friendly)
      
      While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
      occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
      23892440
  23. 19 Apr, 2014 1 commit
  24. 27 Jun, 2013 3 commits
    • Peter Wortmann's avatar
      LLVM refactor cleanups · fe44d053
      Peter Wortmann authored
      Slightly more documentation, removed unused label map (huh),
      removed MonadIO instance on LlvmM to improve encapsulation.
      fe44d053
    • Peter Wortmann's avatar
      Major Llvm refactoring · a948fe83
      Peter Wortmann authored
      This combined patch reworks the LLVM backend in a number of ways:
      
      1. Most prominently, we introduce a LlvmM monad carrying the contents of
         the old LlvmEnv around. This patch completely removes LlvmEnv and
         refactors towards standard library monad combinators wherever possible.
      
      2. Support for streaming - we can now generate chunks of Llvm for Cmm as
         it comes in. This might improve our speed.
      
      3. To allow streaming, we need a more flexible way to handle forward
         references. The solution (getGlobalPtr) unifies LlvmCodeGen.Data
         and getHsFunc as well.
      
      4. Skip alloca-allocation for registers that are actually never written.
         LLVM will automatically eliminate these, but output is smaller and
         friendlier to human eyes this way.
      
      5. We use LlvmM to collect references for llvm.used. This allows places
         other than cmmProcLlvmGens to generate entries.
      a948fe83
    • Peter Wortmann's avatar
      Extend globals to aliases · 720a87c7
      Peter Wortmann authored
      Also give them a proper constructor - getGlobalVar and getGlobalValue
      map directly to the accessors.
      720a87c7
  25. 12 Jun, 2013 1 commit
  26. 17 Jan, 2013 2 commits
  27. 12 Nov, 2012 2 commits
    • Simon Marlow's avatar
      Fix warnings · 92957808
      Simon Marlow authored
      92957808
    • Simon Marlow's avatar
      Remove OldCmm, convert backends to consume new Cmm · d92bd17f
      Simon Marlow authored
      This removes the OldCmm data type and the CmmCvt pass that converts
      new Cmm to OldCmm.  The backends (NCGs, LLVM and C) have all been
      converted to consume new Cmm.
      
      The main difference between the two data types is that conditional
      branches in new Cmm have both true/false successors, whereas in OldCmm
      the false case was a fallthrough.  To generate slightly better code we
      occasionally need to invert a conditional to ensure that the
      branch-not-taken becomes a fallthrough; this was previously done in
      CmmCvt, and it is now done in CmmContFlowOpt.
      
      We could go further and use the Hoopl Block representation for native
      code, which would mean that we could use Hoopl's postorderDfs and
      analyses for native code, but for now I've left it as is, using the
      old ListGraph representation for native code.
      d92bd17f
  28. 30 Oct, 2012 2 commits
    • gmainlan@microsoft.com's avatar
      Generate correct LLVM for the new register allocation scheme. · dcf88e66
      gmainlan@microsoft.com authored
      We now have accurate global register liveness information attached to all Cmm
      procedures and jumps. With this patch, the LLVM back end uses this information
      to pass only the live floating point (F and D) registers on tail calls. This
      makes the LLVM back end compatible with the new register allocation strategy.
      
      Ideally the GHC LLVM calling convention would put all registers that are always
      live first in the parameter sequence. Unfortunately the specification is written
      so that on x86-64 SpLim (always live) is passed after the R registers. Therefore
      we must always pass *something* in the R registers, so we pass the LLVM value
      undef.
      dcf88e66
    • gmainlan@microsoft.com's avatar
      Attach global register liveness info to Cmm procedures. · 5ee08ddf
      gmainlan@microsoft.com authored
      All Cmm procedures now include the set of global registers that are live on
      procedure entry, i.e., the global registers used to pass arguments to the
      procedure. Only global registers that are use to pass arguments are included in
      this list.
      5ee08ddf
  29. 12 Sep, 2012 1 commit
    • ian@well-typed.com's avatar
      Pass DynFlags down to bWord · f611396a
      ian@well-typed.com authored
      I've switched to passing DynFlags rather than Platform, as (a) it's
      simpler to not have to extract targetPlatform in so many places, and
      (b) it may be useful to have DynFlags around in future.
      f611396a
  30. 21 Aug, 2012 1 commit
  31. 07 Aug, 2012 1 commit
  32. 30 Jul, 2012 1 commit
    • Simon Marlow's avatar
      New codegen: do not split proc-points when using the NCG · f1ed6a10
      Simon Marlow authored
      Proc-point splitting is only required by backends that do not support
      having proc-points within a code block (that is, everything except the
      native backend, i.e. LLVM and C).
      
      Not doing proc-point splitting saves some compilation time, and might
      produce slightly better code in some cases.
      f1ed6a10
  33. 25 Jun, 2012 2 commits