summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/FunctionImport.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix Windows bot failure in Transforms/FunctionImport/funcimport.llTeresa Johnson2016-02-101-1/+1
| | | | | | | | | Make sure we split ":" from the end of the global function id (which is <path>:<function> for local functions) instead of the beginning to avoid splitting at the wrong place for Windows file paths that contain a ":". llvm-svn: 260469
* FunctionImport: add a progressive heuristic to limit importing too deep in ↵Mehdi Amini2016-02-101-26/+62
| | | | | | | | | | | | | | | | | | | | the callgraph The current function importer will walk the callgraph, importing transitively any callee that is below the threshold. This can lead to import very deep which is costly in compile time and not necessarily beneficial as most of the inline would happen in imported function and not necessarilly in user code. The actual factor has been carefully chosen by flipping a coin ;) Some tuning need to be done (just at the existing limiting threshold). Reviewers: tejohnson Differential Revision: http://reviews.llvm.org/D17082 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 260466
* Restore "[ThinLTO] Use MD5 hash in function index." with fixTeresa Johnson2016-02-101-8/+10
| | | | | | | | | | | This restores commit r260408, along with a fix for a bot failure. The bot failure was caused by dereferencing a unique_ptr in the same call instruction parameter list where it was passed via std::move. Apparently due to luck this was not exposed when I built the compiler with clang, only with gcc. llvm-svn: 260442
* Revert "[ThinLTO] Use MD5 hash in function index." due to bot failureTeresa Johnson2016-02-101-10/+8
| | | | | | This reverts commit r260408. Bot failure that I need to investigate. llvm-svn: 260412
* [ThinLTO] Use MD5 hash in function index.Teresa Johnson2016-02-101-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch uses the lower 64-bits of the MD5 hash of a function name as a GUID in the function index, instead of storing function names. Any local functions are first given a global name by prepending the original source file name. This is the same naming scheme and GUID used by PGO in the indexed profile format. This change has a couple of benefits. The primary benefit is size reduction in the combined index file, for example 483.xalancbmk's combined index file was reduced by around 70%. It should also result in memory savings for the index file in memory, as the in-memory map is also indexed by the hash instead of the string. Second, this enables integration with indirect call promotion, since the indirect call profile targets are recorded using the same global naming convention and hash. This will enable the function importer to easily locate function summaries for indirect call profile targets to enable their import and subsequent promotion. The original source file name is recorded in the bitcode in a new module-level record for use in the ThinLTO backend pipeline. Reviewers: davidxl, joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D17028 llvm-svn: 260408
* [ThinLTO] Move global processing from Linker to TransformUtils (NFC)Teresa Johnson2016-02-101-0/+1
| | | | | | | | | | | | | | | Summary: As discussed on IRC, move the ThinLTOGlobalProcessing code out of the linker, and into TransformUtils. The name of the class is changed to FunctionImportGlobalProcessing. Reviewers: joker.eph, rafael Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D17081 llvm-svn: 260395
* [ThinLTO] Do metadata linking during batch function importingTeresa Johnson2016-01-221-27/+7
| | | | | | | | | | | | | | | | | | | | Summary: Since we are currently not doing incremental importing there is no need to link metadata as a postpass. The module linker will only link in the imported subroutines due to the functionality added by r256003. (Note that the metadata postpass linking functionalitiy is still used by llvm-link, and may be needed here in the future if a more incremental strategy is adopted.) Reviewers: joker.eph Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16424 llvm-svn: 258458
* [ThinLTO] Handle an external call from an import to an alias in destTeresa Johnson2016-01-121-0/+2
| | | | | | | | | The findExternalCalls routine ignores calls to functions already defined in the dest module. This was not handling the case where the definition in the current module is actually an alias to a function call. llvm-svn: 257493
* [ThinLTO] Use new in-place symbol changes for exporting moduleTeresa Johnson2016-01-081-2/+7
| | | | | | | | | | | | | | Due to the new in-place ThinLTO symbol handling support added in r257174, we now invoke renameModuleForThinLTO on the current module from within the FunctionImport pass. Additionally, renameModuleForThinLTO no longer needs to return the Module as it is performing the renaming in place on the one provided. This commit will be immediately preceeded by a companion clang patch to remove its invocation of renameModuleForThinLTO. llvm-svn: 257181
* [ThinLTO] Delay metadata materializtion in function importerTeresa Johnson2016-01-081-4/+9
| | | | | | | | | | | | | | | The function importer was still materializing metadata when modules were loaded for function importing. We only want to materialize it when we are going to invoke the metadata linking postpass. Materializing it before function importing is not only unnecessary, but also causes metadata referenced by imported functions to be mapped in early, and then not connected to the rest of the module level metadata when it is ultimately linked in. Augmented the test case to specifically check for the metadata being properly connected, which it wasn't before this fix. llvm-svn: 257171
* [FunctionImport] Move pass into anonymous namespace.Benjamin Kramer2015-12-241-0/+2
| | | | | | No functional change. llvm-svn: 256374
* [ThinLTO] Metadata linking for imported functionsTeresa Johnson2015-12-171-1/+23
| | | | | | | | | | | | | | | | | | | | | | | Summary: Second patch split out from http://reviews.llvm.org/D14752. Maps metadata as a post-pass from each module when importing complete, suturing up final metadata to the temporary metadata left on the imported instructions. This entails saving the mapping from bitcode value id to temporary metadata in the importing pass, and from bitcode value id to final metadata during the metadata linking postpass. Depends on D14825. Reviewers: dexonsmith, joker.eph Subscribers: davidxl, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D14838 llvm-svn: 255909
* Change linkInModule to take a std::unique_ptr.Rafael Espindola2015-12-161-13/+22
| | | | | | | Passing in a std::unique_ptr should help find errors when the module is used after being linked into another module. llvm-svn: 255842
* A better attempt to add a missing includeRafael Espindola2015-12-141-1/+0
| | | | llvm-svn: 255578
* Trying to fix the build in a bot.Rafael Espindola2015-12-141-0/+1
| | | | llvm-svn: 255577
* Use diagnostic handler in the LLVMContextRafael Espindola2015-12-141-2/+2
| | | | | | | | | | | | | | | | This patch converts code that has access to a LLVMContext to not take a diagnostic handler. This has a few advantages * It is easier to use a consistent diagnostic handler in a single program. * Less clutter since we are not passing a handler around. It does make it a bit awkward to implement some C APIs that return a diagnostic string. I will propose new versions of these APIs and deprecate the current ones. llvm-svn: 255571
* [ThinLTO] Debug message cleanup (NFC)Teresa Johnson2015-12-101-8/+8
| | | | | | | | Added some missing spaces between the module identifier and the start of the debug message. Also added a ":" after the module identifier to make this look a little nicer. llvm-svn: 255259
* Don't assign a temporary string to a StringRef.Rafael Espindola2015-12-091-1/+1
| | | | | | Should fix the windows debug and asan bots. llvm-svn: 255149
* [ThinLTO] FunctionImport pass can take a const index pointer (NFC)Teresa Johnson2015-12-091-3/+3
| | | | llvm-svn: 255140
* The current importing scheme is processing one function at a time,Mehdi Amini2015-12-091-54/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | loading the source Module, linking the function in the destination module, and destroying the source Module before repeating with the next function to import (potentially from the same Module). Ideally we would keep the source Module alive and import the next Function needed from this Module. Unfortunately this is not possible because the linker does not leave it in a usable state. However we can do better by first computing the list of all candidates per Module, and only then load the source Module and import all the function we need for it. The trick to process callees is to materialize function in the source module when building the list of function to import, and inspect them in their source module, collecting the list of callees for each callee. When we move the the actual import, we will import from each source module exactly once. Each source module is loaded exactly once. The only drawback it that it requires to have all the lazy-loaded source Module in memory at the same time. Currently this patch already improves considerably the link time, a multithreaded link of llvm-dis on my laptop was: real 1m12.175s user 6m32.430s sys 0m10.529s and is now: real 0m40.697s user 2m10.237s sys 0m4.375s Note: this is the full link time (linker+Import+Optimizer+CodeGen) Differential Revision: http://reviews.llvm.org/D15178 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 255100
* Fix/Improve Debug print in FunctionImport passMehdi Amini2015-12-081-9/+12
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 255071
* Remove caching in FunctionImport: a Module can't be reused after being ↵Mehdi Amini2015-12-081-20/+13
| | | | | | | | | linked from The Linker destroys the source module (API change coming to make it explicit) From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 255064
* [ThinLTO] Support for specifying function index from pass managerTeresa Johnson2015-12-071-11/+28
| | | | | | | | | | | | | | | | Summary: Add a field on the PassManagerBuilder that clang or gold can use to pass down a pointer to the function index in memory to use for importing when the ThinLTO backend is triggered. Add support to supply this to the function import pass. Reviewers: joker.eph, dexonsmith Subscribers: davidxl, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D15024 llvm-svn: 254926
* clang-format FunctionImport after refactoring (NFC)Mehdi Amini2015-12-031-9/+10
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 254585
* Refactor FunctionImporter::importFunctions with a helper function to process ↵Mehdi Amini2015-12-031-29/+45
| | | | | | | | | the Worklist (NFC) This precludes some more functional changes to perform bulk imports. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 254583
* Change ModuleLinker to take a set of GlobalValues to import instead of a ↵Mehdi Amini2015-12-021-1/+5
| | | | | | | | | | | | single one For efficiency reason, when importing multiple functions for the same Module, we can avoid reparsing it every time. Differential Revision: http://reviews.llvm.org/D15102 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 254486
* Modify FunctionImport to take a callback to load modulesMehdi Amini2015-12-021-4/+7
| | | | | | | | | | | | When linking static archive, there is no individual module files to load. Instead they can be mmap'ed and could be initialized from a buffer directly. The callback provide flexibility to override the scheme for loading module from the summary. Differential Revision: http://reviews.llvm.org/D15101 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 254479
* Use references now that it is natural to do so.Rafael Espindola2015-12-011-2/+2
| | | | | | | The linker never takes ownership of a module or changes which module it is refering to, making it natural to use references. llvm-svn: 254449
* [ThinLTO] Wrap dbgs() output in DEBUG macroTeresa Johnson2015-12-011-5/+5
| | | | | | Missed in a couple places. llvm-svn: 254422
* [ThinLTO] Remove stale comment (NFC)Teresa Johnson2015-12-011-4/+0
| | | | | | Stale as of r254036 which added basic profitability check. llvm-svn: 254421
* [ThinLTO] Add option to limit importing based on instruction countTeresa Johnson2015-11-241-0/+12
| | | | | | | | Add a simple initial heuristic to control importing based on the number of instructions recorded in the function's summary. Add option to control the limit, and test using option. llvm-svn: 254036
* [ThinLTO] Refactor function body scan during importing into helper (NFC)Teresa Johnson2015-11-241-36/+27
| | | | llvm-svn: 254020
* [ThinLTO] Enable iterative importing in FunctionImport passTeresa Johnson2015-11-241-2/+36
| | | | | | | | | | | Analyze imported function bodies and add any new external calls to the worklist for importing. Currently no controls on the importing so this will end up importing everything possible in the call tree below the importing module. Basic profitability checks coming next. Update test to check for iteratively inlined functions. llvm-svn: 254011
* [ThinLTO] Fix FunctionImport alias checking and testTeresa Johnson2015-11-241-4/+5
| | | | | | | Skip imports for weak_any aliases as well. Fix the test to check non-import of weak aliases and functions, and import of normal alias. llvm-svn: 253991
* Add a FunctionImporter helper to perform summary-based cross-module function ↵Mehdi Amini2015-11-241-0/+239
importing Summary: This is a helper to perform cross-module import for ThinLTO. Right now it is importing naively every possible called functions. Reviewers: tejohnson Subscribers: dexonsmith, llvm-commits Differential Revision: http://reviews.llvm.org/D14914 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 253954
OpenPOWER on IntegriCloud