summaryrefslogtreecommitdiff
path: root/test/Transforms/ScalarRepl
Commit message (Collapse)AuthorAge
* Fix a crash in scalarrepl for memcpy/memmove where the source and destinationBob Wilson2010-01-19
| | | | | | | | | | are the same. I had already fixed a similar problem where the source and destination were different bitcasts derived from the same alloca, but the previous fix still did not handle the case where both operands are exactly the same value. Radar 7552893. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93848 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete useless trailing semicolons.Dan Gohman2010-01-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92740 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize SROA to allow the first index of a GEP to be non-zero. Add aBob Wilson2009-12-22
| | | | | | | | | missing check that an array reference doesn't go past the end of the array, and remove some redundant checks for in-bound array and vector references that are no longer needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91897 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply 91459 with a simple fix for the problem that broke the x86_64-darwinBob Wilson2009-12-18
| | | | | | | | bootstrap. This also replaces the WeakVH references that Chris objected to with normal Value references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91711 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-revert 91459. It's breaking the x86_64 darwin bootstrap.Bob Wilson2009-12-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91607 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r91459, it was only unmasking the bug, and since TOT is still broken ↵Daniel Dunbar2009-12-16
| | | | | | having it reverted does no good. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91559 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Reapply 91184 with fixes and an addition to the testcase to cover theDaniel Dunbar2009-12-16
| | | | | | | | | problem", this broke llvm-gcc bootstrap for release builds on x86_64-apple-darwin10. This reverts commit db22309800b224a9f5f51baf76071d7a93ce59c9. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91534 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply 91184 with fixes and an addition to the testcase to cover the problemBob Wilson2009-12-15
| | | | | | | | | | | found last time. Instead of trying to modify the IR while iterating over it, I've change it to keep a list of WeakVH references to dead instructions, and then delete those instructions later. I also added some special case code to detect and handle the situation when both operands of a memcpy intrinsic are referencing the same alloca. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91459 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove empty file completelyShantonu Sen2009-12-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91277 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r91184, because it causes a crash on a .bc file I justChris Lattner2009-12-14
| | | | | | | sent to Bob. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91268 91177308-0d34-0410-b5e6-96231b3b80d8
* Revise scalar replacement to be more flexible about handle bitcasts and GEPs.Bob Wilson2009-12-11
| | | | | | | | | | | | | | | | While scanning through the uses of an alloca, keep track of the current offset relative to the start of the alloca, and check memory references to see if the offset & size correspond to a component within the alloca. This has the nice benefit of unifying much of the code from isSafeUseOfAllocation, isSafeElementUse, and isSafeUseOfBitCastedAllocation. The code to rewrite the uses of a promoted alloca, after it is determined to be safe, is reorganized in the same way. Also, when rewriting GEP instructions, mark them as "in-bounds" since all the indices are known to be safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91184 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR5436 by making the 'simple' case of SRoA not promote out of range Chris Lattner2009-11-27
| | | | | | | | | | | array indexes. The "complex" case of SRoA still handles them, and correctly. This fixes a weirdness where we'd correctly avoid transforming A[0][42] if the 42 was too large, but we'd only do it if it was one gep, not two separate ones. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90007 91177308-0d34-0410-b5e6-96231b3b80d8
* filecheckizeChris Lattner2009-11-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90006 91177308-0d34-0410-b5e6-96231b3b80d8
* Make opt default to not adding a target data string and update tests that ↵Kenneth Uildriks2009-11-03
| | | | | | depend on target data to supply it within the test git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85900 91177308-0d34-0410-b5e6-96231b3b80d8
* Change tests from "opt %s" to "opt < %s" so that opt doesn't see theDan Gohman2009-09-11
| | | | | | | | | input filename so that opt doesn't print the input filename in the output so that grep lines in the tests don't unintentionally match strings in the input filename. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81537 91177308-0d34-0410-b5e6-96231b3b80d8
* Use opt -S instead of piping bitcode output through llvm-dis.Dan Gohman2009-09-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81257 91177308-0d34-0410-b5e6-96231b3b80d8
* Change these tests to feed the assembly files to opt directly, insteadDan Gohman2009-09-08
| | | | | | | of using llvm-as, now that opt supports this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81226 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't crash trying to promote VLAs.Nick Lewycky2009-08-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79226 91177308-0d34-0410-b5e6-96231b3b80d8
* Split the Add, Sub, and Mul instruction opcodes into separateDan Gohman2009-06-04
| | | | | | | | | | | | | | | | integer and floating-point opcodes, introducing FAdd, FSub, and FMul. For now, the AsmParser, BitcodeReader, and IRBuilder all preserve backwards compatability, and the Core LLVM APIs preserve backwards compatibility for IR producers. Most front-ends won't need to change immediately. This implements the first step of the plan outlined here: http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
* PR4286: Make RewriteLoadUserOfWholeAlloca and Eli Friedman2009-06-01
| | | | | | | | | | RewriteStoreUserOfWholeAlloca deal with tail padding because isSafeUseOfBitCastedAllocation expects them to. Otherwise, we crash trying to erase the bitcast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72688 91177308-0d34-0410-b5e6-96231b3b80d8
* fix RewriteStoreUserOfWholeAlloca to use the correct type sizeChris Lattner2009-05-08
| | | | | | | | | | method, fixing a crash on PR4146. While the store will ultimately overwrite the "padded size" number of bits in memory, the stored value may be a subset of this size. This function only wants to handle the case where all bits are stored. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71224 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a crash on a pointless but valid zero-length memset, rdar://6808691Chris Lattner2009-04-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69680 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug.Zhou Sheng2009-03-18
| | | | | | | If I->use_empty(), this method should return false. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67180 91177308-0d34-0410-b5e6-96231b3b80d8
* teach SROA to handle promoting vector allocas with a memset into them intoChris Lattner2009-03-08
| | | | | | | | a vector type instead of into an integer type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66368 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance SROA to "promote to scalar" allocas which are Chris Lattner2009-03-08
| | | | | | | | memcpy/memmove'd into or out of. This fixes a serious perf issue that Nate ran into. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66366 91177308-0d34-0410-b5e6-96231b3b80d8
* While converting an aggregate to scalare, ignore and remove aggregate's ↵Devang Patel2009-03-06
| | | | | | debug info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66262 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR3720 by properly propagating alignment information from memcpy/memmove Chris Lattner2009-03-04
| | | | | | | onto element accesses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66053 91177308-0d34-0410-b5e6-96231b3b80d8
* adjust for asmprinter change.Chris Lattner2009-03-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65741 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable scalar replacement of AllocaInst whose one of the user is dbg info.Devang Patel2009-02-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64207 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR3489, use bits instead of bytes.Chris Lattner2009-02-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63916 91177308-0d34-0410-b5e6-96231b3b80d8
* teach "convert from scalar" to handle loads of fca's.Chris Lattner2009-02-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63659 91177308-0d34-0410-b5e6-96231b3b80d8
* make scalar conversion handle stores of first classChris Lattner2009-02-03
| | | | | | | | aggregate values. loads are not yet handled (coming soon to an sroa near you). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63649 91177308-0d34-0410-b5e6-96231b3b80d8
* Make SROA produce a vector only when the alloca is actually Chris Lattner2009-02-03
| | | | | | | | | | | | | | | | | | | | | accessed at least once as a vector. This prevents it from compiling the example in not-a-vector into: define double @test(double %A, double %B) { %tmp4 = insertelement <7 x double> undef, double %A, i32 0 %tmp = insertelement <7 x double> %tmp4, double %B, i32 4 %tmp2 = extractelement <7 x double> %tmp, i32 4 ret double %tmp2 } instead, producing the integer code. Producing vectors when they aren't otherwise in the program is dangerous because a lot of other code treats them carefully and doesn't want to break them down. OTOH, many things want to break down tasty i448's. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63638 91177308-0d34-0410-b5e6-96231b3b80d8
* this produces an undefined result, just check that the alloca is goneChris Lattner2009-02-03
| | | | | | | and that sroa doesn't crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63637 91177308-0d34-0410-b5e6-96231b3b80d8
* add another case of undefined behavior without crashing, PR3466.Chris Lattner2009-02-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63620 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ConvertUsesToScalar to handle memset, allowing it to handle Chris Lattner2009-02-03
| | | | | | | | | | | | | | | | crazy cases like: struct f { int A, B, C, D, E, F; }; short test4() { struct f A; A.A = 1; memset(&A.B, 2, 12); return A.C; } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63596 91177308-0d34-0410-b5e6-96231b3b80d8
* rearrange how SRoA handles promotion of allocas to vectors.Chris Lattner2009-02-03
| | | | | | | | | | | | With the new world order, it can handle cases where the first store into the alloca is an element of the vector, instead of requiring the first analyzed store to have the vector type itself. This allows us to un-xfail test/CodeGen/X86/vec_ins_extract.ll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63590 91177308-0d34-0410-b5e6-96231b3b80d8
* this test produces an undefined value, we don't careChris Lattner2009-02-03
| | | | | | | what it is, but we do want the alloca promoted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63587 91177308-0d34-0410-b5e6-96231b3b80d8
* update testChris Lattner2009-02-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63532 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug which caused us to miscompile a couple of AdaChris Lattner2009-02-02
| | | | | | | tests. Thanks for the beautiful reduced testcase Duncan! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63529 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify and generalize the SROA "convert to scalar" transformation toChris Lattner2009-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | be able to handle *ANY* alloca that is poked by loads and stores of bitcasts and GEPs with constant offsets. Before the code had a number of annoying limitations and caused it to miss cases such as storing into holes in structs and complex casts (as in bitfield-sroa) where we had unions of bitfields etc. This also handles a number of important cases that are exposed due to the ABI lowering stuff we do to pass stuff by value. One case that is pretty great is that we compile 2006-11-07-InvalidArrayPromote.ll into: define i32 @func(<4 x float> %v0, <4 x float> %v1) nounwind { %tmp10 = call <4 x i32> @llvm.x86.sse2.cvttps2dq(<4 x float> %v1) %tmp105 = bitcast <4 x i32> %tmp10 to i128 %tmp1056 = zext i128 %tmp105 to i256 %tmp.upgrd.43 = lshr i256 %tmp1056, 96 %tmp.upgrd.44 = trunc i256 %tmp.upgrd.43 to i32 ret i32 %tmp.upgrd.44 } which turns into: _func: subl $28, %esp cvttps2dq %xmm1, %xmm0 movaps %xmm0, (%esp) movl 12(%esp), %eax addl $28, %esp ret Which is pretty good code all things considering :). One effect of this is that SROA will start generating arbitrary bitwidth integers that are a multiple of 8 bits. In the case above, we got a 256 bit integer, but the codegen guys assure me that it can handle the simple and/or/shift/zext stuff that we're doing on these operations. This addresses rdar://6532315 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63469 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix some issues with volatility, move "CanConvertToScalar" check Chris Lattner2009-01-28
| | | | | | | after the others. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63227 91177308-0d34-0410-b5e6-96231b3b80d8
* strengthen this test.Chris Lattner2009-01-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63222 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR3304Chris Lattner2009-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61995 91177308-0d34-0410-b5e6-96231b3b80d8
* This implements the second half of the fix for PR3290, handlingChris Lattner2009-01-08
| | | | | | | | | | | | loads from allocas that cover the entire aggregate. This handles some memcpy/byval cases that are produced by llvm-gcc. This triggers a few times in kc++ (with std::pair<std::_Rb_tree_const_iterator <kc::impl_abstract_phylum*>,bool>) and once in 176.gcc (with %struct..0anon). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61915 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the first half of PR3290: if there is a store of an Chris Lattner2009-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | integer to a (transitive) bitcast the alloca and if that integer has the full size of the alloca, then it clobbers the whole thing. Handle this by extracting pieces out of the stored integer and filing them away in the SROA'd elements. This triggers fairly frequently because the CFE uses integers to pass small structs by value and the inliner exposes these. For example, in kimwitu++, I see a bunch of these with i64 stores to "%struct.std::pair<std::_Rb_tree_const_iterator<kc::impl_abstract_phylum*>,bool>" In 176.gcc I see a few i32 stores to "%struct..0anon". In the testcase, this is a difference between compiling test1 to: _test1: subl $12, %esp movl 20(%esp), %eax movl %eax, 4(%esp) movl 16(%esp), %eax movl %eax, (%esp) movl (%esp), %eax addl 4(%esp), %eax addl $12, %esp ret vs: _test1: movl 8(%esp), %eax addl 4(%esp), %eax ret The second half of this will be to handle loads of the same form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61853 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow scalarrepl to treat an all-zero GEP just as bitcast.Matthijs Kooijman2008-10-06
| | | | | | | | This includes not marking a GEP involving a vector as unsafe, but only when it has all zero indices. This allows scalarrepl to work in a few more cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57177 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a testcase showing that scalarrepl supports first class structs.Matthijs Kooijman2008-09-29
| | | | | | | | I originally made this script to show that scalarrepl didn't support them, but it turned out it does. Better to still add the testcase then. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56781 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR2423 by checking all indices for out of range access, not only Chris Lattner2008-08-23
| | | | | | | | indices that start with an array subscript. x->field[10000] is just as bad as (*X)[14][10000]. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55226 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR2369 by making scalarrepl more careful about promoting Chris Lattner2008-06-22
| | | | | | | | | | | structures. Its default threshold is to promote things that are smaller than 128 bytes, which is sane. However, it is not sane to do this for things that turn into 128 *registers*. Add a cap on the number of registers introduced, defaulting to 128/4=32. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52611 91177308-0d34-0410-b5e6-96231b3b80d8