summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
Commit message (Collapse)AuthorAge
* [C++] Use 'nullptr'. Transforms edition.Craig Topper2014-04-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207196 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle addrspacecast when looking at memcpys from globalsMatt Arsenault2014-04-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207054 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-22
| | | | | | | | | | | | | | | | | definition below all of the header #include lines, lib/Transforms/... edition. This one is tricky for two reasons. We again have a couple of passes that define something else before the includes as well. I've sunk their name macros with the DEBUG_TYPE. Also, InstCombine contains headers that need DEBUG_TYPE, so now those headers #define and #undef DEBUG_TYPE around their code, leaving them well formed modular headers. Fixing these headers was a large motivation for all of these changes, as "leaky" macros of this form are hard on the modules implementation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206844 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules] Sink all the DEBUG_TYPE defines for InstCombine out of theChandler Carruth2014-04-21
| | | | | | | | | | | header files and into the cpp files. These files will require more touches as the header files actually use DEBUG(). Eventually, I'll have to introduce a matched #define and #undef of DEBUG_TYPE for the header files, but that comes as step N of many to clean all of this up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206777 91177308-0d34-0410-b5e6-96231b3b80d8
* [InstCombine] Don't fold bitcast into store if it would need addrspacecastRichard Osborne2014-03-25
| | | | | | | | | | | | | | | | | | Summary: Previously the code didn't check if the before and after types for the store were pointers to different address spaces. This resulted in instcombine using a bitcast to convert between pointers to different address spaces, causing an assertion due to the invalid cast. It is not be appropriate to use addrspacecast this case because it is not guaranteed to be a no-op cast. Instead bail out and do not do the transformation. CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3117 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204733 91177308-0d34-0410-b5e6-96231b3b80d8
* Reuse earlier variables to make it clear the types involved in the cast.Richard Osborne2014-03-25
| | | | | | No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204732 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in InstCombine where we would incorrectly attempt to construct aOwen Anderson2014-03-13
| | | | | | | | bitcast between pointers of two different address spaces if they happened to have the same pointer size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203862 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Add range based accessors for the Use-Def chain of a Value.Chandler Carruth2014-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires a number of steps. 1) Move value_use_iterator into the Value class as an implementation detail 2) Change it to actually be a *Use* iterator rather than a *User* iterator. 3) Add an adaptor which is a User iterator that always looks through the Use to the User. 4) Wrap these in Value::use_iterator and Value::user_iterator typedefs. 5) Add the range adaptors as Value::uses() and Value::users(). 6) Update *all* of the callers to correctly distinguish between whether they wanted a use_iterator (and to explicitly dig out the User when needed), or a user_iterator which makes the Use itself totally opaque. Because #6 requires churning essentially everything that walked the Use-Def chains, I went ahead and added all of the range adaptors and switched them to range-based loops where appropriate. Also because the renaming requires at least churning every line of code, it didn't make any sense to split these up into multiple commits -- all of which would touch all of the same lies of code. The result is still not quite optimal. The Value::use_iterator is a nice regular iterator, but Value::user_iterator is an iterator over User*s rather than over the User objects themselves. As a consequence, it fits a bit awkwardly into the range-based world and it has the weird extra-dereferencing 'operator->' that so many of our iterators have. I think this could be fixed by providing something which transforms a range of T&s into a range of T*s, but that *can* be separated into another patch, and it isn't yet 100% clear whether this is the right move. However, this change gets us most of the benefit and cleans up a substantial amount of code around Use and User. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203364 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename many DataLayout variables from TD to DL.Rafael Espindola2014-02-21
| | | | | | | | | I am really sorry for the noise, but the current state where some parts of the code use TD (from the old name: TargetData) and other parts use DL makes it hard to write a patch that changes where those variables come from and how they are passed along. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201827 91177308-0d34-0410-b5e6-96231b3b80d8
* Update optimization passes to handle inalloca argumentsReid Kleckner2014-01-28
| | | | | | | | | | | | | | | Summary: I searched Transforms/ and Analysis/ for 'ByVal' and updated those call sites to check for inalloca if appropriate. I added tests for any change that would allow an optimization to fire on inalloca. Reviewers: nlewycky Differential Revision: http://llvm-reviews.chandlerc.com/D2449 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200281 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix assert with copy from global through addrspacecastMatt Arsenault2013-12-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196638 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Don't allow turning vector-of-pointer loads into vector-of-integer.Benjamin Kramer2013-09-19
| | | | | | The code below can't handle any pointers. PR17293. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191036 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert the load slicing done in r190870.Quentin Colombet2013-09-17
| | | | | | | | To avoid regressions with bitfield optimizations, this slicing should take place later, like ISel time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190891 91177308-0d34-0410-b5e6-96231b3b80d8
* [InstCombiner] Slice a big load in two loads when the elements are next to eachQuentin Colombet2013-09-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | other in memory. The motivation was to get rid of truncate and shift right instructions that get in the way of paired load or floating point load. E.g., Consider the following example: struct Complex { float real; float imm; }; When accessing a complex, llvm was generating a 64-bits load and the imm field was obtained by a trunc(lshr) sequence, resulting in poor code generation, at least for x86. The idea is to declare that two load instructions is the canonical form for loading two arithmetic type, which are next to each other in memory. Two scalar loads at a constant offset from each other are pretty easy to detect for the sorts of passes that like to mess with loads. <rdar://problem/14477220> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190870 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach InstCombineLoadCast about address spaces.Matt Arsenault2013-09-03
| | | | | | | | This is another one that doesn't matter much, but uses the right GEP index types in the first place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189854 91177308-0d34-0410-b5e6-96231b3b80d8
* Use type form of getIntPtrType in alloca visitor.Matt Arsenault2013-09-03
| | | | | | | This doesn't actually matter, since alloca is always 0 address space, but this is more consistent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189853 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix always creating GEP with i32 indicesMatt Arsenault2013-08-14
| | | | | | | | | | | | | | | | Use the pointer size if datalayout is available. Use i64 if it's not, which is consistent with what other places do when the pointer size is unknown. The test doesn't really test this in a useful way since it will be transformed to that later anyway, but this now tests it for non-zero arrays and when datalayout isn't available. The cases in visitGetElementPtrInst should save an extra re-visit to the newly created GEP since it won't need to cleanup after itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188339 91177308-0d34-0410-b5e6-96231b3b80d8
* Use array initializer, space around operatorMatt Arsenault2013-08-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188337 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy up a bit. No functional change.Jim Grosbach2013-04-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178915 91177308-0d34-0410-b5e6-96231b3b80d8
* switch from pointer equality comparison to MDNode::getMostGenericTBAA Chris Lattner2013-01-05
| | | | | | | when merging two TBAA tags, pointed out by Nuno. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171627 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
* teach instcombine to preserve TBAA tag when merging two stores, part ofChris Lattner2012-12-31
| | | | | | | PR14753 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171279 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
* Get rid of the getPointeeAlignment helper function fromEli Friedman2012-11-26
| | | | | | | | | | InstCombineLoadStoreAlloca.cpp, which had many issues. (At least two bugs were noted on llvm-commits, and it was overly conservative.) Instead, use getOrEnforceKnownAlignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168629 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't try to calculate the alignment of an unsigned type. Fixes PR14371!Nick Lewycky2012-11-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168280 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
* 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
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-27
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164768 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164767 91177308-0d34-0410-b5e6-96231b3b80d8
* Add missing check for presence of target data.Richard Osborne2012-09-24
| | | | | | This avoids a crash in visitAllocaInst when target data isn't available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164539 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix instcombine to obey requested alignment when merging allocas.Richard Osborne2012-09-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164117 91177308-0d34-0410-b5e6-96231b3b80d8
* Port the global copy optimization from the SROA pass to InstCombine.Chandler Carruth2012-08-21
| | | | | | | | | | This optimization is really just replacing allocas wholesale with globals, there is no scalarization. The underlying motivation for this patch is to simplify the SROA pass and focus it on splitting and promoting allocas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162271 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: merge the functions that remove dead allocas and dead ↵Nuno Lopes2012-07-09
| | | | | | | | | mallocs/callocs/... This patch removes ~70 lines in InstCombineLoadStoreAlloca.cpp and makes both functions a bit more aggressive than before :) In theory, we can be more aggressive when removing an alloca than a malloc, because an alloca pointer should never escape, but we are not taking advantage of this anyway git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159952 91177308-0d34-0410-b5e6-96231b3b80d8
* Replacing zero-sized alloca's with a null pointer is too aggressive, insteadDuncan Sands2012-06-26
| | | | | | | | | | | | | | | | | merge all zero-sized alloca's into one, fixing c43204g from the Ada ACATS conformance testsuite. What happened there was that a variable sized object was being allocated on the stack, "alloca i8, i32 %size". It was then being passed to another function, which tested that the address was not null (raising an exception if it was) then manipulated %size bytes in it (load and/or store). The optimizers cleverly managed to deduce that %size was zero (congratulations to them, as it isn't at all obvious), which made the alloca zero size, causing the optimizers to replace it with null, which then caused the check mentioned above to fail, and the exception to be raised, wrongly. Note that no loads and stores were actually being done to the alloca (the loop that does them is executed %size times, i.e. is not executed), only the not-null address check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159202 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach InstCombine to nuke a common alloca pattern -- an alloca which hasChandler Carruth2012-04-08
| | | | | | | | | | | | GEPs, bit casts, and stores reaching it but no other instructions. These often show up during the iterative processing of the inliner, SROA, and DCE. Once we hit this point, we can completely remove the alloca. These were actually showing up in the final, fully optimized code in a bunch of inliner tests I've been working on, and notably they show up after LLVM finishes optimizing away all function calls involved in hash_combine(a, b). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154285 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r152907.Bill Wendling2012-03-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152935 91177308-0d34-0410-b5e6-96231b3b80d8
* The alignment of the pointer part of the store instruction may have anBill Wendling2012-03-16
| | | | | | | | | | | alignment. If that's the case, then we want to make sure that we don't increase the alignment of the store instruction. Because if we increase it to be "more aligned" than the pointer, code-gen may use instructions which require a greater alignment than the pointer guarantees. <rdar://problem/11043589> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152907 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the getFirstInsertionPt() method instead of getFirstNonPHI + an 'isa<>'Bill Wendling2011-08-16
| | | | | | | check for a LandingPadInst. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137745 91177308-0d34-0410-b5e6-96231b3b80d8
* A few places where we want to skip the landingpad instruction for insertion.Bill Wendling2011-08-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137712 91177308-0d34-0410-b5e6-96231b3b80d8
* Update instcombine for atomic load/store.Eli Friedman2011-08-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137664 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135904 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to useJay Foad2011-07-22
| | | | | | | ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135761 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an MSVC warning, caused by a case I missed when convertingJay Foad2011-07-22
| | | | | | ConstantExpr::getGetElementPtr to use ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135758 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
* Final step of instcombine debuginfo; switch a couple more places over to ↵Eli Friedman2011-05-27
| | | | | | InsertNewInstWith, and use setDebugLoc for the cases which can't be easily handled by the automated mechanisms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132167 91177308-0d34-0410-b5e6-96231b3b80d8
* More instcombine cleanup, towards improving debug line info.Eli Friedman2011-05-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131604 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove PHINode::reserveOperandSpace(). Instead, add a parameter toJay Foad2011-03-30
| | | | | | PHINode::Create() giving the (known or expected) number of operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128537 91177308-0d34-0410-b5e6-96231b3b80d8
* This case is solved by Scalar Replacement of Aggregates (DT) andJin-Gu Kang2011-03-14
| | | | | | | Early CSE pass so this patch reverts it to original source code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127574 91177308-0d34-0410-b5e6-96231b3b80d8
* Add comment as following:Jin-Gu Kang2011-03-13
| | | | | | | | | | | | | | | | | | load and store reference same memory location, the memory location is represented by getelementptr with two uses (load and store) and the getelementptr's base is alloca with single use. At this point, instructions from alloca to store can be removed. (this pattern is generated when bitfield is accessed.) For example, %u = alloca %struct.test, align 4 ; [#uses=1] %0 = getelementptr inbounds %struct.test* %u, i32 0, i32 0;[#uses=2] %1 = load i8* %0, align 4 ; [#uses=1] %2 = and i8 %1, -16 ; [#uses=1] %3 = or i8 %2, 5 ; [#uses=1] store i8 %3, i8* %0, align 4 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127565 91177308-0d34-0410-b5e6-96231b3b80d8