summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
Commit message (Collapse)AuthorAgeFilesLines
* [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
* LoopInfo: Simplify ownership of Loop objectsJustin Bogner2016-01-081-2/+2
| | | | | | | | | | | It's strange that LoopInfo mostly owns the Loop objects, but that it defers deleting them to the loop pass manager. Instead, change the oddly named "updateUnloop" to "markAsRemoved" and have it queue the Loop object for deletion. We can't delete the Loop immediately when we remove it, since we need its pointer identity still, so we'll mark the object as "invalid" so that clients can see what's going on. llvm-svn: 257191
* [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
* [attrs] Split the late-revisit pattern for deducing norecurse inChandler Carruth2016-01-083-64/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a top-down manner into a true top-down or RPO pass over the call graph. There are specific patterns of function attributes, notably the norecurse attribute, which are most effectively propagated top-down because all they us caller information. Walk in RPO over the call graph SCCs takes the form of a module pass run immediately after the CGSCC pass managers postorder walk of the SCCs, trying again to deduce norerucrse for each singular SCC in the call graph. This removes a very legacy pass manager specific trick of using a lazy revisit list traversed during finalization of the CGSCC pass. There is no analogous finalization step in the new pass manager, and a lazy revisit list is just trying to produce an RPO iteration of the call graph. We can do that more directly if more expensively. It seems unlikely that this will be the expensive part of any compilation though as we never examine the function bodies here. Even in an LTO run over a very large module, this should be a reasonable fast set of operations over a reasonably small working set -- the function call graph itself. In the future, if this really is a compile time performance issue, we can look at building support for both post order and RPO traversals directly into a pass manager that builds and maintains the PO list of SCCs. Differential Revision: http://reviews.llvm.org/D15785 llvm-svn: 257163
* Fix option desc in FunctionAttrs; NFCWeiming Zhao2016-01-061-1/+1
| | | | | | | | | | Summary: The example in desc should match with actual option name Reviewers: jmolloy Differential Revision: http://reviews.llvm.org/D15800 llvm-svn: 256951
* [BasicAA] Remove special casing of memset_pattern16 in favor of generic ↵Philip Reames2016-01-061-0/+24
| | | | | | | | | | | | attribute inference Most of the properties of memset_pattern16 can be now covered by the generic attributes and inferred by InferFunctionAttrs. The only exceptions are: - We don't yet have a writeonly attribute for the first argument. - We don't have an attribute for modeling the access size facts encoded in MemoryLocation.cpp. Differential Revision: http://reviews.llvm.org/D15879 llvm-svn: 256911
* [MemoryBuiltins] Remove isOperatorNewLike by consolidating non-null ↵Philip Reames2016-01-041-1/+28
| | | | | | | | | | | | inference handling This patch removes the isOperatorNewLike predicate since it was only being used to establish a non-null return value and we have attributes specifically for that purpose with generic handling. To keep approximate the same behaviour for existing frontends, I added the various operator new like (i.e. instances of operator new) to InferFunctionAttrs. It's not really clear to me why this isn't handled in Clang, but I didn't want to break existing code and any subtle assumptions it might have. Once this patch is in, I'm going to start separating the isAllocLike family of predicates. These appear to be being used for a mixture of things which should be more clearly separated and documented. Today, they're being used to indicate (at least) aliasing facts, CSE-ability, and default values from an allocation site. Differential Revision: http://reviews.llvm.org/D15820 llvm-svn: 256787
* Refactor inline costs analysis by removing the InlineCostAnalysis classEaswaran Raman2015-12-283-34/+24
| | | | | | | | | | InlineCostAnalysis is an analysis pass without any need for it to be one. Once it stops being an analysis pass, it doesn't maintain any useful state and the member functions inside can be made free functions. NFC. Differential Revision: http://reviews.llvm.org/D15701 llvm-svn: 256521
* [attrs] Extract the pure inference of function attributes intoChandler Carruth2015-12-275-860/+954
| | | | | | | | | | | | | | | | | | | | | | | | | a standalone pass. There is no call graph or even interesting analysis for this part of function attributes -- it is literally inferring attributes based on the target library identification. As such, we can do it using a much simpler module pass that just walks the declarations. This can also happen much earlier in the pass pipeline which has benefits for any number of other passes. In the process, I've cleaned up one particular aspect of the logic which was necessary in order to separate the two passes cleanly. It now counts inferred attributes independently rather than just counting all the inferred attributes as one, and the counts are more clearly explained. The two test cases we had for this code path are both ... woefully inadequate and copies of each other. I've kept the superset test and updated it. We need more testing here, but I had to pick somewhere to stop fixing everything broken I saw here. Differential Revision: http://reviews.llvm.org/D15676 llvm-svn: 256466
* [attrs] Split off the forced attributes utility into its own pass thatChandler Carruth2015-12-275-66/+130
| | | | | | | | | | | | | | | is (by default) run much earlier than FuncitonAttrs proper. This allows forcing optnone or other widely impactful attributes. It is also a bit simpler as the force attribute behavior needs no specific iteration order. I've added the pass into the default module pass pipeline and LTO pass pipeline which mirrors where function attrs itself was being run. Differential Revision: http://reviews.llvm.org/D15668 llvm-svn: 256465
* [FunctionImport] Move pass into anonymous namespace.Benjamin Kramer2015-12-241-0/+2
| | | | | | No functional change. llvm-svn: 256374
* [OperandBundles] Have DeadArgElim play nice with operand bundlesDavid Majnemer2015-12-231-0/+4
| | | | | | | A call site's use of a Value might not correspond to an argument operand but to a bundle operand. llvm-svn: 256326
* Provide a way to specify inliner's attribute compatibility and merging.Akira Hatanaka2015-12-221-34/+1
| | | | | | | | | | | | | | | | | | | | | This reapplies r256277 with two changes: - In emitFnAttrCompatCheck, change FuncName's type to std::string to fix a use-after-free bug. - Remove an unnecessary install-local target in lib/IR/Makefile. Original commit message for r252949: Provide a way to specify inliner's attribute compatibility and merging rules using table-gen. NFC. This commit adds new classes CompatRule and MergeRule to Attributes.td, which are used to generate code to check attribute compatibility and merge attributes of the caller and callee. rdar://problem/19836465 llvm-svn: 256304
* Also add unnamed_addr to functions.Rafael Espindola2015-12-221-13/+24
| | | | llvm-svn: 256281
* Revert r256277 and r256279.Akira Hatanaka2015-12-221-1/+34
| | | | | | Some of the bots failed again. llvm-svn: 256280
* Provide a way to specify inliner's attribute compatibility and merging.Akira Hatanaka2015-12-221-34/+1
| | | | | | | | | | | | | | | | | | This reapplies r252990 and r252949. I've added member function getKind to the Attr classes which returns the enum or string of the attribute. Original commit message for r252949: Provide a way to specify inliner's attribute compatibility and merging rules using table-gen. NFC. This commit adds new classes CompatRule and MergeRule to Attributes.td, which are used to generate code to check attribute compatibility and merge attributes of the caller and callee. rdar://problem/19836465 llvm-svn: 256277
* Delete dead GlobalAliases.Rafael Espindola2015-12-221-1/+8
| | | | llvm-svn: 256276
* Merge duplicated code.Rafael Espindola2015-12-221-21/+28
| | | | | | | | | The code for deleting dead global variables and functions was duplicated. This is in preparation for also deleting dead global aliases. llvm-svn: 256274
* Use early continue to reduce indentation.Rafael Espindola2015-12-221-19/+21
| | | | llvm-svn: 256272
* Simplify iterator management. NFC.Rafael Espindola2015-12-221-45/+27
| | | | | | | Not passing an iterator to processGlobal will allow it to work with other GlobalValues. llvm-svn: 256271
* Determine callee's hotness and adjust threshold based on that. NFC.Easwaran Raman2015-12-221-7/+31
| | | | | | | | | | This uses the same criteria used in CFE's CodeGenPGO to identify hot and cold callees and uses values of inlinehint-threshold and inlinecold-threshold respectively as the thresholds for such callees. Differential Revision: http://reviews.llvm.org/D15245 llvm-svn: 256222
* [cfi] Fix LowerBitSets on 32-bit targets.Evgeniy Stepanov2015-12-211-1/+1
| | | | | | | This code attempts to truncate IntPtrTy to i32, which may be the same type. llvm-svn: 256205
* Re-reapply "[IR] Move optional data in llvm::Function into a hungoff uselist"Vedant Kumar2015-12-191-8/+2
| | | | | | | | | | | | | | | | | Make personality functions, prefix data, and prologue data hungoff operands of Function. This is based on the email thread "[RFC] Clean up the way we store optional Function data" on llvm-dev. Thanks to sanjoyd, majnemer, rnk, loladiro, and dexonsmith for feedback! Includes a fix to scrub value subclass data in dropAllReferences. Does not use binary literals. Differential Revision: http://reviews.llvm.org/D13829 llvm-svn: 256095
* Revert "Reapply "[IR] Move optional data in llvm::Function into a hungoff ↵Vedant Kumar2015-12-191-2/+8
| | | | | | | | | | uselist"" This reverts commit r256093. This broke lld-x86_64-win7 because of -Werror,-Wc++1y-extensions. llvm-svn: 256094
* Reapply "[IR] Move optional data in llvm::Function into a hungoff uselist"Vedant Kumar2015-12-191-8/+2
| | | | | | | | | | | | | | | | Make personality functions, prefix data, and prologue data hungoff operands of Function. This is based on the email thread "[RFC] Clean up the way we store optional Function data" on llvm-dev. Thanks to sanjoyd, majnemer, rnk, loladiro, and dexonsmith for feedback! Includes a fix to scrub value subclass data in dropAllReferences. Differential Revision: http://reviews.llvm.org/D13829 llvm-svn: 256093
* Revert "[IR] Move optional data in llvm::Function into a hungoff uselist"Vedant Kumar2015-12-191-2/+8
| | | | | | | | This reverts commit r256090. This broke llvm-clang-lld-x86_64-debian-fast. llvm-svn: 256091
* [IR] Move optional data in llvm::Function into a hungoff uselistVedant Kumar2015-12-191-8/+2
| | | | | | | | | | | | | | Make personality functions, prefix data, and prologue data hungoff operands of Function. This is based on the email thread "[RFC] Clean up the way we store optional Function data" on llvm-dev. Thanks to sanjoyd, majnemer, rnk, loladiro, and dexonsmith for feedback! Differential Revision: http://reviews.llvm.org/D13829 llvm-svn: 256090
* [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
* LPM: Make callers of LPM.deleteLoopFromQueue update LoopInfo directly. NFCJustin Bogner2015-12-161-3/+5
| | | | | | | | | | | As of r255720, the loop pass manager will DTRT when passes update the loop info for removed loops, so they no longer need to reach into LPPassManager APIs to do this kind of transformation. This change very nearly removes the need for the LPPassManager to even be passed into loop passes - the only remaining pass that uses the LPM argument is LoopUnswitch. llvm-svn: 255797
* Remove one of the void casts used to suppress unused variable warning.Richard Trieu2015-12-151-1/+0
| | | | llvm-svn: 255709
* Suppress unused variable warning in the no-asserts build.Evgeniy Stepanov2015-12-151-0/+1
| | | | llvm-svn: 255706
* Cast variable to void to resolve unused variable warning in non-asserts builds.Richard Trieu2015-12-151-0/+1
| | | | llvm-svn: 255704
* Cross-DSO control flow integrity (LLVM part).Evgeniy Stepanov2015-12-154-0/+171
| | | | | | | | An LTO pass that generates a __cfi_check() function that validates a call based on a hash of the call-site-known type and the target pointer. llvm-svn: 255693
* [PassManagerBuilder] Add a few more scalar optimization passesJames Molloy2015-12-151-0/+13
| | | | | | | | | | | | | | | | | | | | This patch does two things: 1. mem2reg is now run immediately after globalopt. Now that globalopt can localize variables more aggressively, it makes sense to lower them to SSA form earlier rather than later so they can benefit from the full set of optimization passes. 2. More scalar optimizations are run after the loop optimizations in LTO mode. The loop optimizations (especially indvars) can clean up scalar code sufficiently to make it worthwhile running more scalar passes. I've particularly added SCCP here as it isn't run anywhere else in the LTO pass pipeline. Mem2reg is super cheap and shouldn't affect compilation time at all. The rest of the added passes are in the LTO pipeline only so doesn't affect the vast majority of compilations, just the link step. llvm-svn: 255634
* 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
* [MergeFunctions] Use II instead of CI for InvokeInst; NFCSanjoy Das2015-12-141-5/+5
| | | | | | Using `CI` is slightly misleading. llvm-svn: 255529
* Teach MergeFunctions about operand bundlesSanjoy Das2015-12-141-0/+31
| | | | llvm-svn: 255528
* SamplePGO - Reduce memory utilization by 10x.Diego Novillo2015-12-111-1/+1
| | | | | | | | | | | | | | | DenseMap is the wrong data structure to use for sample records and call sites. The keys are too large, causing massive core memory growth when reading profiles. Before this patch, a 21Mb input profile was causing the compiler to grow to 3Gb in memory. By switching to std::map, the compiler now grows to 300Mb in memory. There still are some opportunities for memory footprint reduction. I'll be looking at those next. llvm-svn: 255389
* PruneEH pass incorrectly reports that a change was madeArtur Pilipenko2015-12-111-12/+7
| | | | | | | | Reviewed By: reames Differential Revision: http://reviews.llvm.org/D14097 llvm-svn: 255343
* [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
* Add arg_begin() and arg_end() to CallInst and InvokeInst; NFCISanjoy Das2015-12-101-2/+1
| | | | | | | | | | - This simplifies the CallSite class, arg_begin / arg_end are now simple wrapper getters. - In several places, we were creating CallSite instances solely to call arg_begin and arg_end. With this change, that's no longer required. llvm-svn: 255226
* 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
* [OperandBundles] Have PruneEH work correct with operand bundles.Sanjoy Das2015-12-081-2/+7
| | | | | | | | For an invoke with operand bundles, the [op_begin(), op_end()-3] range can contain things other than invoke arguments. This change teaches PruneEH to use arg_begin() and arg_end() explicitly. llvm-svn: 255073
* Fix/Improve Debug print in FunctionImport passMehdi Amini2015-12-081-9/+12
| | | | | From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 255071
OpenPOWER on IntegriCloud