summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
Commit message (Collapse)AuthorAgeFilesLines
...
* IRMover: Merge flags LinkModuleInlineAsm and IsPerformingImport.Peter Collingbourne2017-02-031-1/+1
| | | | | | | | | 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
* FunctionImport: Use IRMover directly.Peter Collingbourne2017-02-031-7/+12
| | | | | | | | | | | | The importer was previously using ModuleLinker in a sort of "IRMover mode". Use IRMover directly instead in order to remove a level of indirection. I will remove all importing support from ModuleLinker in a separate change. Differential Revision: https://reviews.llvm.org/D29468 llvm-svn: 294014
* Revert "[ThinLTO] Add an auto-hide feature"Mehdi Amini2017-02-031-7/+0
| | | | | | | | | 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-0/+7
| | | | | | | | | | | | | | | 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-7/+0
| | | | | | This reverts commit r293918, one lld test does not pass. llvm-svn: 293961
* FunctionImport: Remove the -disable-force-link-odr flag and change ↵Peter Collingbourne2017-02-021-13/+3
| | | | | | | | | | importFunctions to never force link. This removes some functionality that was only being used by tests. Differential Revision: https://reviews.llvm.org/D29439 llvm-svn: 293919
* [ThinLTO] Add an auto-hide featureMehdi Amini2017-02-021-0/+7
| | | | | | | | | | | | | | 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-7/+0
| | | | | | This reverts r293912, bots are broken. llvm-svn: 293914
* [ThinLTO] Add an auto-hide featureMehdi Amini2017-02-021-0/+7
| | | | | | | | | | | | 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
* Explicitly promote indirect calls before sample profile annotation.Dehao Chen2017-01-311-5/+24
| | | | | | | | | | | | | | Summary: In iterative sample pgo where profile is collected from PGOed binary, we may see indirect call targets promoted and inlined in the profile. Before profile annotation, we need to make this happen in order to annotate correctly on IR. This patch explicitly promotes these indirect calls and inlines them before profile annotation. Reviewers: xur, davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29040 llvm-svn: 293657
* Revert r292979 which causes compile time failure.Dehao Chen2017-01-301-19/+5
| | | | llvm-svn: 293557
* [Inliner] Fold analysis remarks into missed remarksAdam Nemet2017-01-301-15/+12
| | | | | | This significantly reduces the noise level of these messages. llvm-svn: 293492
* [Inliner] Fix a comment to match the code. NFC.Haicheng Wu2017-01-301-2/+2
| | | | | | | | TotalAltCost => TotalSecondaryCost Differential Revision: https://reviews.llvm.org/D29231 llvm-svn: 293490
* [ArgPromote] Move static helpers to modern LLVM naming conventions whileChandler Carruth2017-01-291-15/+15
| | | | | | | | | | here. NFC. Simple refactoring while prepping a port to the new PM. Differential Revision: https://reviews.llvm.org/D29249 llvm-svn: 293426
* [ArgPromote] Run clang-format to normalize remarkably idiosyncraticChandler Carruth2017-01-291-112/+121
| | | | | | | | | | formatting that has evolved here over the past years prior to making somewhat invasive changes to thread new PM support through the business logic. Differential Revision: https://reviews.llvm.org/D29248 llvm-svn: 293425
* [ArgPromote] Re-arrange the code in a more typical, logical way.Chandler Carruth2017-01-291-561/+547
| | | | | | | | | | | | | | | | | | | | This arranges the static helpers in an order where they are defined prior to their use to avoid the need of forward declarations, and collect the core pass components at the bottom below their helpers. This also folds one trivial function into the pass itself. Factoring this 'runImpl' was an attempt to help porting to the new pass manager, however in my attempt to begin this port in earnest it turned out to not be a substantial help. I think it will be easier to factor things without it. This is an NFC change and does a minimal amount of edits over all. Subsequent NFC cleanups will normalize the formatting with clang-format and improve the basic doxygen commenting. Differential Revision: https://reviews.llvm.org/D29247 llvm-svn: 293424
* [PM] MLSM has been enabled for a way. Reclaim a cl::opt.Davide Italiano2017-01-281-8/+2
| | | | llvm-svn: 293401
* Use print() instead of dump() in codeMatthias Braun2017-01-281-5/+2
| | | | llvm-svn: 293371
* Global DCE performance improvementMehdi Amini2017-01-271-60/+83
| | | | | | | | | | | | | | | | | | | Change the original algorithm so that it scales better when meeting very large bitcode where every instruction does not implies a global. The target query is "how to you get all the globals referenced by another global"? Before this patch, it was doing this by walking the body (or the initializer) and collecting the references. What this patch is doing, it precomputing the answer to this query for the whole module by walking the use-list of every global instead. Patch by: Serge Guelton <serge.guelton@telecom-bretagne.eu> Differential Revision: https://reviews.llvm.org/D28549 llvm-svn: 293328
* LowerTypeTests: Ignore external globals with type metadata.Peter Collingbourne2017-01-261-3/+6
| | | | | | Thanks to Davide Italiano for finding the problem and providing a test case. llvm-svn: 293119
* Add loop pass insertion point EP_LateLoopOptimizationsKrzysztof Parzyszek2017-01-251-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D28694 llvm-svn: 293067
* Explicitly promote indirect calls before sample profile annotation.Dehao Chen2017-01-241-5/+19
| | | | | | | | | | | | | | Summary: In iterative sample pgo where profile is collected from PGOed binary, we may see indirect call targets promoted and inlined in the profile. Before profile annotation, we need to make this happen in order to annotate correctly on IR. This patch explicitly promotes these indirect calls and inlines them before profile annotation. Reviewers: xur, davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29040 llvm-svn: 292979
* [PH] Replace uses of AssertingVH from members of analysis results withChandler Carruth2017-01-243-30/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a lazy-asserting PoisoningVH. AssertVH is fundamentally incompatible with cache-invalidation of analysis results. The invaliadtion happens after the AssertingVH has already fired. Instead, use a PoisoningVH that will assert if the dangling handle is ever used rather than merely be assigned or destroyed. This patch also removes all of the (numerous) doomed attempts to work around this fundamental incompatibility. It is a pretty significant simplification IMO. The most interesting change is in the Inliner where we still do some clearing because we don't want to rely on the coarse grained invalidation strategy of the containing pass manager. However, I prefer the approach that contains this logic to the cleanup phase of the Inliner, and I think we could enhance the CGSCC analysis management layer to make this even better in the future if desired. The rest is straight cleanup. I've also added a test for one of the harder cases to work around: when a *module analysis* contains many AssertingVHes pointing at functions. Differential Revision: https://reviews.llvm.org/D29006 llvm-svn: 292928
* [Analysis] Add LibFunc_ prefix to enums in TargetLibraryInfo. (NFC)David L. Jones2017-01-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The LibFunc::Func enum holds enumerators named for libc functions. Unfortunately, there are real situations, including libc implementations, where function names are actually macros (musl uses "#define fopen64 fopen", for example; any other transitively visible macro would have similar effects). Strictly speaking, a conforming C++ Standard Library should provide any such macros as functions instead (via <cstdio>). However, there are some "library" functions which are not part of the standard, and thus not subject to this rule (fopen64, for example). So, in order to be both portable and consistent, the enum should not use the bare function names. The old enum naming used a namespace LibFunc and an enum Func, with bare enumerators. This patch changes LibFunc to be an enum with enumerators prefixed with "LibFFunc_". (Unfortunately, a scoped enum is not sufficient to override macros.) There are additional changes required in clang. Reviewers: rsmith Subscribers: mehdi_amini, mzolotukhin, nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D28476 llvm-svn: 292848
* Revert "Refactor SampleProfile.cpp to move computation inside a branch. (NFC)"Evgeniy Stepanov2017-01-231-2/+2
| | | | | | Causes MSan failures on the buildbot. llvm-svn: 292840
* Refactor SampleProfile.cpp to move computation inside a branch. (NFC)Dehao Chen2017-01-231-2/+2
| | | | llvm-svn: 292803
* [PM] Replace the hard invalidate in JumpThreading for LVI with correctChandler Carruth2017-01-231-2/+25
| | | | | | | | | | | | | | | | | | | | | invalidation of deleted functions in GlobalDCE. This was always testing a bug really triggered in GlobalDCE. Right now we have analyses with asserting value handles into IR. As long as those remain, when *deleting* an IR unit, we cannot wait for the normal invalidation scheme to kick in even though it was designed to work correctly in the face of these kinds of deletions. Instead, the pass needs to directly handle invalidating the analysis results pointing at that IR unit. I've tought the Inliner about this and this patch teaches GlobalDCE. This will handle the asserting VH case in the existing test as well as other issues of the same fundamental variety. I've moved the test into the GlobalDCE directory and added a comment explaining what is going on. Note that we cannot simply require LVI here because LVI is too lazy. llvm-svn: 292773
* [PM] Clear any analyses for a dead function after inlining it and beforeChandler Carruth2017-01-231-2/+3
| | | | | | | | | | clearing its body. This is essential to avoid triggering asserting value handles in analyses on the function's body. I'm working on a test case for this behavior in LLVM, but Clang has a great one that managed to trigger this on all of the bots already. llvm-svn: 292770
* [PM] Fix a really nasty bug introduced when adding PGO support to theChandler Carruth2017-01-221-18/+25
| | | | | | | | | | | | | | | | | | | | | new PM's inliner. The bug happens when we refine an SCC after having computed a proxy for the FunctionAnalysisManager, and then proceed to compute fresh analyses for functions in the *new* SCC using the manager provided by the old SCC's proxy. *And* when we manage to mutate a function in this new SCC in a way that invalidates those analyses. This can be... challenging to reproduce. I've managed to contrive a set of functions that trigger this and added a test case, but it is a bit brittle. I've directly checked that the passes run in the expected ways to help avoid the test just becoming silently irrelevant. This gets the new PM back to passing the LLVM test suite after the PGO improvements landed. llvm-svn: 292757
* [PM] Add some debug logging to the new PM inliner to make it easier toChandler Carruth2017-01-221-0/+3
| | | | | | trace its behavior. llvm-svn: 292756
* MergeFunctions: Preserve debug info in thunks, under option ↵Anmol P. Paralkar2017-01-211-22/+248
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -mergefunc-preserve-debug-info Summary: Under option -mergefunc-preserve-debug-info we: - Do not create a new function for a thunk. - Retain the debug info for a thunk's parameters (and associated instructions for the debug info) from the entry block. Note: -debug will display the algorithm at work. - Create debug-info for the call (to the shared implementation) made by a thunk and its return value. - Erase the rest of the function, retaining the (minimally sized) entry block to create a thunk. - Preserve a thunk's call site to point to the thunk even when both occur within the same translation unit, to aid debugability. Note that this behaviour differs from the underlying -mergefunc implementation which modifies the thunk's call site to point to the shared implementation when both occur within the same translation unit. Reviewers: echristo, eeckstein, dblaikie, aprantl, friss Reviewed By: aprantl Subscribers: davide, fhahn, jfb, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D28075 llvm-svn: 292702
* LowerTypeTests: Fix use-after-free. Found by asan/msan.Peter Collingbourne2017-01-211-2/+5
| | | | llvm-svn: 292700
* LowerTypeTests: Simplify; always create SizeM1 with type IntPtrTy, move ↵Peter Collingbourne2017-01-201-7/+2
| | | | | | initialization out of if statement. llvm-svn: 292674
* Add indirect call promotion to SamplePGODehao Chen2017-01-201-7/+49
| | | | | | | | | | | | | | Summary: This patch adds metadata for indirect call promotion in the sample profile loader. Reviewers: xur, davidxl, dnovillo Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28923 llvm-svn: 292672
* Improve PGO support for the new inlinerEaswaran Raman2017-01-202-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | This adds the following to the new PM based inliner in PGO mode: * Use block frequency analysis to derive callsite's profile count and use that to adjust thresholds of hot and cold callsites. * Incrementally update the BFI of the caller after a callee gets inlined into it. This incremental update is only within an invocation of the run method - BFI is not preserved across calls to run. Update the function entry count of the callee after inlining it into a caller. * I've tuned the thresholds for the hot and cold callsites using a hacked up version of the old inliner that explicitly computes BFI on a set of internal benchmarks and spec. Once the new PM based pipeline stabilizes (IIRC Chandler mentioned there are known issues) I'll benchmark this again and adjust the thresholds if required. Inliner PGO support. Differential revision: https://reviews.llvm.org/D28331 llvm-svn: 292666
* IPO, LTO: Plumb the summary from the LTO API into the pass manager.Peter Collingbourne2017-01-201-2/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D28840 llvm-svn: 292661
* [ThinLTO] Drop non-prevailing non-ODR weak to declarationsTeresa Johnson2017-01-201-8/+32
| | | | | | | | | | | | | | | 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
* LowerTypeTests: Implement importing of type identifiers.Peter Collingbourne2017-01-201-2/+84
| | | | | | | | | To import a type identifier we read the summary and create external references to the symbols defined when exporting. Differential Revision: https://reviews.llvm.org/D28546 llvm-svn: 292654
* LowerTypeTests: Compute SizeM1BitWidth in exportTypeId. NFCI.Peter Collingbourne2017-01-201-7/+6
| | | | | | This avoids needing to store it in a separate field in TypeIdLowering. llvm-svn: 292647
* clang-format SampleProfile.cpp (NFC)Dehao Chen2017-01-191-6/+4
| | | | llvm-svn: 292533
* LowerTypeTests: Implement exporting of type identifiers.Peter Collingbourne2017-01-191-31/+103
| | | | | | | | | | | | Type identifiers are exported by: - Adding coarse-grained information about how to test the type identifier to the summary. - Creating symbols in the object file (aliases and absolute symbols) containing fine-grained information about the type identifier. Differential Revision: https://reviews.llvm.org/D28424 llvm-svn: 292462
* ThinLTOBitcodeWriter: Clear comdats on filtered globals.Peter Collingbourne2017-01-181-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D28839 llvm-svn: 292431
* Apply clang-tidy's performance-unnecessary-value-param to LLVM.Benjamin Kramer2017-01-133-3/+3
| | | | | | | With some minor manual fixes for using function_ref instead of std::function. No functional change intended. llvm-svn: 291904
* [ThinLTO] Import static functions from the same module as callerTeresa Johnson2017-01-121-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We can sometimes end up with multiple copies of a local function that have the same GUID in the index. This happens when there are local functions with the same name that are in different source files with the same name (but in different directories), and they were compiled in their own directory so had the same path at compile time. In this case make sure we import the copy in the caller's module. While it isn't a correctness problem (the renamed reference which is based on the module IR hash will be unique since the module must have had an externally visible function that was imported), importing the wrong copy will result in lost performance opportunity since it won't be referenced and inlined. Reviewers: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28440 llvm-svn: 291841
* LowerTypeTests: Represent the memory region size with the constant size-1.Peter Collingbourne2017-01-111-15/+15
| | | | | | | | | This means that we can use a shorter instruction sequence in the case where the size is a power of two and on the boundary between two representations. Differential Revision: https://reviews.llvm.org/D28421 llvm-svn: 291706
* Re-apply r291205, "LowerTypeTests: Split the pass in two: a resolution phase ↵Peter Collingbourne2017-01-111-110/+155
| | | | | | and a lowering phase.", with a fix for an off-by-one error. llvm-svn: 291699
* Revert rL291205 because it breaks Chrome tests under CFI.Ivan Krasin2017-01-111-155/+110
| | | | | | | | | | | | | | | | | | | | | Summary: Revert LowerTypeTests: Split the pass in two: a resolution phase and a lowering phase. This change separates how type identifiers are resolved from how intrinsic calls are lowered. All information required to lower an intrinsic call is stored in a new TypeIdLowering data structure. The idea is that this data structure can either be initialized using the module itself during regular LTO, or using the module summary in ThinLTO backends. Original URL: https://reviews.llvm.org/D28341 Reviewers: pcc Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D28532 llvm-svn: 291684
* LowerTypeTests: Thread summary and action from the API and command line into ↵Peter Collingbourne2017-01-072-37/+75
| | | | | | | | | | | the pass. Also move command line handling out of the pass constructor and into a separate function. Differential Revision: https://reviews.llvm.org/D28422 llvm-svn: 291323
* LowerTypeTests: Split the pass in two: a resolution phase and a lowering phase.Peter Collingbourne2017-01-061-110/+155
| | | | | | | | | | | | This change separates how type identifiers are resolved from how intrinsic calls are lowered. All information required to lower an intrinsic call is stored in a new TypeIdLowering data structure. The idea is that this data structure can either be initialized using the module itself during regular LTO, or using the module summary in ThinLTO backends. Differential Revision: https://reviews.llvm.org/D28341 llvm-svn: 291205
* ThinLTO: add early "dead-stripping" on the IndexTeresa Johnson2017-01-051-5/+98
| | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud