summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ICF.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify InputFile ownership management.Rui Ueyama2016-09-141-2/+1
| | | | | | | | | | | | | | | | | | | | Previously, all input files were owned by the symbol table. Files were created at various places, such as the Driver, the lazy symbols, or the bitcode compiler, and the ownership of new files was transferred to the symbol table using std::unique_ptr. All input files were then free'd when the symbol table is freed which is on program exit. I think we don't have to transfer ownership just to free all instance at once on exit. In this patch, all instances are automatically collected to a vector and freed on exit. In this way, we no longer have to use std::unique_ptr. Differential Revision: https://reviews.llvm.org/D24493 llvm-svn: 281425
* Store an ArrayRef for Data in InputSectionData.Rafael Espindola2016-09-121-2/+1
| | | | llvm-svn: 281210
* Compute section names only once.Rafael Espindola2016-09-081-3/+3
| | | | | | | | This simplifies error handling as there is now only one place in the code that needs to consider the possibility that the name is corrupted. Before we would do it in every access. llvm-svn: 280937
* [ELF] ICF should respect section alignmentPetr Hosek2016-08-221-1/+5
| | | | | | | | | When performing ICF, we have to respect the alignment requirement of each section within each group. Differential Revision: https://reviews.llvm.org/D23732 llvm-svn: 279456
* Do not pass Symtab to markLive/doICF since Symtab is globally accessible.Rui Ueyama2016-05-021-14/+12
| | | | llvm-svn: 268286
* ELF: Move code to where it is used, and related cleanups. NFC.Peter Collingbourne2016-04-261-11/+2
| | | | | | Differential Revision: http://reviews.llvm.org/D19490 llvm-svn: 267637
* Call repl in getSymbolBody. NFC.Rafael Espindola2016-04-261-1/+1
| | | | | | Every caller was doing it. llvm-svn: 267603
* Update for llvm change.Rafael Espindola2016-04-051-10/+6
| | | | llvm-svn: 265404
* Don't store an Elf_Sym for most symbols.Rafael Espindola2016-04-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our symbol representation was redundant, and some times would get out of sync. It had an Elf_Sym, but some fields were copied to SymbolBody. Different parts of the code were checking the bits in SymbolBody and others were checking Elf_Sym. There are two general approaches to fix this: * Copy the required information and don't store and Elf_Sym. * Don't copy the information and always use the Elf_Smy. The second way sounds tempting, but has a big problem: we would have to template SymbolBody. I started doing it, but it requires templeting *everything* and creates a bit chicken and egg problem at the driver where we have to find ELFT before we can create an ArchiveFile for example. As much as possible I compared the test differences with what gold and bfd produce to make sure they are still valid. In most cases we are just adding hidden visibility to a local symbol, which is harmless. In most tests this is a small speedup. The only slowdown was scylla (1.006X). The largest speedup was clang with no --build-id, -O3 or --gc-sections (i.e.: focus on the relocations): 1.019X. llvm-svn: 265293
* Error/warning/log messages should start with lowercase letters.George Rimar2016-03-151-2/+2
| | | | llvm-svn: 263549
* Use ELFT instead of ELFFile<ELFT>.Rui Ueyama2016-03-141-3/+3
| | | | llvm-svn: 263510
* Create a SymbolBody for locals.Rafael Espindola2016-03-111-19/+8
| | | | | | pr26878 shows a case where locals have to be in the got. llvm-svn: 263222
* Rename elf2 to elf.Rafael Espindola2016-02-281-7/+7
| | | | llvm-svn: 262159
* ELF: Remove relSize function from ICF.cpp. NFC.Rui Ueyama2016-02-271-11/+3
| | | | llvm-svn: 262155
* Fix unsafe dereference.Rui Ueyama2016-02-261-2/+2
| | | | | | | Bound may point to one element beyond the end of the vector, so *Bound is not safe. llvm-svn: 262022
* Fix typo in comment.Rui Ueyama2016-02-261-2/+2
| | | | llvm-svn: 261943
* ELF: Define log() to print out message if --verbose is given.Rui Ueyama2016-02-251-6/+3
| | | | llvm-svn: 261919
* ELF: Implement ICF.Rui Ueyama2016-02-251-0/+382
This patch implements the same algorithm as LLD/COFF's ICF. I'm not going to repeat the same description about how it works, so you want to read the comment in ICF.cpp in this patch if you want to know the details. This algorithm should be more powerful than the ICF algorithm implemented in GNU gold. It can even merge mutually-recursive functions (which is harder than one might think). ICF is a fairly effective size optimization. Here are some examples. LLD: 37.14 MB -> 35.80 MB (-3.6%) Clang: 59.41 MB -> 57.80 MB (-2.7%) The lacking feature is "safe" version of ICF. This merges all identical sections. That is not compatible with a C/C++ language requirement that two distinct functions must have distinct addresses. But as long as your program do not rely on the pointer equality (which is in many cases true), your program should work with the feature. LLD works fine for example. GNU gold implements so-called "safe ICF" that identifies functions that are safe to merge by heuristics -- for example, gold thinks that constructors are safe to merge because there is no way to take an address of a constructor in C++. We have a different idea which David Majnemer suggested that we add NOPs at beginning of merged functions so that two or more pointers can have distinct values. We can do whichever we want, but this patch does not include neither. http://reviews.llvm.org/D17529 llvm-svn: 261912
OpenPOWER on IntegriCloud