summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-lto/llvm-lto.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add an internalization step to the ThinLTOCodeGeneratorMehdi Amini2016-04-241-4/+45
| | | | | | | | | | | | | Keeping as much as possible internal/private is known to help the optimizer. Let's try to benefit from this in ThinLTO. Note: this is early work, but is enough to build clang (and all the LLVM tools). I still need to write some lit-tests... Differential Revision: http://reviews.llvm.org/D19103 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 267317
* llvm-lto: run the module verifier when doing IR level workMehdi Amini2016-04-201-0/+9
| | | | | | | It seems it was only running during CodeGen previously. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266846
* [llvm-lto] Uniform error handling. NFC.Davide Italiano2016-04-131-30/+14
| | | | llvm-svn: 266255
* [llvm-lto] clang-format before working on this file.Davide Italiano2016-04-131-33/+28
| | | | llvm-svn: 266250
* Clean up calls to WriteBitcodeToFile (NFC)Teresa Johnson2016-04-041-1/+1
| | | | | | | | | | | Remove a default parameter value being passed unnecessarily, which also reduces the changes required when this parameter is changed in D18763. Document the remaining non-default bool value passed for another parameter. llvm-svn: 265348
* Rename ModuleSummaryIndex::modPathStringEntries() into modulePaths()Mehdi Amini2016-03-261-1/+1
| | | | | | | It now return the map instead of an iterator. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 264489
* Add a test for r263577: "Add missing error handling in llvm-lto"Mehdi Amini2016-03-191-1/+1
| | | | | | | | On Rafael's suggestion! (also fix a discrepancy between this error message format and the others) From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263860
* Add missing error handling in llvm-ltoMehdi Amini2016-03-151-0/+1
| | | | | | | | | Annoyingly, ErrorOr allows to *not check* the error when things go well. It will crash badly when there is an error though. It should runtime assert when it is used without being checked! From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263577
* [ThinLTO] Renaming of function index to module summary index (NFC)Teresa Johnson2016-03-151-13/+13
| | | | | | | | | | | | | | | (Resubmitting after fixing missing file issue) With the changes in r263275, there are now more than just functions in the summary. Completed the renaming of data structures (started in r263275) to reflect the wider scope. In particular, changed the FunctionIndex* data structures to ModuleIndex*, and renamed related variables and comments. Also renamed the files to reflect the changes. A companion clang patch will immediately succeed this patch to reflect this renaming. llvm-svn: 263513
* Revert "[ThinLTO] Renaming of function index to module summary index (NFC)"Teresa Johnson2016-03-141-13/+13
| | | | | | This reverts commit r263490. Missed a file. llvm-svn: 263493
* [ThinLTO] Renaming of function index to module summary index (NFC)Teresa Johnson2016-03-141-13/+13
| | | | | | | | | | | | | With the changes in r263275, there are now more than just functions in the summary. Completed the renaming of data structures (started in r263275) to reflect the wider scope. In particular, changed the FunctionIndex* data structures to ModuleIndex*, and renamed related variables and comments. Also renamed the files to reflect the changes. A companion clang patch will immediately succeed this patch to reflect this renaming. llvm-svn: 263490
* [ThinLTO] Support for reference graph in per-module and combined summary.Teresa Johnson2016-03-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds support for including a full reference graph including call graph edges and other GV references in the summary. The reference graph edges can be used to make importing decisions without materializing any source modules, can be used in the plugin to make file staging decisions for distributed build systems, and is expected to have other uses. The call graph edges are recorded in each function summary in the bitcode via a list of <CalleeValueIds, StaticCount> tuples when no PGO data exists, or <CalleeValueId, StaticCount, ProfileCount> pairs when there is PGO, where the ValueId can be mapped to the function GUID via the ValueSymbolTable. In the function index in memory, the call graph edges reference the target via the CalleeGUID instead of the CalleeValueId. The reference graph edges are recorded in each summary record with a list of referenced value IDs, which can be mapped to value GUID via the ValueSymbolTable. Addtionally, a new summary record type is added to record references from global variable initializers. A number of bitcode records and data structures have been renamed to reflect the newly expanded scope of the summary beyond functions. More cleanup will follow. Reviewers: joker.eph, davidxl Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D17212 llvm-svn: 263275
* libLTO: add a ThinLTOCodeGenerator on the model of LTOCodeGenerator.Mehdi Amini2016-03-091-0/+290
| | | | | | | | | | | | | | | | | This is intended to provide a parallel (threaded) ThinLTO scheme for linker plugin use through the libLTO C API. The intent of this patch is to provide a first implementation as a proof-of-concept and allows linker to start supporting ThinLTO by definiing the libLTO C API. Some part of the libLTO API are left unimplemented yet. Following patches will add support for these. The current implementation can link all clang/llvm binaries. Differential Revision: http://reviews.llvm.org/D17066 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 262977
* [LTO] Fix error reporting from lto_module_create_in_local_context()Petr Pavlu2016-03-011-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Function lto_module_create_in_local_context() would previously rely on the default LLVMContext being created for it by LTOModule::makeLTOModule(). This context exits the program on error and is not arranged to update sLastStringError in tools/lto/lto.cpp. Function lto_module_create_in_local_context() now creates an LLVMContext by itself, sets it up correctly to its needs and then passes it to LTOModule::createInLocalContext() which takes ownership of the context and keeps it present for the lifetime of the returned LTOModule. Function LTOModule::makeLTOModule() is modified to take a reference to LLVMContext (instead of a pointer) and no longer creates a default context when nullptr is passed to it. Method LTOModule::createInContext() that takes a pointer to LLVMContext is removed because it allows to pass a nullptr to it. Instead LTOModule::createFromBuffer() (that takes a reference to LLVMContext) should be used. Differential Revision: http://reviews.llvm.org/D17715 llvm-svn: 262330
* [LTO] Fix error reporting when a file passed to libLTO is invalid or ↵Petr Pavlu2016-01-201-1/+0
| | | | | | | | | | | | | | | | | | non-existent This addresses PR26060 where function lto_module_create() could return nullptr but lto_get_error_message() returned an empty string. The error() call after LTOModule::createFromFile() in llvm-lto is then removed because any error from this function should go through the diagnostic handler in llvm-lto which will exit the program. The error() call was added because this previously did not happen when the file was non-existent. This is fixed by the patch. (The situation that llvm-lto reports an error when the input file does not exist is tested by llvm/tools/llvm-lto/error.ll). Differential Revision: http://reviews.llvm.org/D16106 llvm-svn: 258298
* Add a change accidentally left out from r258100Tobias Edler von Koch2016-01-181-0/+5
| | | | | | Also remove an executable bit introduced by r258083. llvm-svn: 258101
* Add a missing error handling to llvm-lto.Rafael Espindola2016-01-111-0/+1
| | | | llvm-svn: 257395
* Modernize the C++ APIs for creating LTO modules.Rafael Espindola2015-12-041-20/+29
| | | | | | | | | | | | | | | | This is a continuation of r253367. These functions return is owned by the caller, so they return std::unique_ptr now. The call can fail, so the return is wrapped in ErrorOr. They have a context where to report diagnostics, so they don't need to take a string out parameter. With this there are no call to getGlobalContext in lib/LTO. llvm-svn: 254721
* Move a call to getGlobalContext out of lib/LTO.Rafael Espindola2015-12-041-1/+1
| | | | llvm-svn: 254696
* Simplify the error handling in llvm-lto a bit.Rafael Espindola2015-12-041-36/+37
| | | | llvm-svn: 254675
* [ThinLTO] Deduplicate function index loading into shared helper (NFC)Teresa Johnson2015-11-231-27/+1
| | | | | | | | Add a shared helper routine to read the function index from a file and create/return the function index object. Use it in llvm-link and llvm-lto. llvm-svn: 253903
* [ThinLTO] Handle bitcode without function summary sections gracefullyTeresa Johnson2015-11-211-14/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Several fixes to the handling of bitcode files without function summary sections so that they are skipped during ThinLTO processing in llvm-lto and the gold plugin when appropriate instead of aborting. 1 Don't assert when trying to add a FunctionInfo that doesn't have a summary attached. 2 Skip FunctionInfo structures that don't have attached function summary sections when trying to create the combined function summary. 3 In both llvm-lto and gold-plugin, check whether a bitcode file has a function summary section before trying to parse the index, and skip the bitcode file if it does not. 4 Fix hasFunctionSummaryInMemBuffer in BitcodeReader, which had a bug where we returned to early while looking for the summary section. Also added llvm-lto and gold-plugin based tests for cases where we don't have function summaries in the bitcode file. I verified that either the first couple fixes described above are enough to avoid the crashes, or fixes 1,3,4. But have combined them all here for added robustness. Reviewers: joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D14903 llvm-svn: 253796
* [LTO] Add options to llvm-lto to select output format and dump merged moduleTobias Edler von Koch2015-11-201-0/+23
| | | | | | | | | | | | This introduces two new options: - "llvm-lto -save-merged-module -o outfile" dumps the LTO Module to outfile.merged.bc prior to CodeGen and after LTO optimizations have been run. - "llvm-lto -filetype=asm -o outfile" makes llvm-lto emit assembly instead of object code in outfile. Both are intended for use in lit tests. llvm-svn: 253624
* Do not require a Context to extract the FunctionIndex from Bitcode (NFC)Mehdi Amini2015-11-191-4/+30
| | | | | | | | | | The LLVMContext was only used for Diagnostic. Pass a DiagnosticHandler instead. Differential Revision: http://reviews.llvm.org/D14794 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 253540
* Switch lto codegen to using diagnostic handlers.Yunzhong Gao2015-11-171-11/+9
| | | | | | | | | | | This patch removes the std::string& argument from a number of C++ LTO API calls and instead makes them use the installed diagnostic handler. This would also improve consistency of diagnostic handling infrastructure: if an LTO client used lto_codegen_set_diagnostic_handler() to install a custom error handler, we do not want some error messages to go through the custom error handler, and some other error messages to go into sLastErrorString. llvm-svn: 253367
* llvm-lto: trivial spelling changes to distinguish custom diagnostic handler andYunzhong Gao2015-11-101-0/+1
| | | | | | | | default diagnostic handler. Differential Revision: http://reviews.llvm.org/D14520 llvm-svn: 252633
* Clang format a few prior patches (NFC)Teresa Johnson2015-11-021-6/+8
| | | | | | | I had clang formatted my earlier patches using the wrong style. Reformatted with the LLVM style. llvm-svn: 251812
* Pass FunctionInfoIndex by reference to WriteFunctionSummaryToFile (NFC)Teresa Johnson2015-10-191-1/+1
| | | | | | Implemented suggestion by dblakie in review for r250704. llvm-svn: 250723
* llvm-lto support for generating combined function indexesTeresa Johnson2015-10-191-0/+64
| | | | | | | | | | | | | | | | | Summary: This patch adds support to llvm-lto that mirrors the support added by r249270 to the gold plugin. This enables better testing of combined index generation for ThinLTO. Added a new test, and this support will be used in the test in D13515. Reviewers: joker.eph Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13847 llvm-svn: 250699
* Reapply "LTO: Disable extra verify runs in release builds"Duncan P. N. Exon Smith2015-09-151-2/+6
| | | | | | | This reverts commit r247730, effectively reapplying r247729. This time I have an lld commit ready to follow. llvm-svn: 247735
* Revert "LTO: Disable extra verify runs in release builds"Duncan P. N. Exon Smith2015-09-151-6/+2
| | | | | | | This temporarily reverts commit r247729, as it caused lld build failures. I'll recommit once I have an lld patch ready-to-go. llvm-svn: 247730
* LTO: Disable extra verify runs in release buildsDuncan P. N. Exon Smith2015-09-151-2/+6
| | | | | | | | | | | | | | | | | | | | | | The verifier currently runs three times in LTO: (1) after parsing, (2) at the beginning of the optimization pipeline, and (3) at the end of it. The first run is important, since we're not sure where the bitcode comes from and it's nice to validate it, but in release builds the extra runs aren't appropriate. This commit: - Allows these runs to be disabled in LTOCodeGenerator. - Adds command-line options to llvm-lto. - Adds command-line options to libLTO.dylib, and disables the verifier by default in release builds (based on NDEBUG). This shaves about 3.5% off the runtime of ld64 when linking verify-uselistorder with -flto -g. rdar://22509081 llvm-svn: 247729
* Add a non-exiting diagnostic handler for LTO.Yunzhong Gao2015-09-111-1/+4
| | | | | | | This is in order to give LTO clients a chance to do some clean-up before terminating the process. llvm-svn: 247461
* CodeGen: Introduce splitCodeGen and teach LTOCodeGenerator to use it.Peter Collingbourne2015-08-271-11/+33
| | | | | | | | | | | | | | | llvm::splitCodeGen is a function that implements the core of parallel LTO code generation. It uses llvm::SplitModule to split the module into linkable partitions and spawning one code generation thread per partition. The function produces multiple object files which can be linked in the usual way. This has been threaded through to LTOCodeGenerator (and llvm-lto for testing purposes). Separate patches will add parallel LTO support to the gold plugin and lld. Differential Revision: http://reviews.llvm.org/D12260 llvm-svn: 246236
* LTO: Simplify merged module ownership.Peter Collingbourne2015-08-241-1/+1
| | | | | | | | | | | This change moves LTOCodeGenerator's ownership of the merged module to a field of type std::unique_ptr<Module>. This helps simplify parts of the code and clears the way for the module to be consumed by LLVM CodeGen (see D12132 review comments). Differential Revision: http://reviews.llvm.org/D12205 llvm-svn: 245891
* LTO: Change signature of LTOCodeGenerator::setCodePICModel() to take a ↵Peter Collingbourne2015-08-211-13/+1
| | | | | | | | | Reloc::Model. This allows us to remove a bunch of code in LTOCodeGenerator and llvm-lto and has the side effect of improving error handling in the libLTO C API. llvm-svn: 245756
* llvm-lto: Re-order code.Peter Collingbourne2015-08-211-12/+10
| | | | | | | This saves us from needing to asave a pointer, and will be needed for an upcoming ownership change. llvm-svn: 245722
* Make the C++ LTO API easier to use from C++ clients.Peter Collingbourne2015-06-011-5/+3
| | | | | | | | | | | Start using C++ types such as StringRef and MemoryBuffer in the C++ LTO API. In doing so, clarify the ownership of the native object file: the caller now owns it, not the LTOCodeGenerator. The C libLTO library has been modified to use a derived class of LTOCodeGenerator that owns the object file. Differential Revision: http://reviews.llvm.org/D10114 llvm-svn: 238776
* libLTO, llvm-lto, gold: Introduce flag for controlling optimization level.Peter Collingbourne2015-03-191-5/+16
| | | | | | | | | | This change also introduces a link-time optimization level of 1. This optimization level runs only the globaldce pass as well as cleanup passes for passes that run at -O0, specifically simplifycfg which cleans up lowerbitsets. http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150316/266951.html llvm-svn: 232769
* Make helper functions static.Benjamin Kramer2015-03-091-4/+4
| | | | | | Found by -Wmissing-prototypes. NFC. llvm-svn: 231664
* [LTO API] add lto_codegen_set_module to set the destination module.Manman Ren2015-02-241-4/+15
| | | | | | | | | | | | | | | | | | When debugging LTO issues with ld64, we use -save-temps to save the merged optimized bitcode file, then invoke ld64 again on the single bitcode file to speed up debugging code generation passes and ld64 stuff after code generation. llvm linking a single bitcode file via lto_codegen_add_module will generate a different bitcode file from the single input. With the newly-added lto_codegen_set_module, we can make sure the destination module is the same as the input. lto_codegen_set_module will transfer the ownship of the module to code generator. rdar://19024554 llvm-svn: 230290
* [llvm-lto] Add a line for setting LTOCodeGenerator's CPU string from commandAkira Hatanaka2015-01-301-0/+3
| | | | | | | | line. This is needed for a test case I plan to commit later. llvm-svn: 227532
* llvm-lto: Add testing coverage for local contextsDuncan P. N. Exon Smith2014-12-171-0/+47
| | | | | | | | | | | Add coverage in `llvm-lto` for the API exposed by libLTO to create modules in local contexts. The goal here isn't to test the symbol-related API extensively, just to confirm that these modules work at all. (I'll be shifting code around soon that should be NFC and I realized there was no test coverage.) llvm-svn: 224408
* Add an option to the LTO code generator to disable vectorization during LTOArnold Schwaighofer2014-10-261-3/+9
| | | | | | | | | | | | | | | | | | | | We used to always vectorize (slp and loop vectorize) in the LTO pass pipeline. r220345 changed it so that we used the PassManager's fields 'LoopVectorize' and 'SLPVectorize' out of the desire to be able to disable vectorization using the cl::opt flags 'vectorize-loops'/'slp-vectorize' which the before mentioned fields default to. Unfortunately, this turns off vectorization because those fields default to false. This commit adds flags to the LTO library to disable lto vectorization which reconciles the desire to optionally disable vectorization during LTO and the desired behavior of defaulting to enabled vectorization. We really want tools to set PassManager flags directly to enable/disable vectorization and not go the route via cl::opt flags *in* PassManagerBuilder.cpp. llvm-svn: 220652
* Update the error handling of lib/Linker.Rafael Espindola2014-10-251-5/+1
| | | | | | Instead of passing a std::string&, use the new diagnostic infrastructure. llvm-svn: 220608
* LTO: Ignore disabled diagnostic remarksDuncan P. N. Exon Smith2014-10-011-0/+26
| | | | | | | | | | | | | | | | | | | | | | | r206400 and r209442 added remarks that are disabled by default. However, if a diagnostic handler is registered, the remarks are sent unfiltered to the handler. This is the right behaviour for clang, since it has its own filters. However, the diagnostic handler exposed in the LTO API receives only the severity and message. It doesn't have the information to filter by pass name. For LTO, disabled remarks should be filtered by the producer. I've changed `LLVMContext::setDiagnosticHandler()` to take a `bool` argument indicating whether to respect the built-in filters. This defaults to `false`, so other consumers don't have a behaviour change, but `LTOCodeGenerator::setDiagnosticHandler()` sets it to `true`. To make this behaviour testable, I added a `-use-diagnostic-handler` command-line option to `llvm-lto`. This fixes PR21108. llvm-svn: 218784
* Modernize raw_fd_ostream's constructor a bit.Rafael Espindola2014-08-251-4/+4
| | | | | | | | | | Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393
* LTO: rename the various makeLTOModule overloads.Peter Collingbourne2014-07-031-1/+1
| | | | | | | | | This rename makes it easier to identify the specific overload being called in each particular case and makes future refactorings easier. Differential Revision: http://reviews.llvm.org/D4370 llvm-svn: 212302
* raw_ostream: Forward declare OpenFlags and include FileSystem.h only where ↵Benjamin Kramer2014-04-291-0/+1
| | | | | | necessary. llvm-svn: 207593
* Add an -mattr option to the gold plugin to support subtarget features in LTOTom Roeder2014-04-251-0/+10
| | | | | | | | | | This adds support for an -mattr option to the gold plugin and to llvm-lto. This allows the caller to specify details of the subtarget architecture, like +aes, or +ssse3 on x86. Note that this requires a change to the include/llvm-c/lto.h interface: it adds a function lto_codegen_set_attr and it increments the version of the interface. llvm-svn: 207279
OpenPOWER on IntegriCloud