summaryrefslogtreecommitdiff
path: root/lib/Analysis/MemoryBuiltins.cpp
Commit message (Collapse)AuthorAge
* Revert r176408 and r176407 to address PR15540.Nadav Rotem2013-04-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179111 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert 179071 because it is not the right way to support non standard ↵Nadav Rotem2013-04-09
| | | | | | new/new[] operators. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179084 91177308-0d34-0410-b5e6-96231b3b80d8
* c++ new operators are not malloc-like functions because they do not return ↵Nadav Rotem2013-04-08
| | | | | | | | | | uninitialized memory. Users may overide new-operators and implement any function that they like. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179071 91177308-0d34-0410-b5e6-96231b3b80d8
* Early exit from getAllocationData() and isFreeCall() for intrinsics.Michael Ilseman2013-03-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176722 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing whitespaceMichael Ilseman2013-03-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176720 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify code. No functionality change.Jakub Staszak2013-03-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176646 91177308-0d34-0410-b5e6-96231b3b80d8
* Change NULL to 0.Jakub Staszak2013-03-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176642 91177308-0d34-0410-b5e6-96231b3b80d8
* recommit r172363 & r171325 (reverted in r172756)Nuno Lopes2013-03-02
| | | | | | | | This adds minimalistic support for PHI nodes to llvm.objectsize() evaluation fingers crossed so that it does break clang boostrap again.. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176408 91177308-0d34-0410-b5e6-96231b3b80d8
* add getUnderlyingObjectSize()Nuno Lopes2013-03-02
| | | | | | | this is similar to getObjectSize(), but doesnt subtract the offset tweak the BasicAA code accordingly (per PR14988) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176407 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverting r171325 & r172363. This was causing a mis-compile on the ↵Bill Wendling2013-01-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | self-hosted LTO build bots. Okay, here's how to reproduce the problem: 1) Build a Release (or Release+Asserts) version of clang in the normal way. 2) Using the clang & clang++ binaries from (1), build a Release (or Release+Asserts) version of the same sources, but this time enable LTO --- specify the `-flto' flag on the command line. 3) Run the ARC migrator tests: $ arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ ./src/tools/clang/test/ARCMT/cxx-rewrite.mm You'll see that the output isn't correct (the whitespace is off). The mis-compile is in the function `RewriteBuffer::RemoveText' in the clang/lib/Rewrite/Core/Rewriter.cpp file. When that function and RewriteRope.cpp are compiled with LTO and the `arcmt-test' executable is regenerated, you'll see the error. When those files are not LTO'ed, then the output of the `arcmt-test' is fine. It is *really* hard to get a testcase out of this. I'll file a PR with what I have currently. --- Reverse-merging r172363 into '.': U include/llvm/Analysis/MemoryBuiltins.h U lib/Analysis/MemoryBuiltins.cpp --- Reverse-merging r171325 into '.': U test/Transforms/InstCombine/objsize.ll G include/llvm/Analysis/MemoryBuiltins.h G lib/Analysis/MemoryBuiltins.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172756 91177308-0d34-0410-b5e6-96231b3b80d8
* fix compile-time regression report by Joerg Sonnenberger:Nuno Lopes2013-01-13
| | | | | | cache result of Size/OffsetVisitor to speedup analysis of PHI nodes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172363 91177308-0d34-0410-b5e6-96231b3b80d8
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-02
| | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
* recommit r171298 (add support for PHI nodes to ObjectSizeOffsetVisitor). ↵Nuno Lopes2012-12-31
| | | | | | Hopefully with bugs corrected now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171325 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "add support for PHI nodes to ObjectSizeOffsetVisitor"Benjamin Kramer2012-12-31
| | | | | | This reverts r171298. Breaks clang selfhost. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171318 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r171306, since we cannot compare APInts with different bitwidthsNuno Lopes2012-12-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171308 91177308-0d34-0410-b5e6-96231b3b80d8
* minor code simplificationNuno Lopes2012-12-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171306 91177308-0d34-0410-b5e6-96231b3b80d8
* add support for GlobalAlias to ObjectSizeOffsetVisitorNuno Lopes2012-12-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171303 91177308-0d34-0410-b5e6-96231b3b80d8
* add support for PHI nodes to ObjectSizeOffsetVisitorNuno Lopes2012-12-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171298 91177308-0d34-0410-b5e6-96231b3b80d8
* convert a bunch of callers from DataLayout::getIndexedOffset() to ↵Nuno Lopes2012-12-30
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171259 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-19
| | | | | | single attribute in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170502 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | 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. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167221 91177308-0d34-0410-b5e6-96231b3b80d8
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-24
| | | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the attribute enums to query if a function has an attribute.Bill Wendling2012-10-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165551 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove more uses of the attribute enums by supplying appropriate query ↵Bill Wendling2012-10-09
| | | | | | | | | methods for them. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165466 91177308-0d34-0410-b5e6-96231b3b80d8
* Move TargetData to DataLayout.Micah Villmow2012-10-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
* Make MemoryBuiltins aware of TargetLibraryInfo.Benjamin Kramer2012-08-29
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162841 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuiltins: Properly guard ObjectSizeOffsetVisitor against cycles in the IR.Benjamin Kramer2012-08-17
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162120 91177308-0d34-0410-b5e6-96231b3b80d8
* Guard MemoryBuiltins against self-looping GEPs, which can occur in ↵Benjamin Kramer2012-08-17
| | | | | | | | unreachable code due to constant propagation. Fixes PR13621. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162098 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR13390: do not loop forever with self-referencing self instructionsNuno Lopes2012-07-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160876 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r160742: it's breaking CMake buildNuno Lopes2012-07-25
| | | | | | | original commit msg: MemoryBuiltins: add support to determine the size of strdup'ed non-constant strings git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160751 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuiltins: add support to determine the size of strdup'ed non-constant ↵Nuno Lopes2012-07-25
| | | | | | strings git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160742 91177308-0d34-0410-b5e6-96231b3b80d8
* teach objectsize about strdup() and strndup()Nuno Lopes2012-07-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160676 91177308-0d34-0410-b5e6-96231b3b80d8
* baby steps toward fixing some problems with inbound GEPs that overflow, as ↵Nuno Lopes2012-07-20
| | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160589 91177308-0d34-0410-b5e6-96231b3b80d8
* fold PHI nodes in SizeOffsetEvaluator whenever possible.Nuno Lopes2012-07-03
| | | | | | Unfortunately this change requires the cache map to hold WeakVHs instead git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159667 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuiltins:Nuno Lopes2012-06-28
| | | | | | | | - 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159356 91177308-0d34-0410-b5e6-96231b3b80d8
* check for the NoAlias attribute through CallSiteNuno Lopes2012-06-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159145 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify code from previous commits (Thanks Duncan)Nuno Lopes2012-06-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158999 91177308-0d34-0410-b5e6-96231b3b80d8
* remove extractMallocCallFromBitCast, since it was tailor maded for its sole ↵Nuno Lopes2012-06-22
| | | | | | user. Update GlobalOpt accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158952 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for invoke to the MemoryBuiltin analysid.Nuno Lopes2012-06-21
| | | | | | | | Update comments accordingly. Make instcombine remove useless invokes to C++'s 'new' allocation function (test attached). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158937 91177308-0d34-0410-b5e6-96231b3b80d8
* fix build in C++11 mode.Nuno Lopes2012-06-21
| | | | | | Thanks to Chandler for pointing out the problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158928 91177308-0d34-0410-b5e6-96231b3b80d8
* hopefully fix the buildbots: some tests have wrong definitions of malloc ↵Nuno Lopes2012-06-21
| | | | | | and were crashing this code on 64 bits machines git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158923 91177308-0d34-0410-b5e6-96231b3b80d8
* refactor the MemoryBuiltin analysis:Nuno Lopes2012-06-21
| | | | | | | | | | | | - 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158919 91177308-0d34-0410-b5e6-96231b3b80d8
* remove calls to calloc if the allocated memory is not used (it was already ↵Nuno Lopes2012-05-03
| | | | | | | | being done for malloc) fix a few typos found by Chad in my previous commit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156110 91177308-0d34-0410-b5e6-96231b3b80d8
* add support for calloc to objectsize loweringNuno Lopes2012-05-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156102 91177308-0d34-0410-b5e6-96231b3b80d8
* Validate the return type when checking if a function is malloc.Benjamin Kramer2011-11-23
| | | | | | Fixes PR11426. Not sure if a test case with a "wrong" malloc would be useful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145106 91177308-0d34-0410-b5e6-96231b3b80d8
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify some code.Chris Lattner2011-06-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133362 91177308-0d34-0410-b5e6-96231b3b80d8
* Add comments for the demanglings. Correct mangled form of operator delete!Nick Lewycky2011-03-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127801 91177308-0d34-0410-b5e6-96231b3b80d8
* Add C++ global operator {new,new[],delete,delete[]}(unsigned {int,long}) to theNick Lewycky2011-03-15
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127673 91177308-0d34-0410-b5e6-96231b3b80d8