- Jan 12, 2017
-
-
George Rimar authored
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 llvm-svn: 291758
-
- Jan 06, 2017
-
-
Rui Ueyama authored
The two overloaded functions hid each other. This patch merges them. llvm-svn: 291222
-
- Dec 20, 2016
-
-
Rui Ueyama authored
This value is used only once, and we can compute a value. So we don't need to save it. llvm-svn: 290164
-
- Dec 19, 2016
-
-
Rui Ueyama authored
Use of CachedHashStringRef makes sense only when we reuse hash values. Sprinkling it to all DenseMap has no benefits and just complicates data types. Basically we shouldn't use CachedHashStringRef unless there is a strong reason to to do so. llvm-svn: 290076
-
- Dec 06, 2016
-
-
Rui Ueyama authored
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. llvm-svn: 288757
-
- Dec 05, 2016
-
-
Rui Ueyama authored
Also add a citation to GNU gold safe ICF paper. Differential Revision: https://reviews.llvm.org/D27398 llvm-svn: 288684
-
- Dec 01, 2016
-
-
Rui Ueyama authored
Use "color" instead of "group id" to describe the ICF algorithm. llvm-svn: 288409
-
Rui Ueyama authored
ICF is short for Identical Code Folding. It is a size optimization to identify two or more functions that happened to have the same contents to merges them. It usually reduces output size by a few percent. ICF is slow because it is computationally intensive process. I tried to paralellize it before but failed because I couldn't make a parallelized version produce consistent outputs. Although it didn't create broken executables, every invocation of the linker generated slightly different output, and I couldn't figure out why. I think I now understand what was going on, and also came up with a simple algorithm to fix it. So is this patch. The result is very exciting. Chromium for example has 780,662 input sections in which 20,774 are reducible by ICF. LLD previously took 7.980 seconds for ICF. Now it finishes in 1.065 seconds. As a result, LLD can now link a Chromium binary (output size 1.59 GB) in 10.28 seconds on my machine with ICF enabled. Compared to gold which takes 40.94 seconds to do the same thing, this is an amazing number. From here, I'll describe what we are doing for ICF, what was the previous problem, and what I did in this patch. In ICF, two sections are considered identical if they have the same section flags, section data, and relocations. Relocations are tricky, becuase two relocations are considered the same if they have the same relocation type, values, and if they point to the same section _in terms of ICF_. Here is an example. If foo and bar defined below are compiled to the same machine instructions, ICF can (and should) merge the two, although their relocations point to each other. void foo() { bar(); } void bar() { foo(); } This is not an easy problem to solve. What we are doing in LLD is some sort of coloring algorithm. We color non-identical sections using different colors repeatedly, and sections in the same color when the algorithm terminates are considered identical. Here is the details: 1. First, we color all sections using their hash values of section types, section contents, and numbers of relocations. At this moment, relocation targets are not taken into account. We just color sections that apparently differ in different colors. 2. Next, for each color C, we visit sections having color C to see if their relocations are the same. Relocations are considered equal if their targets have the same color. We then recolor sections that have different relocation targets in new colors. 3. If we recolor some section in step 2, relocations that were previously pointing to the same color targets may now be pointing to different colors. Therefore, repeat 2 until a convergence is obtained. Step 2 is a heavy operation. For Chromium, the first iteration of step 2 takes 2.882 seconds, and the second iteration takes 1.038 seconds, and in total it needs 23 iterations. Parallelizing step 1 is easy because we can color each section independently. This patch does that. Parallelizing step 2 is tricky. We could work on each color independently, but we cannot recolor sections in place, because it will break the invariance that two possibly-identical sections must have the same color at any moment. Consider sections S1, S2, S3, S4 in the same color C, where S1 and S2 are identical, S3 and S4 are identical, but S2 and S3 are not. Thread A is about to recolor S1 and S2 in C'. After thread A recolor S1 in C', but before recolor S2 in C', other thread B might observe S1 and S2. Then thread B will conclude that S1 and S2 are different, and it will split thread B's sections into smaller groups wrongly. Over- splitting doesn't produce broken results, but it loses a chance to merge some identical sections. That was the cause of indeterminism. To fix the problem, I made sections have two colors, namely current color and next color. At the beginning of each iteration, both colors are the same. Each thread reads from current color and writes to next color. In this way, we can avoid threads from reading partial results. After each iteration, we flip current and next. This is a very simple solution and is implemented in less than 50 lines of code. I tested this patch with Chromium and confirmed that this parallelized ICF produces the identical output as the non-parallelized one. Differential Revision: https://reviews.llvm.org/D27247 llvm-svn: 288373
-
- Nov 26, 2016
-
-
Rui Ueyama authored
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. llvm-svn: 287979
-
- Nov 25, 2016
-
-
Rui Ueyama authored
The function was used only within Relocations.cpp, but now we are using it in many places, so this patch moves it to a file that fits to the functionality. llvm-svn: 287943
-
- Nov 23, 2016
-
-
Rui Ueyama authored
We have different functions to stringize objects to construct error messages. For InputFile, we have getFilename, and for InputSection, we have getName. You had to memorize them. I think this is the case where the function overloading comes in handy. This patch defines toString() functions that are overloaded for all these types, so that you just call it in error(). Differential Revision: https://reviews.llvm.org/D27030 llvm-svn: 287787
-
Eugene Leviant authored
Differential revision: https://reviews.llvm.org/D26914 llvm-svn: 287750
-
- Nov 21, 2016
-
-
Rui Ueyama authored
Previously, we set (uintptr_t)-1 to InputSectionBase::OutSec to record that a section has already been set to be assigned to some output section by linker scripts. Later, we restored nullptr to the pointer to use the field for the original purpose. That overloading is not very easy to understand. This patch adds a bit flag for that purpose, so that we don't need to piggyback the flag on an unrelated pointer. llvm-svn: 287508
-
- Nov 20, 2016
-
-
Rui Ueyama authored
Also this patch uses file-scope functions instead of class member function. Now that ICF class is not visible from outside, InputSection class can no longer be "friend" of it. So I removed the friend relation and just make it expose the features to public. llvm-svn: 287480
-
- Nov 18, 2016
-
-
Rui Ueyama authored
MergeOutputSection class was a bit hard to use because it provdes a series of finalize functions that have to be called in a right way at a right time. It also intereacted with MergeInputSection, and the logic was somewhat entangled between the two classes. This patch simplifies it by providing only one finalize function. Now, all you have to do is to call MergeOutputSection::finalize when you have added all sections to the output section. Then, it internally merges strings and initliazes StringPiece objects. I think this is much easier to understand. This patch also adds comments. llvm-svn: 287314
-
- Nov 14, 2016
-
-
George Rimar authored
llvm-svn: 286805
-
- Nov 11, 2016
-
-
Rui Ueyama authored
llvm-svn: 286557
-
- Nov 10, 2016
-
-
Rafael Espindola authored
Relocations are the last thing that we wore storing a raw section pointer to and parsing on demand. With this patch we parse it only once and store a pointer to the actual data. The patch also changes where we store it. It is now in InputSectionBase. Not all sections have relocations, but most do and this simplifies the logic. It also means that we now only support one relocation section per section. Given that that constraint is maintained even with -r with gold bfd and lld, I think it is OK. llvm-svn: 286459
-
Eugene Leviant authored
Differential revision: https://reviews.llvm.org/D26349 llvm-svn: 286443
-
Rafael Espindola authored
The disadvantage is that we use uint64_t instad of uint32_t for some value in 32 bit files. The advantage is a substantially simpler code, faster builds and less code duplication. llvm-svn: 286414
-
- Nov 09, 2016
-
-
Simon Atanasyan authored
Previously, we have both input and output section for .MIPS.abiflags. Now we have only one class for .MIPS.abiflags, which is MipsAbiFlagsSection. This class is a synthetic input section. .MIPS.abiflags sections are handled as regular sections until the control reaches Writer. Writer then aggregates all sections whose type is SHT_MIPS_ABIFLAGS to create a single synthesized input section. The synthesized section is then processed normally as if it came from an input file. llvm-svn: 286398
-
Simon Atanasyan authored
Previously, we have both input and output sections for .reginfo and .MIPS.options. Now for each such sections we have one synthetic input sections: MipsReginfoSection and MipsOptionsSection respectively. Both sections are handled as regular sections until the control reaches Writer. Writer then aggregates all sections whose type is SHT_MIPS_REGINFO or SHT_MIPS_OPTIONS to create a single synthesized input section. In that moment Writer also save GP0 value to the MipsGp0 field of the corresponding ObjectFile. This value required for R_MIPS_GPREL16 and R_MIPS_GPREL32 relocations calculation. Differential revision: https://reviews.llvm.org/D26444 llvm-svn: 286397
-
Rafael Espindola authored
It was quite confusing that it had SectionKind of Regular, but was not actually a InputSection. llvm-svn: 286379
-
Rafael Espindola authored
llvm-svn: 286370
-
- Nov 08, 2016
-
-
Rafael Espindola authored
This reverts commit r286100. This saves 8 bytes of every InputSection. llvm-svn: 286235
-
- Nov 07, 2016
-
-
Eugene Leviant authored
Differential revision: https://reviews.llvm.org/D26281 llvm-svn: 286100
-
- Nov 06, 2016
-
-
Rui Ueyama authored
A CommonInputSection is a section containing all common symbols. That was an input section but was abstracted in a different way than the synthetic input sections because it was written before the synthetic input section was invented. This patch rewrites CommonInputSection as a synthetic input section so that it behaves better with other sections. llvm-svn: 286053
-
- Nov 01, 2016
-
-
Rui Ueyama authored
We are going to have many more classes for linker-synthesized input sections, so it's worth to be added to a separate file than to the file for regular input sections. llvm-svn: 285740
-
Rafael Espindola authored
It was only used by build-id and that can easily compute it. llvm-svn: 285691
-
Eugene Leviant authored
llvm-svn: 285683
-
Eugene Leviant authored
Differential revision: https://reviews.llvm.org/D25627 llvm-svn: 285682
-
Eugene Leviant authored
Differential revision: https://reviews.llvm.org/D26070 llvm-svn: 285680
-
- Oct 27, 2016
-
-
Rafael Espindola authored
Now that it is easy to create input section and symbols, this is simple. llvm-svn: 285322
-
- Oct 26, 2016
-
-
Rafael Espindola authored
This allows a non template class to hold input sections. llvm-svn: 285221
-
Rafael Espindola authored
llvm-svn: 285190
-
Rafael Espindola authored
Instead of storing a pointer, store the members we need. The reason for doing this is that it makes it far easier to create synthetic sections. It also avoids reading data from files multiple times., which might help with cross endian linking and host architectures with slow unaligned access. There are obvious compacting opportunities, but this already has mixed results even on native x86_64 linking. There is also the possibility of better refactoring the code for handling common symbols, but this already shows that a custom class is not necessary. llvm-svn: 285148
-
- Oct 25, 2016
-
-
Rafael Espindola authored
llvm-svn: 285082
-
Rafael Espindola authored
We were fairly inconsistent as to what information should be accessed with getSectionHdr and what information (like alignment) was stored elsewhere. Now all section info has a dedicated getter. The code is also a bit more compact. llvm-svn: 285079
-
- Oct 20, 2016
-
-
Hans Wennborg authored
Builds were failing with: InputSection.h(139): error C2338: SectionPiece is too big because MSVC does record layout differently, probably not packing the 'OutputOff' and 'Live' bitfields because their types are of different size. Using size_t for 'Live' seems to fix it. llvm-svn: 284740
-
Rafael Espindola authored
We allocate a lot of these when linking debug info. This speeds up the link of debug programs by 1% to 2%. llvm-svn: 284716
-