summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LTO.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ThinLTO] Pass CodeGenOpts like UnrollLoops/VectorizeLoop/VectorizeSLPWei Mi2020-01-091-0/+3
| | | | | | | | | | | | | down to pass builder in ltobackend. Currently CodeGenOpts like UnrollLoops/VectorizeLoop/VectorizeSLP in clang are not passed down to pass builder in ltobackend when new pass manager is used. This is inconsistent with the behavior when new pass manager is used and thinlto is not used. Such inconsistency causes slp vectorization pass not being enabled in ltobackend for O3 + thinlto right now. This patch fixes that. Differential Revision: https://reviews.llvm.org/D72386
* Revert an accidental commit af5ca40b47b3e85c3add81ccdc0b787c4bc355aeRui Ueyama2019-12-131-3/+0
|
* temporaryRui Ueyama2019-12-131-0/+3
|
* [ELF] Replace SymbolTable::forEachSymbol with iterator_range symbols()Fangrui Song2019-11-261-2/+2
| | | | | | | | | | | | | | D62381 introduced forEachSymbol(). It seems that many call sites cannot be parallelized because the body shared some states. Replace forEachSymbol with iterator_range<filter_iterator<...>> symbols() to simplify code and improve debuggability (std::function calls take some frames). It also allows us to use early return to simplify code added in D69650. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D70505
* [ELF] Wrap things in `namespace lld { namespace elf {`, NFCFangrui Song2019-10-071-2/+5
| | | | | | | | | | | This makes it clear `ELF/**/*.cpp` files define things in the `lld::elf` namespace and simplifies `elf::foo` to `foo`. Reviewed By: atanasyan, grimar, ruiu Differential Revision: https://reviews.llvm.org/D68323 llvm-svn: 373885
* [LLD] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-4/+4
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368936
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-1/+1
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* [ELF] Support explicitly overriding relocation model in LTOPetr Hosek2019-07-201-1/+3
| | | | | | | | lld currently selects the relocation model automatically depending on the link flags specified, but in some cases it'd be useful to allow explicitly overriding the relocation model using a flag. llvm-svn: 366644
* [ELF] Fix variable names in comments after VariableName -> variableName changeFangrui Song2019-07-161-3/+3
| | | | | | Also fix some typos. llvm-svn: 366181
* [Coding style change] Rename variables so that they start with a lowercase ↵Rui Ueyama2019-07-101-145/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | letter This patch is mechanically generated by clang-llvm-rename tool that I wrote using Clang Refactoring Engine just for creating this patch. You can see the source code of the tool at https://reviews.llvm.org/D64123. There's no manual post-processing; you can generate the same patch by re-running the tool against lld's code base. Here is the main discussion thread to change the LLVM coding style: https://lists.llvm.org/pipermail/llvm-dev/2019-February/130083.html In the discussion thread, I proposed we use lld as a testbed for variable naming scheme change, and this patch does that. I chose to rename variables so that they are in camelCase, just because that is a minimal change to make variables to start with a lowercase letter. Note to downstream patch maintainers: if you are maintaining a downstream lld repo, just rebasing ahead of this commit would cause massive merge conflicts because this patch essentially changes every line in the lld subdirectory. But there's a remedy. clang-llvm-rename tool is a batch tool, so you can rename variables in your downstream repo with the tool. Given that, here is how to rebase your repo to a commit after the mass renaming: 1. rebase to the commit just before the mass variable renaming, 2. apply the tool to your downstream repo to mass-rename variables locally, and 3. rebase again to the head. Most changes made by the tool should be identical for a downstream repo and for the head, so at the step 3, almost all changes should be merged and disappear. I'd expect that there would be some lines that you need to merge by hand, but that shouldn't be too many. Differential Revision: https://reviews.llvm.org/D64121 llvm-svn: 365595
* [Remarks] Extend -fsave-optimization-record to specify the formatFrancis Visoiu Mistrih2019-06-171-0/+1
| | | | | | | | | Use -fsave-optimization-record=<format> to specify a different format than the default, which is YAML. For now, only YAML is supported. llvm-svn: 363573
* Use SymbolTable::insert() to implement --trace.Rui Ueyama2019-05-281-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D62381 llvm-svn: 361791
* Remove LazyObjFile::AddedToLink.Rui Ueyama2019-05-231-1/+1
| | | | | | | Instead we can just clear a MemoryBuffer so that we cannot get the same buffer more than once. llvm-svn: 361477
* Make replaceSymbol a member function of Symbol.Rui Ueyama2019-05-201-2/+2
| | | | | | | | | | | | This is a mechanical rewrite of replaceSymbol(A, B) to A->replace(B). I also added a comment to Symbol::replace(). Technically this change is not necessary, but this change makes code a bit more concise. Differential Revision: https://reviews.llvm.org/D62117 llvm-svn: 361123
* Move symbol resolution code out of SymbolTable class.Rui Ueyama2019-05-171-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the last patch of the series of patches to make it possible to resolve symbols without asking SymbolTable to do so. The main point of this patch is the introduction of `elf::resolveSymbol(Symbol *Old, Symbol *New)`. That function resolves or merges given symbols by examining symbol types and call replaceSymbol (which memcpy's New to Old) if necessary. With the new function, we have now separated symbol resolution from symbol lookup. If you already have a Symbol pointer, you can directly resolve the symbol without asking SymbolTable to do that. Now that the nice abstraction become available, I can start working on performance improvement of the linker. As a starter, I'm thinking of making --{start,end}-lib faster. --{start,end}-lib is currently unnecessarily slow because it looks up the symbol table twice for each symbol. - The first hash table lookup/insertion occurs when we instantiate a LazyObject file to insert LazyObject symbols. - The second hash table lookup/insertion occurs when we create an ObjFile from LazyObject file. That overwrites LazyObject symbols with Defined symbols. I think it is not too hard to see how we can now eliminate the second hash table lookup. We can keep LazyObject symbols in Step 1, and then call elf::resolveSymbol() to do Step 2. Differential Revision: https://reviews.llvm.org/D61898 llvm-svn: 360975
* Simplify SymbolTable::add{Defined,Undefined,...} functions.Rui Ueyama2019-05-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | SymbolTable's add-family functions have lots of parameters because when they have to create a new symbol, they forward given arguments to Symbol's constructors. Therefore, the functions take at least as many arguments as their corresponding constructors. This patch simplifies the add-family functions. Now, the functions take a symbol instead of arguments to construct a symbol. If there's no existing symbol, a given symbol is memcpy'ed to the symbol table. Otherwise, the functions attempt to merge the existing and a given new symbol. I also eliminated `CanOmitFromDynSym` parameter, so that the functions take really one argument. Symbol classes are trivially constructible, so looks like constructing them to pass to add-family functions is as cheap as passing a lot of arguments to the functions. A quick benchmark showed that this patch seems performance-neutral. This is a preparation for http://lists.llvm.org/pipermail/llvm-dev/2019-April/131902.html Differential Revision: https://reviews.llvm.org/D61855 llvm-svn: 360838
* [ELF] Reorder BitcodeFiles.empty() to call thinLTOCreateEmptyIndexFiles() in ↵Fangrui Song2019-05-071-7/+8
| | | | | | | | | | | | | | | | | only one place It makes the --plugin-opt=obj-path= and --plugin-opt=thinlto-index-only= behavior more consistent - the files will be created in the BitcodeFiles.empty() case, but I assume whether it behaves this way is not required by anyone. LTOObj->run() cannot run with empty BitcodeFiles. There would be an error: ld.lld: error: No available targets are compatible with triple "" Differential Revision: https://reviews.llvm.org/D61635 llvm-svn: 360129
* [ELF] --plugin-opt=thinlto-index-only: create empty index files even if all ↵Fangrui Song2019-05-021-18/+19
| | | | | | | | | | | | | | | | | | | bitcode files are lazy Summary: The gold plugin behavior (creating empty index files for lazy bitcode files) was added in D46034, but it missed the case when there is no non-lazy bitcode files, e.g. ld.lld -shared crti.o crtbeginS.o --start-lib bitcode.o --end-lib ... crti.o crtbeginS.o are not bitcode, but our distributed build system wants bitcode.o.thinlto.bc to confirm all expected outputs are created based on all of the modules provided to the linker. Differential Revision: https://reviews.llvm.org/D61420 llvm-svn: 359788
* Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 Original llvm-svn: 355964 llvm-svn: 355984
* Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-121-1/+0
| | | | | | This reverts commit 20fff32b7d1f1a1bd417b22aa9f26ededd97a3e5. llvm-svn: 355976
* [Remarks] Add -foptimization-record-passes to filter remark emissionFrancis Visoiu Mistrih2019-03-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 llvm-svn: 355964
* [PGO] Add options for context-sensitive PGORong Xu2019-03-111-0/+3
| | | | | | | | Add lld options for CSPGO (context-sensitive PGO). Differential Revision: https://reviews.llvm.org/D56675 llvm-svn: 355876
* Output ELF files after ThinLTO is run.Bill Wendling2019-02-261-12/+15
| | | | | | | | | | | | | | | | | | Summary: The gold linker allowed you to output the ELF files after LTO was run. It did it by using the 'obj-path' option. This replicates that behavior. Reviewers: espindola, ruiu, MaskRay, pcc Reviewed By: MaskRay, pcc Subscribers: grimar, emaste, inglorion, arichardson, steven_wu, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D56046 llvm-svn: 354917
* Fix names of functions in TargetOptionsCommandFlags.h. NFC.Sam Clegg2019-02-011-4/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D57555 llvm-svn: 352825
* [LTO] Set CGOptLevel in LTO config.Sam Clegg2019-01-301-0/+2
| | | | | | | | | Previously we were never setting this which means it was always being set to Default (-O2/-Os). Differential Revision: https://reviews.llvm.org/D57422 llvm-svn: 352667
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Add --plugin-opt=emit-llvm option.Rui Ueyama2018-12-141-0/+8
| | | | | | | | | | | | | | `--plugin-opt=emit-llvm` is an option for LTO. It makes the linker to combine all bitcode files and write the result to an output file without doing codegen. Gold LTO plugin has this option. This option is being used for some post-link code analysis tools that have to see a whole program but don't need to see them in the native machine code. Differential Revision: https://reviews.llvm.org/D55717 llvm-svn: 349198
* Set MAttrs in LTO modeFangrui Song2018-11-011-0/+1
| | | | | | | | | | | | | | | | Summary: Without this patch, MAttrs are not set. Patch by Yin Ma Reviewers: espindola, MaskRay, ruiu, pcc Reviewed By: MaskRay, pcc Subscribers: pcc, emaste, sbc100, inglorion, arichardson, aheejin, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D53446 llvm-svn: 345884
* Simplify.Rui Ueyama2018-09-111-22/+14
| | | | | | Instead of Map<StringRef, bool>, we can simply use Set<StringRef>. llvm-svn: 341948
* ELF: Enable address-significance tables during LTO.Peter Collingbourne2018-08-061-1/+2
| | | | | | | | This allows safe ICF to work when linking with LTO. Differential Revision: https://reviews.llvm.org/D50221 llvm-svn: 339050
* Support option -plugin-opt=dwo_dir=Yunlian Jiang2018-07-161-0/+1
| | | | | | | | | | | | | | | | Summary: This adds support to option -plugin-opt=dwo_dir=${DIR}. This option is used to specify the directory to store the .dwo files when LTO and debug fission is used at the same time. Reviewers: ruiu, espindola, pcc Reviewed By: pcc Subscribers: eraman, dexonsmith, mehdi_amini, emaste, arichardson, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D47904 llvm-svn: 337195
* [ELF] - Remove dead code. NFC.George Rimar2018-07-051-3/+0
| | | | | | | | | | | | | I think code is dead, because the only way to see Path as empty seems would be if replaceThinLTOSuffix() replaced some prefix with empty prefix (making the result Path empty). But it is impossible to pass the empty prefix, we would file in driver: https://github.com/llvm-mirror/lld/blob/master/ELF/Driver.cpp#L669 llvm-svn: 336338
* [ThinLTO/lld] Document constant bool ModuleSummaryIndex parameter (NFC)Teresa Johnson2018-06-061-1/+1
| | | | | | Makes this consistent with other ModuleSummaryIndex constructor calls. llvm-svn: 334141
* Revert "[ELF] Simplify. NFC"Fangrui Song2018-05-231-2/+2
| | | | | | This reverts commit cc6f052261096dc9d4c9d3123e37b023c3e171df. llvm-svn: 333099
* Code cleanup in preparation for adding LTO for wasm. NFC.Sam Clegg2018-05-221-22/+0
| | | | | | | | | | | | | | - Move some common code into Common/rrorHandler.cpp and Common/Strings.h. - Don't use `fatal` when incompatible bitcode files are encountered. - Rename NameRef variable to just Name See D47162 Differential Revision: https://reviews.llvm.org/D47206 llvm-svn: 333021
* [ELF] Simplify. NFCFangrui Song2018-05-221-2/+2
| | | | llvm-svn: 332952
* Improve error message for -thinlto-object-suffix-replace and simplify code.Rui Ueyama2018-05-171-24/+28
| | | | llvm-svn: 332643
* Add support for ThinLTO plugin option thinlto-object-suffix-replaceRumeet Dhindsa2018-05-161-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D46608 llvm-svn: 332527
* Add support for LTO plugin option obj-pathRumeet Dhindsa2018-05-081-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D46598 llvm-svn: 331817
* Update ThinLTO Indexing logicRumeet Dhindsa2018-05-081-24/+36
| | | | | | | | Instead of writing empty index for file, this patch tracks the state of files in ObjectToIndexFileState. If the files are not indexed , only then we emit the empty files Differential Revision: https://reviews.llvm.org/D46480 llvm-svn: 331803
* Refactor BitcodeCompiler::add(). NFC.Rui Ueyama2018-05-081-8/+7
| | | | | | | This change makes it explicit that the main loop iterates over a parallel array, Syms and ObjSyms. llvm-svn: 331780
* Fix a bug that a copy of a large vector was created. NFC.Rui Ueyama2018-05-081-1/+1
| | | | llvm-svn: 331779
* Rename a local variable whose scope is very narrow. NFC.Rui Ueyama2018-05-071-3/+3
| | | | llvm-svn: 331703
* Rename Config::ThinLTOIndexOnlyObjectFiles -> Config::ThinLTOIndexOnlyArg.Rui Ueyama2018-05-071-4/+4
| | | | llvm-svn: 331699
* Split BitcodeCompiler::init() into two functions. NFC.Rui Ueyama2018-05-071-32/+33
| | | | | | | | | Previously, code to initialize Backend and code to initialize Conf are intermingled in init(), though they don't depend on each other. Differential Revision: https://reviews.llvm.org/D46554 llvm-svn: 331698
* Add support for thinlto option ( thinlto-emit-imports-files) to emit import ↵Rumeet Dhindsa2018-05-071-7/+14
| | | | | | | | files for thinlink. Differential Revision: https://reviews.llvm.org/D46400 llvm-svn: 331696
* Do not call exit() directly from lld.Rui Ueyama2018-05-071-1/+3
| | | | | | | | | | Our promise is that as long as there's no fatal error (i.e. broken file is given to the linker), our main function returns to the caller. So we can't use exit() in the regular code path. Differential Revision: https://reviews.llvm.org/D46442 llvm-svn: 331690
* Refactor ThinLTO-related code in BitcodeCompiler.cpp. NFC.Rui Ueyama2018-05-071-52/+34
| | | | | | | | | | | | Summary: Refactor ThinLTO-related code in BitcodeCompiler.cpp. NFC. Reviewers: rdhindsa, espindola Subscribers: emaste, inglorion, arichardson, llvm-commits, eraman Differential Revision: https://reviews.llvm.org/D46549 llvm-svn: 331689
* Do not pass Config members to simplify function signature. NFC.Rui Ueyama2018-05-071-9/+4
| | | | llvm-svn: 331658
* Parse --thinlto-prefix-replace early so that we don't need to parse it ↵Rui Ueyama2018-05-071-16/+10
| | | | | | later. NFC. llvm-svn: 331657
OpenPOWER on IntegriCloud