summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
Commit message (Collapse)AuthorAgeFilesLines
...
* Bitcode: Change getModuleSummaryIndex() to return an llvm::Expected.Peter Collingbourne2016-11-112-16/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D26539 llvm-svn: 286624
* Bitcode: Clean up error handling for certain bitcode query functions.Peter Collingbourne2016-11-113-15/+32
| | | | | | | | | | | | | The functions getBitcodeTargetTriple(), isBitcodeContainingObjCCategory(), getBitcodeProducerString() and hasGlobalValueSummary() now return errors via their return value rather than via the diagnostic handler. To make this work, re-implement these functions using non-member functions so that they can be used without the LLVMContext required by BitcodeReader. Differential Revision: https://reviews.llvm.org/D26532 llvm-svn: 286623
* Split Bitcode/ReaderWriter.h into separate reader and writer headersTeresa Johnson2016-11-115-5/+8
| | | | | | | | | | | | | | | | | | | | | Summary: Split ReaderWriter.h which contains the APIs into both the BitReader and BitWriter libraries into BitcodeReader.h and BitcodeWriter.h. This is to address Chandler's concern about sharing the same API header between multiple libraries (BitReader and BitWriter). That concern is why we create a single bitcode library in our downstream build of clang, which led to r286297 being reverted as it added a dependency that created a cycle only when there is a single bitcode library (not two as in upstream). Reviewers: mehdi_amini Subscribers: dlj, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D26502 llvm-svn: 286566
* Make the Error class constructor protectedMehdi Amini2016-11-112-20/+20
| | | | | | | | | This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 llvm-svn: 286561
* Bitcode: Change the materializer interface to return llvm::Error.Peter Collingbourne2016-11-093-3/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D26439 llvm-svn: 286382
* Don't store Twine in a local variable.Eli Friedman2016-11-081-2/+1
| | | | | | Fixes post-commit review comment from r286177. llvm-svn: 286275
* IR, Bitcode: Change bitcode reader to no longer own its memory buffer.Peter Collingbourne2016-11-083-9/+5
| | | | | | | | | | | | | | | | | | Unique ownership is just one possible ownership pattern for the memory buffer underlying the bitcode reader. In practice, as this patch shows, ownership can often reside at a higher level. With the upcoming change to allow multiple modules in a single bitcode file, it will no longer be appropriate for modules to generally have unique ownership of their memory buffer. The C API exposes the ownership relation via the LLVMGetBitcodeModuleInContext and LLVMGetBitcodeModuleInContext2 functions, so we still need some way for the module to own the memory buffer. This patch does so by adding an owned memory buffer field to Module, and using it in a few other places where it is convenient. Differential Revision: https://reviews.llvm.org/D26384 llvm-svn: 286214
* [LTO] Add error message on IO error in compileOptimizedToFile.Eli Friedman2016-11-071-0/+2
| | | | | | | | (No testcase because it's difficult to force an error here.) Differential Revision: https://reviews.llvm.org/D26371 llvm-svn: 286177
* [ThinLTO] Disable importing and other cross-module optis at -O0Teresa Johnson2016-10-311-27/+31
| | | | | | | | | | | | | | | | Summary: There is no point to importing at -O0, since we won't inline. We should also disable other cross-module optimizations. (Plan to backport this fix to the 3.9 branch to fix PR30774) Reviewers: pcc Subscribers: johanengelen, mehdi_amini Differential Revision: https://reviews.llvm.org/D25918 llvm-svn: 285648
* [ThinLTO] Correctly resolve linkonce when importing aliaseeTeresa Johnson2016-10-301-3/+8
| | | | | | | | | | | | | | | | | | | Summary: When we have an aliasee that is linkonce, while we can't convert the non-prevailing copies to available_externally, we still need to convert the prevailing copy to weak. If a reference to the aliasee is exported, not converting a copy to weak will result in undefined references when the linkonce is removed in its original module. Add a new test and update existing tests. Reviewers: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26076 llvm-svn: 285512
* Utility functions for appending to llvm.used/llvm.compiler.used.Evgeniy Stepanov2016-10-252-51/+21
| | | | llvm-svn: 285143
* fix warningRafael Espindola2016-10-251-0/+1
| | | | llvm-svn: 285064
* Make the LTO comdat api more symbol table friendly.Rafael Espindola2016-10-251-2/+29
| | | | | | | | | | | | | | | | | | | | | | In an IR symbol table I would expect the comdats to be represented as: - A table of strings, one for each comdat name. - Each symbol has an optional index into that table. The natural api for accessing that would be InputFile: ArrayRef<StringRef> getComdatTable() const; Symbol: int getComdatIndex() const; This patch implements an API as close to that as possible. The implementation on top of the current IRObjectFile is a bit hackish, but should map just fine over a symbol table and is very convenient to use. llvm-svn: 285061
* Remove TimeValue usage from llvm/SupportPavel Labath2016-10-241-2/+2
| | | | | | | | | | | | | | | | | Summary: This is a follow-up to D25416. It removes all usages of TimeValue from llvm/Support library (except for the actual TimeValue declaration), and replaces them with appropriate usages of std::chrono. To facilitate this, I have added small utility functions for converting time points and durations into appropriate OS-specific types (FILETIME, struct timespec, ...). Reviewers: zturner, mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25730 llvm-svn: 284966
* [ThinLTO] Default backend threads to heavyweight_hardware_concurrencyTeresa Johnson2016-10-192-3/+6
| | | | | | | | | | | | | | | | | Summary: Changes default backend parallelism from thread::hardware_concurrency to the new llvm::heavyweight_hardware_concurrency, which for X86 Linux defaults to the number of physical cores (and will fall back to thread::hardware_concurrency otherwise). This avoid oversubscribing the physical cores using hyperthreading. Reviewers: mehdi_amini, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25775 llvm-svn: 284618
* [cmake] Declare LLVM_CMAKE_PATH for use in subprojectsMichal Gorny2016-10-191-1/+1
| | | | | | | | | | | | | | | | | | | Declare the LLVM_CMAKE_PATH to the source directory location of CMake files, in order to make it possible to easily use them in subprojects. Such a variable is already declared in most of LLVM projects (and inconsistently mixed with direct source tree references), including Clang, LLDB, compiler-rt, libcxx... Declaring it inside main LLVM tree makes it possible to avoid having to declare fallback values or use conditionals in those projects. It should be noted that in some of the subprojects LLVM_CMAKE_PATH is used to reference generated LLVMConfig.cmake file. However, these references are conditional to stand-alone builds and explicitly including this file is unnecessary in combined builds. Differential Revision: https://reviews.llvm.org/D25724 llvm-svn: 284581
* Reduce global namespace pollution. NFC.Benjamin Kramer2016-10-181-1/+1
| | | | llvm-svn: 284521
* LTO: Use the correct mangler function in ↵Peter Collingbourne2016-10-121-2/+2
| | | | | | | | | | | | LTOCodeGenerator::applyScopeRestrictions(). We need to use the overload of Mangler::getNameWithPrefix that takes a GlobalValue in order to mangle in the stdcall stack byte count for Windows targets. Differential Revision: https://reviews.llvm.org/D25529 llvm-svn: 284040
* [ThinLTO] Don't link module level assembly when importingTeresa Johnson2016-10-121-1/+2
| | | | | | | | | | | | | | | | | | | | | Module inline asm was always being linked/concatenated when running the IRLinker. This is correct for full LTO but not when we are importing for ThinLTO, as it can result in multiply defined symbols when the module asm defines a global symbol. In order to test with llvm-lto2, I had to work around PR30396, where a symbol that is defined in module assembly but defined in the LLVM IR appears twice. Added workaround to llvm-lto2 with a FIXME. Fixes PR30610. Reviewers: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25359 llvm-svn: 284030
* ThinLTO: don't perform incremental LTO on module without a hashMehdi Amini2016-10-082-4/+13
| | | | | | | | | Clang always emit a hash for ThinLTO, but as other frontend are starting to use ThinLTO, this could be a serious bug. Differential Revision: https://reviews.llvm.org/D25379 llvm-svn: 283655
* ThinLTO: handles modules with empty summariesMehdi Amini2016-10-082-3/+9
| | | | | | | | | | | | | We need to add an entry in the combined-index for modules that have a hash but otherwise empty summary, this is needed so that we can get the hash for the module. Also, if no entry is present in the combined index for a module, we need to skip it when trying to compute a cache entry. Differential Revision: https://reviews.llvm.org/D25300 llvm-svn: 283654
* Recommit "Use StringRef in LTOModule implementation (NFC)""Mehdi Amini2016-10-072-26/+30
| | | | | | | | This reverts commit r283456 and reapply r282997, with explicitly zeroing the struct member to workaround a bug in MSVC2013 with zero-initialization: https://connect.microsoft.com/VisualStudio/feedback/details/802160 llvm-svn: 283581
* Revert "Use StringRef in LTOModule implementation (NFC)"Mehdi Amini2016-10-062-30/+26
| | | | | | | This reverts commit r282997, a windows bot is asserting in one test apparently. llvm-svn: 283456
* Use StringRef in LTOCodegenerator (NFC)Mehdi Amini2016-10-011-4/+4
| | | | llvm-svn: 282998
* Use StringRef in LTOModule implementation (NFC)Mehdi Amini2016-10-012-26/+30
| | | | llvm-svn: 282997
* Add explanatory comment.Peter Collingbourne2016-09-291-0/+4
| | | | llvm-svn: 282678
* LTO: Fix use-after-scope error.Peter Collingbourne2016-09-291-0/+1
| | | | llvm-svn: 282665
* Refactor the ProfileSummaryInfo to use doInitialization and doFinalization ↵Dehao Chen2016-09-281-1/+1
| | | | | | | | | | | | | | to handle Module update. Summary: This refactors the change in r282616 Reviewers: davidxl, eraman, mehdi_amini Subscribers: mehdi_amini, davide, llvm-commits Differential Revision: https://reviews.llvm.org/D25041 llvm-svn: 282630
* Fix the bug introduced in r282616.Dehao Chen2016-09-281-1/+1
| | | | llvm-svn: 282618
* [thinlto] Basic thinlto fdo heuristicPiotr Padlewski2016-09-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch improves thinlto importer by importing 3x larger functions that are called from hot block. I compared performance with the trunk on spec, and there were about 2% on povray and 3.33% on milc. These results seems to be consistant and match the results Teresa got with her simple heuristic. Some benchmarks got slower but I think they are just noisy (mcf, xalancbmki, omnetpp)- running the benchmarks again with more iterations to confirm. Geomean of all benchmarks including the noisy ones were about +0.02%. I see much better improvement on google branch with Easwaran patch for pgo callsite inlining (the inliner actually inline those big functions) Over all I see +0.5% improvement, and I get +8.65% on povray. So I guess we will see much bigger change when Easwaran patch will land (it depends on new pass manager), but it is still worth putting this to trunk before it. Implementation details changes: - Removed CallsiteCount. - ProfileCount got replaced by Hotness - hot-import-multiplier is set to 3.0 for now, didn't have time to tune it up, but I see that we get most of the interesting functions with 3, so there is no much performance difference with higher, and binary size doesn't grow as much as with 10.0. Reviewers: eraman, mehdi_amini, tejohnson Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D24638 llvm-svn: 282437
* Add qualification to fix MSVC build.Peter Collingbourne2016-09-231-1/+1
| | | | llvm-svn: 282313
* LTO: Simplify caching interface.Peter Collingbourne2016-09-233-115/+101
| | | | | | | | | | | | | | | | | The NativeObjectOutput class has a design problem: it mixes up the caching policy with the interface for output streams, which makes the client-side code hard to follow and would for example make it harder to replace the cache implementation in an arbitrary client. This change separates the two aspects by moving the caching policy to a separate field in Config, replacing NativeObjectOutput with a NativeObjectStream class which only deals with streams and does not need to be overridden by most clients and introducing an AddFile callback for adding files (e.g. from the cache) to the link. Differential Revision: https://reviews.llvm.org/D24622 llvm-svn: 282299
* [ThinLTO] Emit files for distributed builds for all modulesTeresa Johnson2016-09-211-20/+20
| | | | | | | | | | | | | | | | | | | | With the new LTO API in r278338, we stopped emitting the individual index files and imports files for some modules in the distributed backend case (thinlto-index-only plugin option). Specifically, this is when the linker decides not to include a module in the link, because it was in an archive library and did not have a strong reference to it. Not creating the expected output files makes the distributed build system implementation more difficult, in terms of checking for the expected outputs of the thin link, and scheduling the backend jobs. To address this, the gold-plugin will write dummy empty .thinlto.bc and .imports files for modules not included in the link (which LTO never sees). Augmented a gold v1.12+ test, since that version of gold has the handling for notifying on modules not being included in the link. llvm-svn: 282100
* [ThinLTO] Always emit a summary when compiling in ThinLTO modeTeresa Johnson2016-09-201-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Emit an empty summary section, instead of no summary section, when there are no global variables in the index. This ensures that LTO will treat these files as ThinLTO inputs, instead of as regular LTO inputs. In addition to not being what the user likely intended when compiling with -flto=thin, the current behavior is problematic for distributed build systems that expect to get ThinLTO index and imports files back for each input compiled with -flto=thin. Combining into a single regular LTO module also reduces the backend parallelism. And in the case where the index was suppressed due to uses in inline assembly, combining into a single LTO module could provoke renaming of duplicates that we were trying to prevent by suppressing the index. This change required a couple of fixes to handle the empty summary section. Reviewers: mehdi_amini Subscribers: mehdi_amini, llvm-commits, pcc Differential Revision: https://reviews.llvm.org/D24779 llvm-svn: 282037
* [lib/LTO] Try harder to reduce code duplication. NFCI.Davide Italiano2016-09-171-13/+14
| | | | llvm-svn: 281843
* [LTO] Add ability to parse AA pipelines.Davide Italiano2016-09-161-1/+10
| | | | | | | This is supposed to be a drop in replacement for what lld provides via --lto-newpm-aa-pipeline. llvm-svn: 281774
* [LTO] Prevent asm references to be dropped from the output.Davide Italiano2016-09-161-0/+18
| | | | | | Differential Revision: https://reviews.llvm.org/D24617 llvm-svn: 281741
* [LTO] Fix handling of mixed (regular and thin) mode LTOTeresa Johnson2016-09-161-6/+9
| | | | | | | | | | | | | | | | | | | | | Summary: In runThinLTO we start the task numbering for ThinLTO backend tasks depending on whether there was also a regular LTO object (CombinedModule). However, the CombinedModule is moved at the end of runRegularLTO, so we need to save this information and pass it into runThinLTO. Otherwise the AddOutput callback to the client will use the same task number for both the regular LTO object and the first ThinLTO object, which in gold-plugin caused only one to be end up in the output filename array and therefore passed back to gold for the final native link. Reviewers: pcc, mehdi_amini Subscribers: mehdi_amini, kromanova Differential Revision: https://reviews.llvm.org/D24643 llvm-svn: 281725
* Move the Mangler from the AsmPrinter down to TLOF and clean up theEric Christopher2016-09-161-4/+1
| | | | | | TLOF API accordingly. llvm-svn: 281708
* [LTO] Fix commons handlingMehdi Amini2016-09-141-3/+7
| | | | | | | | | | | | | | Previously the prevailing information was not honored, and commons symbols could override a strong definition. This patch fixes it and propose the following semantic for commons: the client should mark as prevailing the commons that it expects the LTO implementation to merge (i.e. take the maximum size and alignment). It implies that commons are allowed to have multiple prevailing definitions. Differential Revision: https://reviews.llvm.org/D24545 llvm-svn: 281538
* [lib/LTO] Fix a typo. NFC.Davide Italiano2016-09-141-1/+1
| | | | llvm-svn: 281517
* [LTO] Don't pass SF_Undefined symbols to the IRmover.Davide Italiano2016-09-131-0/+2
| | | | | | This should fix PR 30363. llvm-svn: 281366
* [lib/LTO] Add a way to run a custom pipelineDavide Italiano2016-09-072-1/+46
| | | | | | Differential Revision: https://reviews.llvm.org/D24095 llvm-svn: 280830
* [LTO] Rename variables to be more explicative.Davide Italiano2016-09-071-29/+30
| | | | | | Thanks to Mehdi for the suggestion! llvm-svn: 280772
* [LTO] Constify (NFC)Mehdi Amini2016-09-061-16/+20
| | | | llvm-svn: 280687
* [lib/LTO] Simplify. No functional change intended.Davide Italiano2016-09-021-11/+6
| | | | llvm-svn: 280503
* [lib/LTO] Simplify a bit. NFCI.Davide Italiano2016-09-011-4/+1
| | | | llvm-svn: 280396
* [lib/LTO] Factor out logic for running passes.Davide Italiano2016-08-311-4/+7
| | | | | | | | This is in preparation for adding an option to run a custom pipeline with the new PM. It's currently used in lld. llvm-svn: 280258
* [LTO] Remove extraneous outputTeresa Johnson2016-08-291-1/+0
| | | | | | Remove some debugging output to stderr that snuck in with r279576. llvm-svn: 279974
* [LTO] Don't create a new common unless merged has different sizeTeresa Johnson2016-08-271-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
OpenPOWER on IntegriCloud