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.
      bff2f24b
  2. 19 Jun, 2019 1 commit
  3. 16 Jun, 2019 1 commit
  4. 12 Jun, 2019 1 commit
  5. 09 Jun, 2019 1 commit
  6. 08 Jun, 2019 1 commit
  7. 29 May, 2019 1 commit
    • John Ericson's avatar
      Inline `Settings` into `DynFlags` · bfccd832
      John Ericson authored
      After the previous commit, `Settings` is just a thin wrapper around
      other groups of settings. While `Settings` is used by GHC-the-executable
      to initalize `DynFlags`, in principle another consumer of
      GHC-the-library could initialize `DynFlags` a different way. It
      therefore doesn't make sense for `DynFlags` itself (library code) to
      separate the settings that typically come from `Settings` from the
      settings that typically don't.
      bfccd832
  8. 27 May, 2019 1 commit
    • Ömer Sinan Ağacan's avatar
      Add missing opening braces in Cmm dumps · db8e3275
      Ömer Sinan Ağacan authored
      Previously -ddump-cmm was generating code with unbalanced curly braces:
      
           stg_atomically_entry() //  [R1]
                   { info_tbls: [(cfl,
                                  label: stg_atomically_info
                                  rep: tag:16 HeapRep 1 ptrs { Thunk }
                                  srt: Nothing)]
                     stack_info: arg_space: 8 updfr_space: Just 8
                   }
               {offset
                 cfl: // cfk
                     unwind Sp = Just Sp + 0;
                     _cfk::P64 = R1;
                     //tick src<rts/PrimOps.cmm:(1243,1)-(1245,1)>
                     R1 = I64[_cfk::P64 + 8 + 8 + 0 * 8];
                     call stg_atomicallyzh(R1) args: 8, res: 0, upd: 8;
               }
           }, <---- OPENING BRACE MISSING
      
      After this patch:
      
           stg_atomically_entry() { //  [R1] <---- MISSING OPENING BRACE HERE
                   { info_tbls: [(cfl,
                                  label: stg_atomically_info
                                  rep: tag:16 HeapRep 1 ptrs { Thunk }
                                  srt: Nothing)]
                     stack_info: arg_space: 8 updfr_space: Just 8
                   }
               {offset
                 cfl: // cfk
                     unwind Sp = Just Sp + 0;
                     _cfk::P64 = R1;
                     //tick src<rts/PrimOps.cmm:(1243,1)-(1245,1)>
                     R1 = I64[_cfk::P64 + 8 + 8 + 0 * 8];
                     call stg_atomicallyzh(R1) args: 8, res: 0, upd: 8;
               }
           },
      db8e3275
  9. 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
  10. 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
  11. 14 Apr, 2019 1 commit
  12. 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
  13. 01 Apr, 2019 1 commit
  14. 25 Mar, 2019 1 commit
    • Takenobu Tani's avatar
      Update Wiki URLs to point to GitLab · 3769e3a8
      Takenobu Tani authored
      This moves all URL references to Trac Wiki to their corresponding
      GitLab counterparts.
      
      This substitution is classified as follows:
      
      1. Automated substitution using sed with Ben's mapping rule [1]
          Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...
          New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...
      
      2. Manual substitution for URLs containing `#` index
          Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz
          New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz
      
      3. Manual substitution for strings starting with `Commentary`
          Old: Commentary/XxxYyy...
          New: commentary/xxx-yyy...
      
      See also !539
      
      [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json
      3769e3a8
  15. 15 Mar, 2019 1 commit
  16. 06 Mar, 2019 1 commit
    • Ben Gamari's avatar
      Rip out object splitting · 37f257af
      Ben Gamari authored
      The splitter is an evil Perl script that processes assembler code.
      Its job can be done better by the linker's --gc-sections flag. GHC
      passes this flag to the linker whenever -split-sections is passed on
      the command line.
      
      This is based on @DemiMarie's D2768.
      
      Fixes Trac #11315
      Fixes Trac #9832
      Fixes Trac #8964
      Fixes Trac #8685
      Fixes Trac #8629
      37f257af
  17. 18 Feb, 2019 1 commit
  18. 17 Feb, 2019 1 commit
    • Peter Trommler's avatar
      Cmm: Promote stack arguments to word size · af7b0fdb
      Peter Trommler authored
      Smaller than word size integers must be promoted to word size
      when passed on the stack. While on little endian systems we can
      get away with writing a small integer to a word size stack slot
      and read it as a word ignoring the upper bits, on big endian
      systems a small integer write ends up in the most significant
      bits and a word size read that ignores the upper bits delivers
      a random value.
      
      On little endian systems a smaller than word size write to
      the stack might be more efficient but that decision is
      system specific and should be done as an optimization in the
      respective backends.
      
      Fixes #16258
      af7b0fdb
  19. 31 Jan, 2019 2 commits
  20. 18 Jan, 2019 1 commit
  21. 01 Jan, 2019 1 commit
  22. 22 Nov, 2018 4 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
    • Jessica Clarke's avatar
      UNREG: PprC: Add support for adjacent floats · 35a89778
      Jessica Clarke authored
      When two 32-bit floats are adjacent for a 64-bit target, there is no
      padding between them to force alignment, so we must combine their bit
      representations into a single word.
      
      Reviewers: bgamari, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15853
      
      Differential Revision: https://phabricator.haskell.org/D5306
      35a89778
    • Simon Jakobi's avatar
      Remove warnings-silencing flags for code generated by Alex · 699e5072
      Simon Jakobi authored
      Current versions of Alex don't seem to produce as many warnings any
      more.
      
      In order to silence a warning and to avoid overlong lines, I've taken
      the liberty of refactoring 'tok_num'.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: erikd, rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5319
      699e5072
    • 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
  23. 17 Nov, 2018 3 commits
    • Abhiroop Sarkar's avatar
      Introduce Int16# and Word16# · 36fcf9ed
      Abhiroop Sarkar authored
      This builds off of D4475.
      
      Bumps binary submodule.
      
      Reviewers: carter, AndreasK, hvr, goldfire, bgamari, simonmar
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D5006
      36fcf9ed
    • Gabor Greif's avatar
      798c9437
    • Andreas Klebinger's avatar
      NCG: New code layout algorithm. · 912fd2b6
      Andreas Klebinger authored
      Summary:
      This patch implements a new code layout algorithm.
      It has been tested for x86 and is disabled on other platforms.
      
      Performance varies slightly be CPU/Machine but in general seems to be better
      by around 2%.
      Nofib shows only small differences of about +/- ~0.5% overall depending on
      flags/machine performance in other benchmarks improved significantly.
      
      Other benchmarks includes at least the benchmarks of: aeson, vector, megaparsec, attoparsec,
      containers, text and xeno.
      
      While the magnitude of gains differed three different CPUs where tested with
      all getting faster although to differing degrees. I tested: Sandy Bridge(Xeon), Haswell,
      Skylake
      
      * Library benchmark results summarized:
        * containers: ~1.5% faster
        * aeson: ~2% faster
        * megaparsec: ~2-5% faster
        * xml library benchmarks: 0.2%-1.1% faster
        * vector-benchmarks: 1-4% faster
        * text: 5.5% faster
      
      On average GHC compile times go down, as GHC compiled with the new layout
      is faster than the overhead introduced by using the new layout algorithm,
      
      Things this patch does:
      
      * Move code responsilbe for block layout in it's own module.
      * Move the NcgImpl Class into the NCGMonad module.
      * Extract a control flow graph from the input cmm.
      * Update this cfg to keep it in sync with changes during
        asm codegen. This has been tested on x64 but should work on x86.
        Other platforms still use the old codelayout.
      * Assign weights to the edges in the CFG based on type and limited static
        analysis which are then used for block layout.
      * Once we have the final code layout eliminate some redundant jumps.
      
        In particular turn a sequences of:
            jne .foo
            jmp .bar
          foo:
        into
            je bar
          foo:
            ..
      
      Test Plan: ci
      
      Reviewers: bgamari, jmct, jrtc27, simonmar, simonpj, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, trommler, jmct, carter, thomie, rwbarton
      
      GHC Trac Issues: #15124
      
      Differential Revision: https://phabricator.haskell.org/D4726
      912fd2b6
  24. 15 Nov, 2018 1 commit
    • Simon Marlow's avatar
      Fix a bug in SRT generation (#15892) · eb46345d
      Simon Marlow authored
      Summary:
      The logic in `Note [recursive SRTs]` was correct. However, my
      implementation of it wasn't: I got the associativity of
      `Set.difference` wrong, which led to an extremely subtle and difficult
      to find bug.
      
      Fortunately now we have a test case. I was able to cut down the code
      to something manageable, and I've added it to the test suite.
      
      Test Plan:
      Before (using my stage 1 compiler without the fix):
      
      ```
      ====> T15892(normal) 1 of 1 [0, 0, 0]
      cd "T15892.run" &&  "/home/smarlow/ghc/inplace/bin/ghc-stage1" -o T15892
      T15892.hs -dcore-lint -dcmm-lint -no-user-package-db -rtsopts
      -fno-warn-missed-specialisations -fshow-warning-groups
      -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat
      -dno-debug-output  -O
      cd "T15892.run" && ./T15892  +RTS -G1 -A32k -RTS
      Wrong exit code for T15892(normal)(expected 0 , actual 134 )
      Stderr ( T15892 ):
      T15892: internal error: evacuate: strange closure type 0
          (GHC version 8.7.20181113 for x86_64_unknown_linux)
          Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
      Aborted (core dumped)
      *** unexpected failure for T15892(normal)
      =====> T15892(g1) 1 of 1 [0, 1, 0]
      cd "T15892.run" &&  "/home/smarlow/ghc/inplace/bin/ghc-stage1" -o T15892
      T15892.hs -dcore-lint -dcmm-lint -no-user-package-db -rtsopts
      -fno-warn-missed-specialisations -fshow-warning-groups
      -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat
      -dno-debug-output  -O
      cd "T15892.run" && ./T15892 +RTS -G1 -RTS +RTS -G1 -A32k -RTS
      Wrong exit code for T15892(g1)(expected 0 , actual 134 )
      Stderr ( T15892 ):
      T15892: internal error: evacuate: strange closure type 0
          (GHC version 8.7.20181113 for x86_64_unknown_linux)
          Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
      Aborted (core dumped)
      ```
      
      After (using my stage 2 compiler with the fix):
      
      ```
      =====> T15892(normal) 1 of 1 [0, 0, 0]
      cd "T15892.run" &&  "/home/smarlow/ghc/inplace/test   spaces/ghc-stage2"
      -o T15892 T15892.hs -dcore-lint -dcmm-lint -no-user-package-db -rtsopts
      -fno-warn-missed-specialisations -fshow-warning-groups
      -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat
      -dno-debug-output
      cd "T15892.run" && ./T15892  +RTS -G1 -A32k -RTS
      =====> T15892(g1) 1 of 1 [0, 0, 0]
      cd "T15892.run" &&  "/home/smarlow/ghc/inplace/test   spaces/ghc-stage2"
      -o T15892 T15892.hs -dcore-lint -dcmm-lint -no-user-package-db -rtsopts
      -fno-warn-missed-specialisations -fshow-warning-groups
      -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat
      -dno-debug-output
      cd "T15892.run" && ./T15892 +RTS -G1 -RTS +RTS -G1 -A32k -RTS
      ```
      
      Reviewers: bgamari, osa1, erikd
      
      Reviewed By: osa1
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15892
      
      Differential Revision: https://phabricator.haskell.org/D5334
      eb46345d
  25. 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
  26. 15 Oct, 2018 2 commits
    • Zejun Wu's avatar
      Generate correct relocation for external cost centre · 95ec7c88
      Zejun Wu authored
      We used to always generate direct access for cost centre labels.  We
      fixed this by generating indirect data load for cost centre defined in
      external module.
      
      Test Plan:
      The added test used to fail with error message
      ```
      /bin/ld.gold: error: T15723B.o: requires dynamic R_X86_64_PC32 reloc
      against 'T15723A_foo1_EXPR_cc' which may overflow at runtime; recompile
      with -fPIC
      ```
      and now passes.
      
      Also check that `R_X86_64_PC32` is generated for CostCentre from the
      same module and `R_X86_64_GOTPCREL` is generated for CostCentre from
      external module:
      ```
      $ objdump -rdS T15723B.o
      0000000000000028 <T15723B_test_info>:
        28:   48 8d 45 f0             lea    -0x10(%rbp),%rax
        2c:   4c 39 f8                cmp    %r15,%rax
        2f:   72 70                   jb     a1 <T15723B_test_info+0x79>
        31:   48 83 ec 08             sub    $0x8,%rsp
        35:   48 8d 35 00 00 00 00    lea    0x0(%rip),%rsi        # 3c
      <T15723B_test_info+0x14>
                              38: R_X86_64_PC32
      T15723B_test1_EXPR_cc-0x4
        3c:   49 8b bd 60 03 00 00    mov    0x360(%r13),%rdi
        43:   31 c0                   xor    %eax,%eax
        45:   e8 00 00 00 00          callq  4a <T15723B_test_info+0x22>
                              46: R_X86_64_PLT32      pushCostCentre-0x4
        4a:   48 83 c4 08             add    $0x8,%rsp
        4e:   48 ff 40 30             incq   0x30(%rax)
        52:   49 89 85 60 03 00 00    mov    %rax,0x360(%r13)
        59:   48 83 ec 08             sub    $0x8,%rsp
        5d:   49 8b bd 60 03 00 00    mov    0x360(%r13),%rdi
        64:   48 8b 35 00 00 00 00    mov    0x0(%rip),%rsi        # 6b
      <T15723B_test_info+0x43>
                              67: R_X86_64_GOTPCREL   T15723A_foo1_EXPR_cc-0x4
        6b:   31 c0                   xor    %eax,%eax
        6d:   e8 00 00 00 00          callq  72 <T15723B_test_info+0x4a>
                              6e: R_X86_64_PLT32      pushCostCentre-0x4
        72:   48 83 c4 08             add    $0x8,%rsp
        76:   48 ff 40 30             incq   0x30(%rax)
      ```
      
      Reviewers: simonmar, bgamari
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15723
      
      Differential Revision: https://phabricator.haskell.org/D5214
      95ec7c88
    • Ben Gamari's avatar
      Deprecate -fllvm-pass-vectors-in-regs · 58dffa0a
      Ben Gamari authored
      Summary:
      The behavior previously enabled by this flag is as been the default
      since 8.6.1.
      
      Reviewers: simonmar
      
      Subscribers: rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5193
      58dffa0a
  27. 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
  28. 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
  29. 06 Oct, 2018 1 commit
    • Sergei Trofimovich's avatar
      UNREG: don't prefix asm prefixes in via-C mode · 4e3562c0
      Sergei Trofimovich authored
      commit 64c54fff
      ("Mark system and internal symbols as private symbols in asm")
      
      Added `internalNamePrefix` helper. Unfortunately it
      generates invalid label in unregisterised mode:
      
      ```
      $ ./configure --enable-unregisterised
      /tmp/ghc19372_0/ghc_4.hc:2831:22: error:
           error: expected identifier or '(' before '.' token
           static const StgWord .Lcl3_info[]__attribute__((aligned(8)))= {
                                ^
      ```
      
      Here asm-style prefix is applied to C symbol.
      The fix is simple: apply asm-style labels only to assembly code.
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      
      Reviewers: simonmar, last_g, bgamari
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5207
      4e3562c0
  30. 18 Sep, 2018 1 commit
  31. 14 Sep, 2018 2 commits
    • Sergei Azovskov's avatar
      Mark code related symbols as @function not @object · c23f057f
      Sergei Azovskov authored
      Summary:
      This diff is a part of the bigger project which goal is to improve
      common profiling tools support (perf) for GHC binaries.
      
      A similar job was already done and reverted in the past:
       * https://phabricator.haskell.org/rGHCb1f453e16f0ce11a2ab18cc4c350bdcbd36299a6
       * https://phabricator.haskell.org/rGHCf1f3c4f50650110ad0f700d6566a44c515b0548f
      
      Reasoning:
      
      `Perf` and similar tools build in memory symbol table from the .symtab
      section of the ELF file to display human-readable function names instead
      of the addresses in the output. `Perf` uses only two types of symbols:
      `@function` and `@notype` but GHC is not capable to produce any
      `@function` symbols so the `perf` output is pretty useless (All the
      haskell symbols that you can see in `perf` now are `@notype` internal
      symbols extracted by mistake/hack).
      
      The changes:
       * mark code related symbols as @function
       * small hack to mark InfoTable symbols as code if TABLES_NEXT_TO_CODE is true
      
      Limitations:
       * The perf symbolization support is not complete after this patch but
         I'm working on the second patch.
       * Constructor symbols are not supported. To fix that we can issue extra
         local symbols which mark code sections as code and will be only used
         for debug.
      
      Test Plan:
      tests
      any additional ideas?
      
      Perf output on stock ghc 8.4.1:
      ```
           9.78%  FibbSlow  FibbSlow            [.] ckY_info
           9.59%  FibbSlow  FibbSlow            [.] cjqd_info
           7.17%  FibbSlow  FibbSlow            [.] c3sg_info
           6.62%  FibbSlow  FibbSlow            [.] c1X_info
           5.32%  FibbSlow  FibbSlow            [.] cjsX_info
           4.18%  FibbSlow  FibbSlow            [.] s3rN_info
           3.82%  FibbSlow  FibbSlow            [.] c2m_info
           3.68%  FibbSlow  FibbSlow            [.] cjlJ_info
           3.26%  FibbSlow  FibbSlow            [.] c3sb_info
           3.19%  FibbSlow  FibbSlow            [.] cjPQ_info
           3.05%  FibbSlow  FibbSlow            [.] cjQd_info
           2.97%  FibbSlow  FibbSlow            [.] cjAB_info
           2.78%  FibbSlow  FibbSlow            [.] cjzP_info
           2.40%  FibbSlow  FibbSlow            [.] cjOS_info
           2.38%  FibbSlow  FibbSlow            [.] s3rK_info
           2.27%  FibbSlow  FibbSlow            [.] cjq0_info
           2.18%  FibbSlow  FibbSlow            [.] cKQ_info
           2.13%  FibbSlow  FibbSlow            [.] cjSl_info
           1.99%  FibbSlow  FibbSlow            [.] s3rL_info
           1.98%  FibbSlow  FibbSlow            [.] c2cC_info
           1.80%  FibbSlow  FibbSlow            [.] s3rO_info
           1.37%  FibbSlow  FibbSlow            [.] c2f2_info
      ...
      ```
      
      Perf output on patched ghc:
      ```
           7.97%  FibbSlow  FibbSlow            [.] c3rM_info
           6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
           6.63%  FibbSlow  FibbSlow            [.] cifA_info
           4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
           4.55%  FibbSlow  FibbSlow            [.] chXn_info
           4.52%  FibbSlow  FibbSlow            [.] c3rH_info
           4.45%  FibbSlow  FibbSlow            [.] chZB_info
           4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
           4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
           3.76%  FibbSlow  FibbSlow            [.] chXA_info
           3.67%  FibbSlow  FibbSlow            [.] cifu_info
           3.25%  FibbSlow  FibbSlow            [.] ci4r_info
           2.64%  FibbSlow  FibbSlow            [.] s3rf_info
           2.42%  FibbSlow  FibbSlow            [.] s3rg_info
           2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
           2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
           2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
           2.09%  FibbSlow  FibbSlow            [.] cicc_info
           2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
           2.02%  FibbSlow  FibbSlow            [.] s3ri_info
           1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
           1.89%  FibbSlow  FibbSlow            [.] ci4N_info
      ...
      ```
      
      Reviewers: simonmar, niteria, bgamari, goldfire
      
      Reviewed By: simonmar, bgamari
      
      Subscribers: lelf, rwbarton, thomie, carter
      
      GHC Trac Issues: #15501
      
      Differential Revision: https://phabricator.haskell.org/D4713
      c23f057f
    • Sergei Azovskov's avatar
      Mark system and internal symbols as private symbols in asm · 64c54fff
      Sergei Azovskov authored
      Summary:
      This marks system and internal symbols as private in asm output so those
      random generated sysmbols won't appear in .symtab
      
      Reasoning:
       * internal symbols don't help to debug because names are just random
       * the symbols style breaks perf logic
       * internal symbols can take ~75% of the .symtab. In the same time
         .symtab can take about 20% of the binary file size
      
      Notice:
      This diff mostly makes sense on top of the D4713 (or similar)
      
      Test Plan:
      tests
      
      Perf from D4713
      ```
           7.97%  FibbSlow  FibbSlow            [.] c3rM_info
           6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
           6.63%  FibbSlow  FibbSlow            [.] cifA_info
           4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
           4.55%  FibbSlow  FibbSlow            [.] chXn_info
           4.52%  FibbSlow  FibbSlow            [.] c3rH_info
           4.45%  FibbSlow  FibbSlow            [.] chZB_info
           4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
           4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
           3.76%  FibbSlow  FibbSlow            [.] chXA_info
           3.67%  FibbSlow  FibbSlow            [.] cifu_info
           3.25%  FibbSlow  FibbSlow            [.] ci4r_info
           2.64%  FibbSlow  FibbSlow            [.] s3rf_info
           2.42%  FibbSlow  FibbSlow            [.] s3rg_info
           2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
           2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
           2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
           2.09%  FibbSlow  FibbSlow            [.] cicc_info
           2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
           2.02%  FibbSlow  FibbSlow            [.] s3ri_info
           1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
           1.89%  FibbSlow  FibbSlow            [.] ci4N_info
      ...
      ```
      
      Perf from this patch:
      ```
          15.37%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
          15.33%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
          13.34%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
           9.24%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_plusInteger_info
           9.08%  FibbSlow  FibbSlow            [.] frame_dummy
           8.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
           4.29%  FibbSlow  FibbSlow            [.] 0x0000000000321ab0
           3.84%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
           3.07%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
           2.39%  FibbSlow  FibbSlow            [.] 0x0000000000321ab7
           1.90%  FibbSlow  FibbSlow            [.] 0x00000000003266b8
           1.88%  FibbSlow  FibbSlow            [.] base_GHCziNum_zm_info
           1.83%  FibbSlow  FibbSlow            [.] 0x0000000000326915
           1.34%  FibbSlow  FibbSlow            [.] 0x00000000003248cc
           1.07%  FibbSlow  FibbSlow            [.] base_GHCziNum_zp_info
           0.98%  FibbSlow  FibbSlow            [.] 0x00000000003247c8
           0.80%  FibbSlow  FibbSlow            [.] 0x0000000000121498
           0.79%  FibbSlow  FibbSlow            [.] stg_gc_noregs
           0.75%  FibbSlow  FibbSlow            [.] 0x0000000000321ad6
           0.67%  FibbSlow  FibbSlow            [.] 0x0000000000321aca
           0.64%  FibbSlow  FibbSlow            [.] 0x0000000000321b4a
           0.61%  FibbSlow  FibbSlow            [.] 0x00000000002ff633
      ```
      
      Reviewers: simonmar, niteria, bgamari
      
      Reviewed By: simonmar
      
      Subscribers: lelf, angerman, olsner, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4722
      64c54fff
  32. 30 Aug, 2018 1 commit