1. 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.
  2. 31 Jan, 2019 1 commit
  3. 22 Nov, 2018 1 commit
    • 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
  4. 03 May, 2018 2 commits
    • niteria's avatar
      Correctly add unwinding info in manifestSp and makeFixupBlocks · 6132d7c5
      niteria authored
      In `manifestSp` the unwind info was before the relevant instruction, not
      after.  I added some notes to establish semantics.  Also removes
      redundant annotation in stg_catch_frame.
      For `makeFixupBlocks` it looks like we were off by `wORD_SIZE dflags`.
      I'm not sure why, but it lines up with `manifestSp`.  In fact it lines
      up so well so that I can consolidate the Sp unwind logic in
      `maybeAddUnwind`.  I detected the problems with `makeFixupBlocks` by
      running T14779b after patching D4559.
      Test Plan: added a new test
      Reviewers: bgamari, scpmw, simonmar, erikd
      Reviewed By: bgamari
      Subscribers: thomie, carter
      GHC Trac Issues: #14999
      Differential Revision: https://phabricator.haskell.org/D4606
    • Bertram Felgenhauer's avatar
      Compute DW_FORM_block length correctly; also fixes #15068 · 358b5080
      Bertram Felgenhauer authored
      Before this patch, the pprUnwindwExpr function computed the length of
      by the following assembly fragment:
      	.uleb128 1f-.-1
      	<expression data>
      That is, to compute the length, it takes the difference of the label 1
      and the address of the .uleb128 directive, and subtracts 1.
      In #15068 it was reported that `as` from binutils 4.30 has trouble with
      evaluating the `.` part of the expression. However, there is actually a
      problem with the expression, if the length of the data ever becomes
      larger than 128: In that case, the .uleb128 directive will emit more
      than 1 byte, and the computed length will be wrong.
      The present patch changes the assembly fragment to use two labels,
      which fixes both these problems.
      	.uleb128 2f-1f
      	<expression data>
      Test Plan: validate
      Reviewers: bgamari, osa1
      Reviewed By: bgamari
      Subscribers: thomie, carter
      GHC Trac Issues: #15068
      Differential Revision: https://phabricator.haskell.org/D4654
  5. 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
      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
  6. 31 Aug, 2017 1 commit
    • Simon Peyton Jones's avatar
      Add debugPprType · 805b29bb
      Simon Peyton Jones authored
      We pretty-print a type by converting it to an IfaceType and
      pretty-printing that.  But
       (a) that's a bit indirect, and
       (b) delibrately loses information about (e.g.) the kind
            on the /occurrences/ of a type variable
      So this patch implements debugPprType, which pretty prints
      the type directly, with no fancy formatting.  It's just used
      for debugging.
      I took the opportunity to refactor the debug-pretty-printing
      machinery a little.  In particular, define these functions
      and use them:
        ifPprDeubug :: SDoc -> SDOc -> SDoc
          -- Says what to do with and without -dppr-debug
        whenPprDebug :: SDoc -> SDoc
          -- Says what to do with  -dppr-debug; without is empty
        getPprDebug :: (Bool -> SDoc) -> SDoc
      getPprDebug used to be called sdocPprDebugWith
      whenPprDebug used to be called ifPprDebug
      So a lot of files get touched in a very mechanical way
  7. 26 Jun, 2017 1 commit
    • Ben Gamari's avatar
      DWARF: Use .short to render half-machine-words · 904255eb
      Ben Gamari authored
      The binutils documentation states that .short is a synonym for .word,
      which I assumed to mean "machine word", leading me to believe that we
      needed to use .hword to render half-machine-words. However, Darwin's
      toolchain doesn't understand .hword, so there we instead used .short.
      However, as it turns out the binutils documentation confusingly uses
      "word" to refer to a 16-bit word, so .short should work fine. Moreover,
      LLVM's internal assembler also doesn't understand .hword, so using
      .short consistently simplies things remarkably.
      Test Plan: Validate using binutils and LLVM internal assembler,
      validate on Darwin
      Reviewers: niteria, austin
      Reviewed By: niteria
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #13866
      Differential Revision: https://phabricator.haskell.org/D3667
  8. 02 Jun, 2017 1 commit
    • Ryan Scott's avatar
      Use lengthIs and friends in more places · a786b136
      Ryan Scott authored
      While investigating #12545, I discovered several places in the code
      that performed length-checks like so:
      length ts == 4
      This is not ideal, since the length of `ts` could be much longer than 4,
      and we'd be doing way more work than necessary! There are already a slew
      of helper functions in `Util` such as `lengthIs` that are designed to do
      this efficiently, so I found every place where they ought to be used and
      did just that. I also defined a couple more utility functions for list
      length that were common patterns (e.g., `ltLength`).
      Test Plan: ./validate
      Reviewers: austin, hvr, goldfire, bgamari, simonmar
      Reviewed By: bgamari, simonmar
      Subscribers: goldfire, rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3622
  9. 12 Feb, 2017 1 commit
  10. 08 Feb, 2017 2 commits
    • Ben Gamari's avatar
      Cmm: Add support for undefined unwinding statements · 3328ddb8
      Ben Gamari authored
      And use to mark `stg_stack_underflow_frame`, which we are unable to
      determine a caller from.
      To simplify parsing at the moment we steal the `return` keyword to
      indicate an undefined unwind value. Perhaps this should be revisited.
      Reviewers: scpmw, simonmar, austin, erikd
      Subscribers: dfeuer, thomie
      Differential Revision: https://phabricator.haskell.org/D2738
    • Ben Gamari's avatar
      Generalize CmmUnwind and pass unwind information through NCG · 3eb737ee
      Ben Gamari authored
      As discussed in D1532, Trac Trac #11337, and Trac Trac #11338, the stack
      unwinding information produced by GHC is currently quite approximate.
      Essentially we assume that register values do not change at all within a
      basic block. While this is somewhat true in normal Haskell code, blocks
      containing foreign calls often break this assumption. This results in
      unreliable call stacks, especially in the code containing foreign calls.
      This is worse than it sounds as unreliable unwinding information can at
      times result in segmentation faults.
      This patch set attempts to improve this situation by tracking unwinding
      information with finer granularity. By dispensing with the assumption of
      one unwinding table per block, we allow the compiler to accurately
      represent the areas surrounding foreign calls.
      Towards this end we generalize the representation of unwind information
      in the backend in three ways,
       * Multiple CmmUnwind nodes can occur per block
       * CmmUnwind nodes can now carry unwind information for multiple
         registers (while not strictly necessary; this makes emitting
         unwinding information a bit more convenient in the compiler)
       * The NCG backend is given an opportunity to modify the unwinding
         records since it may need to make adjustments due to, for instance,
         native calling convention requirements for foreign calls (see
      This sets the stage for resolving #11337 and #11338.
      Test Plan: Validate
      Reviewers: scpmw, simonmar, austin, erikd
      Subscribers: qnikst, thomie
      Differential Revision: https://phabricator.haskell.org/D2741
  11. 28 Sep, 2016 1 commit
  12. 20 Mar, 2016 1 commit
  13. 18 Jan, 2016 1 commit
    • Jan Stolarek's avatar
      Replace calls to `ptext . sLit` with `text` · b8abd852
      Jan Stolarek authored
      In the past the canonical way for constructing an SDoc string literal was the
      composition `ptext . sLit`.  But for some time now we have function `text` that
      does the same.  Plus it has some rules that optimize its runtime behaviour.
      This patch takes all uses of `ptext . sLit` in the compiler and replaces them
      with calls to `text`.  The main benefits of this patch are clener (shorter) code
      and less dependencies between module, because many modules now do not need to
      import `FastString`.  I don't expect any performance benefits - we mostly use
      SDocs to report errors and it seems there is little to be gained here.
      Test Plan: ./validate
      Reviewers: bgamari, austin, goldfire, hvr, alanz
      Subscribers: goldfire, thomie, mpickering
      Differential Revision: https://phabricator.haskell.org/D1784
  14. 12 Dec, 2015 1 commit
  15. 23 Nov, 2015 1 commit
  16. 12 Nov, 2015 1 commit
    • olsner's avatar
      Implement function-sections for Haskell code, #8405 · 4a32bf92
      olsner authored
      This adds a flag -split-sections that does similar things to
      -split-objs, but using sections in single object files instead of
      relying on the Satanic Splitter and other abominations. This is very
      similar to the GCC flags -ffunction-sections and -fdata-sections.
      The --gc-sections linker flag, which allows unused sections to actually
      be removed, is added to all link commands (if the linker supports it) so
      that space savings from having base compiled with sections can be
      Supported both in LLVM and the native code-gen, in theory for all
      architectures, but really tested on x86 only.
      In the GHC build, a new SplitSections variable enables -split-sections
      for relevant parts of the build.
      Test Plan: validate with both settings of SplitSections
      Reviewers: dterei, Phyx, austin, simonmar, thomie, bgamari
      Reviewed By: simonmar, thomie, bgamari
      Subscribers: hsyl20, erikd, kgardas, thomie
      Differential Revision: https://phabricator.haskell.org/D1242
      GHC Trac Issues: #8405
  17. 01 Nov, 2015 3 commits
    • Ben Gamari's avatar
      cmm: Expose machine's stack and return address register · 159a1a2b
      Ben Gamari authored
      We will need to use these to setup proper unwinding information for the
      stg_stop_thread closure. This pokes a hole in the STG abstraction,
      exposing the machine's stack pointer register so that we can accomplish
      this. We also expose a dummy return address register, which corresponds
      to the register used to hold the DWARF return address.
      Differential Revision: https://phabricator.haskell.org/D1225
    • Ben Gamari's avatar
      Dwarf.Types: Fix comment style · 76611d75
      Ben Gamari authored
    • Ben Gamari's avatar
      Dwarf: Preserve stack pointer register · 6fb0ba65
      Ben Gamari authored
      Here we add a `same_value $sp` instruction to our default unwinding
      rules to ensure that the implicit `$sp = CFA` rule (which `libdw`
      appears to exhibit on x86_64) doesn't overwrite it (necessary since we
      don't use $sp to track our call stack).
      See Phab Diff D1189 for details on how we arrived at this resolution.
      Reviewers: scpmw, austin, simonmar
      Reviewed By: austin, simonmar
      Subscribers: thomie, simonmar
      Differential Revision: https://phabricator.haskell.org/D1224
  18. 25 Sep, 2015 2 commits
  19. 29 Aug, 2015 3 commits
  20. 11 Jun, 2015 1 commit
    • Peter Wortmann's avatar
      Fix DWARF generation for MinGW (#10468) · a66ef356
      Peter Wortmann authored
      Fortunately this is relatively straightforward - all we need to do is
      switch to a non-ELF-specific way of specifying object file sections and
      make sure that section-relative addresses work correctly. This is enough
      to make "gdb" work on MinGW builds.
  21. 13 Jan, 2015 1 commit
    • Peter Wortmann's avatar
      Dwarf generation fixed pt 2 · 36df0988
      Peter Wortmann authored
      - Don't bracket HsTick expression uneccessarily
      - Generate debug information in UTF8
      - Reduce amount of information generated - we do not currently need
        block information, for example.
      Special thanks to slyfox for the reports!
  22. 19 Dec, 2014 1 commit
    • Peter Wortmann's avatar
      Some Dwarf generation fixes · f85db756
      Peter Wortmann authored
      - Make abbrev offset absolute on Non-Mac systems
      - Add another termination byte at the end of the abbrev section
        (readelf complains)
      - Scope combination was wrong for the simpler cases
      - Shouldn't have a "global/" in front of all scopes
  23. 17 Dec, 2014 2 commits
    • Peter Wortmann's avatar
      Generate DWARF unwind information · edd6d676
      Peter Wortmann authored
      This tells debuggers such as GDB how to "unwind" a program state,
      which allows them to walk the stack up.
      * The code is quite general, perhaps unnecessarily so. Unless we get
        more unwind information, only the first case of pprSetUnwind will
        get used - and pprUnwindExpr and pprUndefUnwind will never be
        called. It just so happens that this is a point where we can get a
        lot of features cheaply, even if we don't use them.
      * When determining what location to show for a return address, most
        debuggers check the map for "rip-1", assuming that's where the
        "call" instruction is. For tables-next-to-code, that happens to
        always be the end of an info table. We therefore cheat a bit here by
        shifting .debug_frame information so it covers the end of the info
        table, as well as generating a .loc directive for the info table
        Debuggers will still show the wrong label for the return address,
        though.  Haven't found a way around that one yet.
      (From Phabricator D396)
    • Peter Wortmann's avatar
      Generate DWARF info section · cc481ec8
      Peter Wortmann authored
      This is where we actually make GHC emit DWARF code. The info section
      contains all the general meta information bits as well as an entry for
      every block of native code.
      * We need quite a few new labels in order to properly address starts
        and ends of blocks.
      * Thanks to Nathan Howell for taking the iniative to get our own Haskell
        language ID for DWARF!
      (From Phabricator D396)