Skip to content
  1. Dec 01, 2016
    • Sean Silva's avatar
      Add `isRelExprOneOf` helper · 2eed7592
      Sean Silva authored
      In various places in LLD's hot loops, we have expressions of the form
      "E == R_FOO || E == R_BAR || ..." (E is a RelExpr).
      
      Some of these expressions are quite long, and even though they usually go just
      a very small number of ways and so should be well predicted, they can still
      occupy branch predictor resources harming other parts of the code, or they
      won't be predicted well if they overflow branch predictor resources or if the
      branches are too dense and the branch predictor can't track them all (the
      compiler can in theory avoid this, at a cost in text size). And some of these
      expressions are so large and executed so frequently that even when
      well-predicted they probably still have a nontrivial cost.
      
      This speedup should be pretty portable. The cost of these simple bit tests is
      independent of:
      
      - the target we are linking for
      - the distribution of RelExpr's for a given link (which can depend on how the
        input files were compiled)
      - what compiler was used to compile LLD (it is just a simple bit test;
        hopefully the compiler gets it right!)
      - adding new target-dependent relocations (e.g. needsPlt doesn't pay any extra
        cost checking R_PPC_PLT_OPD on x86-64 builds)
      
      I did some rough measurements on clang-fsds and this patch gives over about 4%
      speedup for a regular -O1 link, about 2.5% for -O3 --gc-sections and over 5%
      for -O0. Sorry, I don't have my current machine set up for doing really
      accurate measurements right now.
      
      This also is just a bit cleaner. Thanks for Joerg for suggesting for
      this approach.
      
      Differential Revision: https://reviews.llvm.org/D27156
      
      llvm-svn: 288314
      2eed7592
    • Rui Ueyama's avatar
      Simplify ScriptParser. · 10091b0a
      Rui Ueyama authored
       - Rename currentBuffer -> getCurrentMB to start it with verb.
       - Simplify containsString.
       - Add llvm_unreachable at end of getCurrentMB.
      
      llvm-svn: 288310
      10091b0a
    • Rui Ueyama's avatar
      Do not name a variable Ret which is not a return value. · 3cd22d31
      Rui Ueyama authored
      llvm-svn: 288309
      3cd22d31
    • Rui Ueyama's avatar
      Make get{Line,Column}Number members of StringParser. · b5f1c3ec
      Rui Ueyama authored
      This patch also renames currentLocation getCurrentLocation.
      
      llvm-svn: 288308
      b5f1c3ec
    • Rui Ueyama's avatar
      Split getPos into getLineNumber and getColumnNumber. · 50fb8274
      Rui Ueyama authored
      llvm-svn: 288306
      50fb8274
  2. Nov 30, 2016
    • Rui Ueyama's avatar
      Change how we manage groups in ICF. · 9dedfb1f
      Rui Ueyama authored
      Previously, on each iteration in ICF, we scan the entire vector of
      input sections to find boundaries of groups having the same ID.
      
      This patch changes the algorithm so that we now have a vector of ranges.
      Each range contains a starting index and an ending index of the group.
      So we no longer have to search boundaries on each iteration.
      
      Performance-wise, this seems neutral. Instead of searching boundaries,
      we now have to maintain ranges. But I think this is more readable
      than the previous implementation.
      
      Moreover, this makes easy to parallelize the main loop of ICF,
      which I'll do in a follow-up patch.
      
      llvm-svn: 288228
      9dedfb1f
  3. Nov 29, 2016
  4. Nov 28, 2016
  5. Nov 27, 2016
  6. Nov 26, 2016
  7. Nov 25, 2016
    • Rui Ueyama's avatar
      Fix typo. · 1df93169
      Rui Ueyama authored
      llvm-svn: 287951
      1df93169
    • Rui Ueyama's avatar
      c01321c6
    • Rui Ueyama's avatar
      Support -color-diagnostics={auto,always,never}. · 8c8818a5
      Rui Ueyama authored
      -color-diagnostics=auto is default because that's the same as
      Clang's default. When color is enabled, error or warning messages
      are colored like this.
      
        error:
        <bold>ld.lld</bold> <red>error:</red> foo.o: no such file
      
        warning:
        <bold>ld.lld</bold> <magenta>warning:</magenta> foo.o: no such file
      
      Differential Revision: https://reviews.llvm.org/D27117
      
      llvm-svn: 287949
      8c8818a5
    • Rui Ueyama's avatar
      We shouldn't call parallle_for_each if -no-thread is given. · 60666414
      Rui Ueyama authored
      llvm-svn: 287948
      60666414
    • Rui Ueyama's avatar
      Parallelize uncompress() and splitIntoPieces(). · 2555952b
      Rui Ueyama authored
      Uncompressing section contents and spliting mergeable section contents
      into smaller chunks are heavy tasks. They scan entire section contents
      and do CPU-intensive tasks such as uncompressing zlib-compressed data
      or computing a hash value for each section piece.
      
      Luckily, these tasks are independent to each other, so we can do that
      in parallel_for_each. The number of input sections is large (as opposed
      to the number of output sections), so there's a large parallelism here.
      
      Actually the current design to call uncompress() and splitIntoPieces()
      in batch was chosen with doing this in mind. Basically what we need to
      do here is to replace `for` with `parallel_for_each`.
      
      It seems this patch improves latency significantly if linked programs
      contain debug info (which in turn contain lots of mergeable strings.)
      For example, the latency to link Clang (debug build) improved by 20% on
      my machine as shown below. Note that ld.gold took 19.2 seconds to do
      the same thing.
      
      Before:
          30801.782712 task-clock (msec)         #    3.652 CPUs utilized            ( +-  2.59% )
               104,084 context-switches          #    0.003 M/sec                    ( +-  1.02% )
                 5,063 cpu-migrations            #    0.164 K/sec                    ( +- 13.66% )
             2,528,130 page-faults               #    0.082 M/sec                    ( +-  0.47% )
        85,317,809,130 cycles                    #    2.770 GHz                      ( +-  2.62% )
        67,352,463,373 stalled-cycles-frontend   #   78.94% frontend cycles idle     ( +-  3.06% )
       <not supported> stalled-cycles-backend
        44,295,945,493 instructions              #    0.52  insns per cycle
                                                 #    1.52  stalled cycles per insn  ( +-  0.44% )
         8,572,384,877 branches                  #  278.308 M/sec                    ( +-  0.66% )
           141,806,726 branch-misses             #    1.65% of all branches          ( +-  0.13% )
      
           8.433424003 seconds time elapsed                                          ( +-  1.20% )
      
      After:
          35523.764575 task-clock (msec)         #    5.265 CPUs utilized            ( +-  2.67% )
               159,107 context-switches          #    0.004 M/sec                    ( +-  0.48% )
                 8,123 cpu-migrations            #    0.229 K/sec                    ( +- 23.34% )
             2,372,483 page-faults               #    0.067 M/sec                    ( +-  0.36% )
        98,395,342,152 cycles                    #    2.770 GHz                      ( +-  2.62% )
        79,294,670,125 stalled-cycles-frontend   #   80.59% frontend cycles idle     ( +-  3.03% )
       <not supported> stalled-cycles-backend
        46,274,151,813 instructions              #    0.47  insns per cycle
                                                 #    1.71  stalled cycles per insn  ( +-  0.47% )
         8,987,621,670 branches                  #  253.003 M/sec                    ( +-  0.60% )
           148,900,624 branch-misses             #    1.66% of all branches          ( +-  0.27% )
      
           6.747548004 seconds time elapsed                                          ( +-  0.40% )
      
      llvm-svn: 287946
      2555952b
    • Rui Ueyama's avatar
      Move typedefs inside a class definition. · 623b36e3
      Rui Ueyama authored
      llvm-svn: 287945
      623b36e3
    • Rui Ueyama's avatar
      Remove a parameter from ScriptParser. · 22375f24
      Rui Ueyama authored
      llvm-svn: 287944
      22375f24
Loading