summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LTO.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use StringRef instead of `const std::string &`. NFC.Rui Ueyama2018-05-071-3/+3
| | | | llvm-svn: 331656
* Refactor BitcodeCompiler::createLTO. NFC.Rui Ueyama2018-05-071-18/+19
| | | | llvm-svn: 331655
* Updated ThinLTO test to not include forward or backward slash for testingRumeet Dhindsa2018-05-031-1/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D46372 llvm-svn: 331419
* Added support for ThinLTO plugin options : thinlto-index-only and ↵Rumeet Dhindsa2018-05-021-3/+91
| | | | | | | | thinlto-prefix-replace Differential Revision: https://reviews.llvm.org/D46034 llvm-svn: 331405
* Added support for LTO options: sample_profile, new_pass_manager and ↵Rumeet Dhindsa2018-04-091-0/+5
| | | | | | | | debug_pass_manager Differential Revision: https://reviews.llvm.org/D45275 llvm-svn: 329598
* [lld/LTO] Remove unused Path parameter to AddBufferFnTeresa Johnson2018-02-201-2/+3
| | | | | | | | | | | | | | | | Summary: With D43396, no clients use the Path parameter anymore. This is the lld side fix with D43400. Depends on D43396 and D43400. Reviewers: pcc Subscribers: emaste, inglorion, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D43401 llvm-svn: 325620
* Symbols defined in linker scripts should not have dso_local flag set in LTO ↵Dmitry Mikulin2018-02-081-2/+3
| | | | | | | | resolutions. Differential Revision: https://reviews.llvm.org/D43051 llvm-svn: 324559
* Don't set dso_local flag in LTO resolutions for absolute symbols defined in ELFDmitry Mikulin2018-02-071-1/+7
| | | | | | | | | objects, it confuses codegen into generating pc-rel relocations for those symbols, which leads to linker errors. Differential Revision: https://reviews.llvm.org/D42977 llvm-svn: 324435
* Pass CPU string to LTO pipeline.Rafael Espindola2018-01-301-0/+1
| | | | | | | | | | Previously an empty CPU string was passed to the LTO engine which resulted in a generic CPU for which certain features like NOPL were disabled. This fixes that. Patch by Pratik Bhatu! llvm-svn: 323801
* [ELF] - Define linkerscript symbols early.George Rimar2018-01-301-11/+4
| | | | | | | | | | | | | | | | Currently symbols assigned or created by linkerscript are not processed early enough. As a result it is not possible to version them or assign any other flags/properties. Patch creates Defined symbols for -defsym and linkerscript symbols early, so that issue from above can be addressed. It is based on Rafael Espindola's version of D38239 patch. Fixes PR34121. Differential revision: https://reviews.llvm.org/D41987 llvm-svn: 323729
* Use the combined visibility when computing dso_local.Rafael Espindola2018-01-161-2/+1
| | | | | | | | | | | We track both the combined visibility that will be used for the output symbol and the original input visibility of the selected symbol. Almost everything should use the computed visibility. I will make the names less confusing an a followup patch. llvm-svn: 322576
* Set dso_local in lld.Rafael Espindola2018-01-161-0/+6
| | | | | | We were already doing this in gold, but not in lld. llvm-svn: 322572
* Use Symbol::File directly.Rafael Espindola2017-11-291-1/+1
| | | | | | | We are already paying the cost of storing a InputFile in every Symbol, so use it uniformly. llvm-svn: 319378
* Remove IsLocal.Rafael Espindola2017-11-171-2/+2
| | | | | | | Since we always have Binding in the current symbol design IsLocal is redundant. llvm-svn: 318497
* Rename replaceBody -> replaceSymbol.Rui Ueyama2017-11-031-2/+2
| | | | llvm-svn: 317383
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-4/+4
| | | | | | | | | | | | | Now that we have only SymbolBody as the symbol class. So, "SymbolBody" is a bit strange name now. This is a mechanical change generated by perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF) nd clang-format-diff. Differential Revision: https://reviews.llvm.org/D39459 llvm-svn: 317370
* Merge SymbolBody and Symbol into one class, SymbolBody.Rui Ueyama2017-10-311-9/+8
| | | | | | | | | | | | | | | | | | | SymbolBody and Symbol were separated classes due to a historical reason. Symbol used to be a pointer to a SymbolBody, and the relationship between Symbol and SymbolBody was n:1. r2681780 changed that. Since that patch, SymbolBody and Symbol are allocated next to each other to improve memory locality, and they have 1:1 relationship now. So, the separation of Symbol and SymbolBody no longer makes sense. This patch merges them into one class. In order to avoid updating too many places, I chose SymbolBody as a unified name. I'll rename it Symbol in a follow-up patch. Differential Revision: https://reviews.llvm.org/D39406 llvm-svn: 317006
* [lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman2017-10-251-1/+1
| | | | | | | | | | | | | | | | | | | Summary: The COFF linker and the ELF linker have long had similar but separate Error.h and Error.cpp files to implement error handling. This change introduces new error handling code in Common/ErrorHandler.h, changes the COFF and ELF linkers to use it, and removes the old, separate implementations. Reviewers: ruiu Reviewed By: ruiu Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D39259 llvm-svn: 316624
* Rename Commands -> SectionCommands.Rui Ueyama2017-10-111-1/+1
| | | | | | | | | | "Commands" was ambiguous because in the linker script, everything is a command. We used to handle only SECTIONS commands, and at the time, it might make sense to call them the commands, but it is no longer the case. We handle not only SECTIONS but also MEMORY, PHDRS, VERSION, etc., and they are all commands. llvm-svn: 315409
* Remove ScriptConfiguration class and move the members to LinkerScript class.Rui Ueyama2017-10-111-1/+1
| | | | | | | | | | | | | | | | ScriptConfiguration was a class to contain parsed results of linker scripts. LinkerScript is a class to interpret it. That ditinction was needed because we haven't instantiated LinkerScript early (because, IIRC, LinkerScript class was a ELFT template function). So, when we parse linker scripts, we couldn't directly store the result to a LinkerScript instance. Now, that limitation is gone. We instantiate LinkerScript at the very beginning of our main function. We can directly store parse results to a LinkerScript instance. llvm-svn: 315403
* Move new lld's code to Common subdirectory.Rui Ueyama2017-10-021-2/+2
| | | | | | | | | | New lld's files are spread under lib subdirectory, and it isn't easy to find which files are actually maintained. This patch moves maintained files to Common subdirectory. Differential Revision: https://reviews.llvm.org/D37645 llvm-svn: 314719
* [ELF] - LTO: do not optimize away symbols accessed from linkerscript.George Rimar2017-09-251-1/+13
| | | | | | | | | | | Previously when BC file had global variable that was accessed from script, it was optimized away or inlined by IPO. In this patch I add symbols at left side of assignment expression as LinkerRedefined, what prevents optimization for them. Differential revision: https://reviews.llvm.org/D37059 llvm-svn: 314097
* Move Config->SymbolRenaming to SymbolTable.Rui Ueyama2017-09-251-1/+1
| | | | | | | | | | | | In order to keep track of symbol renaming, we used to have Config->SymbolRenaming, and whether a symbol is in the map or not affects its symbol attribute (i.e. "LinkeRedefined" bit). This patch adds "CanInline" bit to Symbol to aggreagate symbol information in one place and removed the member from Config since no one except SymbolTable now uses the table. llvm-svn: 314088
* Simplify error handling. NFC.Rafael Espindola2017-09-211-4/+2
| | | | llvm-svn: 313930
* LTO: Try to open cache files before renaming them.Peter Collingbourne2017-09-051-3/+2
| | | | | | | | | | | | | | It appears that a potential race between the cache client and the cache pruner that I thought was unlikely actually happened in practice [1]. Try to avoid the race condition by opening the temporary file before renaming it. Do this only on non-Windows platforms because we cannot rename open files on Windows using the sys::fs::rename function. [1] https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.memory%2FLinux_CFI%2F1610%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout Differential Revision: https://reviews.llvm.org/D37410 llvm-svn: 312567
* [ELF] - Make IR symbols be visible when doing relocatable link.George Rimar2017-08-221-1/+7
| | | | | | | | | | This is PR33097. Previously when doing relocatable link, all IR symbols were absent in result object file. Patch makes external symbols to be exported. Differential revision: https://reviews.llvm.org/D36957 llvm-svn: 311431
* Move File from SymbolBody to Symbol.Rafael Espindola2017-08-041-3/+3
| | | | | | | | | | | | | With this Symbol has the same size as before, but DefinedRegular goes from 72 to 64 bytes. I also find this a bit easier to read. There are fewer places initializing File for example. This has a small but measurable speed improvement on all tests (1% max). llvm-svn: 310142
* Use more consistent namesRafael Espindola2017-08-021-3/+3
| | | | | | | | | | | | | | | | | | | | Reviewing another change I noticed that we use "getSymbols" to mean different things in different files. Depending on the file it can return ArrayRef<StringRef> ArrayRef<SymbolBody*> ArrayRef<Symbol*> ArrayRef<Elf_Sym> With this change it always returns an ArrayRef<SymbolBody*>. The other functions are renamed getELFsyms() and getSymbolNames(). Note that we cannot return ArrayRef<Symbol*> instead of ArreyRef<SymbolBody*> because local symbols have a SymbolBody but not a Symbol. llvm-svn: 309840
* Make __start_sec __end_sec handling more precise.Rafael Espindola2017-07-261-2/+10
| | | | | | | | | | With this we only ask LTO to keep a C named section if there is a __start_ or __end symbol. This is not as strict as lld's --gc-sections, but is as good as we can get without having a far more detailed ir summary. llvm-svn: 309232
* LTO: Handle sections with valid C names.Rafael Espindola2017-07-251-2/+3
| | | | | | | These can be referenced with __start_/__stop_ symbols. I will try to make this more precise in a followup patch. llvm-svn: 309048
* [LTO] Make sure symbol ordering is honoured also for data.Davide Italiano2017-07-241-1/+2
| | | | | | Follow-up to r308915 suggested by Rafael and Peter. llvm-svn: 308920
* [LTO] Make sure symbol ordering is honoured.Davide Italiano2017-07-241-0/+3
| | | | | | | | | We do this emitting a section for every function when LTO is used. Fixes PR33888. Differential Revision: https://reviews.llvm.org/D35809 llvm-svn: 308915
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-1/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* Symbols re-defined with -wrap and -defsym need to be excluded from inter-Dmitry Mikulin2017-06-051-0/+1
| | | | | | | | | | procedural optimizations to prevent dropping symbols and allow the linker to process re-directs. PR33145: --wrap doesn't work with lto. Differential Revision: https://reviews.llvm.org/D33621 llvm-svn: 304719
* [lld] Infer relocation model from module flags in relocatable LTO link.Evgeniy Stepanov2017-05-221-1/+6
| | | | | | Fix for PR33096. llvm-svn: 303579
* Revert r301897, "ELF: Set symbol binding to STB_GLOBAL when undefining ↵Peter Collingbourne2017-05-031-5/+0
| | | | | | | | | | | symbols during LTO." It doesn't matter what binding we store in a non-UsedInRegularObj undefined symbol because we should reset it when we see a real undefined symbol in a combined LTO object. The fact that we weren't doing so before is a bug (PR32899) which is now fixed. llvm-svn: 302067
* ELF: Set symbol binding to STB_GLOBAL when undefining symbols during LTO.Peter Collingbourne2017-05-021-0/+5
| | | | | | | | | | | | | | | | If there is a bug in the LTO implementation that causes it to fail to provide an expected symbol definition, the linker should report an undefined symbol error. Unfortunately, we were failing to do so if the symbol definition was weak, as the undefine() function was turning the definition into a weak undefined symbol, which resolves to zero if the symbol remains undefined. This patch causes us to set the binding to STB_GLOBAL when we undefine a symbol. I can't see a good way to test this. The behaviour should only be observable if there is a bug in the LTO implementation. Differential Revision: https://reviews.llvm.org/D32731 llvm-svn: 301897
* LTO: Replace InputFile::Symbol::getFlags() with predicate accessors. NFC.Peter Collingbourne2017-03-281-3/+1
| | | | | | | This makes the predicates independent of the flag representation and makes the code a little easier to read. llvm-svn: 298951
* Compute Config member function return values only once.Rui Ueyama2017-03-171-1/+1
| | | | | | | | | | | We had a few Config member functions that returns configuration values. For example, we had is64() which returns true if the target is 64-bit. The return values of these functions are constant and never change. This patch is to compute them only once to make it clear that they'll never change. llvm-svn: 298168
* ELF: Add cache pruning support.Peter Collingbourne2017-03-171-0/+3
| | | | | | | | | | This patch causes us to use pruneCache() to prune the ThinLTO cache after completing LTO. A new flag --thinlto-cache-policy allows users to configure the policy. Differential Revision: https://reviews.llvm.org/D31021 llvm-svn: 298036
* LTO: Fix a potential race condition in the caching API.Peter Collingbourne2017-03-171-4/+5
| | | | | | | | | | | | | | | | | | | | | After the call to sys::fs::exists succeeds, indicating a cache hit, we call AddFile and the client will open the file using the supplied path. If the client is using cache pruning, there is a potential race between the pruner and the client. To avoid this, change the caching API so that it provides a MemoryBuffer to the client, and have clients use that MemoryBuffer where possible. This scheme won't work with the gold plugin because the plugin API expects a file path. So we have the gold plugin use the buffer identifier as a path and live with the race for now. (Note that the gold plugin isn't actually affected by the problem at the moment because it doesn't support cache pruning.) This effectively reverts r279883 modulo the change to use the existing path in the gold plugin. Differential Revision: https://reviews.llvm.org/D31063 llvm-svn: 298020
* LTO: When creating a local cache, create the cache directory if it does not ↵Peter Collingbourne2017-03-021-4/+4
| | | | | | | | already exist. Differential Revision: https://reviews.llvm.org/D30519 llvm-svn: 296726
* ELF: Add ThinLTO caching support.Peter Collingbourne2017-03-011-5/+24
| | | | | | | | | | This patch adds an option named --thinlto-cache-dir, which specifies the path to a directory in which to cache native object files for ThinLTO incremental builds. Differential Revision: https://reviews.llvm.org/D30509 llvm-svn: 296702
* [ELF] - Allow the Code Model flag when using LTOMartell Malone2017-02-281-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D29445 llvm-svn: 296542
* Do not store a computable attributes to Config.Rui Ueyama2017-02-141-1/+1
| | | | llvm-svn: 295031
* [LTO] Add support for optimization remarks.Davide Italiano2017-02-131-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D29878 llvm-svn: 294971
* add the ability to call InitTargetOptionsFromCodeGenFlags from multiple objectsBob Haarman2017-02-021-1/+1
| | | | | | | | | | | | | | Summary: llvm/CodeGen/CommandFlags.h a utility function InitTargetOptionsFromCodeGenFlags which is used to set target options from flags based on the command line. The command line flags are stored in globals defined in the same file, and including the file in multiple places causes the globals to be defined multiple times, leading to linker errors. This change adds a single place in lld where these globals are defined and exports only the utility function. This makes it possible to call InitTargetOptionsFromCodeGenFlags from multiple places in lld, which a follow-up change will do. Reviewers: davide, ruiu Reviewed By: davide, ruiu Subscribers: mgorny Differential Revision: https://reviews.llvm.org/D29058 llvm-svn: 293965
* [ELF] Use SyntheticSections for ThunksPeter Smith2017-02-011-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. This is a recommit of r293283 with a fixed comparison predicate as std::merge requires a strict weak ordering. Differential revision: https://reviews.llvm.org/D29327 llvm-svn: 293757
* Revert "[ELF][ARM] Use SyntheticSections for Thunks"Rui Ueyama2017-01-281-5/+10
| | | | | | This reverts commit r293283 because it broke MSVC build. llvm-svn: 293352
* [ELF][ARM] Use SyntheticSections for ThunksPeter Smith2017-01-271-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 293283
OpenPOWER on IntegriCloud