summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Added support for the Builtin attribute.Michael Gottesman2013-06-271-1/+1
| | | | | | | | The Builtin attribute is an attribute that can be placed on function call site that signal that even though a function is declared as being a builtin, rdar://problem/13727199 llvm-svn: 185049
* Remove the simplify-libcalls pass (finally)Meador Inge2013-06-201-0/+50
| | | | | | | | | | | This commit completely removes what is left of the simplify-libcalls pass. All of the functionality has now been migrated to the instcombine and functionattrs passes. The following C API functions are now NOPs: 1. LLVMAddSimplifyLibCallsPass 2. LLVMPassManagerBuilderSetDisableSimplifyLibCalls llvm-svn: 184459
* Do not optimise fprintf() calls if its return value is used.Peter Collingbourne2013-04-171-9/+12
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D620 llvm-svn: 179661
* LibCallSimplifier: optimize speed for short-lived instancesMeador Inge2013-03-121-177/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | Nadav reported a performance regression due to the work I did to merge the library call simplifier into instcombine [1]. The issue is that a new LibCallSimplifier object is being created whenever InstCombiner::runOnFunction is called. Every time a LibCallSimplifier object is used to optimize a call it creates a hash table to map from a function name to an object that optimizes functions of that name. For short-lived LibCallSimplifier instances this is quite inefficient. Especially for cases where no calls are actually simplified. This patch fixes the issue by dropping the hash table and implementing an explicit lookup function to correlate the function name to the object that optimizes functions of that name. This avoids the cost of always building and destroying the hash table in cases where the LibCallSimplifier object is short-lived and avoids the cost of building the table when no simplifications are actually preformed. On a benchmark containing 100,000 calls where none of them are simplified I noticed a 30% speedup. On a benchmark containing 100,000 calls where all of them are simplified I noticed an 8% speedup. [1] http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130304/167639.html llvm-svn: 176840
* Modify {Call,Invoke}Inst::addAttribute to take an AttrKind.Peter Collingbourne2013-03-021-2/+1
| | | | llvm-svn: 176397
* For each function that we optimize we initialize a new list of lib ↵Nadav Rotem2013-02-271-1/+2
| | | | | | functions. For each function name we malloc memory. This patch changes the Libcall map to use BumpPtrAllocator. Now we malloc only once. This speeds up instcombine by a few % on a large c++ program. llvm-svn: 176170
* Implement the NoBuiltin attribute.Bill Wendling2013-02-221-0/+1
| | | | | | | | The 'nobuiltin' attribute is applied to call sites to indicate that LLVM should not treat the callee function as a built-in function. I.e., it shouldn't try to replace that function with different code. llvm-svn: 175835
* Temporarily revert r175470 for more review.Bill Wendling2013-02-191-3/+0
| | | | llvm-svn: 175476
* Check to see if the 'no-builtin' attribute is set before simplifying a ↵Bill Wendling2013-02-181-0/+3
| | | | | | library call. llvm-svn: 175470
* [SimplifyLibCalls] Library call simplification doen't work if the call site Chad Rosier2013-02-081-1/+7
| | | | | | | | isn't using the default calling convention. However, if the transformation is from a call to inline IR, then the calling convention doesn't matter. rdar://13157990 llvm-svn: 174724
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-021-6/+6
| | | | | | | | | | | | | | | | | | | | | into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-2/+2
| | | | | | single attribute in the future. llvm-svn: 170502
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-2/+2
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* instcombine: Migrate puts optimizationsMeador Inge2012-11-291-0/+27
| | | | | | | | | | | | This patch migrates the puts optimizations from the simplify-libcalls pass into the instcombine library call simplifier. All the simplifiers from simplify-libcalls have now been migrated to instcombine. Yay! Just a few other bits to migrate (prototype attribute inference and a few statistics) and simplify-libcalls can finally be put to rest. llvm-svn: 168925
* instcombine: Migrate fputs optimizationsMeador Inge2012-11-291-0/+24
| | | | | | | This patch migrates the fputs optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168893
* instcombine: Migrate fwrite optimizationsMeador Inge2012-11-291-0/+35
| | | | | | | This patch migrates the fwrite optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168892
* instcombine: Migrate fprintf optimizationsMeador Inge2012-11-291-0/+77
| | | | | | | This patch migrates the fprintf optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168891
* instcombine: Migrate sprintf optimizationsMeador Inge2012-11-271-0/+95
| | | | | | | This patch migrates the sprintf optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168677
* Fix a comment bug in toascii simplifierMeador Inge2012-11-261-1/+1
| | | | | | | When I migrated the toascii simplifier in r168580 Benjamin Kramer noticed a bug in one of the comments that I migrated. llvm-svn: 168605
* instcombine: Migrate printf optimizationsMeador Inge2012-11-261-0/+103
| | | | | | | This patch migrates the printf optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168604
* instcombine: Migrate toascii optimizationsMeador Inge2012-11-261-0/+16
| | | | | | | This patch migrates the toascii optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168580
* instcombine: Migrate isascii optimizationsMeador Inge2012-11-261-0/+17
| | | | | | | This patch migrates the isascii optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168579
* instcombine: Migrate isdigit optimizationsMeador Inge2012-11-261-0/+18
| | | | | | | This patch migrates the isdigit optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168578
* instcombine: Migrate *abs optimizationsMeador Inge2012-11-261-0/+21
| | | | | | | This patch migrates the *abs optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168574
* instcombine: Migrate ffs* optimizationsMeador Inge2012-11-251-0/+46
| | | | | | | This patch migrates the ffs* optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 168571
* instcombine: Migrate math library call simplificationsMeador Inge2012-11-131-3/+262
| | | | | | | | | | | | | | | | | This patch migrates the math library call simplifications from the simplify-libcalls pass into the instcombine library call simplifier. I have typically migrated just one simplifier at a time, but the math simplifiers are interdependent because: 1. CosOpt, PowOpt, and Exp2Opt all depend on UnaryDoubleFPOpt. 2. CosOpt, PowOpt, Exp2Opt, and UnaryDoubleFPOpt all depend on the option -enable-double-float-shrink. These two factors made migrating each of these simplifiers individually more of a pain than it would be worth. So, I migrated them all together. llvm-svn: 167815
* Normalize memcmp constant folding results.Meador Inge2012-11-121-1/+8
| | | | | | | | | | | | | | | | | | | The library call simplifier folds memcmp calls with all constant arguments to a constant. For example: memcmp("foo", "foo", 3) -> 0 memcmp("hel", "foo", 3) -> 1 memcmp("foo", "hel", 3) -> -1 The folding is implemented in terms of the system memcmp that LLVM gets linked with. It currently just blindly uses the value returned from the system memcmp as the folded constant. This patch normalizes the values returned from the system memcmp to (-1, 0, 1) so that we get consistent results across multiple platforms. The test cases were adjusted accordingly. llvm-svn: 167726
* instcombine: Migrate memset optimizationsMeador Inge2012-11-111-0/+21
| | | | | | | This patch migrates the memset optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167689
* instcombine: Migrate memmove optimizationsMeador Inge2012-11-111-0/+21
| | | | | | | This patch migrates the memmove optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167687
* instcombine: Migrate memcpy optimizationsMeador Inge2012-11-111-0/+21
| | | | | | | This patch migrates the memcpy optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167686
* instcombine: Migrate memcmp optimizationsMeador Inge2012-11-111-2/+53
| | | | | | | This patch migrates the memcmp optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167683
* instcombine: Migrate strstr optimizationsMeador Inge2012-11-111-0/+80
| | | | | | | This patch migrates the strstr optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167682
* Add method for replacing instructions to LibCallSimplifierMeador Inge2012-11-111-4/+15
| | | | | | | | | | | | | | | In some cases the library call simplifier may need to replace instructions other than the library call being simplified. In those cases it may be necessary for clients of the simplifier to override how the replacements are actually done. As such, a new overrideable method for replacing instructions was added to LibCallSimplifier. A new subclass of LibCallSimplifier is also defined which overrides the instruction replacement method. This is because the instruction combiner defines its own replacement method which updates the worklist when instructions are replaced. llvm-svn: 167681
* instcombine: Migrate strcspn optimizationsMeador Inge2012-11-101-0/+34
| | | | | | | This patch migrates the strcspn optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167675
* instcombine: Query target library information to gate libcall simplificationsMeador Inge2012-11-101-19/+25
| | | | | | | | | Several of the simplifiers migrated from the simplify-libcalls pass to the instcombine pass were not correctly checking the target library information to gate the simplifications. This patch ensures that the check is made. llvm-svn: 167660
* instcombine: Migrate strspn optimizationsMeador Inge2012-11-081-0/+31
| | | | | | | This patch migrates the strspn optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167568
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-011-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getIntPtrType support for multiple address spaces via a pointer type, and also introduced a crasher bug in the constant folder reported in PR14233. These commits also contained several problems that should really be addressed before they are re-committed. I have avoided reverting various cleanups to the DataLayout APIs that are reasonable to have moving forward in order to reduce the amount of churn, and minimize the number of commits that were reverted. I've also manually updated merge conflicts and manually arranged for the getIntPtrType function to stay in DataLayout and to be defined in a plausible way after this revert. Thanks to Duncan for working through this exact strategy with me, and Nick Lewycky for tracking down the really annoying crasher this triggered. (Test case to follow in its own commit.) After discussing with Duncan extensively, and based on a note from Micah, I'm going to continue to back out some more of the more problematic patches in this series in order to ensure we go into the LLVM 3.2 branch with a reasonable story here. I'll send a note to llvmdev explaining what's going on and why. Summary of reverted revisions: r166634: Fix a compiler warning with an unused variable. r166607: Add some cleanup to the DataLayout changes requested by Chandler. r166596: Revert "Back out r166591, not sure why this made it through since I cancelled the command. Bleh, sorry about this! r166591: Delete a directory that wasn't supposed to be checked in yet. r166578: Add in support for getIntPtrType to get the pointer type based on the address space. llvm-svn: 167221
* instcombine: Migrate strto* optimizationsMeador Inge2012-10-311-0/+28
| | | | | | | This patch migrates the strto* optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167119
* instcombine: Migrate strpbrk optimizationsMeador Inge2012-10-311-0/+37
| | | | | | | This patch migrates the strpbrk optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167105
* instcombine: Migrate strlen optimizationsMeador Inge2012-10-311-0/+44
| | | | | | | This patch migrates the strlen optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167103
* instcombine: Migrate strncpy optimizationsMeador Inge2012-10-311-0/+49
| | | | | | | This patch migrates the strncpy optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167102
* instcombine: Migrate stpcpy optimizationsMeador Inge2012-10-311-0/+38
| | | | | | | | This patch migrates the stpcpy optimizations from the simplify-libcalls pass into the instcombine library call simplifier. Note that the __stpcpy_chk simplifications were migrated in a previous commit. llvm-svn: 167083
* instcombine: Split out the __stpcpy_chk simplifications from StrCpyChkOptMeador Inge2012-10-311-3/+54
| | | | | | | | | | | | | | | | r166198 migrated the strcpy optimization to instcombine. The strcpy simplifier that was migrated from Transforms/Scalar/SimplifyLibCalls.cpp was also doing some __strcpy_chk simplifications. Those fortified simplifications were migrated as well, but introduced a bug in the __stpcpy_chk simplifier in the process. This happened because the __strcpy_chk and __stpcpy_chk simplifiers were both mapped to StrCpyChkOpt which was updated with simplifications that worked for __strcpy_chk, but not __stpcpy_chk. This patch fixes the problem by adding proper test coverage and creating a new simplifier for __stpcpy_chk (instead of sharing one with __strcpy_chk). llvm-svn: 167082
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-241-17/+17
| | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. llvm-svn: 166578
* Cosmetic change -- move two simplifiers to the right commented statement group.Meador Inge2012-10-181-2/+2
| | | | llvm-svn: 166199
* instcombine: Migrate strcpy optimizationsMeador Inge2012-10-181-2/+49
| | | | | | | | | | | | This patch migrates the strcpy optimizations from the simplify-libcalls pass into the instcombine library call simplifier. Note also that StrCpyChkOpt has been updated with a few simplifications that were being done in the simplify-libcalls version of StrCpyOpt, but not in the migrated implementation of StrCpyOpt. There is no reason to overload StrCpyOpt with fortified and regular simplifications in the new model since there is already a dedicated simplifier for __strcpy_chk. llvm-svn: 166198
* instcombine: Migrate strcmp and strncmp optimizationsMeador Inge2012-10-151-0/+99
| | | | | | | This patch migrates the strcmp and strncmp optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 165915
* Remove unused private field.Benjamin Kramer2012-10-131-1/+0
| | | | llvm-svn: 165881
* instcombine: Migrate strchr and strrchr optimizationsMeador Inge2012-10-131-0/+86
| | | | | | | This patch migrates the strchr and strrchr optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 165875
* instcombine: Migrate strcat and strncat optimizationsMeador Inge2012-10-131-0/+106
| | | | | | | This patch migrates the strcat and strncat optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 165874
OpenPOWER on IntegriCloud