summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemoryBuiltins.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* add support for GlobalAlias to ObjectSizeOffsetVisitorNuno Lopes2012-12-311-0/+9
| | | | llvm-svn: 171303
* add support for PHI nodes to ObjectSizeOffsetVisitorNuno Lopes2012-12-311-3/+14
| | | | llvm-svn: 171298
* convert a bunch of callers from DataLayout::getIndexedOffset() to ↵Nuno Lopes2012-12-301-3/+2
| | | | | | | | | GEP::accumulateConstantOffset(). The later API is nicer than the former, and is correct regarding wrap-around offsets (if anyone cares). There are a few more places left with duplicated code, which I'll remove soon. llvm-svn: 171259
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-1/+1
| | | | | | 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-4/+4
| | | | | | | | | | | | | | | | | 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
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-011-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-241-4/+6
| | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. llvm-svn: 166578
* Use the attribute enums to query if a function has an attribute.Bill Wendling2012-10-091-1/+1
| | | | llvm-svn: 165551
* Remove more uses of the attribute enums by supplying appropriate query ↵Bill Wendling2012-10-091-1/+1
| | | | | | | | methods for them. No functionality change intended. llvm-svn: 165466
* Move TargetData to DataLayout.Micah Villmow2012-10-081-7/+7
| | | | llvm-svn: 165402
* Make MemoryBuiltins aware of TargetLibraryInfo.Benjamin Kramer2012-08-291-56/+86
| | | | | | | | | | | | | | | | This disables malloc-specific optimization when -fno-builtin (or -ffreestanding) is specified. This has been a problem for a long time but became more severe with the recent memory builtin improvements. Since the memory builtin functions are used everywhere, this required passing TLI in many places. This means that functions that now have an optional TLI argument, like RecursivelyDeleteTriviallyDeadFunctions, won't remove dead mallocs anymore if the TLI argument is missing. I've updated most passes to do the right thing. Fixes PR13694 and probably others. llvm-svn: 162841
* MemoryBuiltins: Properly guard ObjectSizeOffsetVisitor against cycles in the IR.Benjamin Kramer2012-08-171-18/+14
| | | | | | | | | | The previous fix only checked for simple cycles, use a set to catch longer cycles too. Drop the broken check from the ObjectSizeOffsetEvaluator. The BoundsChecking pass doesn't have to deal with invalid IR like InstCombine does. llvm-svn: 162120
* Guard MemoryBuiltins against self-looping GEPs, which can occur in ↵Benjamin Kramer2012-08-171-0/+4
| | | | | | | | unreachable code due to constant propagation. Fixes PR13621. llvm-svn: 162098
* fix PR13390: do not loop forever with self-referencing self instructionsNuno Lopes2012-07-271-0/+8
| | | | llvm-svn: 160876
* revert r160742: it's breaking CMake buildNuno Lopes2012-07-251-18/+7
| | | | | | | original commit msg: MemoryBuiltins: add support to determine the size of strdup'ed non-constant strings llvm-svn: 160751
* MemoryBuiltins: add support to determine the size of strdup'ed non-constant ↵Nuno Lopes2012-07-251-7/+18
| | | | | | strings llvm-svn: 160742
* teach objectsize about strdup() and strndup()Nuno Lopes2012-07-241-3/+16
| | | | llvm-svn: 160676
* baby steps toward fixing some problems with inbound GEPs that overflow, as ↵Nuno Lopes2012-07-201-1/+1
| | | | | | | | discussed 2 months ago or so. Make sure we do not emit index computations with NSW flags so that we dont get an undef value if the GEP overflows llvm-svn: 160589
* fold PHI nodes in SizeOffsetEvaluator whenever possible.Nuno Lopes2012-07-031-1/+13
| | | | | | Unfortunately this change requires the cache map to hold WeakVHs instead llvm-svn: 159667
* MemoryBuiltins:Nuno Lopes2012-06-281-14/+37
| | | | | | | | - recognize C++ new(std::nothrow) friends - ignore ExtractElement and ExtractValue instructions in size/offset analysis (all easy cases are probably folded away before we get here) - also recognize realloc as noalias llvm-svn: 159356
* check for the NoAlias attribute through CallSiteNuno Lopes2012-06-251-2/+2
| | | | llvm-svn: 159145
* simplify code from previous commits (Thanks Duncan)Nuno Lopes2012-06-221-7/+2
| | | | llvm-svn: 158999
* remove extractMallocCallFromBitCast, since it was tailor maded for its sole ↵Nuno Lopes2012-06-221-8/+1
| | | | | | user. Update GlobalOpt accordingly. llvm-svn: 158952
* Add support for invoke to the MemoryBuiltin analysid.Nuno Lopes2012-06-211-15/+22
| | | | | | | | Update comments accordingly. Make instcombine remove useless invokes to C++'s 'new' allocation function (test attached). llvm-svn: 158937
* fix build in C++11 mode.Nuno Lopes2012-06-211-7/+7
| | | | | | Thanks to Chandler for pointing out the problem. llvm-svn: 158928
* hopefully fix the buildbots: some tests have wrong definitions of malloc ↵Nuno Lopes2012-06-211-3/+5
| | | | | | and were crashing this code on 64 bits machines llvm-svn: 158923
* refactor the MemoryBuiltin analysis:Nuno Lopes2012-06-211-88/+522
| | | | | | | | | | | | - provide more extensive set of functions to detect library allocation functions (e.g., malloc, calloc, strdup, etc) - provide an API to compute the size and offset of an object pointed by Move a few clients (GVN, AA, instcombine, ...) to the new API. This implementation is a lot more aggressive than each of the custom implementations being replaced. Patch reviewed by Nick Lewycky and Chandler Carruth, thanks. llvm-svn: 158919
* remove calls to calloc if the allocated memory is not used (it was already ↵Nuno Lopes2012-05-031-2/+2
| | | | | | | | being done for malloc) fix a few typos found by Chad in my previous commit llvm-svn: 156110
* add support for calloc to objectsize loweringNuno Lopes2012-05-031-0/+40
| | | | llvm-svn: 156102
* Validate the return type when checking if a function is malloc.Benjamin Kramer2011-11-231-4/+4
| | | | | | Fixes PR11426. Not sure if a test case with a "wrong" malloc would be useful. llvm-svn: 145106
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-8/+8
| | | | llvm-svn: 135375
* simplify some code.Chris Lattner2011-06-181-8/+3
| | | | llvm-svn: 133362
* Add comments for the demanglings. Correct mangled form of operator delete!Nick Lewycky2011-03-171-4/+6
| | | | llvm-svn: 127801
* Add C++ global operator {new,new[],delete,delete[]}(unsigned {int,long}) to theNick Lewycky2011-03-151-2/+11
| | | | | | | | | | | | | memory builtins as equivalent to malloc/free. This is different from any attribute we have. For example, you can delete the allocators when their result is unused, but you can't collapse two calls to the same function, even if no global/memory state has changed in between. The noalias return states that the result does not alias any other pointer, but instcombine optimizes malloc() as though the result is non-null for the purpose of eliminating unused pointers. llvm-svn: 127673
* minor enhancement to llvm::isFreeCall API: return CallInst; no functional changeGabor Greif2010-06-231-8/+8
| | | | llvm-svn: 106686
* use ArgOperand gettersGabor Greif2010-06-231-3/+3
| | | | llvm-svn: 106685
* Revert 101465, it broke internal OpenGL testing.Eric Christopher2010-04-161-2/+2
| | | | | | | Probably the best way to know that all getOperand() calls have been handled is to replace that API instead of updating. llvm-svn: 101579
* reapply r101434Gabor Greif2010-04-161-2/+2
| | | | | | | | | | | | | with a fix for self-hosting rotate CallInst operands, i.e. move callee to the back of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101465
* back out r101423 and r101397, they break llvm-gcc self-host on darwin10Gabor Greif2010-04-161-2/+2
| | | | llvm-svn: 101434
* reapply r101364, which has been backed out in r101368Gabor Greif2010-04-151-2/+2
| | | | | | | | | | | | | with a fix rotate CallInst operands, i.e. move callee to the back of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101397
* back out r101364, as it trips the linux nightlybot on some clang C++ testsGabor Greif2010-04-151-2/+2
| | | | llvm-svn: 101368
* rotate CallInst operands, i.e. move callee to the backGabor Greif2010-04-151-2/+2
| | | | | | | | | | of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101364
* rename use_const_iterator to const_use_iterator for consistency's sakeGabor Greif2010-03-251-1/+1
| | | | llvm-svn: 99564
* Fix "the the" and similar typos.Dan Gohman2010-02-101-2/+2
| | | | llvm-svn: 95781
* Simplify ComputeMultiple so that it doesn't depend on TargetData.Dan Gohman2009-11-181-2/+1
| | | | llvm-svn: 89175
* Update computeArraySize() to use ComputeMultiple() to determine the array ↵Victor Hernandez2009-11-101-90/+19
| | | | | | size associated with a malloc; also extend PerformHeapAllocSRoA() to check if the optimized malloc's arg had its highest bit set, so that it is safe for ComputeMultiple() to look through sext instructions while determining the optimized malloc's array size llvm-svn: 86676
* Re-commit r86077 now that r86290 fixes the 179.art and 175.vpr ARM regressions.Victor Hernandez2009-11-071-35/+41
| | | | | | | | | | | | | | | | | | | | | | | Here is the original commit message: This commit updates malloc optimizations to operate on malloc calls that have constant int size arguments. Update CreateMalloc so that its callers specify the size to allocate: MallocInst-autoupgrade users use non-TargetData-computed allocation sizes. Optimization uses use TargetData to compute the allocation size. Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays. Extend getMallocType() to support malloc calls that have non-bitcast uses. Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses. The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly. Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses. The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use. Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use. Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes. llvm-svn: 86311
* remove a bunch of extraneous LLVMContext argumentsChris Lattner2009-11-061-13/+9
| | | | | | from various APIs, addressing PR5325. llvm-svn: 86231
* Revert r86077 because it caused crashes in 179.art and 175.vpr on ARMVictor Hernandez2009-11-061-41/+35
| | | | llvm-svn: 86213
* Update CreateMalloc so that its callers specify the size to allocate:Victor Hernandez2009-11-051-35/+41
| | | | | | | | | | | | | | | | | | MallocInst-autoupgrade users use non-TargetData-computed allocation sizes. Optimization uses use TargetData to compute the allocation size. Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays. Extend getMallocType() to support malloc calls that have non-bitcast uses. Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses. The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly. Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses. The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use. Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use. Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes. llvm-svn: 86077
OpenPOWER on IntegriCloud