Commit Graph

349 Commits

Author SHA1 Message Date
Jack Andersen 2fa85b9bd4 Merge branch 'master' into small-data 2017-01-27 08:22:12 -10:00
Peter Smith 1a0ca791ab [ELF][ARM] Use SyntheticSections for Thunks
Thunks are now implemented by redirecting the relocation to the
symbol S, to a symbol TS in a Thunk. The Thunk will transfer control
to S. This has the following implications:
- All the side-effects of Thunks happen within createThunks()
- Thunks are no longer stored in InputSections and Symbols no longer
  need to hold a pointer to a Thunk
- The synthetic Thunk sections need to be merged into OutputSections
    
This implementation is almost a direct conversion of the existing
Thunks with the following exceptions:
- Mips LA25 Thunks are placed before the InputSection that defines
  the symbol that needs a Thunk.
- All ARM Thunks are placed at the end of the OutputSection of the
  first caller to the Thunk.
    
Range extension Thunks are not supported yet so it is optimistically
assumed that all Thunks can be reused.

Differential Revision:  https://reviews.llvm.org/D29129



git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@293283 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27 13:10:16 +00:00
George Rimar eaded4dbeb [ELF] - Added additional comments on top of r292789 (D29021)
It was requested during post commit review.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292903 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 09:31:02 +00:00
George Rimar af811a7e32 [ELF] - Stop handling local symbols in a special way.
Previously we stored kept locals in a KeptLocalSyms arrays,
belonged to files.

Patch makes SymbolTableSection to store locals in Symbols member,
that already present and was used for globals.
SymbolTableSection already had NumLocals counter member, so change
itself is trivial.

That allows to simplify handling of -r,
Body::DynsymIndex is no more used as "symbol table index" for relocatable
output.

Change was suggested during review of D28773 and opens road for D28612.

Differential revision: https://reviews.llvm.org/D29021

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@292789 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-23 14:07:23 +00:00
Rui Ueyama d6802083ef Do not use the same name for both a class and a variable.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291835 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 21:44:20 +00:00
Rui Ueyama 0b4c7959d9 Improve an error message and remove fatal(Error &, const Twine &)
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291834 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 21:43:58 +00:00
Rui Ueyama 267714c0b9 Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291812 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 21:09:58 +00:00
George Rimar 2627e90284 [ELF] - Do not crash if user section has name equal to one of synthetic sections.
Previously we just crashed when had user defined
section .shstrtab, for example. Which name equals to synthetic one,
but have different type.

Testcase reveals an issue.

Differential revision: https://reviews.llvm.org/D28559

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291765 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 13:00:31 +00:00
George Rimar 3358d46117 [ELF] - Reuse Decompressor class.
Intention of change is to get rid of code duplication.
Decompressor was introduced in D28105.

Change allows to get rid of few methods relative to decompression.

Differential revision: https://reviews.llvm.org/D28106

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291758 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 10:53:31 +00:00
Rui Ueyama 83d4f18a3b Merge elf::toString and coff::toString.
The two overloaded functions hid each other. This patch merges them.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291222 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-06 10:04:08 +00:00
Rui Ueyama 20a95df793 Remove Compressed member from InputSectionData.
This value is used only once, and we can compute a value.
So we don't need to save it.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290164 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 05:47:55 +00:00
Rui Ueyama 54b01a52e8 Remove lld/Support/Memory.h.
I thought for a while about how to remove it, but it looks like we
can just copy the file for now. Of course I'm not happy about that,
but it's just less than 50 lines of code, and we already have
duplicate code in Error.h and some other places. I want to solve
them all at once later.

Differential Revision: https://reviews.llvm.org/D27819

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@290062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-18 14:06:06 +00:00
Sean Silva 47608c2c98 Rename InputSection.cpp:getSymVA to getRelocTargetVA.
This name was really confusing because there is also another static
helper Symbols.cpp:getSymVA which has the same name.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289733 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14 22:45:52 +00:00
Rui Ueyama ca7af8d122 Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@289084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 18:31:13 +00:00
Rui Ueyama feee152733 Inline MergeInputSection::getData().
This change seems to make LLD 0.6% faster when linking Clang with
debug info. I don't want us to have lots of local optimizations,
but this function is very hot, and the improvement is small but
not negligible, so I think it's worth doing.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288757 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 02:19:30 +00:00
Adhemerval Zanella 3f65a6c0b4 ELF/AArch64: consolidate getAArch64Page implementation
This patch avoid getAArch64Page code duplication by removing the
implementation at InputSection.


git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288668 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 14:14:26 +00:00
Rui Ueyama db52dfea56 Simplify ICF alignment handling.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288630 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 01:31:39 +00:00
Rafael Espindola 083dae3a91 Ignone SHF_INFO_LINK.
Some elf producers (dtrace) put this flag in relocation sections and
some (MC) don't. If we don't ignore the flag we end up with multiple
relocation sections poiting to the same section, which we don't
support.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-03 15:26:18 +00:00
Jack Andersen 89f2cd22cb Merge branch 'master' into small-data 2016-11-29 15:51:44 -10:00
George Rimar 656286750d [ELF] - Disable emiting multiple output sections when merging is disabled.
When -O0 is specified, we do not do section merging.
Though before this patch several sections were generated instead
of single, what is useless.

Differential revision: https://reviews.llvm.org/D27041

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288151 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29 16:11:09 +00:00
Simon Atanasyan 3de9f3362e [ELF][MIPS] Do not change MipsGotSection state in the getPageEntryOffset method
The MipsGotSection::getPageEntryOffset calculates index of GOT entry
with a "page" address. Previously this method changes the state
of MipsGotSection because it modifies PageIndexMap field. That leads
to the unpredictable results if getPageEntryOffset called from multiple threads.

The patch makes getPageEntryOffset constant. To do so it calculates GOT
entry index but does not update PageIndexMap field. Later in the
MipsGotSection::writeTo method linker calculates "page" addresses and
writes them to the output.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@288129 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29 10:23:56 +00:00
Rui Ueyama c5ad55dcce Change return types of split{Non,}Strings.
They return new vectors, but at the same time they mutate other vectors,
so returning values doesn't make much sense. We should just mutate two
vectors.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287979 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-26 15:15:11 +00:00
Rui Ueyama c19d73d974 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-25 20:41:45 +00:00
Rui Ueyama 7d536b76d5 Parallelize uncompress() and splitIntoPieces().
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% )

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287946 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-25 20:05:08 +00:00
Jack Andersen 2088a6f644 Merge branch 'master' into small-data 2016-11-25 09:42:36 -10:00