Commit Graph

9858 Commits

Author SHA1 Message Date
Nadav Rotem
dc0a5fd226 Fix a comment. Induction vars dont need to start at zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173061 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 17:59:18 +00:00
Chandler Carruth
a5157e68d1 Switch CodeMetrics itself over to use TTI to determine if an instruction
is free. The whole CodeMetrics API should probably be reworked more, but
this is enough to allow deleting the duplicate code there for computing
whether an instruction is free.

All of the passes using this have been updated to pull in TTI and hand
it to the CodeMetrics stuff. Further, a dead CodeMetrics API
(analyzeFunction) is nuked for lack of users.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173036 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 13:04:33 +00:00
Chandler Carruth
86953b5795 Make the inline cost a proper analysis pass. This remains essentially
a dynamic analysis done on each call to the routine. However, now it can
use the standard pass infrastructure to reference other analyses,
instead of a silly setter method. This will become more interesting as
I teach it about more analysis passes.

This updates the two inliner passes to use the inline cost analysis.
Doing so highlights how utterly redundant these two passes are. Either
we should find a cheaper way to do always inlining, or we should merge
the two and just fiddle with the thresholds to get the desired behavior.
I'm leaning increasingly toward the latter as it would also remove the
Inliner sub-class split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173030 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 11:39:18 +00:00
Chandler Carruth
0378e3916a Formatting and comment fixes to the always inliner.
Formatting fixes brought to you by clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173029 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 11:39:16 +00:00
Chandler Carruth
5a47127c4c Clean up the formatting and doxygen for the simple inliner a bit. No
functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173028 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 11:39:14 +00:00
Benjamin Kramer
5ff7a3f947 LoopVectorize: Fix a C++11 incompatibility.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172990 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-20 20:29:52 +00:00
Nadav Rotem
e6e7606118 Fix a build error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172971 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-20 09:39:17 +00:00
Nadav Rotem
0bbbc52dc8 LoopVectorizer: Implement a new heuristics for selecting the unroll factor.
We ignore the cpu frontend and focus on pipeline utilization. We do this because we
don't have a good way to estimate the loop body size at the IR level.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172964 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-20 05:24:29 +00:00
Benjamin Kramer
1af132dcf3 LoopVectorizer: Emit memory checks into their own basic block.
This separates the check for "too few elements to run the vector loop" from the
"memory overlap" check, giving a lot nicer code and allowing to skip the memory
checks when we're not going to execute the vector code anyways. We still leave
the decision of whether to emit the memory checks as branches or setccs, but it
seems to be doing a good job. If ugly code pops up we may want to emit them as
separate blocks too. Small speedup on MultiSource/Benchmarks/MallocBench/espresso.

Most of this is legwork to allow multiple bypass blocks while updating PHIs,
dominators and loop info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172902 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19 13:57:58 +00:00
Chandler Carruth
90230c8466 Sort all of the includes. Several files got checked in with mis-sorted
includes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172891 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19 08:03:47 +00:00
Michael Gottesman
ffd5f9ad60 Improved comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172864 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 23:02:45 +00:00
Michael Gottesman
8a8cef7156 Fixed typo in comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172863 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 23:00:33 +00:00
Bill Wendling
1b0c54f1c5 Use AttributeSet accessor methods instead of Attribute accessor methods.
Further encapsulation of the Attribute object. Don't allow direct access to the
Attribute object as an aggregate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172853 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 21:53:16 +00:00
Bill Wendling
956f13440a Push some more methods down to hide the use of the Attribute class.
Because the Attribute class is going to stop representing a collection of
attributes, limit the use of it as an aggregate in favor of using AttributeSet.
This replaces some of the uses for querying the function attributes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172844 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 21:11:39 +00:00
Benjamin Kramer
b52677c0ad Silence GCC warning about dropping off a non-void function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172839 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 19:45:22 +00:00
Alexey Samsonov
fe7d2b61f2 80 columns
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172813 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 12:49:06 +00:00
Will Dietz
ae36eccdfb Move Blacklist.h to include/ to enable use from clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172806 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 11:29:21 +00:00
Craig Topper
081c29b256 Check for less than 0 in shuffle mask instead of -1. It's more consistent with other code related to shuffles and easier to implement in compiled code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172788 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 05:30:07 +00:00
Craig Topper
37d093f0b0 Remove trailing whitespace. Remove new lines between closing brace and 'else'
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172784 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 05:09:16 +00:00
Michael Gottesman
268e0ffa78 Fixed 80+ violation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172782 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 03:08:39 +00:00
Michael Gottesman
222f02f7eb Added missing const from my last commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172736 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 18:36:17 +00:00
Michael Gottesman
88ceb186f1 [ObjCARC] Implemented operator<< for InstructionClass and changed a ``Visited'' Debug message to use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172735 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 18:32:34 +00:00
Alexey Samsonov
11af9a873f ASan: add optional 'zero-based shadow' option to ASan passes. Always tell the values of shadow scale and offset to the runtime
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172709 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 11:12:32 +00:00
Alexey Samsonov
19cd7e9ce2 ASan: wrap mapping scale and offset in a struct and make it a member of ASan passes. Add test for non-default mapping scale and offset. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172610 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-16 13:23:28 +00:00
Michael Gottesman
09c84f13c6 [ObjCARC] Turn off ignoring unwind edges in ObjCARC when -fno-objc-arc-exception is enabled due to it's affect on correctness.
Specifically according to the semantics of ARC -fno-objc-arc-exception simply
states that it is expected that the unwind path out of a call *MAY* not release
objects. Thus we can have the situation where a release gets moved into a catch
block which we ignore when we remove a retain/release pair resulting in (even
though we assume the program is exiting anyways) the cleanup code path
potentially blowing up before program exit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172599 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-16 06:32:39 +00:00
Nadav Rotem
83d5853833 Teach InstCombine to optimize extract of a value from a vector add operation with a constant zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172576 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-15 23:43:14 +00:00
Shuxin Yang
a1444219b2 1. Hoist minus sign as high as possible in an attempt to reveal
some optimization opportunities (in the enclosing supper-expressions).

   rule 1. (-0.0 - X ) * Y => -0.0 - (X * Y)
     if expression "-0.0 - X" has only one reference.

   rule 2. (0.0 - X ) * Y => -0.0 - (X * Y)
     if expression "0.0 - X" has only one reference, and
        the instruction is marked "noSignedZero".

2. Eliminate negation (The compiler was already able to handle these
    opt if the 0.0s are replaced with -0.0.)

   rule 3: (0.0 - X) * (0.0 - Y) => X * Y
   rule 4: (0.0 - X) * C => X * -C
   if the expr is flagged "noSignedZero".

3. 
  Rule 5: (X*Y) * X => (X*X) * Y
   if X!=Y and the expression is flagged with "UnsafeAlgebra".

   The purpose of this transformation is two-fold:
    a) to form a power expression (of X).
    b) potentially shorten the critical path: After transformation, the
       latency of the instruction Y is amortized by the expression of X*X,
       and therefore Y is in a "less critical" position compared to what it
      was before the transformation. 

4. Remove the InstCombine code about simplifiying "X * select".
   
   The reasons are following:
    a) The "select" is somewhat architecture-dependent, therefore the
       higher level optimizers are not able to precisely predict if
       the simplification really yields any performance improvement
       or not.

    b) The "select" operator is bit complicate, and tends to obscure
       optimization opportunities. It is btter to keep it as low as
       possible in expr tree, and let CodeGen to tackle the optimization.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172551 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-15 21:09:32 +00:00
Nadav Rotem
6a459e65c8 LoopVectorizer cost model. Honor the user command line flag that selects the vectorization factor even if the target machine does not have any vector registers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172544 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-15 18:25:16 +00:00
Evgeniy Stepanov
967a946cb4 [msan] Fix handling of equality comparison of pointer vectors.
Also improve test coveration of the handling of relational comparisons.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172539 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-15 16:44:52 +00:00
Jakub Staszak
e673b54bdd Remove trailing spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172489 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 23:16:36 +00:00
Shuxin Yang
7d72cf892e This change is to implement following rules under the condition C_A and/or C_R
---------------------------------------------------------------------------
 C_A: reassociation is allowed
 C_R: reciprocal of a constant C is appropriate, which means 
    - 1/C is exact, or 
    - reciprocal is allowed and 1/C is neither a special value nor a denormal.
 -----------------------------------------------------------------------------

 rule1:  (X/C1) / C2 => X / (C2*C1)  (if C_A)
                     => X * (1/(C2*C1))  (if C_A && C_R)
 rule 2:  X*C1 / C2 => X * (C1/C2)  if C_A
 rule 3: (X/Y)/Z = > X/(Y*Z)  (if C_A && at least one of Y and Z is symbolic value)
 rule 4: Z/(X/Y) = > (Z*Y)/X  (similar to rule3)

 rule 5: C1/(X*C2) => (C1/C2) / X (if C_A)
 rule 6: C1/(X/C2) => (C1*C2) / X (if C_A)
 rule 7: C1/(C2/X) => (C1/C2) * X (if C_A)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172488 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 22:48:41 +00:00
David Greene
4ee576fac3 Fix Casting Bug
Add a const version of getFpValPtr to avoid a cast-away-const warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172467 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 21:04:40 +00:00
Nick Lewycky
eb3ac4518e Fix typo in comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172460 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 20:56:10 +00:00
Michael Gottesman
f3c1335c59 Changed SmallPtrSet.count guard + SmallPtrSet.insert to just SmallPtrSet.insert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172452 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 19:18:39 +00:00
Michael Gottesman
7899e47f20 Fixed some 80+ violations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172374 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 01:47:53 +00:00
Michael Gottesman
81c6121699 Updated the documentation in ObjCARC.cpp to fit the style guide better (i.e. use doxygen). Still some work to do though.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172371 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14 00:35:14 +00:00
Michael Gottesman
6056b85bb5 Fixed an infinite loop in the block escape in analysis in ObjCARC caused by 2x blocks each assigned a value via a phi-node causing each to depend on the other.
A test case is provided as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172368 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-13 22:12:06 +00:00
Dmitri Gribenko
96f498bd9f Remove redundant 'llvm::' qualifications
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172358 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-13 16:01:15 +00:00
Nadav Rotem
b6db95f42b Fix PR14547. Handle induction variables of small sizes smaller than i32 (i8 and i16).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172348 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-13 07:56:29 +00:00
Michael Gottesman
981308cffb [ObjCARC] Even more debug messages!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172347 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-13 07:47:32 +00:00
Michael Gottesman
cf14005185 [ObjCARC] More debug messages.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172346 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-13 07:00:51 +00:00
Chandler Carruth
eab0ba03cf Fix an editor goof in r171738 that Bill spotted. He may even have a test
case, but looking at the diff this was an obviously unintended change.

Thanks for the careful review Bill! =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172336 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 23:46:04 +00:00
Benjamin Kramer
0813589f72 GlobalOpt: Avoid jump on uninitialized value.
Found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172318 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 15:34:31 +00:00
Michael Gottesman
e7a715f61e Fixed debug message in ObjCARC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172299 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 03:45:49 +00:00
Michael Gottesman
0d3582b1d1 Fixed a few debug messages in ObjCARC and added one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172298 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 02:57:16 +00:00
Michael Gottesman
0e385450fc Fixed bug in ObjCARC where we were changing a call from objc_autoreleaseRV => objc_autorelease but were not updating the InstructionClass to IC_Autorelease.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172288 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 01:25:19 +00:00
Michael Gottesman
e8c161a924 Fixed a bug where we were tail calling objc_autorelease causing an object to not be placed into an autorelease pool.
The reason that this occurs is that tail calling objc_autorelease eventually
tail calls -[NSObject autorelease] which supports fast autorelease. This can
cause us to violate the semantic gaurantees of __autoreleasing variables that
assignment to an __autoreleasing variables always yields an object that is
placed into the innermost autorelease pool.

The fix included in this patch works by:

1. In the peephole optimization function OptimizeIndividualFunctions, always
remove tail call from objc_autorelease.
2. Whenever we convert to/from an objc_autorelease, set/unset the tail call
keyword as appropriate.

*NOTE* I also handled the case where objc_autorelease is converted in
OptimizeReturns to an autoreleaseRV which still violates the ARC semantics. I
will be removing that in a later patch and I wanted to make sure that the tree
is in a consistent state vis-a-vis ARC always.

Additionally some test cases are provided and all tests that have tail call marked
objc_autorelease keywords have been modified so that tail call has been removed.

*NOTE* One test fails due to a separate bug that I am going to commit soon. Thus
I marked the check line TMP: instead of CHECK: so make check does not fail.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172287 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 01:25:15 +00:00
Michael Gottesman
dcf669560e Fixed whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172271 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-11 23:08:52 +00:00
Michael Gottesman
cddd8a613e Added debug messages to GlobalOpt.
Specifically:
1. Added a missing new line when we emit a debug message saying that we are marking a global variable as constant.
2. Added debug messages that describe what is occuring when GlobalOpt is evaluating a block/function.
3. Added a debug message that says what specific constructor is being evaluated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172247 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-11 20:07:53 +00:00
Nadav Rotem
a675c74208 ARM Cost Model: We need to detect the max bitwidth of types in the loop in order to select the max vectorization factor.
We don't have a detailed analysis on which values are vectorized and which stay scalars in the vectorized loop so we use
another method. We look at reduction variables, loads and stores, which are the only ways to get information in and out
of loop iterations. If the data types are extended and truncated then the cost model will catch the cost of the vector
zext/sext/trunc operations.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172178 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-11 07:11:59 +00:00