Commit Graph

9609 Commits

Author SHA1 Message Date
Chandler Carruth
7065a2bcec Revert the patches adding a popcount loop idiom recognition pass.
There are still bugs in this pass, as well as other issues that are
being worked on, but the bugs are crashers that occur pretty easily in
the wild. Test cases have been sent to the original commit's review
thread.

This reverts the commits:
  r169671: Fix a logic error.
  r169604: Move the popcnt tests to an X86 subdirectory.
  r168931: Initial commit adding the pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169683 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-08 22:18:29 +00:00
Shuxin Yang
19bfae4797 Fix an inadvertent typo error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169671 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-08 05:00:59 +00:00
Bill Wendling
99faa3b4ec s/AttrListPtr/AttributeSet/g to better label what this class is going to be in the near future.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169651 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-07 23:16:57 +00:00
Evgeniy Stepanov
ece6db5f16 [msan] Remove readonly/readnone attributes from all called functions.
MSan uses a TLS slot to pass shadow for function arguments and return values.
This makes all instrumented functions not readonly, and at the same time
requires that all callees of an instrumented function that may be
MSan-instrumented do not have readonly attribute (otherwise some of the
instrumentation may be optimized out).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169591 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-07 09:08:32 +00:00
Jakub Staszak
5b4af8b52a Remove unused field.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169551 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 22:08:59 +00:00
Jakub Staszak
582088c088 Remove trailing spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169550 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 21:57:16 +00:00
NAKAMURA Takumi
67b9928a93 MemorySanitizer.cpp: Suppress a warning. [-Wunused-variable]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169504 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 13:38:00 +00:00
Evgeniy Stepanov
7baaee37cc [msan] Fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169491 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 11:58:59 +00:00
Evgeniy Stepanov
4031b194ac [msan] Do not store origin for clean values.
Instead of unconditionally storing origin with every application store,
only do this when the shadow of the stored value is != 0.

This change also delays instrumentation of stores until after the walk over
function's instructions, because adding new basic blocks confuses InstVisitor.

We only keep 1 origin value per 4 bytes of application memory. This change
fixes the bug when a store of a single clean byte wiped the origin for the
whole 4-byte area.

Since stores of uninitialized values are relatively uncommon, this change
improves performance of track-origins mode by 5% median and by up to 47% on
specs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169490 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 11:41:03 +00:00
Bill Wendling
1c211640e5 Set the 'MadeChange' variable if we are deleting blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169455 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 00:30:20 +00:00
Evgeniy Stepanov
1e3b656be5 [msan] Instrument bswap intrinsic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169383 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 14:39:55 +00:00
Evgeniy Stepanov
1b3fcf94a4 [msan] Initialize callbacks in runOnFunction as opposed to doInitialization.
This mirrors the change in ASan & TSan done in r168864.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169378 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 13:14:33 +00:00
Evgeniy Stepanov
61cac0619a [msan] Change linkage type of __msan_track_origins.
LinkOnceODRLinkage globals may be removed in GlobalOpt if not used in the
current module.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169377 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 12:49:41 +00:00
Nadav Rotem
46c5f79789 LoopVectorizer: Increase the number of pointers that can be tested at runtime. If we cant prove statically that the pointers are disjoint then we add the runtime check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169334 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 23:25:24 +00:00
Nadav Rotem
dc5eff5b98 Enable if-conversion during vectorization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169331 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 22:59:52 +00:00
Nadav Rotem
e570dee4b0 Fix a bug in vectorization of if-converted reduction variables. If the
reduction variable is not used outside the loop then we ran into an
endless loop. This change checks if we found the original PHI.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169324 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 22:40:22 +00:00
Shuxin Yang
a09e18fcfa For rdar://12329730, last piece.
This change attempts to simplify (X^Y) -> X or Y in the user's context if we know that
only bits from X or Y are demanded.

  A minimized case is provided bellow. This change will simplify "t>>16" into "var1 >>16".

  =============================================================
  unsigned foo (unsigned val1, unsigned val2) {
    unsigned t = val1 ^ 1234;
    return (t >> 16) | t; // NOTE: t is used more than once.
  }
  =============================================================

  Note that if the "t" were used only once, the expression would be finally optimized as well.
However, with with this change, the optimization will take place earlier.

  Reviewed by Nadav, Thanks a lot!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169317 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 22:15:32 +00:00
Nadav Rotem
f6088d126e Add support for reduction variables when IF-conversion is enabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169288 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 18:17:33 +00:00
Chandler Carruth
a1514e24cc Sort includes for all of the .h files under the 'lib' tree. These were
missed in the first pass because the script didn't yet handle include
guards.

Note that the script is now able to handle all of these headers without
manual edits. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169224 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 07:12:27 +00:00
Nadav Rotem
e6f2df9610 Give scalar if-converted blocks half the score because they are not always executed due to CF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169223 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 07:11:52 +00:00
Nadav Rotem
319d594e22 Add the last part that is needed for vectorization of if-converted code.
Added the code that actually performs the if-conversion during vectorization.

We can now vectorize this code:

for (int i=0; i<n; ++i) {
  unsigned k = 0;

  if (a[i] > b[i])   <------ IF inside the loop.
    k = k * 5 + 3;

  a[i] = k;          <---- K is a phi node that becomes vector-select.
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169217 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 06:15:11 +00:00
Kostya Serebryany
6c55412ea4 [asan] add experimental -asan-realign-stack option (true by default, which does not change the current behavior)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169216 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 06:14:01 +00:00
Matt Beaumont-Gay
ee72115670 Add 'using' declarations to suppress -Woverloaded-virtual warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169214 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 05:41:27 +00:00
Shuxin Yang
bba3eb054a rdar://12329730 (2nd part, revised)
The type of shirt-right (logical or arithemetic) should remain unchanged 
when transforming  "X << C1 >> C2" into "X << (C1-C2)"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169209 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 03:28:32 +00:00
Alexey Samsonov
f985f44b13 ASan: add initial support for handling llvm.lifetime intrinsics in ASan - emit calls into runtime library that poison memory for local variables when their lifetime is over and unpoison memory when their lifetime begins.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169200 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 01:34:23 +00:00
NAKAMURA Takumi
915584ed13 LoopVectorize.cpp: Suppress a warning. [-Wunused-variable]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169195 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 00:49:34 +00:00
NAKAMURA Takumi
36422d8876 Fix whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169194 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 00:49:28 +00:00
Shuxin Yang
c811976b04 rdar://12329730 (2nd part)
This change tries to simmplify E1 = " X >> C1 << C2" into :
  - E2 = "X << (C2 - C1)" if C2 > C1, or
  - E2 = "X >> (C1 - C2)" if C1 > C2, or
  - E2 = X if C1 == C2.

 Reviewed by Nadav. Thanks!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169182 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 00:04:54 +00:00
Nadav Rotem
b8f842dce4 minor renaming, documentation and cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169175 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 22:57:09 +00:00
Nadav Rotem
fa72ee729a IF-conversion: teach the cost-model how to grade if-converted loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169171 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 22:46:31 +00:00
Nadav Rotem
56f1ce22dc Now that we have a basic if-conversion infrastructure we can rename the
"single basic block loop vectorizer" to "innermost loop vectorizer".



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169158 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 21:33:08 +00:00
Nadav Rotem
dd8b1015c8 Add initial support for IF-conversion. This patch implements the first 1/3,
which is the legality of the if-conversion transformation. The next step is to
implement the cost-model for the if-converted code as well as the
vectorization itself.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169152 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 21:06:35 +00:00
Alexey Samsonov
b0dcf61252 ASan: add blacklist file to ASan pass options. Clang patch for this will follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169143 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 19:09:26 +00:00
Nadav Rotem
c69908695a Teach the jump threading optimization to stop scanning the basic block when calculating the cost after passing the threshold.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169135 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 17:34:44 +00:00
Chandler Carruth
d04a8d4b33 Use the new script to sort the includes of every file under lib.
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
2012-12-03 16:50:05 +00:00
Chandler Carruth
e74a4a7915 Remove some buggy and apparantly unnecessary code from SROA.
The partitioning logic attempted to handle uses of an alloca with an
offset starting before the alloca so long as the use had some overlap
with the alloca itself. However, there was a bug where we tested
'(uint64_t)Offset >= AllocSize' without first checking whether 'Offset'
was positive. As a consequence, essentially every negative offset (that
is, starting *before* the alloca does) would be thrown out, even if it
was overlapping. The subsequent code to throw out negative offsets which
were actually non-overlapping was essentially dead. The code to *handle*
overlapping negative offsets was actually dead!

I've just removed all of this, and taught SROA to discard any uses which
start prior to the alloca from the beginning. It has the lovely property
of simplifying the code. =] All the tests still pass, and in fact no new
tests are needed as this is already covered by our testsuite. Fixing the
code so that negative offsets work the way the comments indicate they
were supposed to work causes regressions. That's how I found this.

Anyways, this is all progress in the correct direction -- tightening up
SROA to be maximally aggressive. Some day, I really hope to turn
out-of-bounds accesses to an alloca into 'unreachable'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169120 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 10:59:55 +00:00
Nuno Lopes
53916aa78f fix stats for added checks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169119 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03 10:15:03 +00:00
Benjamin Kramer
5bded7525b SROA: Avoid struct and array types early to avoid creating an overly large integer type.
Fixes PR14465.

Differential Revision: http://llvm-reviews.chandlerc.com/D148

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169084 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 11:53:32 +00:00
Zhou Sheng
efcdb2944b Revert previous check in r168581, r169079 as they are still in code review status.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169083 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 10:54:28 +00:00
Zhou Sheng
702aa2ee19 The patch is to improve the memory footprint of pass GlobalOpt.
Also check in a case to repeat the issue, on which 'opt -globalopt' consumes 1.6GB memory.
The big memory footprint cause is that current GlobalOpt one by one hoists and stores the leaf element constant into the global array, in each iteration, it recreates the global array initializer constant and leave the old initializer alone. This may result in many obsolete constants left.
For example:  we have global array @rom = global [16 x i32] zeroinitializer
After the first element value is hoisted and installed:   @rom = global [16 x i32] [ 1, 0, 0, ... ]
After the second element value is installed:  @rom = global [16 x 32] [ 1, 2, 0, 0, ... ]        // here the previous initializer is obsolete
...
When the transform is done, we have 15 obsolete initializers left useless.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169079 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 04:38:53 +00:00
Pedro Artigas
ef2ef3e246 reversed the logic of the log2 detection routine to reduce the number of nested ifs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169049 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 22:47:15 +00:00
Nadav Rotem
d6964741f5 minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169048 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 22:37:11 +00:00
Bill Wendling
08510b14d4 Replace r168930 with a more reasonable patch.
The original patch removed a bunch of code that the SjLjEHPrepare pass placed
into the entry block if all of the landing pads were removed during the
CodeGenPrepare class. The more natural way of doing things is to run the CGP
*before* we run the SjLjEHPrepare pass.

Make it so!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169044 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 22:08:55 +00:00
Pedro Artigas
c2a08d28eb Addresses many style issues with prior checkin (r169025)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169043 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 22:07:05 +00:00
Pedro Artigas
84030dcb3f Add fast math inst combine X*log2(Y*0.5)-->X*log2(Y)-X
reviewed by Michael Ilseman <milseman@apple.com>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169025 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 19:09:41 +00:00
Nadav Rotem
f735a7f88d Remove the use of LPPassManager. We can remove LPM because we dont need to run any additional loop passes on the new vector loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169016 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 17:27:53 +00:00
Kostya Serebryany
a17babb021 [asan] simplify the code around doesNotReturn call. It now magically works.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168995 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 11:08:59 +00:00
Chandler Carruth
66ea2f9986 Fix non-determinism introduced in r168970 and pointed out by Duncan.
We're iterating over a non-deterministically ordered container looking
for two saturating flags. To do this correctly, we have to saturate
both, and only stop looping if both saturate to their final value.
Otherwise, which flag we see first changes the result.

This is also a micro-optimization of the previous version as now we
don't go into the (possibly expensive) test logic once the first
violation of either constraint is detected.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168989 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 09:34:29 +00:00
Chandler Carruth
06ec7211c1 Rearrange the comments, control flow, and variable names; no
functionality changed.

Evan's commit r168970 moved the code that the primary comment in this
function referred to to the other end of the function without moving the
comment, and there has been a steady creep of "boolean" logic in it that
is simpler if handled via early exit. That way each special case can
have its own comments. I've also made the variable name a bit more
explanatory than "AllFit". This is in preparation to fix the
non-deterministic output of this function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168988 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 09:26:25 +00:00
Meador Inge
63f932ca3c Move library call simplification statistic to instcombine
The simplify-libcalls pass maintained a statistic to count the number
of library calls that have been simplified.  Now that library call
simplification is being carried out in instcombine the statistic should
be moved to there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168975 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 04:05:06 +00:00