aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTO.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-09-06[LTO] Constify (NFC)Mehdi Amini1-16/+20
llvm-svn: 280687
2016-08-27[LTO] Don't create a new common unless merged has different sizeTeresa Johnson1-3/+4
Summary: This addresses a regression in common handling from the new LTO API in r278338. Only create a new common if the size is different. The type comparison against an array type fails when the size is different but not an array. GlobalMerge does not handle the array types as well and we lose some global merging opportunities. Reviewers: mehdi_amini Subscribers: junbuml, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D23955 llvm-svn: 279911
2016-08-26Make writeToResolutionFile a static helper.Rafael Espindola1-10/+10
llvm-svn: 279859
2016-08-23[ThinLTO] Add caching to the new LTO APIMehdi Amini1-28/+121
Add the ability to plug a cache on the LTO API. I tried to write such that a linker implementation can control the cache backend. This is intrusive and I'm not totally happy with it, but I can't figure out a better design right now. Differential Revision: https://reviews.llvm.org/D23599 llvm-svn: 279576
2016-08-23Stop always creating and running an LTO compilation if there is not a single ↵Mehdi Amini1-21/+13
LTO object Summary: I assume there was a use case, so maybe this strawman patch will help clarifying if it is legit. In any case the current situation is not legit: a ThinLTO compilation should not trigger an unexpected full LTO compilation. Right now, adding a --save-temps option triggers this and makes the number of output differs. Reviewers: tejohnson Subscribers: pcc, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D23600 llvm-svn: 279550
2016-08-23[ThinLTO] Make sure the Context used for the ThinLTO backend has all the ↵Mehdi Amini1-1/+1
appropriate options An important performance setting on the LLVMContext for LTO is enableDebugTypeODRUniquing(), this adds an automatic merging of debug information in the context based on type ids. Also, the lto::Config includes a diagnostic handler that needs to be set on the Context, as well as the setDiscardValueNames() setting. llvm-svn: 279532
2016-08-22[LTO] Handles commons in monolithic LTOMehdi Amini1-0/+33
The gold-plugin was doing this internally, now the API is handling commons correctly based on the given resolution. Differential Revision: https://reviews.llvm.org/D23739 llvm-svn: 279417
2016-08-22[LTO] Add a "CodeGenOnly" option. Allows the client to skip the optimizer.Mehdi Amini1-19/+21
Summary: Slowly getting on par with libLTO Reviewers: tejohnson Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D23615 llvm-svn: 279416
2016-08-19[LTO] Remove dead-code: collectUsedGlobalVariables has been moved to Thin ↵Mehdi Amini1-3/+1
and LTO specifc path (NFC) llvm-svn: 279261
2016-08-19[LTO] Move callback member from base class to the derived where it is used (NFC)Mehdi Amini1-12/+10
llvm-svn: 279212
2016-08-19[LTO] Add a move to inialize member in ctor initialization list (NFC)Mehdi Amini1-1/+1
llvm-svn: 279210
2016-08-17[LTO] Introduce an Output class to wrap the output stream creation (NFC)Mehdi Amini1-21/+21
Summary: While NFC for now, this will allow more flexibility on the client side to hold state necessary to back up the stream. Also when adding caching, this class will grow in complexity. Note I blindly modified the gold-plugin as I can't compile it. Reviewers: tejohnson Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23542 llvm-svn: 278907
2016-08-16[LTO] Simplify APIs and constify (NFC)Mehdi Amini1-8/+8
Summary: Multiple APIs were taking a StringMap for the ImportLists containing the entries for for all the modules while operating on a single entry for the current module. Instead we can pass the desired ModuleImport directly. Also some of the APIs were not const, I believe just to be able to use operator[] on the StringMap. Reviewers: tejohnson Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D23537 llvm-svn: 278776
2016-08-11Fix type truncation warningsTeresa Johnson1-8/+8
Avoid type truncation warnings from a 32-bit bot due to size_t not being unsigned long long, by converting the variables and constants to unsigned. This was introduced by r278338 and caused warnings here: http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux/builds/15527/steps/build_llvmclang/logs/warnings%20%287%29 llvm-svn: 278406
2016-08-11Restore "Resolution-based LTO API."Teresa Johnson1-5/+531
This restores commit r278330, with fixes for a few bot failures: - Fix a late change I had made to the save temps output file that I missed due to existing files sitting on my disk - Fix a bunch of Windows bot failures with "ambiguous call to overloaded function" due to confusion between llvm::make_unique vs std::make_unique (preface the new make_unique calls with "llvm::") - Attempt to fix a modules bot failure by adding a missing include to LTO/Config.h. Original change: Resolution-based LTO API. Summary: This introduces a resolution-based LTO API. The main advantage of this API over existing APIs is that it allows the linker to supply a resolution for each symbol in each object, rather than the combined object as a whole. This will become increasingly important for use cases such as ThinLTO which require us to process symbol resolutions in a more complicated way than just adjusting linkage. Patch by Peter Collingbourne. Reviewers: rafael, tejohnson, mehdi_amini Subscribers: lhames, tejohnson, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D20268 llvm-svn: 278338
2016-08-11Revert "Resolution-based LTO API."Teresa Johnson1-531/+5
This reverts commit r278330. I made a change to the save temps output that is causing issues with the bots. Didn't realize this because I had older output files sitting on disk in my test output directory. llvm-svn: 278331
2016-08-11Resolution-based LTO API.Teresa Johnson1-5/+531
Summary: This introduces a resolution-based LTO API. The main advantage of this API over existing APIs is that it allows the linker to supply a resolution for each symbol in each object, rather than the combined object as a whole. This will become increasingly important for use cases such as ThinLTO which require us to process symbol resolutions in a more complicated way than just adjusting linkage. Patch by Peter Collingbourne. Reviewers: rafael, tejohnson, mehdi_amini Subscribers: lhames, tejohnson, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D20268 Address review comments llvm-svn: 278330
2016-07-07ThinLTO: Do not take into account whether a definition has multiple copies ↵Peter Collingbourne1-13/+3
when promoting. We currently do not touch a symbol's linkage in the case where a definition has a single copy. However, this code is effectively unnecessary: either the definition is not exported, in which case the internalize phase sets its linkage to internal, or it is exported, in which case we need to promote linkage to weak. Those two cases are already handled by existing code. I believe that the only real functional change here is in the case where we have a single definition which does not prevail (e.g. because the definition in a native object file prevails). In that case we now lower linkage to available_externally following the existing code path for that case. As a result we can remove the isExported function parameter from the thinLTOResolveWeakForLinkerInIndex function. Differential Revision: http://reviews.llvm.org/D21883 llvm-svn: 274784
2016-07-07ThinLTO: Remove check for multiple modules before applying weak resolutions.Peter Collingbourne1-4/+0
This check is not only unnecessary, it can produce the wrong result. If we are linking a single module and it has an exported linkonce symbol, we need to promote to weak in order to avoid PR19901-style problems. Differential Revision: http://reviews.llvm.org/D21917 llvm-svn: 274722
2016-06-12Move instances of std::function.Benjamin Kramer1-8/+8
Or replace with llvm::function_ref if it's never stored. NFC intended. llvm-svn: 272513
2016-05-26[ThinLTO] Resolve LinkOnceAnyTeresa Johnson1-15/+6
Summary: Ensure we keep prevailing copy of LinkOnceAny by converting it to WeakAny. Rename odr_resolution test to the now more appropriate weak_resolution (weak in the linker sense includes linkonce). Reviewers: joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D20634 llvm-svn: 270850
2016-05-25[ThinLTO] Refactor ODR resolution and internalization (NFC)Teresa Johnson1-0/+100
Move the now index-based ODR resolution and internalization routines out of ThinLTOCodeGenerator.cpp and into either LTO.cpp (index-based analysis) or FunctionImport.cpp (index-driven optimizations). This is to enable usage by other linkers. llvm-svn: 270698
2016-05-23[ThinLTO] Refactor module loader handling into new LTO file (NFC)Teresa Johnson1-0/+42
Moved the ModuleLoader and supporting helper loadModuleFromBuffer out of ThinLTOCodeGenerator and into new LTO.h/LTO.cpp files. This is in preparation for a patch that will utilize these in the gold-plugin. Note that there are some other pending patches (D20268 and D20290) that also plan to refactor common interfaces and functionality into this same pair of new files. llvm-svn: 270509