Commit Graph

8607 Commits

Author SHA1 Message Date
Eli Friedman
4090e1ce91 Remap blockaddress correctly when inlining a function. Fixes PR10162.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142684 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 20:45:19 +00:00
Eli Friedman
8d992f5c2c Minor simplification: use ShuffleVectorInst::getMaskValue instead of a more expensive helper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142672 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 19:11:34 +00:00
Eli Friedman
d2822e7572 Extend instcombine's shufflevector simplification to handle more cases where the input and output vectors have different sizes. Patch by Xiaoyi Guo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142671 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21 19:06:29 +00:00
Eli Friedman
c66330504c Refactor code from inlining and globalopt that checks whether a function definition is unused, and enhance it so it can tell that functions which are only used by a blockaddress are in fact dead. This probably doesn't happen much on most code, but the Linux kernel's _THIS_IP_ can trigger this issue with blockaddress. (GlobalDCE can also handle the given tescase, but we only run that at -O3.) Found while looking at PR11180.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142572 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-20 05:23:42 +00:00
Devang Patel
9be72d4394 Initialze ScalarEvalution dependency.
Patch by Pranav Bhandarkar!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142556 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-19 23:56:07 +00:00
Dan Gohman
a974beaa1f Teach the ARC optimizer about the !clang.arc.copy_on_escape metadata
tag on objc_retainBlock calls, which indicates that they may be
optimized away. rdar://10211286.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142298 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 22:53:25 +00:00
Bill Wendling
76f267df17 Add support for the Objective-C personality function to the instruction
combining of the landingpad instruction. The ObjC personality function acts
almost identically to the C++ personality function. In particular, it uses
"null" as a "catch-all" value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142256 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 21:20:24 +00:00
Dan Gohman
90b8bcd33a Suppress partial retain+release elimination when there's a
possibility that it will span multiple CFG diamonds/triangles which
could have different controlling predicates.  rdar://10282956


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142222 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 18:48:25 +00:00
Bill Wendling
3c5e60994f Correct over-zealous removal of hack.
Some code want to check that *any* call within a function has the 'returns
twice' attribute, not just that the current function has one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142221 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 18:43:40 +00:00
Bill Wendling
728662f9e8 Now that we have the ReturnsTwice function attribute, this method is
obsolete. Check the attribute instead.
<rdar://problem/8031714>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142212 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 18:22:52 +00:00
Michael J. Spencer
9904056a70 Fix CMake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142204 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 17:50:39 +00:00
Devang Patel
827454e6e2 svn mv Target/ARM/ARMGlobalMerge.cpp Transforms/Scalar/GlobalMerge.cpp
There is no reason to have simple IR level pass in lib/Target.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142200 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 17:17:43 +00:00
Chandler Carruth
602650c988 Add a routine to swap branch instruction operands, and update any
profile metadata at the same time. Use it to preserve metadata attached
to a branch when re-writing it in InstCombine.

Add metadata to the canonicalize_branch InstCombine test, and check that
it is tranformed correctly.

Reviewed by Nick Lewycky!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142168 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 01:11:57 +00:00
Chandler Carruth
5820d62803 Add a proper LLVM banner to this file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142162 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16 22:15:07 +00:00
Nick Lewycky
36c7e6c36c When looking for dependencies on the src pointer, scan the src pointer. Scanning
on the memcpy call will pull up other unrelated stuff. Fixes PR11142.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142150 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16 20:13:32 +00:00
Duncan Sands
1673b15da2 Don't replace all dominated uses if there is only one use, since that
use can't be dominated, saving one domtree lookup.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142066 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-15 11:13:42 +00:00
Andrew Trick
513b1f47c1 Fix indvars randomness by removing iteration over a map.
I rewrote the algorithm a while back so it doesn't require map lookup,
but neglected to change the data structure. This was caught by
llvm-gcc self host, not because there's anything special about
llvm-gcc, but because it is the only test for nondeterminism we
currently have. Unit tests don't work well for everything; we should
always try to have a nondeterminism stress test running.

Fixes PR11133: llvm-gcc self host .o mismatch after enable-iv-rewrite=false


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142036 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-15 01:38:14 +00:00
Eli Friedman
dae36ba802 Avoid undefined behavior in negation in LSR. Patch by Ahmed Charles.
Someone more familiar with LSR should double-check that the extra cast is actually doing the right thing in the overflow cases; I'm not completely confident that's that case. 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141916 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-13 23:48:33 +00:00
Eli Friedman
b414142036 Enhance the memdep interface so that users can tell the difference between a dependency which cannot be calculated and a path reaching the entry point of the function. This patch introduces isNonFuncLocal, which replaces isUnknown in some cases.
Patch by Xiaoyi Guo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141896 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-13 22:14:57 +00:00
Eli Friedman
18ead6b587 Fix a couple hash functions so that they do not depend on undefined shifts. Based on patch by Ahmed Charles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141820 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 22:00:26 +00:00
Nick Lewycky
865703e53a Add missing space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141750 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 00:14:31 +00:00
Cameron Zwarich
c055a8782e Fix PR11106 by correcting a typo that has been in the code for over a year. This
would have never worked, since the element type of a vector type is never a
vector type. Also fix the conditional to be more direct in checking whether
EltTy is a vector type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141713 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 21:26:40 +00:00
Cameron Zwarich
446d95224b Remove a lot of the fancy scalar replacement code for dealing with llvm-gcc's
lowering of NEON code. It provides little-to-no benefit now and only introduces
additional complexity.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141646 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 06:10:30 +00:00
Andrew Trick
a02bfced06 Add experimental -enable-lsr-phielim option.
I'm not sure we will need it in the long run, but the option is
currently useful for checking if the output of LSR is "clean".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141634 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 02:30:45 +00:00
Andrew Trick
204494149b Move replaceCongruentIVs into SCEVExapander and bias toward "expanded"
IVs.

Indvars previously chose randomly between congruent IVs. Now it will
bias the decision toward IVs that SCEVExpander likes to create. This
was not done to fix any problem, it's just a welcome side effect of
factoring code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141633 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 02:28:51 +00:00
Lang Hames
bb5b3f3359 Add a natural stack alignment field to TargetData, and prevent InstCombine from
promoting allocas to preferred alignments that exceed the natural
alignment. This avoids some potentially expensive dynamic stack realignments.

The natural stack alignment is set in target data strings via the "S<size>"
option. Size is in bits and must be a multiple of 8. The natural stack alignment
defaults to "unspecified" (represented by a zero value), and the "unspecified"
value does not prevent any alignment promotions. Target maintainers that care
about avoiding promotions should explicitly add the "S<size>" option to their
target data strings.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141599 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-10 23:42:08 +00:00
Andrew Trick
c570191060 LSR should only reuse phis that match its formula.
Fixes rdar://problem/5064068


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141442 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 23:46:21 +00:00
Duncan Sands
3f329cb781 Teach GVN to also propagate switch cases. For example, in this code
switch (n) {
    case 27:
      do_something(x);
    ...
  }
the call do_something(x) will be replaced with do_something(27).  In
gcc-as-one-big-file this results in the removal of about 500 lines of
bitcode (about 0.02%), so has about 1/10 of the effect of propagating
branch conditions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141360 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 08:29:06 +00:00
Eli Friedman
8540101252 Remove the old atomic instrinsics. autoupgrade functionality is included with this patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141333 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 23:20:49 +00:00
Eli Friedman
792860883e PR11061: Make simplifylibcalls fold strcmp("", x) correctly.
While I'm here, fix the related issue with strncmp, add some actual tests for strcmp and strncmp, and start using StringRef::compare for constant folding instead of using strcmp/strncmp so that the optimized IR isn't dependent on the host's implementation of strcmp.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141227 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 22:27:16 +00:00
Jim Grosbach
35d9da3d3b Re-commit 141203, but much more conservative.
Just pull the instruction name, but don't change the order of anything
else. That keeps --debug happy and non-crashing, but doesn't change
how the worklist gets built.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141210 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 20:53:43 +00:00
Jim Grosbach
e2999b4899 Revert 141203. InstCombine is looping on unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141209 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 20:44:29 +00:00
Jim Grosbach
30c1ff234d Update InstCombine worklist after instruction transform is complete.
When updating the worklist for InstCombine, the Add/AddUsersToWorklist
functions may access the instruction(s) being added, for debug output for
example. If the instructions aren't yet added to the basic block, this
can result in a crash. Finish the instruction transformation before
adjusting the worklist instead.

rdar://10238555


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141203 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 20:05:00 +00:00
Duncan Sands
02b5e72ac6 GVN does simple propagation of conditions: when it sees a conditional
branch "br i1 %x, label %if_true, label %if_false" then it replaces
"%x" with "true" in places only reachable via the %if_true arm, and
with "false" in places only reachable via the %if_false arm.  Except
that actually it doesn't: if value numbering shows that %y is equal
to %x then, yes, %y will be turned into true/false in this way, but
any occurrences of %x itself are not transformed.  Fix this.  What's
more, it's often the case that %x is an equality comparison such as
"%x = icmp eq %A, 0", in which case every occurrence of %A that is
only reachable via the %if_true arm can be replaced with 0.  Implement
this and a few other variations on this theme.  This reduces the number
of lines of LLVM IR in "GCC as one big file" by 0.2%.  It has a bigger
impact on Ada code, typically reducing the number of lines of bitcode
by around 0.4% by removing repeated compiler generated checks.  Passes
the LLVM nightly testsuite and the Ada ACATS testsuite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141177 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 14:28:49 +00:00
Duncan Sands
452c58f4c4 Generalize GVN's conditional propagation logic slightly:
it's OK for the false/true destination to have multiple
predecessors as long as the extra ones are dominated by
the branch destination.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141176 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 14:17:01 +00:00
Andrew Trick
f143b79b78 LSR should avoid redundant edge splitting.
This handles the case in which LSR rewrites an IV user that is a phi and
splits critical edges originating from a switch.
Fixes <rdar://problem/6453893> LSR is not splitting edges "nicely"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141059 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04 03:50:44 +00:00
Andrew Trick
2aeb8027d6 whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141058 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04 03:34:49 +00:00
Nick Lewycky
11357d4f40 Add a new icmp+select optz'n. Also shows off the load(cst) folding added in
r140966.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140969 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-02 10:37:37 +00:00
Nick Lewycky
267236ade3 Enhance a couple places where we were doing constant folding of instructions,
but not load instructions. Noticed by inspection.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140966 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-02 09:12:55 +00:00
Andrew Trick
b2ab2fa524 Inlining and unrolling heuristics should be aware of free truncs.
We want heuristics to be based on accurate data, but more importantly
we don't want llvm to behave randomly. A benign trunc inserted by an
upstream pass should not cause a wild swings in optimization
level. See PR11034. It's a general problem with threshold-based
heuristics, but we can make it less bad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140919 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-01 01:39:05 +00:00
Andrew Trick
5c655413cf whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140916 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-01 01:27:56 +00:00
Jim Grosbach
68e05fb368 Don't modify constant in-place.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140875 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-30 19:58:46 +00:00
Jim Grosbach
cbf676b3ba float comparison to double 'zero' constant can just be a float 'zero.'
InstCombine was incorrectly considering the conversion of the constant
zero to be unsafe.

We want to transform:
define float @bar(float %x) nounwind readnone optsize ssp {
  %conv = fpext float %x to double
  %cmp = fcmp olt double %conv, 0.000000e+00
  %conv1 = zext i1 %cmp to i32
  %conv2 = sitofp i32 %conv1 to float
  ret float %conv2
}

Into:
define float @bar(float %x) nounwind readnone optsize ssp {
  %cmp = fcmp olt float %x, 0.000000e+00   ; <---- This
  %conv1 = zext i1 %cmp to i32
  %conv2 = sitofp i32 %conv1 to float
  ret float %conv2
}


rdar://10215914


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140869 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-30 18:45:50 +00:00
Jim Grosbach
0cc4a958f3 Tidy up. Trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140865 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-30 18:09:53 +00:00
Duncan Sands
0ad7b6e773 Inlining often produces landingpad instructions with repeated
catch or repeated filter clauses.  Teach instcombine a bunch
of tricks for simplifying landingpad clauses.  Currently the
code only recognizes the GNU C++ and Ada personality functions,
but that doesn't stop it doing a bunch of "generic" transforms
which are hopefully fine for any real-world personality function.
If these "generic" transforms turn out not to be generic, they
can always be conditioned on the personality function.  Probably
someone should add the ObjC++ personality function.  I didn't as
I don't know anything about it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140852 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-30 13:12:16 +00:00
Nick Lewycky
48105286cb Fold two identical set lookups into one. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140821 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 23:40:12 +00:00
Dan Gohman
27e0666725 When eliminating unnecessary retain+autorelease on return values,
handle the case where the retain is in a different basic block.
rdar://10210274.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140815 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 22:27:34 +00:00
Dan Gohman
597fece886 Don't eliminate objc_retainBlock calls on stack objects if the
objc_retainBlock call is potentially responsible for copying
the block to the heap to extend its lifetime. rdar://10209613.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140814 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 22:25:23 +00:00
Eli Friedman
bb5a7442e3 Clean up uses of switch instructions so they are not dependent on the operand ordering. Patch by Stepan Dyatkovskiy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140803 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 20:21:17 +00:00
Andrew Trick
5219f86a0b typo + pasto
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140769 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 01:53:08 +00:00
Andrew Trick
0c01bc385a LSR: rewrite inner loops only.
Rewriting the entire loop nest now requires -enable-lsr-nested.
See PR11035 for some performance data.
A few unit tests specifically test nested LSR, and are now under a flag.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140762 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 01:33:38 +00:00
Andrew Trick
909ef7db3d indvars should hoist [sz]ext because licm is not rerun.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140670 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-28 01:35:36 +00:00
Benjamin Kramer
a9390a4d5f Stop emitting instructions with the name "tmp" they eat up memory and have to be uniqued, without any benefit.
If someone prefers %tmp42 to %42, run instnamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140634 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27 20:39:19 +00:00
Bill Wendling
d5520987d1 Split the landing pad basic block with the correct function. Also merge the
split landingpad instructions into a PHI node.
PR11016


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140592 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27 00:59:31 +00:00
Andrew Trick
80ef1b287f Disable LSR retry by default.
Disabling aggressive LSR saves compilation time, and with the new
indvars behavior usually improves performance.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140590 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27 00:44:14 +00:00
Andrew Trick
25b689e067 LSR, one of the new Cost::isLoser() checks did not get merged in the previous checkin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140583 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-26 23:35:25 +00:00
Andrew Trick
7d11bd850f LSR cost metric minor fix and verification.
The minor bug heuristic was noticed by inspection. I added the
isLoser/isValid helpers because they will become more
important with subsequent checkins.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140580 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-26 23:11:04 +00:00
Andrew Trick
b5b7c96ce4 LSR minor bug fix in RateRegister.
No test case. Noticed by inspection and I doubt it ever affects the
outcome of the overall heuristic, let alone final codegen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140431 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-23 23:05:19 +00:00
Eli Friedman
d102a03b36 PR10987: add a missed safety check to isSafePHIToSpeculate in scalarrepl.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140327 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-22 18:56:30 +00:00
Eli Friedman
79782fc864 Make sure IPSCCP never marks a tracked call as overdefined in SCCPSolver::ResolvedUndefsIn. If we do, we can end up in a situation where a function is resolved to return a constant, but the caller is marked overdefined, which confuses the code later.
<rdar://problem/9956541> (again).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140210 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 23:28:51 +00:00
Bill Wendling
f0dc257a8f Relax this condition.
Some passes require breaking critical edges before they're called. Don't
segfault because of that.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140196 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 22:28:17 +00:00
Bill Wendling
b7e807f9a9 Place the check for an exit landing pad where it will be run on both code paths through the if-then-else.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140195 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 22:27:16 +00:00
Bill Wendling
84b6706d90 Omit extracting a loop if one of the exits is a landing pad.
The landing pad must accompany the invoke when it's extracted. However, if it
does, then the loop isn't properly extracted. I.e., the resulting extraction has
a loop in it. The extracted function is then extracted, etc. resulting in an
infinite loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140193 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 22:23:09 +00:00
Bill Wendling
8c93d5b602 Check the terminator, not the basic block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140176 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 20:20:50 +00:00
Bill Wendling
2f1cd85598 When extracting a basic block that ends in an 'invoke' instruction, we need to
extract its associated landing pad block as well. However, that landing pad
block may have more than one predecessor. So split the landing pad block so that
individual landing pads have only one predecessor.

This type of transformation may produce a false positive with bugpoint.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140173 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 19:10:24 +00:00
Bill Wendling
9e7013a506 Use ArrayRef instead of an explicit 'const std::vector &'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140172 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 19:05:04 +00:00
Devang Patel
680018ff89 If simple ownership works then friendship is not required.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140169 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 18:48:56 +00:00
Bill Wendling
51bae90289 Use ArrayRef instead of 'const std::vector' to pass around the list of basic blocks to extract.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140168 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 18:42:07 +00:00
Devang Patel
16c19a155c Update GCOVLines to provide interfaces to write line table and calculate complete length.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140167 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 18:35:00 +00:00
Bill Wendling
b6777eae58 Fix comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140164 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 18:24:46 +00:00
Devang Patel
29d9610f23 Update comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140156 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 18:05:45 +00:00
Devang Patel
68155d31cd Use StringRef instead of std::string.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140154 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 17:55:19 +00:00
Devang Patel
865375ca7f Eliminate unnecessary copy of FileName from GCOVLines.
GCOVLines is always accessed through a StringMap where the key is FileName.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140151 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 17:43:14 +00:00
Devang Patel
ec6f2559fe There is no need to write a local utility routine to find subprogram info if the utility routine is already available in DebugInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140145 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-20 15:57:19 +00:00
Bill Wendling
a846585050 Revert r140083 and r140084 until buildbots can be fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140094 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19 23:30:41 +00:00
Bill Wendling
ad027053fe If we are extracting a basic block that ends in an invoke call, we must also
extract the landing pad block. Otherwise, there will be a situation where the
invoke's unwind edge lands on a non-landing pad.

We also forbid the user from extracting the landing pad block by itself. Again,
this is not a valid transformation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140083 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19 23:00:52 +00:00
Eli Friedman
c6b8ba8673 Fix an infinite loop where a transform in InstCombiner::visitAnd claims a construct is changed when it is not. (See included testcase.)
Patch by Xiaoyi Guo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140072 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19 21:58:15 +00:00
Andrew Trick
24f48ece52 [indvars] Fix PR10946: SCEV cannot handle Vector IVs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140026 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19 17:54:39 +00:00
Andrew Trick
b0598b14aa Reapply r139759. Disable IV rewriting by default. See PR10916.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139842 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 20:58:37 +00:00
Eli Friedman
c82751dd67 Make demanded-elt simplification for shufflevector slightly stronger. Spotted by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139768 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 01:14:29 +00:00
Dan Gohman
1d2fd75e3b Don't mark objc_retainBlock as nounwind. It calls user copy constructors
which could theoretically throw.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139710 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 18:33:34 +00:00
Dan Gohman
211048286b objc_retainBlock is not NoModRef because it can update forwarding pointers
in memory relevant to the optimizer. rdar://10050579.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139708 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 18:13:00 +00:00
Andrew Trick
effb647154 [indvars] Revert r139579 until 401.bzip -arch i386 miscompilation is fixed. PR10920.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139583 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 05:23:49 +00:00
Andrew Trick
dd9d758a31 Disable IV rewriting by default. See PR10916.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139579 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 03:23:21 +00:00
Andrew Trick
94f2c23d24 [indvars] Fix bugs in floating point IV range checks noticed by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139574 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 01:59:32 +00:00
Eli Friedman
1582e7f1e2 Add comment to clarify the behavior of a helper in DSE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139571 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 01:28:59 +00:00
Eli Friedman
5ac7c7da3e Correct grammar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139565 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 00:44:16 +00:00
Eli Friedman
2bc3d52b9a Change a bunch of isVolatile() checks to check for atomic load/store as well.
No tests; these changes aren't really interesting in the sense that the logic is the same for volatile and atomic.

I believe this completes all of the changes necessary for the optimizer to handle loads and stores correctly.  I'm going to try and come up with some additional testing, though.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139533 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 20:23:13 +00:00
Andrew Trick
f21bdf4f42 Rename -disable-iv-rewrite to -enable-iv-rewrite=false in preparation for default change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139517 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 18:28:44 +00:00
Andrew Trick
20151da8c3 [disable-iv-rewrite] Allow WidenIV to handle NSW/NUW operations
better.

Don't immediately give up when an add operation can't be trivially
sign/zero-extended within a loop. If it has NSW/NUW flags, generate a
new expression with sign extended (non-recurrent) operand. As before,
if SCEV says that all sign extends are loop invariant, then we can
widen the operation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139453 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-10 01:24:17 +00:00
Andrew Trick
39d7802224 Comment formatting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139375 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 17:35:10 +00:00
Andrew Trick
75ebc0ec20 Add -verify-indvars for imperfect SCEV trip count verification after indvars.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139169 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 20:20:38 +00:00
Devang Patel
2048c379dd Use IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139156 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 18:49:53 +00:00
Owen Anderson
81856f7313 Try again at r138809 (make DSE more aggressive in removing dead stores at the end of a function), now with less deleting stores before memcpy's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139150 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 18:14:09 +00:00
Duncan Sands
4a544a79bd Split the init.trampoline intrinsic, which currently combines GCC's
init.trampoline and adjust.trampoline intrinsics, into two intrinsics
like in GCC.  While having one combined intrinsic is tempting, it is
not natural because typically the trampoline initialization needs to
be done in one function, and the result of adjust trampoline is needed
in a different (nested) function.  To get around this llvm-gcc hacks the
nested function lowering code to insert an additional parent variable
holding the adjust.trampoline result that can be accessed from the child
function.  Dragonegg doesn't have the luxury of tweaking GCC code, so it
stored the result of adjust.trampoline in the memory GCC set aside for
the trampoline itself (this is always available in the child function),
and set up some new memory (using an alloca) to hold the trampoline.
Unfortunately this breaks Go which allocates trampoline memory on the
heap and wants to use it even after the parent has exited (!).  Rather
than doing even more hacks to get Go working, it seemed best to just use
two intrinsics like in GCC.  Patch mostly by Sanjoy Das.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139140 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 13:37:06 +00:00
Duncan Sands
ad99ef8bf5 Delete trivial landing pads that just continue unwinding the caught
exception.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139117 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-05 12:57:57 +00:00
Bill Wendling
a268468d50 Use Duncan's patch to delete the instructions in reverse order (minus the landingpad and terminator).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139090 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 09:43:36 +00:00
Bill Wendling
9dc31e8705 Update comments to reflect reality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139023 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 18:43:33 +00:00
Andrew Trick
12d1ebe943 Enable SCEV-based unrolling by default.
This changes loop unrolling to use the same mechanism for trip count
computation as indvars. This is a stronger check that tends to unroll
more loops. A very common side-effect is that many single iteration
loops will be removed sooner. The real goal was simply to remove
dependence on canonical IVs.

x86 is break even.
ARM performance changes to expect (+ is good):
External/SPEC/CFP2000/183.equake/183.equake +13%
SingleSource/Benchmarks/Dhrystone/fldry     +21%
MultiSource/Applications/spiff/spiff         +3%
SingleSource/Benchmarks/Stanford/Puzzle     -14%

The Puzzle regression is actually an improvement in loop optimization
that defeats GVN: rdar://problem/10065079.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139009 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 17:26:28 +00:00
Jakub Staszak
8cec759339 Compare type size instead of type _store_ size to make sure that BitCastInst
will be valid. This fixes PR10820.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139005 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 14:57:37 +00:00
Bill Wendling
6bb4e7e8e8 Reduce indentation. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138968 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 21:29:49 +00:00
Bill Wendling
c8c0fd3993 Change worklist driven deletion to be an iterative process.
Duncan noticed this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138967 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 21:28:33 +00:00
Eli Friedman
86b5db8c01 Fix an issue with the IR sink pass found by inspection. (I'm not sure anyone is actually using this, but might as well fix it since I found the issue.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138965 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 21:21:24 +00:00
Bill Wendling
a8d1393093 Resubmit with fix. Properly remove the instructions except for landingpad, which should be removed only when its invokes are.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138932 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 01:28:11 +00:00
Bill Wendling
c1b4cd6c11 Submitted this too early.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138931 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 01:18:33 +00:00
Bill Wendling
1893cd3131 Don't DCE the landingpad instruction.
The landingpad instruction can be removed only when its invokes are removed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138930 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 01:16:58 +00:00
Bill Wendling
4f8aaa0928 Make sure we aren't deleting the landingpad instruction.
The landingpad instruction is required in the landing pad block. Because we're
not deleting terminating instructions, the invoke may still jump to here (see
Transforms/SCCP/2004-11-16-DeadInvoke.ll). Remove all uses of the landingpad
instruction, but keep it around until code-gen can remove the basic block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138890 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-31 20:55:20 +00:00
Rafael Espindola
f940a1a869 Remove the old tail duplication pass. It is not used and is unable to update
ssa, so it has to be run really early in the pipeline. Any replacement
should probably use the SSAUpdater.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138841 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 23:03:45 +00:00
Owen Anderson
54c4735db3 Speculatively revert r138809 in an attempt to fix DragonEgg.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 21:11:06 +00:00
Owen Anderson
6e4be237b0 When walking backwards to eliminate final stores to allocas at the end of a function, encountering an unrelated store should not cause us to give up like encountering a load does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138809 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 18:51:55 +00:00
Nadav Rotem
89879ec76b Fixes following the CR by Chris and Duncan:
Optimize chained bitcasts of the form A->B->A.
Undo r138722 and change isEliminableCastPair to allow this case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138756 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-29 19:58:36 +00:00
Nadav Rotem
be6ceb6ebc Bitcasts are transitive. Bitcast-Bitcast-X becomes Bitcast-X.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138722 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-28 11:51:08 +00:00
Bill Wendling
2b18881185 Don't sink landingpad instructions during ind-var simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138651 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-26 20:40:15 +00:00
Benjamin Kramer
9bb5488dbd Address review comments.
- Reword comments.
- Allow undefined behavior interfering with undefined behavior.
- Add address space checks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138619 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-26 02:25:55 +00:00
Benjamin Kramer
98d6d2372f SimplifyCFG: If we have a PHI node that can evaluate to NULL and do a load or store to the address returned by the PHI node then we can consider this incoming value as dead and remove the edge pointing there, unless there are instructions that can affect control flow executed in between.
In theory this could be extended to other instructions, eg. division by zero, but it's likely that it will "miscompile" some code because people depend on div by zero not trapping. NULL pointer dereference usually leads to a crash so we should be on the safe side.

This shrinks the size of a Release clang by 16k on x86_64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138618 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-26 01:22:29 +00:00
Bill Wendling
8b6af8a2a9 LSR wants to split the landing pad's critical edge. Let it do it, but use the
proper function to do it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138550 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 05:55:40 +00:00
Bill Wendling
89d4411cef When inserting new instructions, use getFirstInsertionPt instead of
getFirstNonPHI so that it will skip over the landingpad instructions as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138537 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 01:08:34 +00:00
Bill Wendling
a4c86ab073 Skip the landingpad instruction when determining the insertion point.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138481 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-24 21:06:46 +00:00
Bill Wendling
b05fdd6bab Use getFirstInsertionPt instead of getFirstNonPHI so that it skips to the proper
insertion place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138473 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-24 20:28:43 +00:00
Rafael Espindola
605e2b5184 Fix a crashing bug in SplitBlock when it is called on a block with no
dominator information even though dominators were previously computed.

Patch by Nick Sumner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138449 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-24 18:07:01 +00:00
Dan Gohman
d446460f42 Add a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 17:29:37 +00:00
Dan Gohman
1b31ea8f93 Constant pointers to objects don't need reference counting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138242 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 17:29:11 +00:00
Bill Wendling
94657b964f If we're splitting the landing pad block and assigning it only one predecessor,
then don't split it a second time, since that block will be dead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138153 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 23:46:30 +00:00
Bill Wendling
cbe003b243 The landingpad instruction isn't dead simply because it's value isn't used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138102 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 21:52:06 +00:00
Benjamin Kramer
a67f14bf53 Make a bunch of symbols private.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138025 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 01:42:18 +00:00
Benjamin Kramer
613d13beb0 C API functions must be able to see their extern "C" definitions, or it will be impossible to call them from C.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138022 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 01:36:54 +00:00
Dan Gohman
e6d5e88c12 Track a retain+release nesting level independently of the
known-incremented level, because the two concepts can be used
to prove the saftey of a retain+release removal in different
ways.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138016 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 00:26:36 +00:00
Bill Wendling
b29ec06421 Intelligently split the landing pad block.
We have to be careful when splitting the landing pad block, because the
landingpad instruction is required to remain as the first non-PHI of an invoke's
unwind edge. To retain this, we split the block into two blocks, moving the
predecessors within the loop to one block and the remaining predecessors to the
other. The landingpad instruction is cloned into the new blocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138015 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 00:09:22 +00:00
Bill Wendling
7e8840c4d9 Add SplitLandingPadPredecessors().
SplitLandingPadPredecessors is similar to SplitBlockPredecessors in that it
splits the current block and attaches a set of predecessors to the new basic
block. However, it differs from SplitBlockPredecessors in that it's specifically
designed to handle landing pad blocks.

Two new basic blocks are created: one that is has the vector of predecessors as
its predecessors and one that has the remaining predecessors as its
predecessors. Those two new blocks then receive a cloned copy of the landingpad
instruction from the original block. The landingpad instructions are joined in a
PHI, etc. Like SplitBlockPredecessors, it updates the LLVM IR, AliasAnalysis,
DominatorTree, DominanceFrontier, LoopInfo, and LCCSA analyses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138014 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 00:05:40 +00:00
Bill Wendling
26665de4f7 Use 'getFirstInsertionPt' when trying to insert new instructions during LICM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138008 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 23:42:36 +00:00
Dan Gohman
b48ef3a3ec Make it clear that this code is iterating in reverse order through the array.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137985 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 21:27:42 +00:00
Bill Wendling
66af89f642 Revert r137871. The loop simplify pass should require all exits from a loop that
aren't from an indirect branch need to be dominated by the loop header.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137981 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 21:10:01 +00:00
Bill Wendling
1c44d869cd Split out the updating of PHI nodes after splitting the BB into a separate
function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137979 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 20:51:04 +00:00
Bill Wendling
9210e840dd Use this fantzy ArrayRef thing to pass in the list of predecessors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137978 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 20:39:32 +00:00
Nick Lewycky
58e2cdfabd The edge from DISubprogram to DICompileUnit has been removed in recent versions
of debug info.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137972 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 19:07:42 +00:00
Bill Wendling
d4770144d4 Use static instead of anonymous namespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137959 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 17:57:57 +00:00
Bill Wendling
a644b33e8b Split out the analysis updating code into a helper function. No intended
functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137926 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 05:25:23 +00:00
Devang Patel
f56ea610ed Dramatically speedup codegen prepare by a) avoiding use of dominator tree and b) doing a separate pass over dbg.value instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137908 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 00:50:51 +00:00
Devang Patel
f6d3a4c7c4 Do not use DebugInfoFinder. Extract debug info directly from llvm.dbg.cu named mdnode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137890 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 22:49:38 +00:00
Eli Friedman
56efe24431 Atomic load/store handling for the passes using memdep (GVN, DSE, memcpyopt).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137888 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 22:22:24 +00:00
Bill Wendling
795cf5efba Disable PRE for landing pads.
PRE needs the landing pads to have their critical edges split. Doing this for a
landing pad is non-trivial. Abandon the attempt to perform PRE when we come
across a landing pad. (Reviewed by Owen!)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137876 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 21:32:02 +00:00
Bill Wendling
ab82fd9ff6 Increment the insertion iterator to beyond the landingpad instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137872 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 21:21:31 +00:00
Bill Wendling
0906a7c46c Don't optimize the landing pad exit block.
One way to exit the loop is through an unwind edge. However, that may involve
splitting the critical edge of the landing pad, which is non-trivial. Prevent
the transformation from rewriting the landing pad exit loop block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137871 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 21:20:43 +00:00
Bill Wendling
490606e613 Assert that we aren't trying to split the critical edge of a landing pad. Doing
so requires more care than this generic algorithm should handle.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137866 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 21:04:05 +00:00
Bill Wendling
c9b2a987a2 Revert r137655. There is some question about whether the 'landingpad'
instruction should be marked as potentially reading and/or writing memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137863 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 20:36:44 +00:00
Eli Friedman
447f95202a Silly mistake from r137777; restore significant isStructTy() checks. While here, be a bit more defensive
with unknown instructions.

Fixes PR10687.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137836 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 18:10:43 +00:00
Eli Friedman
054ddf799b A bunch of misc fixes to SCCPSolver::ResolvedUndefsIn, including a fix to stop
making random bad assumptions about instructions which are not explicitly listed.  

Includes fix for rdar://9956541, a version of "undef ^ undef should return
0 because it's easier than arguing with users".



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137777 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 22:06:31 +00:00
Eli Friedman
1fc291f0d3 Minor bug in SCCP found by inspection. (I don't think it's possible to hit this with a normal pass pipeline, but fixing for completeness.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137755 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 21:12:35 +00:00
Bill Wendling
5b6f42f57e Use the getFirstInsertionPt() method instead of getFirstNonPHI + an 'isa<>'
check for a LandingPadInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137745 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 20:45:24 +00:00
Bill Wendling
23b49ba6d5 I think there was some confusion about what I meant. :-) Replacing the comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137743 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 20:41:17 +00:00
David Chisnall
7a817eae6c Add a mechanism for optimisation plugins to register passes that all front ends can use without needing to be aware of the plugin (or the plugin be aware of the front end).
Before 3.0, I'd like to add a mechanism for automatically loading a set of plugins from a config file.  API suggestions welcome...



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137717 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 13:58:41 +00:00
Bill Wendling
05d0023a95 A few places where we want to skip the landingpad instruction for insertion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137712 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 04:52:55 +00:00
Eli Friedman
2199dfb0e6 Revert a bit of r137667; the logic in question can safely handle atomic load/store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137702 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 01:28:22 +00:00
Eli Friedman
6437f2c2e2 After talking with Bill, it seems like the LandingPad handling here is likely
to be wrong (or at least somewhat suspect).  Leave a FIXME for Bill.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137694 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 00:41:37 +00:00
Eli Friedman
33cb445fb6 Minor comment fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137693 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 00:20:11 +00:00
Eli Friedman
8176388d65 Update SimplifyCFG for atomic operations.
This commit includes a mention of the landingpad instruction, but it's not
changing the behavior around it.  I think the current behavior is correct,
though.  Bill, can you double-check that?



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137691 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 23:59:28 +00:00
Eli Friedman
fd06b3cfa1 Add comments and test for atomic load/store and mem2reg.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137690 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 23:55:52 +00:00
Bill Wendling
5e38c473a4 In places where it's using "getFirstNonPHI", skip the landingpad instruction if necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137679 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 23:19:54 +00:00
Bill Wendling
6456a62178 Don't sink the instruction to before a landingpad instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137672 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 22:53:05 +00:00
Eli Friedman
3d30b435e2 Update inter-procedural optimizations for atomic load/store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137667 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 22:16:46 +00:00
Eli Friedman
cc4a0435b7 Update instcombine for atomic load/store.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137664 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 22:09:40 +00:00
Bill Wendling
9d6070f161 Duncan pointed out that the LandingPadInst might read memory. (It might also
write to memory.) Marking it as such makes some checks for immobility go away.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137655 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 21:14:31 +00:00
Eli Friedman
0455bb89cd Fix llvm::CloneModule to correctly clone globals. Patch per bug report by Simon Moll on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137654 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 21:05:06 +00:00
Eli Friedman
97671565ff Atomic load/store support in LICM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137648 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 20:52:09 +00:00
Bill Wendling
187b1924a4 The "landingpad" instruction will never be "trivially" dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137642 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 20:10:51 +00:00
Bill Wendling
06f20ebfcf Don't try to sink the landingpad instruction. It's immobile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137629 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 18:23:40 +00:00
Bill Wendling
bc4fcbbc7b Mark the SCC as "might unwind" if we run into a 'resume' instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137627 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 18:22:00 +00:00
Bill Wendling
1178fb4701 Skip the insertion iterator past the landingpad instruction if there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137626 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 18:21:07 +00:00
Bill Wendling
fe7a071a19 Add inlining for the new EH scheme.
This builds off of the current scheme, but instead of llvm.eh.exception and
llvm.eh.selector, it uses the landingpad instruction. And instead of
llvm.eh.resume, it uses the resume instruction.

Because of the invariants in the landing pad instruction, a lot of code that's
currently needed to find the appropriate intrinsic calls for an invoke
instruction won't be needed once we go to the new EH scheme. The "FIXME"s tell
us what to remove after we switch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 08:01:36 +00:00
Nick Lewycky
28b84ff4ce This transform is not safe. Thanks to Eli for pointing that out!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137575 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 04:51:49 +00:00
Nick Lewycky
7f0170c197 Don't attempt to add 'nsw' when intermediate instructions had no such guarantee.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137572 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 03:41:33 +00:00
Nick Lewycky
daf27ea899 Teach instcombine to preserve the nsw bit by doing an after-the-fact analysis
when combining add and sub instructions. Patch by Pranav Bhandarkar!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137570 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 01:45:19 +00:00
Bill Wendling
e6e8826870 Initial commit of the 'landingpad' instruction.
This implements the 'landingpad' instruction. It's used to indicate that a basic
block is a landing pad. There are several restrictions on its use (see
LangRef.html for more detail). These restrictions allow the exception handling
code to gather the information it needs in a much more sane way.

This patch has the definition, implementation, C interface, parsing, and bitcode
support in it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137501 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 20:24:12 +00:00
Chris Lattner
3ebb64946b switch to use the new api for structtypes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137480 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 18:06:37 +00:00
Duncan Sands
1f6a329f79 Silence a bunch (but not all) "variable written but not read" warnings
when building with assertions disabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137460 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 14:54:45 +00:00
Dan Gohman
126a54f1fa Don't convert objc_autoreleaseReturnValue to objc_autorelease if the result
is returned through a bitcast.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137402 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 00:36:31 +00:00
Dan Gohman
a7f7db2ebd Don't let arbitrary calls disrupt nested retain+release pairs if
the retains and releases all use the same SSA pointer value.

Also, don't let CFG hazards disrupt nested retain+release pair
optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137399 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 00:26:31 +00:00
Dan Gohman
d8e48c4821 Use an actual reverse-CFG reverse-postorder for the bottom-up traversal,
rather than plain postorder, so that CFG constructs like single-exit loops
are reliably visited in a sensible order.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137398 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 00:24:29 +00:00
Andrew Trick
b1831c6640 Allow loop unrolling to get known trip counts from ScalarEvolution.
SCEV unrolling can unroll loops with arbitrary induction variables. It
is a prerequisite for -disable-iv-rewrite performance. It is also
easily handles loops of arbitrary structure including multiple exits
and is generally more robust.

This is under a temporary option to avoid affecting default
behavior for the next couple of weeks. It is needed so that I can
checkin unit tests for updateUnloop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137384 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 23:36:16 +00:00
Dan Gohman
fa7eed1f8e Fix typos in comments, and delete an unused function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137352 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 21:06:32 +00:00
Devang Patel
b549bcfe6c Distinguish between two copies of one inlined variable. Take 2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 21:50:54 +00:00
Andrew Trick
7cb3dcb927 Comments. Thanks for the spell check Nick!
Also, my apologies for spoiling the autocomplete on SimplifyInstructions.cpp. I couldn't think of a better filename.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137229 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 18:07:05 +00:00
Andrew Trick
39f40299a6 Invoke SimplifyIndVar when we partially unroll a loop. Fixes PR10534.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137203 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 04:29:49 +00:00
Andrew Trick
bddb7f8210 Cleanup. Make ScalarEvolution an explicit argument of the
SimplifyIndVar utility since it is required.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137202 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 04:22:26 +00:00
Andrew Trick
ea23daa446 SimplifyIndVar: make foldIVUser iterative to fold a chain of operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137199 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 04:01:31 +00:00
Benjamin Kramer
4a1a5eb95b Update CMake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137198 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 03:51:58 +00:00
Andrew Trick
4b4bb71bcd Added a SimplifyIndVar utility to simplify induction variable users
based on ScalarEvolution without changing the induction variable phis.

This utility is the main tool of IndVarSimplifyPass, but the pass also
restructures induction variables in strange ways that are sensitive to
pass ordering. This provides a way for other loop passes to simplify
new uses of induction variables created during transformation. The
utility may be used by any pass that preserves ScalarEvolution. Soon
LoopUnroll will use it.

The net effect in this checkin is to cleanup the IndVarSimplify pass
by factoring out the SimplifyIndVar algorithm into a standalone utility.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137197 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 03:46:27 +00:00
Andrew Trick
2d31ae3d9d Cleanup. Added LoopBlocksDFS::perform for simple clients.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137195 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 01:59:05 +00:00
Andrew Trick
b1eede1281 Fix the LoopUnroller to handle nontrivial loops and partial unrolling.
These are not individual bug fixes. I had to rewrite a good chunk of
the unroller to make it sane. I think it was getting lucky on trivial
completely unrolled loops with no early exits. I included some fairly
simple unit tests for partial unrolling. I didn't do much stress
testing, so it may not be perfect, but should be usable now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137190 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 00:28:10 +00:00
Eli Friedman
21006d40ac Representation of 'atomic load' and 'atomic store' in IR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137170 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 23:02:53 +00:00
Rafael Espindola
69cb216009 Add a C interface to PassManagerBuilder. It is missing the addExtension
functionality since in the C api a pass is created and added to a pass
manager in a single call.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137159 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 22:17:34 +00:00
Andrew Trick
70d0ca999c LoopUnroll looks like it has some stale code. Remove it to prove my sanity and avoid further confusion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137106 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 03:11:29 +00:00
Bill Wendling
8d676c2199 There is only one instance of this placeholder being created. Just use that
instead of a vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137099 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 01:17:10 +00:00
Bill Wendling
4fa93b7ce1 Remove an instance where the 'unwind' instruction was created.
The 'unwind' instruction was acting essentially as a placeholder, because it
would be replaced at the end of this function by a branch to the "unwind
handler". The 'unwind' instruction is going away, so use 'unreachable' instead,
which serves the same purpose as a placeholder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137098 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 01:09:21 +00:00
Andrew Trick
06988bcf6a Made SCEV's UDiv expressions more canonical. When dividing a
recurrence, the initial values low bits can sometimes be ignored.

To take advantage of this, added FoldIVUser to IndVarSimplify to fold
an IV operand into a udiv/lshr if the operator doesn't affect the
result.

-indvars -disable-iv-rewrite now transforms

i = phi i4
i1 = i0 + 1
idx = i1 >> (2 or more)
i4 = i + 4

into

i = phi i4
idx = i0 >> ...
i4 = i + 4


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137013 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-06 07:00:37 +00:00
Chandler Carruth
4147f39769 Temporarily revert r135528 which distinguishes between two copies of one
inlined variable, based on the discussion in PR10542.

This explodes the runtime of several passes down the pipeline due to
a large number of "copies" remaining live across a large function. This
only shows up with both debug and opt, but when it does it creates
a many-minute compile when self-hosting LLVM+Clang. There are several
other cases that show these types of regressions.

All of this is tracked in PR10542, and progress is being made on fixing
the issue. Once its addressed, the re-instated, but until then this
restores the performance for self-hosting and other opt+debug builds.

Devang, let me know if this causes any trouble, or impedes fixing it in
any way, and thanks for working on this!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136953 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-05 00:51:31 +00:00
Devang Patel
1f35b17885 We need to map DebugLoc. It leads to Fuction * (through subprogram entry node) which should be appropriately mapped.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136910 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 20:02:18 +00:00
Evan Cheng
a81388fb4a Fix an obvious type. Patch by Ivan Krasin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136900 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 18:40:26 +00:00
Bill Wendling
2626dba9c5 Remove the LowerSetJmp pass. It wasn't used effectively by any of the targets.
This is some of my original LLVM code. *wipes tear*


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136821 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 22:18:20 +00:00
Andrew Trick
1009c3299b SCEV: Use AssertingVH to catch dangling BasicBlock* when passes forget
to notify SCEV of a change. Add forgetLoop in a couple of those places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136797 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 18:32:11 +00:00
Andrew Trick
1c3ff6595f whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136795 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 18:28:21 +00:00
Nick Lewycky
dbd2255091 Small cleanups:
- use SmallVectorImpl& for the function argument.
  - ignore the operands on the GEP, even if they aren't constant! Much as we
    pretend the malloc succeeds, we pretend that malloc + whatever-you-GEP'd-by
    is not null. It's magic!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136757 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 01:11:40 +00:00
Nick Lewycky
d5061a9268 Fix logical error when detecting lifetime intrinsics.
Don't replace a gep/bitcast with 'undef' because that will form a "free(undef)"
which in turn means "unreachable". What we wanted was a no-op. Instead, analyze
the whole tree and look for all the instructions we need to delete first, then
delete them second, not relying on the use_list to stay consistent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136752 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 00:43:35 +00:00
Nick Lewycky
d8030c79fd Teach InstCombine that lifetime intrincs aren't a real user on the result of a
malloc call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136732 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 22:08:01 +00:00
Rafael Espindola
c684e83e45 Move methods in PassManagerBuilder offline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136727 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 21:50:27 +00:00
Eli Friedman
fe1926e351 Add new atomic instructions to SCCP. No functional change, but stops debug spam.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136723 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 21:35:16 +00:00
Nick Lewycky
3e69c13c30 Lifetime intrinsics on undef are dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136722 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 21:19:27 +00:00
Owen Anderson
9b7fdc7e8a Revert r136503 and r136480 in an effort to fix non-determinism in the llvm-gcc buildbots on i386. Devang is looking into the root cause.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136674 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 02:23:42 +00:00
Bill Wendling
dccc03b242 Add the 'resume' instruction for the new EH rewrite.
This adds the 'resume' instruction class, IR parsing, and bitcode reading and
writing. The 'resume' instruction resumes propagation of an existing (in-flight)
exception whose unwinding was interrupted with a 'landingpad' instruction (to be
added later).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136589 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-31 06:30:59 +00:00
Rafael Espindola
592ad6a82f Add a small gep optimization I noticed was missing while reading some IL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136585 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-31 04:43:41 +00:00
Bill Wendling
10c6d12a9f Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,
r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444,
r136445, r136446, r136253 pending review.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136556 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 05:42:50 +00:00
Devang Patel
6e8bb8a0cb Clear DbgValues in the end.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136503 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 19:49:58 +00:00
Devang Patel
1619560521 Clean up debug info after reassociation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136480 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 19:00:35 +00:00
Eli Friedman
55ba816883 Misc optimizer+codegen work for 'cmpxchg' and 'atomicrmw'. They appear to be
working on x86 (at least for trivial testcases); other architectures will
need more work so that they actually emit the appropriate instructions for
orderings stricter than 'monotonic'. (As far as I can tell, the ARM, PPC,
Mips, and Alpha backends need such changes.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136457 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 03:05:32 +00:00
Eli Friedman
ef71597242 Make sure to correctly clear the exact/nuw/nsw flags off of shifts when they are combined together. <rdar://problem/9859829>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136435 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 00:18:19 +00:00
Chandler Carruth
ac03e736c7 Rewrite the CMake build to use explicit dependencies between libraries,
specified in the same file that the library itself is created. This is
more idiomatic for CMake builds, and also allows us to correctly specify
dependencies that are missed due to bugs in the GenLibDeps perl script,
or change from compiler to compiler. On Linux, this returns CMake to
a place where it can relably rebuild several targets of LLVM.

I have tried not to change the dependencies from the ones in the current
auto-generated file. The only places I've really diverged are in places
where I was seeing link failures, and added a dependency. The goal of
this patch is not to start changing the dependencies, merely to move
them into the correct location, and an explicit form that we can control
and change when necessary.

This also removes a serialization point in the build because we don't
have to scan all the libraries before we begin building various tools.
We no longer have a step of the build that regenerates a file inside the
source tree. A few other associated cleanups fall out of this.

This isn't really finished yet though. After talking to dgregor he urged
switching to a single CMake macro to construct libraries with both
sources and dependencies in the arguments. Migrating from the two macros
to that style will be a follow-up patch.

Also, llvm-config is still generated with GenLibDeps.pl, which means it
still has slightly buggy dependencies. The internal CMake
'llvm-config-like' macro uses the correct explicitly specified
dependencies however. A future patch will switch llvm-config generation
(when using CMake) to be based on these deps as well.

This may well break Windows. I'm getting a machine set up now to dig
into any failures there. If anyone can chime in with problems they see
or ideas of how to solve them for Windows, much appreciated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136433 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 00:14:25 +00:00
Bill Wendling
9580641d5f Some minor cleanups. No functionalitical change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136341 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 07:44:07 +00:00
Bill Wendling
9a2dde3fd1 Leverage some of the code that John wrote to manage the landing pads.
The new EH is more simple in many respects. Mainly, we don't have to worry about
the "llvm.eh.exception" and "llvm.eh.selector" calls being in weird places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136339 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 07:31:46 +00:00
Bill Wendling
e8ce880f1a Automatically merge the landingpad clauses when we come across a callee's
landingpad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136329 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 02:40:13 +00:00
Benjamin Kramer
b2e7c8250b Fix a use after free. An instruction can't be both an intrinsic call and a fence.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136319 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 01:20:19 +00:00
Bill Wendling
2bf84c15d2 Initial stab at getting inlining working with the EH rewrite.
This takes the new 'resume' instruction and turns it into a direct jump to the
caller's landing pad code. The caller's landingpad instruction is merged with
the landingpad instructions of the callee. This is a bit rough and makes some
assumptions in how the code works. But it passes a simple test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136313 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 00:38:23 +00:00
Bill Wendling
91c56a8d8d Refuse to inline two functions which use different personality functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136269 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:44:28 +00:00
Bill Wendling
772fe17a6d Merge the contents from exception-handling-rewrite to the mainline.
This adds the new instructions 'landingpad' and 'resume'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 20:18:04 +00:00
Nick Lewycky
e511186183 Teach the ConstantMerge pass about alignment. Fixes PR10514!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136250 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 19:47:34 +00:00
Eli Friedman
8a552bb85a Misc mid-level changes for new 'fence' instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136205 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 01:08:30 +00:00
Bill Wendling
726f1b90a9 Use the correct for for the version. It's little endian and my brain is
obviously big endian. :-)
PR10502


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136111 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 18:31:41 +00:00
Rafael Espindola
3d72290ecb Add LLVMAddAlwaysInlinerPass to the C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136083 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 15:23:23 +00:00
Rafael Espindola
a03084d86e LLVM 3.0 is here, remove old do nothing method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136082 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 15:17:32 +00:00
Nick Lewycky
5a1cb644c9 Finish adding support for lifetime intrinsics to SROA. Fixes PR10121!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136008 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 23:14:22 +00:00
Andrew Trick
478849e98c Add clarifying comments for the new arguments to UnrollLoop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135988 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 22:17:47 +00:00
Nick Lewycky
fd47a59661 Add missing space (this line is no longer pushing the 80-column limit).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135973 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 21:16:04 +00:00
Rafael Espindola
0335a14ae7 Add LLVMAddLowerExpectIntrinsicPass to the C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135966 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 20:57:59 +00:00
Frits van Bommel
2eb40f6d86 Shorten some expressions by using ArrayRef::slice().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135910 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 15:13:01 +00:00
Jay Foad
a9203109f4 Convert GetElementPtrInst to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135904 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 09:48:08 +00:00
Andrew Trick
2045ce154a Move trip count discovery outside of the generic LoopUnroll helper. This
removes its dependence on canonical induction variables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 00:33:05 +00:00
Andrew Trick
ba03377fa1 whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135828 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 00:29:16 +00:00
Dan Gohman
4428069f10 Move the last uses of RetainFunc etc. over to using getRetainCallee() etc.
so that a declaration for objc_retain is created when needed if it doesn't
already exist. rdar://9825114.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135821 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 22:29:21 +00:00
Jay Foad
b4263a6ff4 Fix more MSVC warnings caused by a cases I missed when converting
ConstantExpr::getGetElementPtr to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135762 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 08:52:50 +00:00
Jay Foad
0a2a60ace9 Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to use
ArrayRef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135761 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 08:16:57 +00:00
Jay Foad
8908ff207d Fix an MSVC warning, caused by a case I missed when converting
ConstantExpr::getGetElementPtr to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135758 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 07:54:01 +00:00
Dan Gohman
856e13ddac Fix MergeInVectorType to check for vector types with the same alloc
size but different element types, so that it filters out the cases
that CreateShuffleVectorCast doesn't handle. This fixes rdar://9786827.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135721 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 23:30:09 +00:00
Andrew Trick
a305fe7545 Cleanup: make std::pair usage slightly less indecipherable without actually naming variables!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135684 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 17:37:39 +00:00
Jay Foad
4b5e207bf2 Make better use of ConstantExpr::getGetElementPtr's InBounds parameter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135676 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 15:15:37 +00:00
Jay Foad
dab3d29605 Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135673 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 14:31:17 +00:00
Chris Lattner
c30a38f34b move tier out of an anonymous namespace, it doesn't make sense
to for it to be an an anon namespace and be in a header.

Eliminate some extraenous uses of tie.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135669 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 06:21:31 +00:00
Andrew Trick
c205a094bd LSR, correct fix for rdar://9786536. Silly casting bug.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135654 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 01:45:54 +00:00
Andrew Trick
c2c988e5e0 LSR must sometimes sign-extend before generating double constants.
rdar://9786536


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135650 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 01:05:01 +00:00
Andrew Trick
37eb38d3f8 LSR crashes on an empty IVUsers list.
rdar://9786536


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135644 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 00:40:04 +00:00
Eli Friedman
747032522f Clean up includes of llvm/Analysis/ConstantFolding.h so it's included where it's used and not included where it isn't.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135628 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 21:57:23 +00:00
Eli Friedman
73bfa4aecf Bring LICM into compliance with the new "Memory Model for Concurrent Operations" in LangRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135625 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-20 21:37:47 +00:00