Commit Graph

9509 Commits

Author SHA1 Message Date
Nadav Rotem
d7e0b7cdc5 The induction-pointer work is inspired by a research paper. This commit adds a reference.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168559 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-25 09:09:26 +00:00
Nadav Rotem
0af63ac245 Add support for pointer induction variables even when there is no integer induction variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168558 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-25 08:41:35 +00:00
Benjamin Kramer
4ccb49a838 CodeGenPrepare: Move ret duplication out of the instruction iteration loop.
It can delete the block, and the loop continues on free'd memory.
No change in output. Found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168525 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-23 19:17:06 +00:00
Joey Gouly
f284aefa11 Remove unused parameter Penalty from the BoundsChecking pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168511 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-23 10:47:35 +00:00
NAKAMURA Takumi
d59c07255e llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp: Prune AddressSanitizerCreateGlobalRedzonesPass::ID. [-Wunused-variable]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168499 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-22 14:18:25 +00:00
Kostya Serebryany
b9a12ea0fd [asan] rip off the creation of global redzones from the main AddressSanitizer class into a separate class. The intent is to make it a separate ModulePass in the following commmits
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168484 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-22 03:18:50 +00:00
Chandler Carruth
07df765e65 PR14055: Implement support for sub-vector operations in SROA.
Now if we can transform an alloca into a single vector value, but it has
subvector, non-element accesses, we form the appropriate shufflevectors
to allow SROA to proceed. This fixes PR14055 which pointed out a very
common pattern that SROA couldn't handle -- mixed vec3 and vec4
operations on a single alloca.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168418 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-21 08:16:30 +00:00
Kostya Serebryany
51c7c65e32 [asan] use names of globals instead of an external set to distinguish the globals generated by asan
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168368 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 14:16:08 +00:00
Kostya Serebryany
407790604b [asan] don't instrument linker-initialized globals even with external linkage in -asan-initialization-order mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168367 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 13:11:32 +00:00
Kostya Serebryany
ca23d43084 [asan] make sure that linker-initialized globals (non-extern) are not instrumented even in -asan-initialization-order mode. This time with a test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168366 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 13:00:01 +00:00
Chandler Carruth
3a902d0ae7 Use LLVM_ENABLE_DUMP for the variables used in printing as well as the
printing functions themselves.

Part of PR14324 (which should have just been a patch to the list, but
hey...)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168362 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 10:23:07 +00:00
Chandler Carruth
176792990e Fix PR14132 and handle OOB loads speculated throuh PHI nodes.
The issue is that we may end up with newly OOB loads when speculating
a load into the predecessors of a PHI node, and this confuses the new
integer splitting logic in some cases, triggering an assertion failure.
In fact, the branch in question must be dead code as it loads from
a too-narrow alloca. Add code to handle this gracefully and leave the
requisite FIXMEs for both optimizing more aggressively and doing more to
aid sanitizing invalid code which triggers these patterns.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168361 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 10:02:19 +00:00
Bill Wendling
0976e00fd1 Make the AttrListPtr object a part of the LLVMContext.
When code deletes the context, the AttributeImpls that the AttrListPtr points to
are now invalid. Therefore, instead of keeping a separate managed static for the
AttrListPtrs that's reference counted, move it into the LLVMContext and delete
it when deleting the AttributeImpls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168354 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 05:09:20 +00:00
Chandler Carruth
a1237b16c9 Add a comment to associate a FIXME with a PR where it is matters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168347 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 01:27:48 +00:00
Chandler Carruth
f5837aacd4 Rework the rewriting of loads and stores for vector and integer allocas
to properly handle the combinations of these with split integer loads
and stores. This essentially replaces Evan's r168227 by refactoring the
code in a different way, and trynig to mirror that refactoring in both
the load and store sides of the rewriting.

Generally speaking there was some really problematic duplicated code
here that led to poorly founded assumptions and then subtle bugs. Now
much of the code actually flows through and follows a more consistent
style and logical path. There is still a tiny bit of duplication on the
store side of things, but it is much less bad.

This also changes the logic to never re-use a load or store instruction
as that was simply too error prone in practice.

I've added a few tests (one a reduction of the one in Evan's original
patch, which happened to be the same as the report in PR14349). I'm
going to look at adding a few more tests for things I found and fixed in
passing (such as the volatile tests in the vectorizable predicate).

This patch has survived bootstrap, and modulo one bugfix survived
Duncan's test suite, but let me know if anything else explodes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168346 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-20 01:12:50 +00:00
Bob Wilson
28f872f8a1 Clean up handling of always-inline functions in the inliner.
This patch moves the isInlineViable function from the InlineAlways pass into
the InlineCostAnalyzer and then changes the InlineCost computation to use that
simple check for always-inline functions. All the special-case checks for
AlwaysInline in the CallAnalyzer can then go away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168300 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-19 07:04:35 +00:00
Duncan Sands
820b52572f Remove the last bit of constant folding from LinearizeExprTree (most of it was
removed in commit 168035, but I missed this bit).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168292 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-18 20:15:36 +00:00
Duncan Sands
b8e1111fbf Fix PR14060, an infinite loop in reassociate. The problem was that one of the
operands of the expression being written was wrongly thought to be reusable as
an inner node of the expression resulting in it turning up as both an inner node
*and* a leaf, creating a cycle in the def-use graph.  This would have caused the
verifier to blow up if things had gotten that far, however it managed to provoke
an infinite loop first.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168291 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-18 19:27:01 +00:00
Nick Lewycky
294c965146 Don't try to calculate the alignment of an unsigned type. Fixes PR14371!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168280 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-18 05:39:39 +00:00
Benjamin Kramer
9e6ee16b18 Plug a memory leak in the GCOV profiling emitter, which never released the edge table memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168259 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 13:49:37 +00:00
Nadav Rotem
9a6823516f LoopVectorizer: Add initial support for pointer induction variables (for example: *dst++ = *src++).
At the moment we still require to have an integer induction variable (for example: i++).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168231 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 00:27:03 +00:00
Evan Cheng
fd22019ec3 Teach SROA rewriteVectorizedStoreInst to handle cases when the loaded value is narrower than the stored value. rdar://12713675
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168227 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 00:05:06 +00:00
Duncan Sands
4f0dfbb454 Make this easier to understand, as suggested by Chandler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168196 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-16 20:53:08 +00:00
Duncan Sands
afe4539f8e Fix PR14361: wrong simplification of A+B==B+A. You may think that the old logic
replaced by this patch is equivalent to the new logic, but you'd be wrong, and
that's exactly where the bug was.  There's a similar bug in instsimplify which
manifests itself as instsimplify failing to simplify this, rather than doing it
wrong, see next commit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168181 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-16 18:55:49 +00:00
Hans Wennborg
6eac2ba4de SimplifyCFG: Don't assume non-null ScalarTargetTransformInfo.
Patch by Pekka Jääskeläinen!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168176 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-16 18:22:08 +00:00
Nadav Rotem
77d6ae1b01 LoopVectorize: Division reductions generate incorrect code. Remove the part of the code that deals with divs.
Thanks to Paul Redmond for catching this while reviewing the code.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168142 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-16 06:51:17 +00:00
Andrew Trick
c2aa0035a6 misspell
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168058 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 18:40:31 +00:00
Andrew Trick
df523d456c whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168057 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 18:40:29 +00:00
Dmitri Gribenko
79c07d2a36 Use empty parens for empty function parameter list instead of '(void)'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168049 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 16:51:49 +00:00
Hans Wennborg
1839858983 Make GlobalOpt be conservative with TLS variables (PR14309)
For global variables that get the same value stored into them
everywhere, GlobalOpt will replace them with a constant. The problem is
that a thread-local GlobalVariable looks like one value (the address of
the TLS var), but is different between threads.

This patch introduces Constant::isThreadDependent() which returns true
for thread-local variables and constants which depend on them (e.g. a GEP
into a thread-local array), and teaches GlobalOpt not to track such
values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168037 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 11:40:00 +00:00
Duncan Sands
7ecfcc1639 Fix a crash observed by Shuxin Yang. The issue here is that LinearizeExprTree,
the utility for extracting a chain of operations from the IR, thought that it
might as well combine any constants it came across (rather than just returning
them along with everything else).  On the other hand, the factorization code
would like to see the individual constants (this is quite reasonable: it is
much easier to pull a factor of 3 out of 2*3 than it is to pull it out of 6;
you may think 6/3 isn't so hard, but due to overflow it's not as easy to undo
multiplications of constants as it may at first appear).  This patch therefore
makes LinearizeExprTree stupider: it now leaves optimizing to the optimization
part of reassociate, and sticks to just analysing the IR.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168035 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 09:58:38 +00:00
NAKAMURA Takumi
45fc0b65e2 InstCombineAndOrXor.cpp: Escape bracket in doxygen description. [-Wdocumentation]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168013 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 00:35:50 +00:00
Hal Finkel
97d19ebe5b Replace std::vector -> SmallVector in BBVectorize
For now, this uses 8 on-stack elements. I'll need to do some profiling
to see if this is the best number.

Pointed out by Jakob in post-commit review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167966 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 19:53:27 +00:00
Hal Finkel
d7a3425f06 Fix the largest offender of determinism in BBVectorize
Iterating over the children of each node in the potential vectorization
plan must happen in a deterministic order (because it affects which children
are erased when two children conflict). There was no need for this data
structure to be a map in the first place, so replacing it with a vector
is a small change.

I believe that this was the last remaining instance if iterating over the
elements of a Dense* container where the iteration order could matter.
There are some remaining iterations over std::*map containers where the order
might matter, but so long as the Value* for instructions in a block increase
with the order of the instructions in the block (or decrease) monotonically,
then this will appear to be deterministic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167942 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 18:38:11 +00:00
Alexey Samsonov
659c052dfb [TSan] fix indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167928 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 14:33:59 +00:00
Nadav Rotem
e123fd9c59 use the getSplat API. Patch by Paul Redmond.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167892 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 00:02:13 +00:00
Alexey Samsonov
009c4d86c1 Figure out <size> argument of llvm.lifetime intrinsics at the moment they are created (during function inlining)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167821 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 07:15:32 +00:00
Hal Finkel
1a0be4d2a7 BBVectorize: Remove temporary assert used for debugging
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167817 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 05:54:54 +00:00
Meador Inge
2920a71663 instcombine: Migrate math library call simplifications
This patch migrates the math library call simplifications from the
simplify-libcalls pass into the instcombine library call simplifier.

I have typically migrated just one simplifier at a time, but the math
simplifiers are interdependent because:

   1. CosOpt, PowOpt, and Exp2Opt all depend on UnaryDoubleFPOpt.
   2. CosOpt, PowOpt, Exp2Opt, and UnaryDoubleFPOpt all depend on
      the option -enable-double-float-shrink.

These two factors made migrating each of these simplifiers individually
more of a pain than it would be worth.  So, I migrated them all together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167815 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 04:16:17 +00:00
Hal Finkel
4387b8c959 BBVectorize: Don't vectorize vector-manipulation chains
Don't choose a vectorization plan containing only shuffles and
vector inserts/extracts. Due to inperfections in the cost model,
these can lead to infinite recusion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167811 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 03:12:40 +00:00
Shuxin Yang
4df2826166 revert r167740
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167787 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 00:08:49 +00:00
Hal Finkel
b2b2469a91 BBVectorize: Only some insert element operand pairs are free.
This fixes another infinite recursion case when using target costs.
We can only replace insert element input chains that are pure (end
with inserting into an undef).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167784 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 23:55:36 +00:00
Hal Finkel
86c88c938a BBVectorize: Use a more sophisticated check for input cost
The old checking code, which assumed that input shuffles and insert-elements
could always be folded (and thus were free) is too simple.
This can only happen in special circumstances.
Using the simple check caused infinite recursion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167750 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 21:21:02 +00:00
Hal Finkel
5094257518 BBVectorize: Check the types of compare instructions
The pass would previously assert when trying to compute the cost of
compare instructions with illegal vector types (like struct pointers).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167743 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 19:41:38 +00:00
Shuxin Yang
0a46bf13a3 This change is to fix rdar://12571717 which is about assertion in Reassociate pass.
The assertion is trigged when the Reassociater tries to transform expression
     ... + 2 * n * 3 + 2 * m + ...
  into:
     ... + 2 * (n*3 + m).

In the process of the transformation, a helper routine folds the constant 2*3 into 6,
confusing optimizer which is trying the to eliminate the common factor 2, and cannot
find 2 any more. 

Review is pending. But I'd like commit first in order to help those who are waiting 
for this fix. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167740 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 19:34:11 +00:00
Hal Finkel
8b9796f4f8 BBVectorize: Check the input types of shuffles for legality
This fixes a bug where shuffles were being fused such that the
resulting input types were not legal on the target. This would
occur only when both inputs and dependencies were also foldable
operations (such as other shuffles) and there were other connected
pairs in the same block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167731 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 14:50:59 +00:00
Alexey Samsonov
1faf9be569 [ASan] fixup for r167725: Don't fetch name of StructType if it is literal
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167729 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 14:47:00 +00:00
Meador Inge
30d8f0e977 Normalize memcmp constant folding results.
The library call simplifier folds memcmp calls with all constant arguments
to a constant.  For example:

  memcmp("foo", "foo", 3) ->  0
  memcmp("hel", "foo", 3) ->  1
  memcmp("foo", "hel", 3) -> -1

The folding is implemented in terms of the system memcmp that LLVM gets
linked with.  It currently just blindly uses the value returned from
the system memcmp as the folded constant.

This patch normalizes the values returned from the system memcmp to
(-1, 0, 1) so that we get consistent results across multiple platforms.
The test cases were adjusted accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167726 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 14:00:45 +00:00
Alexey Samsonov
9cc45d2d7e [ASan]: Add minimalistic support for turning off initialization-order checking for globals of specified types. Tests for this behavior will go to ASan test suite in compiler-rt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167725 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 14:00:01 +00:00
Meador Inge
b798edd791 Delete a stale comment. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167698 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12 00:28:15 +00:00