summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* [msan] Workaround for invalid origins in shufflevector.Evgeniy Stepanov2014-06-091-4/+8
| | | | | | | | | Makes origin propagation ignore literal undef operands, and, in general, any operand we don't have origin for. https://code.google.com/p/memory-sanitizer/issues/detail?id=56 llvm-svn: 210472
* Fix line numbers for code inlined from __nodebug__ functions.Evgeniy Stepanov2014-06-091-1/+7
| | | | | | | | | | | | | | Instructions from __nodebug__ functions don't have file:line information even when inlined into no-nodebug functions. As a result, intrinsics (SSE and other) from <*intrin.h> clang headers _never_ have file:line information. With this change, an instruction without !dbg metadata gets one from the call instruction when inlined. Fixes PR19001. llvm-svn: 210459
* [msan] Fix vector pack intrinsic handling.Evgeniy Stepanov2014-06-091-8/+72
| | | | | | | | | This fixes a crash on MMX intrinsics, as well as a corner case in handling of all unsigned pack intrinsics. PR19953. llvm-svn: 210454
* [SeparateConstOffsetFromGEP] inbounds zext => sext for better splittingJingyue Wu2014-06-081-1/+57
| | | | | | | | | | For each array index that is in the form of zext(a), convert it to sext(a) if we can prove zext(a) <= max signed value of typeof(a). The conversion helps to split zext(x + y) into sext(x) + sext(y). Reviewed in http://reviews.llvm.org/D4060 llvm-svn: 210444
* [C++11] Use 'nullptr'.Craig Topper2014-06-081-1/+1
| | | | llvm-svn: 210442
* [SeparateConstOffsetFromGEP] Fix an illegitimate optimization on zextJingyue Wu2014-06-081-2/+2
| | | | | | | | | | zext(a + b) != zext(a) + zext(b) even if a + b >= 0 && b >= 0. e.g., a = i4 0b1111, b = i4 0b0001 zext a + b to i8 = zext 0b0000 to i8 = 0b00000000 (zext a to i8) + (zext b to i8) = 0b00001111 + 0b00000001 = 0b00010000 llvm-svn: 210439
* Refactor canonicalizing array indices to a helper functionJingyue Wu2014-06-081-32/+51
| | | | | | No functionality changes. llvm-svn: 210438
* Revert 209903 and 210040.Rafael Espindola2014-06-071-40/+0
| | | | | | | | | | | | The messages were "PR19753: Optimize comparisons with "ashr exact" of a constanst." "Added support to optimize comparisons with "lshr exact" of a constant." They were not correctly handling signed/unsigned operation differences, causing pr19958. llvm-svn: 210393
* InstCombine: Canonicalize addrspacecast between different element typesJingyue Wu2014-06-061-1/+23
| | | | | | | | | | | | | | | | addrspacecast X addrspace(M)* to Y addrspace(N)* --> bitcast X addrspace(M)* to Y addrspace(M)* addrspacecast Y addrspace(M)* to Y addrspace(N)* Updat all affected tests and add several new tests in addrspacecast.ll. This patch is based on http://reviews.llvm.org/D2186 (authored by Matt Arsenault) with fixes and more tests. llvm-svn: 210375
* [SLP] Enable vectorization of GEP expressions.Michael Zolotukhin2014-06-061-0/+87
| | | | | | | | The use cases look like the following: x->a = y->a + 10 x->b = y->b + 12 llvm-svn: 210342
* Added select flavour for ABS and NEG(ABS)Dinesh Dwivedi2014-06-062-20/+51
| | | | | | | | | | | | | | | | This patch can identify ABS(X) ==> (X >s 0) ? X : -X and (X >s -1) ? X : -X ABS(X) ==> (X <s 0) ? -X : X and (X <s 1) ? -X : X NABS(X) ==> (X >s 0) ? -X : X and (X >s -1) ? -X : X NABS(X) ==> (X <s 0) ? X : -X and (X <s 1) ? X : -X and can transform ABS(ABS(X)) -> ABS(X) NABS(NABS(X)) -> NABS(X) Differential Revision: http://reviews.llvm.org/D3658 llvm-svn: 210312
* Fix PR19657 (scalar loads not combined into vector load)Karthik Bhat2014-06-061-2/+14
| | | | | | | | If we have common uses on separate paths in the tree; process the one with greater common depth first. This makes sure that we do not assume we need to extract a load when it is actually going to be part of a vectorized tree. Review: http://reviews.llvm.org/D3800 llvm-svn: 210310
* Fixed several correctness issues in SeparateConstOffsetFromGEPJingyue Wu2014-06-051-204/+338
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most issues are on mishandling s/zext. Fixes: 1. When rebuilding new indices, s/zext should be distributed to sub-expressions. e.g., sext(a +nsw (b +nsw 5)) = sext(a) + sext(b) + 5 but not sext(a + b) + 5. This also affects the logic of recursively looking for a constant offset, we need to include s/zext into the context of the searching. 2. Function find should return the bitwidth of the constant offset instead of always sign-extending it to i64. 3. Stop shortcutting zext'ed GEP indices. LLVM conceptually sign-extends GEP indices to pointer-size before computing the address. Therefore, gep base, zext(a + b) != gep base, a + b Improvements: 1. Add an optimization for splitting sext(a + b): if a + b is proven non-negative (e.g., used as an index of an inbound GEP) and one of a, b is non-negative, sext(a + b) = sext(a) + sext(b) 2. Function Distributable checks whether both sext and zext can be distributed to operands of a binary operator. This helps us split zext(sext(a + b)) to zext(sext(a) + zext(sext(b)) when a + b does not signed or unsigned overflow. Refactoring: Merge some common logic of handling add/sub/or in find. Testing: Add many tests in split-gep.ll and split-gep-and-gvn.ll to verify the changes we made. llvm-svn: 210291
* [PPC64LE] Correct vperm -> shuffle transform for little endianBill Schmidt2014-06-051-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in cfe commit r210279, the correct little-endian semantics for the vec_perm Altivec interfaces are implemented by reversing the order of the input vectors and complementing the permute control vector. This converts the desired permute from little endian element order into the big endian element order that the underlying PowerPC vperm instruction uses. This is represented with a ppc_altivec_vperm intrinsic function. The instruction combining pass contains code to convert a ppc_altivec_vperm intrinsic into a vector shuffle operation when the intrinsic has a permute control vector (mask) that is a constant. However, the vector shuffle operation assumes that vector elements are in natural order for their endianness, so for little endian code we will get the wrong result with the existing transformation. This patch reverses the semantic change to vec_perm that was performed in altivec.h by once again swapping the input operands and complementing the permute control vector, returning the element ordering to little endian. The correctness of this code is tested by the new perm.c test added in a previous patch, and by other tests in the test suite that fail without this patch. llvm-svn: 210282
* Removing spurious dependency of IPO on JumpInstrTablesTom Roeder2014-06-051-1/+0
| | | | llvm-svn: 210281
* Add a new attribute called 'jumptable' that creates jump-instruction tables ↵Tom Roeder2014-06-051-0/+1
| | | | | | | | | | | | for functions marked with this attribute. It includes a pass that rewrites all indirect calls to jumptable functions to pass through these tables. This also adds backend support for generating the jump-instruction tables on ARM and X86. Note that since the jumptable attribute creates a second function pointer for a function, any function marked with jumptable must also be marked with unnamed_addr. llvm-svn: 210280
* [asancov] Fix coverage line info some more.Evgeniy Stepanov2014-06-051-2/+4
| | | | | | | Now it should always point to the opening brace of the function (in -asan-coverage=1 mode). llvm-svn: 210266
* Fix coverage for files with global constructors again. Adds a testcase to ↵Nick Lewycky2014-06-051-0/+10
| | | | | | the commit from r206671, as requested by David Blaikie. llvm-svn: 210239
* Explain why we skip DbgInfoIntrinsics when looking at line numbers in .gcno ↵Nick Lewycky2014-06-041-0/+4
| | | | | | file emission. llvm-svn: 210218
* Add a Constant version of stripPointerCasts.Rafael Espindola2014-06-041-3/+3
| | | | | | Thanks to rnk for the suggestion. llvm-svn: 210205
* Clauses in a landingpad are always Constant. Use a stricter type.Rafael Espindola2014-06-041-4/+4
| | | | llvm-svn: 210203
* InstCombine: Improvement to check if signed addition overflows.Rafael Espindola2014-06-041-7/+46
| | | | | | | | | | | | | | | | | | This patch implements two things: 1. If we know one number is positive and another is negative, we return true as signed addition of two opposite signed numbers will never overflow. 2. Implemented TODO : If one of the operands only has one non-zero bit, and if the other operand has a known-zero bit in a more significant place than it (not including the sign bit) the ripple may go up to and fill the zero, but won't change the sign. e.x - (x & ~4) + 1 We make sure that we are ignoring 0 at MSB. Patch by Suyog Sarda. llvm-svn: 210186
* [asan] Fix coverage instrumentation with -asan-globals=0.Evgeniy Stepanov2014-06-031-25/+32
| | | | llvm-svn: 210103
* Ignore line numbers on debug intrinsics. Add an assert to ensure that we ↵Nick Lewycky2014-06-031-2/+4
| | | | | | aren't emitting line number zero, the .gcno format uses this to indicate that the next field is a filename. llvm-svn: 210068
* Allow alias to point to an arbitrary ConstantExpr.Rafael Espindola2014-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | This patch changes GlobalAlias to point to an arbitrary ConstantExpr and it is up to MC (or the system assembler) to decide if that expression is valid or not. This reduces our ability to diagnose invalid uses and how early we can spot them, but it also lets us do things like @test5 = alias inttoptr(i32 sub (i32 ptrtoint (i32* @test2 to i32), i32 ptrtoint (i32* @bar to i32)) to i32*) An important implication of this patch is that the notion of aliased global doesn't exist any more. The alias has to encode the information needed to access it in its metadata (linkage, visibility, type, etc). Another consequence to notice is that getSection has to return a "const char *". It could return a NullTerminatedStringRef if there was such a thing, but when that was proposed the decision was to just uses "const char*" for that. llvm-svn: 210062
* Add back commit r210029.Rafael Espindola2014-06-021-4/+19
| | | | | | | | The code was actually correct. Sorry for the confusion. I have expanded the comment saying why the analysis is valid to avoid me misunderstaning it again in the future. llvm-svn: 210052
* Revert "Add the nsw flag when we detect that an add will not signed overflow."Rafael Espindola2014-06-021-5/+0
| | | | | | | | | This reverts commit r210029. It was not correctly handling cases where LHS and RHS had multiple but different sign bits. llvm-svn: 210048
* Added support to optimize comparisons with "lshr exact" of a constant.Rafael Espindola2014-06-021-6/+29
| | | | | | Patch by Rahul Jain. llvm-svn: 210040
* Remove sanitizer blacklist from ASan/TSan/MSan function passes.Alexey Samsonov2014-06-023-45/+14
| | | | | | | | | | | | | | | | | Instrumentation passes now use attributes address_safety/thread_safety/memory_safety which are added by Clang frontend. Clang parses the blacklist file and adds the attributes accordingly. Currently blacklist is still used in ASan module pass to disable instrumentation for certain global variables. We should fix this as well by collecting the set of globals we're going to instrument in Clang and passing it to ASan in metadata (as we already do for dynamically-initialized globals and init-order checking). This change also removes -tsan-blacklist and -msan-blacklist LLVM commandline flags in favor of -fsanitize-blacklist= Clang flag. llvm-svn: 210038
* Add the nsw flag when we detect that an add will not signed overflow.Rafael Espindola2014-06-021-0/+5
| | | | | | | We already had a function for checking this, we were just using it only in specialized cases. llvm-svn: 210029
* [msan] Remove an out-of-date comment.Evgeniy Stepanov2014-06-021-2/+0
| | | | | | MSan is no longer an "early prototype". llvm-svn: 210023
* [msan] Handle x86 vector pack intrinsics.Evgeniy Stepanov2014-06-021-0/+36
| | | | llvm-svn: 210020
* Added inst combine tarnsform for (1 << X) & C pattrens where C is (some ↵Dinesh Dwivedi2014-06-021-8/+24
| | | | | | | | | | | | PowerOf2 - 1) This patch can handles following cases from http://nondot.org/sabre/LLVMNotes/InstCombine.txt "((1 << X) & 7) == 0" ==> "X > 2" "((1 << X) & 7) != 0" ==> "X < 3". Differential Revision: http://reviews.llvm.org/D3678 llvm-svn: 210007
* Added inst combine transforms for single bit tests from Chris's noteDinesh Dwivedi2014-06-021-1/+28
| | | | | | | | | | | | if ((x & C) == 0) x |= C becomes x |= C if ((x & C) != 0) x ^= C becomes x &= ~C if ((x & C) == 0) x ^= C becomes x |= C if ((x & C) != 0) x &= ~C becomes x &= ~C if ((x & C) == 0) x &= ~C becomes nothing Differential Revision: http://reviews.llvm.org/D3777 llvm-svn: 210006
* [Reassociate] Similar to "X + -X" -> "0", added code to handle "X + ~X" -> "-1".Benjamin Kramer2014-05-311-8/+23
| | | | | | | | | | | | Handle "X + ~X" -> "-1" in the function Value *Reassociate::OptimizeAdd(Instruction *I, SmallVectorImpl<ValueEntry> &Ops); This patch implements: TODO: We could handle "X + ~X" -> "-1" if we wanted, since "-X = ~X+1". Patch by Rahul Jain! Differential Revision: http://reviews.llvm.org/D3835 llvm-svn: 209973
* [ASan] Behave the same for functions w/o sanitize_address attribute and ↵Alexey Samsonov2014-05-311-2/+1
| | | | | | blacklisted functions llvm-svn: 209946
* [TSan] Behave the same for functions w/o sanitize_thread attribute and ↵Alexey Samsonov2014-05-311-5/+7
| | | | | | blacklisted functions llvm-svn: 209939
* Make bitcast, extractelement, and insertelement considered cheap for ↵Matt Arsenault2014-05-301-0/+3
| | | | | | | | | | speculation. This helps more branches into selects. On R600, vectors are cheap and anything that helps remove branches is very good. llvm-svn: 209914
* PR19753: Optimize comparisons with "ashr exact" of a constanst.Rafael Espindola2014-05-301-0/+17
| | | | | | Patch by suyog sarda. llvm-svn: 209903
* Allow vectorization of intrinsics such as powi,cttz and ctlz in Loop and SLP ↵Karthik Bhat2014-05-302-2/+42
| | | | | | | | | | Vectorizer. This patch adds support to vectorize intrinsics such as powi, cttz and ctlz in Vectorizer. These intrinsics are different from other intrinsics as second argument to these function must be same in order to vectorize them and it should be represented as a scalar. Review: http://reviews.llvm.org/D3851#inline-32769 and http://reviews.llvm.org/D3937#inline-32857 llvm-svn: 209873
* When analyzing params/args for readnone/readonly, don't forget to consider ↵Nick Lewycky2014-05-301-1/+18
| | | | | | that a pointer argument may be passed through a callsite to the return, and that we may need to analyze it. Fixes a bug reported on llvm-dev: http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-May/073098.html llvm-svn: 209870
* And fix my fix to sink down through the type at the right time. MyChandler Carruth2014-05-291-8/+9
| | | | | | | | | original fix would actually trigger the *exact* same crasher as the original bug for a different reason. Awesomesauce. Working on test cases now, but wanted to get bots healthier. llvm-svn: 209860
* Fix one bug in the latest incarnation of r209843 -- combining GEPsChandler Carruth2014-05-291-8/+13
| | | | | | | | | | across PHI nodes. The code was computing the Idxs from the 'GEP' variable's indices when what it wanted was Op1's indices. This caused an ASan heap-overflow for me that pin pointed the issue when Op1 had more indices than GEP did. =] I'll let Louis add a specific test case for this if he wants. llvm-svn: 209857
* LoopVectorizer: Add a check that the backedge taken count + 1 does not overflowArnold Schwaighofer2014-05-291-34/+95
| | | | | | | | | | | The loop vectorizer instantiates be-taken-count + 1 as the loop iteration count. If this expression overflows the generated code was invalid. In case of overflow the code now jumps to the scalar loop. Fixes PR17288. llvm-svn: 209854
* Add support for combining GEPs across PHI nodesLouis Gerbarg2014-05-291-0/+79
| | | | | | | | | | | | | | | | | | | | | | | | Currently LLVM will generally merge GEPs. This allows backends to use more complex addressing modes. In some cases this is not happening because there is PHI inbetween the two GEPs: GEP1--\ |-->PHI1-->GEP3 GEP2--/ This patch checks to see if GEP1 and GEP2 are similiar enough that they can be cloned (GEP12) in GEP3's BB, allowing GEP->GEP merging (GEP123): GEP1--\ --\ --\ |-->PHI1-->GEP3 ==> |-->PHI2->GEP12->GEP3 == > |-->PHI2->GEP123 GEP2--/ --/ --/ This also breaks certain use chains that are preventing GEP->GEP merges that the the existing instcombine would merge otherwise. Tests included. llvm-svn: 209843
* Use range-based for loops in ASan, TSan and MSanAlexey Samsonov2014-05-293-97/+81
| | | | llvm-svn: 209834
* Revert "Revert "Revert "InstCombine: Improvement to check if signed addition ↵Rafael Espindola2014-05-291-44/+6
| | | | | | | | | | overflows.""" This reverts commit r209776. It was miscompiling llvm::SelectionDAGISel::MorphNode. llvm-svn: 209817
* LCSSA should be performed on the outermost affected loop while unrolling loop.Dinesh Dwivedi2014-05-291-0/+9
| | | | | | | | | | During loop-unroll, loop exits from the current loop may end up in in different outer loop. This requires to re-form LCSSA recursively for one level down from the outer most loop where loop exits are landed during unroll. This fixes PR18861. Differential Revision: http://reviews.llvm.org/D2976 llvm-svn: 209796
* Add LoadCombine pass.Michael J. Spencer2014-05-294-0/+281
| | | | | | | | This pass is disabled by default. Use -combine-loads to enable in -O[1-3] Differential revision: http://reviews.llvm.org/D3580 llvm-svn: 209791
* [ASan] Hoist blacklisting globals from init-order checking to Clang.Alexey Samsonov2014-05-291-2/+0
| | | | | | | | | Clang knows about the sanitizer blacklist and it makes no sense to add global to the list of llvm.asan.dynamically_initialized_globals if it will be blacklisted in the instrumentation pass anyway. Instead, we should do as much blacklisting as possible (if not all) in the frontend. llvm-svn: 209790
OpenPOWER on IntegriCloud