summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO/LTO.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Silence warning with assertions disabled.Peter Collingbourne2017-06-151-0/+1
| | | | llvm-svn: 305485
* Apply summary-based dead stripping to regular LTO modules with summaries.Peter Collingbourne2017-06-151-78/+121
| | | | | | | | | | | | | | | If a regular LTO module has a summary index, then instead of linking it into the combined regular LTO module right away, add it to the combined summary index and associate it with a special module that represents the combined regular LTO module. Any such modules are linked during LTO::run(), at which time we use the results of summary-based dead stripping to control whether to link prevailing symbols. Differential Revision: https://reviews.llvm.org/D33922 llvm-svn: 305482
* Object: Factor out the code for creating the irsymtab for an arbitrary ↵Peter Collingbourne2017-06-081-45/+12
| | | | | | | | | | | bitcode file. This code now lives in lib/Object. The idea is that it can now be reused by IRObjectFile among other things. Differential Revision: https://reviews.llvm.org/D31921 llvm-svn: 304958
* Symbols re-defined with -wrap and -defsym need to be excluded from inter-Dmitry Mikulin2017-06-051-4/+13
| | | | | | | | | | 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
* Move summary dead stripping before regular LTO.Evgeniy Stepanov2017-06-021-13/+13
| | | | | | | | | This way dead stripping results are recorded in combined summary and can be used in regular LTO passes. Differential Revision: https://reviews.llvm.org/D33615 llvm-svn: 304577
* [ThinLTO] Move -lto-use-new-pm to llvm-lto2, and change it to -use-new-pm.Tim Shen2017-06-011-0/+1
| | | | | | | | | | | | | | | | | | Summary: As we teach Clang to use ThinkLTO + new PM, it's good for the users to inject through Config, instead of setting a flag in the LTOBackend library. Move the flag to llvm-lto2. As it moves to llvm-lto2, a new name -use-new-pm seems simpler and as clear. Reviewers: davide, tejohnson Subscribers: mehdi_amini, Prazek, inglorion, eraman, chandlerc, llvm-commits Differential Revision: https://reviews.llvm.org/D33799 llvm-svn: 304492
* (NFC) Track global summary liveness in GVFlags.Evgeniy Stepanov2017-06-011-4/+14
| | | | | | | | Replace GVFlags::LiveRoot with GVFlags::Live and use that instead of all the DeadSymbols sets. This is refactoring in order to make liveness information available in the RegularLTO pipeline. llvm-svn: 304466
* [lib/LTO] Don't reinvent the code for switching linkage.Davide Italiano2017-05-261-10/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D33582 llvm-svn: 304040
* LTO: Do summary-based prevailing symbol resolution at --lto-O0.Peter Collingbourne2017-05-251-13/+12
| | | | | | | | | Prevailing symbol resolution is necessary for correctness. Without this we can end up dropping a referenced linkonce symbol from the link. Differential Revision: https://reviews.llvm.org/D33570 llvm-svn: 303939
* Infer relocation model from module flags in relocatable LTO link.Evgeniy Stepanov2017-05-221-1/+4
| | | | | | Fix for PR33096. llvm-svn: 303578
* IR: Give function GlobalValue::getRealLinkageName() a less misleading name: ↵Peter Collingbourne2017-05-161-2/+2
| | | | | | | | | | | | dropLLVMManglingEscape(). This function gives the wrong answer on some non-ELF platforms in some cases. The function that does the right thing lives in Mangler.h. To try to discourage people from using this function, give it a different name. Differential Revision: https://reviews.llvm.org/D33162 llvm-svn: 303134
* Re-apply r302108, "IR: Use pointers instead of GUIDs to represent edges in ↵Peter Collingbourne2017-05-041-4/+5
| | | | | | | | the module summary. NFCI." with a fix for the clang backend. llvm-svn: 302176
* Revert "IR: Use pointers instead of GUIDs to represent edges in the module ↵Eric Liu2017-05-041-5/+4
| | | | | | | | | | summary. NFCI." This reverts commit r302108. This causes crash in clang bootstrap with LTO. Contacted the auther in the original commit. llvm-svn: 302140
* IR: Use pointers instead of GUIDs to represent edges in the module summary. ↵Peter Collingbourne2017-05-041-4/+5
| | | | | | | | | | | | | | | | | | | | NFCI. When profiling a no-op incremental link of Chromium I found that the functions computeImportForFunction and computeDeadSymbols were consuming roughly 10% of the profile. The goal of this change is to improve the performance of those functions by changing the map lookups that they were previously doing into pointer dereferences. This is achieved by changing the ValueInfo data structure to be a pointer to an element of the global value map owned by ModuleSummaryIndex, and changing reference lists in the GlobalValueSummary to hold ValueInfos instead of GUIDs. This means that a ValueInfo will take a client directly to the summary list for a given GUID. Differential Revision: https://reviews.llvm.org/D32471 llvm-svn: 302108
* Bitcode: Make the summary reader responsible for merging. NFCI.Peter Collingbourne2017-05-011-5/+3
| | | | | | | | | This is to prepare for an upcoming change which uses pointers instead of GUIDs to represent references. Differential Revision: https://reviews.llvm.org/D32469 llvm-svn: 301843
* Object: Remove ModuleSummaryIndexObjectFile class.Peter Collingbourne2017-05-011-1/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D32195 llvm-svn: 301832
* LTO: Mark undefined module asm symbols as used.Peter Collingbourne2017-04-261-1/+2
| | | | | | | | | | | | | | | | Marking them as used causes them to be considered visible outside of LTO. This prevents the symbols from being internalized or discarded, either by GlobalDCE or by summary-based dead stripping in ThinLTO. This change makes it unnecessary to add these symbols to llvm.compiler.used in the backend, as the symbols are kept alive by virtue of being external, so remove the backend code that handles that. Fixes PR32798. Differential Revision: https://reviews.llvm.org/D32544 llvm-svn: 301438
* Object, LTO: Add target triple to irsymtab and LTO API.Peter Collingbourne2017-04-141-0/+1
| | | | | | | | | | Start using it in LLD to avoid needing to read bitcode again just to get the target triple, and in llvm-lto2 to avoid printing symbol table information that is inappropriate for the target. Differential Revision: https://reviews.llvm.org/D32038 llvm-svn: 300300
* Support: Add a VCSRevision.h header file.Peter Collingbourne2017-04-131-1/+2
| | | | | | | | | | | | | | | | | | | | | This is a magic header file supported by the build system that provides a single definition, LLVM_REVISION, containing an LLVM revision identifier, if available. This functionality previously lived in the LTO library, but I am moving it out to lib/Support because I want to also start using it in lib/Object to create the IR symbol table. This change also fixes a bug where LLVM_REVISION was never actually being used in lib/LTO because the macro HAS_LLVM_REVISION was never defined (it was misspelled as HAVE_SVN_VERSION_INC in lib/LTO/CMakeLists.txt, and was only being defined in a non-existent file Version.cpp). I also changed the code to use "git rev-parse --git-dir" to locate the .git directory, instead of looking for it in the LLVM source root directory, which makes this compatible with monorepos as well as git worktrees. Differential Revision: https://reviews.llvm.org/D31985 llvm-svn: 300160
* LTO: call getRealLinkageName on IRNames before feeding to getGUIDBob Haarman2017-03-311-3/+5
| | | | | | | | | | | | | | Summary: GlobalValue has two getGUID methods: an instance method and a static method. The static method takes a string, which is expected to be what GlobalValue::getRealLinkageName() would return. In LTO.cpp, we were not doing this consistently, sometimes passing an IR name instead. This change makes it so that we call getRealLinkageName() first, making the static getGUID return value consistent with the instance method. Without this change, compiling FileCheck with ThinLTO on Windows fails with numerous undefined symbol errors. With the change, it builds successfully. Reviewers: pcc, rnk Reviewed By: pcc Subscribers: tejohnson, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D31444 llvm-svn: 299268
* Re-apply r299168 and r299169 now that the libdeps are fixed.Peter Collingbourne2017-03-311-127/+85
| | | | llvm-svn: 299184
* Move llvm::emitLinkerFlagsForGlobalCOFF() to Mangler.Peter Collingbourne2017-03-311-1/+0
| | | | llvm-svn: 299183
* Revert r299168 and r299169 due to library dependency issues.Peter Collingbourne2017-03-311-85/+127
| | | | | | http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux/builds/25073/steps/build_llvmclang/logs/stdio llvm-svn: 299171
* LTO: Reduce memory consumption by creating an in-memory symbol table for ↵Peter Collingbourne2017-03-311-127/+85
| | | | | | | | | | | | | | | | | | | | | | | InputFiles. NFCI. Introduce symbol table data structures that can be potentially written to disk, have the LTO library build those data structures using temporarily constructed modules and redirect the LTO library implementation to go through those data structures. This allows us to remove the LLVMContext and Modules owned by InputFile. With this change I measured a peak memory consumption decrease from 5.4GB to 2.8GB in a no-op incremental ThinLTO link of Chromium on Linux. The impact on memory consumption is larger in COFF linkers where we are currently forced to materialize all metadata in order to read linker options. Peak memory consumption linking a large piece of Chromium for Windows with full LTO and debug info decreases from >64GB (OOM) to 15GB. Part of PR27551. Differential Revision: https://reviews.llvm.org/D31364 llvm-svn: 299168
* More accurate header inclusions. NFC.Peter Collingbourne2017-03-281-0/+1
| | | | llvm-svn: 298960
* LTO: Replace InputFile::Symbol::getFlags() with predicate accessors. NFC.Peter Collingbourne2017-03-281-2/+2
| | | | | | | This makes the predicates independent of the flag representation and makes the code a little easier to read. llvm-svn: 298951
* LTO: Hash type identifier resolutions for WholeProgramDevirt.Peter Collingbourne2017-03-101-0/+16
| | | | | | Differential Revision: https://reviews.llvm.org/D30555 llvm-svn: 297514
* LTO: Hash type identifier resolutions for LowerTypeTests.Peter Collingbourne2017-03-101-11/+68
| | | | | | Differential Revision: https://reviews.llvm.org/D30553 llvm-svn: 297513
* LTO: Hash the set of imported symbols for each module.Peter Collingbourne2017-03-031-1/+19
| | | | | | | | | | This set may affect code generation and is sensitive to link order (and possibly in the future to the linker's choice of prevailing symbol), so we need to include it. Differential Revision: https://reviews.llvm.org/D30586 llvm-svn: 296907
* [LTO] Add ability to emit assembly to new LTO APITobias Edler von Koch2017-02-151-0/+1
| | | | | | | | | | | | | | | | Summary: Add a field to LTO::Config, CGFileType, to select the file type to emit (object or assembly). This is useful for testing and to implement -save-temps. Reviewers: tejohnson, mehdi_amini, pcc Reviewed By: mehdi_amini Subscribers: davide, llvm-commits Differential Revision: https://reviews.llvm.org/D29475 llvm-svn: 295226
* [LTO] Share the optimization remarks setup between Thin/Full LTO.Davide Italiano2017-02-101-0/+24
| | | | llvm-svn: 294807
* IRMover: Merge flags LinkModuleInlineAsm and IsPerformingImport.Peter Collingbourne2017-02-031-1/+0
| | | | | | | | | Currently these flags are always the inverse of each other, so there is no need to keep them separate. Differential Revision: https://reviews.llvm.org/D29471 llvm-svn: 294016
* Revert "[ThinLTO] Add an auto-hide feature"Mehdi Amini2017-02-031-19/+7
| | | | | | | | | This reverts commit r293970. After more discussion, this belongs to the linker side and there is no added value to do it at this level. llvm-svn: 293993
* [ThinLTO] Add an auto-hide featureMehdi Amini2017-02-031-7/+19
| | | | | | | | | | | | | | | When a symbol is not exported outside of the DSO, it is can be hidden. Usually we try to internalize as much as possible, but it is not always possible, for instance a symbol can be referenced outside of the LTO unit, or there can be cross-module reference in ThinLTO. This is a recommit of r293912 after fixing build failures, and a recommit of r293918 after fixing LLD tests. Differential Revision: https://reviews.llvm.org/D28978 llvm-svn: 293970
* Revert "[ThinLTO] Add an auto-hide feature"Mehdi Amini2017-02-021-19/+7
| | | | | | This reverts commit r293918, one lld test does not pass. llvm-svn: 293961
* [lto] add getLinkerOpts()Bob Haarman2017-02-021-0/+30
| | | | | | | | | | | | Summary: Some compilers, including MSVC and Clang, allow linker options to be specified in source files. In the legacy LTO API, there is a getLinkerOpts() method that returns linker options for the bitcode module being processed. This change adds that method to the new API, so that the COFF linker can get the right linker options when using the new LTO API. Reviewers: pcc, ruiu, mehdi_amini, tejohnson Reviewed By: pcc Differential Revision: https://reviews.llvm.org/D29207 llvm-svn: 293950
* [ThinLTO] Add an auto-hide featureMehdi Amini2017-02-021-7/+19
| | | | | | | | | | | | | | When a symbol is not exported outside of the DSO, it is can be hidden. Usually we try to internalize as much as possible, but it is not always possible, for instance a symbol can be referenced outside of the LTO unit, or there can be cross-module reference in ThinLTO. This is a recommit of r293912 after fixing build failures. Differential Revision: https://reviews.llvm.org/D28978 llvm-svn: 293918
* Revert "[ThinLTO] Add an auto-hide feature"Mehdi Amini2017-02-021-19/+7
| | | | | | This reverts r293912, bots are broken. llvm-svn: 293914
* [ThinLTO] Add an auto-hide featureMehdi Amini2017-02-021-7/+19
| | | | | | | | | | | | When a symbol is not exported outside of the DSO, it is can be hidden. Usually we try to internalize as much as possible, but it is not always possible, for instance a symbol can be referenced outside of the LTO unit, or there can be cross-module reference in ThinLTO. Differential Revision: https://reviews.llvm.org/D28978 llvm-svn: 293912
* LTO: Link non-prevailing weak_odr or linkonce_odr globals into the combined ↵Peter Collingbourne2017-02-021-4/+17
| | | | | | | | | | | | module with available_externally linkage. These linkages mean that the ultimately prevailing symbol will have the same semantics as any non-prevailing copy of the symbol, so we are free to ignore the linker's resolution. Differential Revision: https://reviews.llvm.org/D29367 llvm-svn: 293865
* Linker: Move special casing for available_externally in IRMover to clients. ↵Peter Collingbourne2017-02-021-13/+22
| | | | | | | | | | NFCI. The goal is to simplify the semantic model for clients of IRMover. Differential Revision: https://reviews.llvm.org/D29435 llvm-svn: 293864
* [ThinLTO] Don't perform computeDeadSymbols during O0 link, as the result is ↵Mehdi Amini2017-01-201-13/+13
| | | | | | never used (NFC) llvm-svn: 292679
* IPO, LTO: Plumb the summary from the LTO API into the pass manager.Peter Collingbourne2017-01-201-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D28840 llvm-svn: 292661
* [ThinLTO] Drop non-prevailing non-ODR weak to declarationsTeresa Johnson2017-01-201-3/+1
| | | | | | | | | | | | | | | Summary: Allow non-ODR weak/linkonce non-prevailing copies to be marked as available_externally in the index. Add support for dropping these to declarations in the backend. Reviewers: mehdi_amini, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28806 llvm-svn: 292656
* LTO: Flush the resolution file after writing to it.Peter Collingbourne2017-01-191-0/+1
| | | | | | Without this the file could be truncated if the linker crashes. llvm-svn: 292532
* ThinLTO: add early "dead-stripping" on the IndexTeresa Johnson2017-01-051-5/+36
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Using the linker-supplied list of "preserved" symbols, we can compute the list of "dead" symbols, i.e. the one that are not reachable from a "preserved" symbol transitively on the reference graph. Right now we are using this information to mark these functions as non-eligible for import. The impact is two folds: - Reduction of compile time: we don't import these functions anywhere or import the function these symbols are calling. - The limited number of import/export leads to better internalization. Patch originally by Mehdi Amini. Reviewers: mehdi_amini, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23488 llvm-svn: 291177
* [lib/LTO] Simplify logic removing set but unused variable. NFCI.Davide Italiano2017-01-041-9/+3
| | | | | | | Reported by David Binderman and ack'ed by Teresa on IRC. PR: 31527 llvm-svn: 291000
* [ThinLTO] Import composite types as declarationsTeresa Johnson2016-12-161-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | Summary: When reading the metadata bitcode, create a type declaration when possible for composite types when we are importing. Doing this in the bitcode reader saves memory. Also it works naturally in the case when the type ODR map contains a definition for the same composite type because it was used in the importing module (buildODRType will automatically use the existing definition and not create a type declaration). For Chromium built with -g2, this reduces the aggregate size of the generated native object files by 66% (from 31G to 10G). It reduced the time through the ThinLTO link and backend phases by about 20% on my machine. Reviewers: mehdi_amini, dblaikie, aprantl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27775 llvm-svn: 289993
* Pass sample pgo flags to thinlto.Dehao Chen2016-12-161-0/+6
| | | | | | | | | | | | Summary: ThinLTO needs to invoke SampleProfileLoader pass during link time in order to annotate profile correctly after module importing. Reviewers: davidxl, mehdi_amini, tejohnson Subscribers: pcc, davide, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D27790 llvm-svn: 289957
* [LTO] Reject modules without datalayout.Davide Italiano2016-12-141-0/+5
| | | | | | | | | | | Also, udpate the ~60 failing tests in the tree which did not contain a valid datalayout. This fixes PR31123. lld will be updated in a following patch, immediately after this is committed. Differential Revision: https://reviews.llvm.org/D27082 llvm-svn: 289719
OpenPOWER on IntegriCloud