Commit Graph

6974 Commits

Author SHA1 Message Date
Owen Anderson
bd129a7460 Add instcombine transforms to optimize tests of multiple bits of the same value into a single larger comparison.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14 23:33:51 +00:00
Owen Anderson
e84178a0bd Extend SimplifyCFG's common-destination folding heuristic to allow a single
"bonus" instruction to be speculatively executed.  Add a heuristic to
ensure we're not tripping up out-of-order execution by checking that this bonus
instruction only uses values that were already guaranteed to be available.

This allows us to eliminate the short circuit in (x&1)&&(x&2).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108351 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14 19:52:16 +00:00
Chris Lattner
07c9b64719 revert r108320, I see the failures now...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108322 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14 06:16:35 +00:00
Chris Lattner
7e185af930 reapply benjamin's instcombine patch, I don't see anything wrong with it and can't repro any problems with a manual self-host.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108320 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14 05:59:13 +00:00
Eric Christopher
f0193ed8de Grammar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108252 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13 18:27:13 +00:00
Duncan Sands
d0d3ccc827 Handle the case of a tail recursion in which the tail call is followed
by a return that returns a constant, while elsewhere in the function
another return instruction returns a different constant.  This is a
special case of accumulator recursion, so just generalize the existing
logic a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108241 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13 15:41:41 +00:00
Benjamin Kramer
c9fe6374b7 Nope, still breaks the release selfhost bots :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108153 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 16:38:48 +00:00
Benjamin Kramer
8fd437c43f Reapply the "or" half of r108136, which seems to be less problematic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108152 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 16:15:48 +00:00
Gabor Greif
a9b8338bfa cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108150 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 15:48:26 +00:00
Benjamin Kramer
e2d07b5208 Revert r108141 again, sigh.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108148 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 14:42:04 +00:00
Gabor Greif
40119ceeec cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108147 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 14:15:58 +00:00
Gabor Greif
a53029b1fc cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108146 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 14:15:10 +00:00
Gabor Greif
65b9212d34 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108145 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 14:14:03 +00:00
Gabor Greif
aaaaa02a93 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108144 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 14:13:15 +00:00
Gabor Greif
b7df500063 cache results of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108143 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 14:12:11 +00:00
Gabor Greif
ee1f44fba3 cache results of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108142 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 14:10:24 +00:00
Benjamin Kramer
98a8206e58 Reapply 108136 with an ugly pasto fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108141 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 13:44:00 +00:00
Benjamin Kramer
ad854f0764 Move optimization to avoid redundant matching.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108140 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 13:34:22 +00:00
Benjamin Kramer
0cc4ed1ca5 Revert r108136 until I figure out why it broke selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108139 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 12:35:49 +00:00
Gabor Greif
110b75aa75 cache dereferenced iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108138 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 12:03:02 +00:00
Gabor Greif
639e9e47a2 recommit r108131 (hich has been backed out in r108135) with a fix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108137 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 12:02:10 +00:00
Benjamin Kramer
4fc719e607 instcombine: fold (x & y) | (~x & z) and (x & y) ^ (~x & z) into ((y ^ z) & x) ^ z which is one instruction shorter. (PR6773)
before:
  %and = and i32 %y, %x
  %neg = xor i32 %x, -1
  %and4 = and i32 %z, %neg
  %xor = xor i32 %and4, %and

after:
  %xor1 = xor i32 %z, %y
  %and2 = and i32 %xor1, %x
  %xor = xor i32 %and2, %z


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108136 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 11:54:45 +00:00
Gabor Greif
e99e077522 back out r108131 (of TailDuplication.cpp) for now, it causes a buildbot failure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108135 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 11:32:39 +00:00
Gabor Greif
fc41f90817 cache dereferenced iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 11:19:24 +00:00
Gabor Greif
625398343e cache dereferenced iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 10:59:23 +00:00
Gabor Greif
f1b2874c68 cache dereferenced iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108132 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 10:49:54 +00:00
Gabor Greif
a8b9df7bd9 cache dereferenced iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108131 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 10:36:48 +00:00
Duncan Sands
3472766f9e Convert some tab stops into spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108130 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 08:16:59 +00:00
Chris Lattner
5a30a8574c make the prototypes for CreateMalloc and CreateFree more consistent. Patch
by Hans Vandierendonck from PR7605


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108116 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 00:57:28 +00:00
Chris Lattner
0a96144aac if jump threading is able to infer interesting values on both
the LHS and RHS of an and/or instruction, don't multiply add
known predecessor values.  This fixes the crash on testcase
from PR7498


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108114 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 00:47:34 +00:00
Duncan Sands
24080a9878 The accumulator tail recursion transform claims to work for any associative
operation, but the way it's implemented requires the operation to also be
commutative.  So add a check for commutativity (and tweak the corresponding
comments).  This makes no difference in practice since every associative
LLVM instruction is also commutative!  Here's an example to show the need
for commutativity: the accum_recursion.ll testcase calculates the factorial
function.  Before the transformation the result of a call is
  ((((1*1)*2)*3)...)*x
while afterwards it is
  (((1*x)*(x-1))...*2)*1
which clearly requires both associativity and commutativity of * to be equal
to the original.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108056 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-10 20:31:42 +00:00
Gabor Greif
e664267ae7 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107990 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 16:51:20 +00:00
Gabor Greif
9085fcab82 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107984 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 16:31:08 +00:00
Gabor Greif
bf2eefdb0d cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107983 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 16:26:41 +00:00
Gabor Greif
e80ba4f884 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107981 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 16:17:52 +00:00
Gabor Greif
7656018c22 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107976 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 15:40:10 +00:00
Gabor Greif
7556cf541b cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107975 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 15:25:42 +00:00
Gabor Greif
5896935423 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107974 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 15:25:09 +00:00
Gabor Greif
fc36c0f21f cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107972 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 15:01:36 +00:00
Gabor Greif
1d3ae029c4 cache result of operator* (found by inspection)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107971 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 14:48:08 +00:00
Gabor Greif
0814985887 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107969 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 14:36:49 +00:00
Gabor Greif
a29742df5f cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107968 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 14:29:14 +00:00
Gabor Greif
5417a03b55 cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 14:18:23 +00:00
Gabor Greif
9672414017 cache operator*'s result (in multiple functions)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107965 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 14:02:13 +00:00
Gabor Greif
b654435712 do not repeatedly dereference use_iterator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107962 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09 12:23:50 +00:00
Benjamin Kramer
1db071f0da Teach instcombine to transform
(X >s -1) ? C1 : C2 and (X <s  0) ? C2 : C1
into ((X >>s 31) & (C2 - C1)) + C1, avoiding the conditional.

This optimization could be extended to take non-const C1 and C2 but we better
stay conservative to avoid code size bloat for now.

for
int sel(int n) {
     return n >= 0 ? 60 : 100;
}

we now generate
  sarl  $31, %edi
  andl  $40, %edi
  leal  60(%rdi), %eax

instead of
  testl %edi, %edi
  movl  $60, %ecx
  movl  $100, %eax
  cmovnsl %ecx, %eax


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107866 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-08 11:39:10 +00:00
Chris Lattner
0238f8c430 Fix the second half of PR7437: scalarrepl wasn't preserving
address spaces when SRoA'ing memcpy's.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107846 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-08 00:27:05 +00:00
Duncan Sands
8246adc1f0 Rename "Release" builds as "Release+Asserts"; rename "Release-Asserts"
builds to "Release".  The default build is unchanged (optimization on,
assertions on), however it is now called Release+Asserts.  The intent
is that future LLVM releases released via llvm.org will be Release builds
in the new sense, i.e. will have assertions disabled (currently they have
assertions enabled, for a more than 20% slowdown).  This will bring them
in line with MacOS releases, which ship with assertions disabled.  It also
means that "Release" now means the same things in make and cmake builds:
cmake already disables assertions for "Release" builds AFAICS.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107758 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07 07:48:00 +00:00
Nick Lewycky
10d2f4d01b Detabify this file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107637 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06 03:53:43 +00:00
Devang Patel
1192d4d0a5 MDString is already checked earlier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107516 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-02 21:13:23 +00:00
Dan Gohman
8c1ffae068 Don't claim to preserve AliasAnalysis. First, this is doesn't actually
have any effect, and second, deleting stores can potentially invalidate
an AliasAnalysis, and there's currently no notification for this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107496 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-02 18:43:05 +00:00
Bill Wendling
5e721d7682 Implement the "linker_private_weak" linkage type. This will be used for
Objective-C metadata types which should be marked as "weak", but which the
linker will remove upon final linkage. However, this linkage isn't specific to
Objective-C.

For example, the "objc_msgSend_fixup_alloc" symbol is defined like this:

      .globl l_objc_msgSend_fixup_alloc
      .weak_definition l_objc_msgSend_fixup_alloc
      .section __DATA, __objc_msgrefs, coalesced
      .align 3
l_objc_msgSend_fixup_alloc:
       .quad   _objc_msgSend_fixup
       .quad   L_OBJC_METH_VAR_NAME_1

This is different from the "linker_private" linkage type, because it can't have
the metadata defined with ".weak_definition".

Currently only supported on Darwin platforms.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107433 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01 21:55:59 +00:00
Devang Patel
26d14294de Debugging infomration is encoded in llvm IR using metadata. This is designed
such a way that debug info for symbols preserved even if symbols are
optimized away by the optimizer. 

Add new special pass to remove debug info for such symbols.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107416 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01 19:49:20 +00:00
Devang Patel
e62b203570 If a named mdnode is removed then mark module as changed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107412 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01 18:27:46 +00:00
Jim Grosbach
7fa1bbad29 lowerinvoke needs to handle aggregate function args like sjlj eh does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107335 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 22:22:59 +00:00
Devang Patel
444a08cd6f Remove all debug info related named mdnodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107323 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 21:29:00 +00:00
Gabor Greif
8e1ebff9f1 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107278 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 12:42:43 +00:00
Gabor Greif
e9af352d74 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107277 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 12:40:35 +00:00
Gabor Greif
2458513430 use getArgOperand (corrected by CallInst::ArgOffset) instead of getOperand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107275 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 12:38:26 +00:00
Gabor Greif
6e1f330c4c use getArgOperand (corrected by CallInst::ArgOffset) instead of getOperand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107273 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 09:19:23 +00:00
Gabor Greif
237e1da16a use getNumArgOperands instead of getNumOperands
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107272 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 09:17:53 +00:00
Gabor Greif
6f14c8c7c1 use getArgOperand instead of getOperand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107271 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 09:16:16 +00:00
Gabor Greif
ad72e73136 use getArgOperand instead of getOperand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107270 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 09:15:28 +00:00
Gabor Greif
351cbac4d3 use getArgOperand instead of getOperand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107269 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 09:14:26 +00:00
Bill Wendling
07d3177117 Revert r107205 and r107207.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107215 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29 22:34:52 +00:00
Bill Wendling
207855cff9 Introducing the "linker_weak" linkage type. This will be used for Objective-C
metadata types which should be marked as "weak", but which the linker will
remove upon final linkage. For example, the "objc_msgSend_fixup_alloc" symbol is
defined like this:

       .globl l_objc_msgSend_fixup_alloc
       .weak_definition l_objc_msgSend_fixup_alloc
       .section __DATA, __objc_msgrefs, coalesced
       .align 3
l_objc_msgSend_fixup_alloc:
        .quad   _objc_msgSend_fixup
        .quad   L_OBJC_METH_VAR_NAME_1

This is different from the "linker_private" linkage type, because it can't have
the metadata defined with ".weak_definition".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107205 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29 21:24:00 +00:00
Duncan Sands
a7065b1fcc Return Changed. This required setting Changed if dbg metadata
is stripped off.  Currently set unconditionally, since the API
does not provide a way of working out if anything was actually
stripped off.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107142 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29 14:52:10 +00:00
Gabor Greif
a90c5c7605 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107017 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28 16:50:57 +00:00
Gabor Greif
30d2577f64 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107016 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28 16:45:00 +00:00
Gabor Greif
d6bf5cf641 employ CallInst::ArgOffset (for now)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107015 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28 16:43:57 +00:00
Gabor Greif
18c383f87f use setArgOperand
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107004 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28 12:31:35 +00:00
Gabor Greif
245e9c4834 use CallInst::ArgOffset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107003 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28 12:30:07 +00:00
Gabor Greif
f148cb6044 use ArgOperand API and CallInst::ArgOffset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107002 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28 12:29:20 +00:00
Gabor Greif
19101c7585 use cached value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107000 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28 11:20:42 +00:00
Chris Lattner
1495247f51 minor cleanup to SROA: when lowering type unsafe accesses to
large integers, the first inserted value would always create
an 'or X, 0'.  Even though this is trivially zapped by
instcombine, don't bother creating this pointless instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106979 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-27 07:58:26 +00:00
Duncan Sands
d50e9e2566 Fix PR7328: when turning a tail recursion into a loop, need to preserve
the returned value after the tail call if it differs from other return
values.  The optimal thing to do would be to introduce a phi node for
the return value, but for the moment just fix the miscompile.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106947 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-26 12:53:31 +00:00
Dan Gohman
3e3f15bb09 In GenerateReassociations, don't bother thinking about individual
SCEVUnknown values which are loop-variant, as LSR can't do anything
interesting with these values in any case. This fixes very slow compile
times on loops which have large numbers of such values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106897 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25 22:32:18 +00:00
Dale Johannesen
1784d160e4 The hasMemory argument is irrelevant to how the argument
for an "i" constraint should get lowered; PR 6309.  While
this argument was passed around a lot, this is the only
place it was used, so it goes away from a lot of other
places.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106893 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25 21:55:36 +00:00
Gabor Greif
f1ba6513bf use ArgOperand API (one more hunk I could split)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106825 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25 07:58:41 +00:00
Gabor Greif
9c68a7bb45 use ArgOperand API (some hunks I could split)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106824 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25 07:57:14 +00:00
Gabor Greif
7f1d7f5779 use ArgOperand API; tighten type of handleFreeWithNonTrivialDependency to be able to use isFreeCall whithout a cast or new overload
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106823 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25 07:40:32 +00:00
Dan Gohman
fc33a3099e Add an exports file for the Hello example plugin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106768 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 17:36:51 +00:00
Dan Gohman
2ea09e0546 A few minor micro-optimizations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106764 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 16:57:52 +00:00
Dan Gohman
d42819a07b Teach getExactSDiv to evaluate x/1 to x up front, as it's a common
enough special case, and it theoretically allows more folding because
it works even when x is unanalyzable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106763 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 16:51:25 +00:00
Dan Gohman
473e63512a Fix copy+pasto issues in isMulSExtable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106759 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 16:45:11 +00:00
Gabor Greif
caf70b31b0 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106752 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 16:11:44 +00:00
Gabor Greif
2f1ab74e76 use (even more, still) ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106750 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 15:51:11 +00:00
Gabor Greif
9e4f243de7 use ArgOperand API and CallSite for arg range; add necessary casts and perform some cosmetics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106747 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 14:42:01 +00:00
Gabor Greif
fef8c4eb54 use ArgOperand API and CallSite for arg range
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106745 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 14:13:36 +00:00
Gabor Greif
bcda85c743 use (even more) ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106744 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 13:54:33 +00:00
Gabor Greif
c310fcc909 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106743 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 13:42:49 +00:00
Gabor Greif
cea7ac7c01 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106740 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 12:58:35 +00:00
Gabor Greif
3e84e2e90f use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106737 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 12:35:13 +00:00
Gabor Greif
916973706d use ArgOperand API, also tighten the type of visitFree to make this work out smoothly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106736 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 12:21:15 +00:00
Gabor Greif
3ccbb22eaf use ArgOperand API; introduce downcasted pointers into scope to facilitate this
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106734 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 12:03:56 +00:00
Gabor Greif
aee5dc1939 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106731 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 10:42:46 +00:00
Gabor Greif
d883a9d1ed use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106730 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 10:17:17 +00:00
Gabor Greif
0a14be0693 use callsite to obtain all arguments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106729 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 10:04:07 +00:00
Gabor Greif
aeff385e3e use callsite to obtain all arguments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106728 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 09:56:43 +00:00
Gabor Greif
407014f9a5 use getNumArgOperands
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 00:48:48 +00:00
Gabor Greif
de9f5452d3 use ArgOperand API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106707 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 00:44:01 +00:00
Devang Patel
e9916a302f Use ValueMap instead of DenseMap.
The ValueMapper used by various cloning utility maps MDNodes also.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106706 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 00:33:28 +00:00
Devang Patel
774cca70b1 Use available typedef for " DenseMap<const Value*, Value*>".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106699 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-24 00:00:42 +00:00
Devang Patel
29d3dd8a64 Cosmetic change.
Do not use "ValueMap" as a name for a local variable or an argument.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106698 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-23 23:55:51 +00:00
Devang Patel
170f06ebe2 Revert 106592 for now. It causes clang-selfhost build failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106598 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 23:29:55 +00:00
Dan Gohman
caf71ab473 Fix OptimizeMax to handle an odd case where one of the max operands
is another max which folds. This fixes PR7454.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106594 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 23:07:13 +00:00
Devang Patel
186b3d2606 If a metadata operand is seeded in value map and the metadata should also be seeded in value map. This is not limited to function local metadata.
Failure to seed metdata in such cases causes troubles when in a cloned module, metadata from a new module refers to values in old module. Usually this results in mysterious bugpoint crashes. For example,

 Checking to see if we can delete global inits: Unknown constant!
 UNREACHABLE executed at /d/g/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:904!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106592 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 22:53:21 +00:00
Devang Patel
3bf329f495 While cloning a module, clone metadata attached with instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106591 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 22:50:42 +00:00
Devang Patel
d8800e7972 Clone named metadata while cloning a module.
Reapply Bob's patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106560 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 18:52:38 +00:00
Dan Gohman
fe60104ac9 Use pre-increment instead of post-increment when the result is not used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 15:08:57 +00:00
Devang Patel
e4acff8720 Revert 106528. It is causing self host failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106529 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 06:14:09 +00:00
Devang Patel
52e0612f7d Do not rely on DenseMap slot which can be easily invalidated when DenseMap grows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106528 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 05:16:56 +00:00
Bob Wilson
ec68864877 Revert my change to clone named metadata. Buildbots are complaining.
--- Reverse-merging r106508 into '.':
U    lib/Transforms/Utils/CloneModule.cpp


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106521 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 02:08:51 +00:00
Bob Wilson
e42f493f4c Include named metadata when cloning a module.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106508 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 00:11:03 +00:00
Dan Gohman
403a8cdda5 Use A.append(...) instead of A.insert(A.end(), ...) when A is a
SmallVector, and other SmallVector simplifications.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106452 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-21 19:47:52 +00:00
Dan Gohman
74e5ef096e Add a TODO comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106397 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-19 21:30:18 +00:00
Dan Gohman
1e3121c80a Include the use kind along with the expression in the key of the
use sharing map. The reconcileNewOffset logic already forces a
separate use if the kinds differ, so incorporating the kind in the
key means we can track more sharing opportunities.

More sharing means fewer total uses to track, which means smaller
problem sizes, which means the conservative throttles don't kick
in as often.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106396 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-19 21:29:59 +00:00
Dan Gohman
b6211710ac Don't include things in anonymous namespaces that don't need it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106395 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-19 21:21:39 +00:00
Dan Gohman
a52838285b Disable indvars on loops when LoopSimplify form is not available.
This fixes PR7333.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106267 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 01:35:11 +00:00
Jim Grosbach
d0e8469ba6 remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106164 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 22:41:09 +00:00
Rafael Espindola
e96af56a5b Make sure that simplify libcalls does not replace a call with one calling
convention with a new call with a different calling convention.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 19:34:01 +00:00
Benjamin Kramer
ea9ca0236d simplify-libcalls: fold strncmp(x, y, 1) -> memcmp(x, y, 1)
The memcmp will be optimized further and even the pathological case
'strstr(x, "x") == x' generates optimal code now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106097 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 10:30:29 +00:00
Benjamin Kramer
386e918438 simplify-libcalls: fold strstr(a, b) == a -> strncmp(a, b, strlen(b)) == 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106047 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-15 21:34:25 +00:00
Chris Lattner
e58867e55e jump threading can't split a critical edge from an indirectbr. This
fixes PR7356.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105950 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-14 19:45:43 +00:00
Benjamin Kramer
c05cb8d561 SimplifyCFG: don't turn volatile stores to null/undef into unreachable. Fixes PR7369.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105914 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-13 14:35:54 +00:00
Kenneth Uildriks
42c7d23c6d Pulled CodeMetrics out of InlineCost.h and made it a bit more general, so it can be reused from PartialSpecializationCost
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105725 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-09 15:11:37 +00:00
Dan Gohman
b9539745c5 Make bugpoint dead-argument-hacking actually work, and actually test it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105551 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-07 20:20:33 +00:00
Kenneth Uildriks
3a4340d4cb Partial specialization was not checking the callsite to make sure it was using the same constants as the specialization, leading to calls to the wrong specialization. Patch by Takumi Nakamura\!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105528 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-05 14:50:21 +00:00
Dan Gohman
a15ec5dfcc Don't track users of undef values; they aren't interesting for
register pressure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105501 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-04 23:16:05 +00:00
Devang Patel
93031ac032 Copy location info for current function argument from dbg.declare if respective store instruction does not have any location info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105490 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-04 22:27:30 +00:00
Jim Grosbach
23d3d4595c Remove unused code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105293 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-01 21:56:30 +00:00
Jim Grosbach
69081e9291 fix think-o
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105291 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-01 21:35:50 +00:00
Jim Grosbach
aeafb374e2 Simplify things a bit more. Fix prototype to use SmallVectorImpl and
change a few SmallVectors to vanilla C arrays.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105289 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-01 21:06:46 +00:00
Jim Grosbach
0fd8b6283f mirror of r105280 changes for LowerInvoke, which uses the same basic logic here
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105281 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-01 18:04:56 +00:00
Jim Grosbach
601f9d6c03 Use SmallVector instead of std::vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105279 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-01 17:56:41 +00:00
Duncan Sands
2914ba6ec7 Fix PR7272: when inlining through a callsite with byval arguments,
the newly created allocas may be used by inlined calls, so these
need to have their tail call flags cleared.  Fixes PR7272.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105255 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-31 21:00:26 +00:00
Benjamin Kramer
c29df3cac7 Avoid swap when a copy suffices.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105220 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-31 12:50:41 +00:00
Nick Lewycky
a9d6680cb1 The memcpy intrinsic only takes i8* for %src and %dst, so cast them to that
first. Fixes PR7265.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105206 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-31 06:16:35 +00:00
Dan Gohman
dd9344f3fa Move FindAvailableLoadedValue isSafeToLoadUnconditionally out of
lib/Transforms/Utils and into lib/Analysis so that Analysis passes
can use them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104949 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 16:19:17 +00:00
Dan Gohman
05d6253727 Teach instcombine to promote alloca array sizes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104945 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 15:09:00 +00:00
Dan Gohman
28d2e0a39f Fix instcombine's handling of alloca to accept non-i32 types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104935 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 04:33:04 +00:00
Devang Patel
4251d85ae7 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104914 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 01:29:50 +00:00
Devang Patel
f7a3051471 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104913 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 01:17:51 +00:00
Devang Patel
d8720f4ba3 Do not drop location info for inlined function args.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104884 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 20:25:04 +00:00
Duncan Sands
1d9b973fd7 Teach instCombine to remove malloc+free if malloc's only uses are comparisons
to null.  Patch by Matti Niemenmaa.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104871 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 19:09:06 +00:00
Benjamin Kramer
1464c1d60a Kill unneeded SExt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104692 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 09:45:04 +00:00
Benjamin Kramer
48aefe15d0 Properly promote operands when optimizing a single-character memcmp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104648 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-25 22:53:43 +00:00
Dan Gohman
5b71dcedf0 Fix a missing newline in debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104644 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-25 21:50:35 +00:00
Dan Gohman
0fe46d9b48 DominatorTree.getNode can return null for unreachable blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104290 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-20 22:46:54 +00:00
Dan Gohman
9f383eb950 Minor code cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104287 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-20 22:25:20 +00:00