Chris Lattner
3eb0af94c4
fix PR9215, preventing -reassociate from clearing nsw/nuw when
...
it swaps the LHS/RHS of a single binop.
llvm-svn: 125700
2011-02-17 01:29:24 +00:00
Dan Gohman
08d2c98c23
Fix reassociate to clear optional flags, such as nsw.
...
llvm-svn: 124712
2011-02-02 02:02:34 +00:00
Duncan Sands
69bdb585b2
Fix PR9039, a use-after-free in reassociate. The issue was that the
...
operand being factorized (and erased) could occur several times in Ops,
resulting in freed memory being used when the next occurrence in Ops was
analyzed.
llvm-svn: 124287
2011-01-26 10:08:38 +00:00
Owen Anderson
6c18d1aac0
Get rid of static constructors for pass registration. Instead, every pass exposes an initializeMyPassFunction(), which
...
must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize
the pass's dependencies.
Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the
CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h
before parsing commandline arguments.
I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems
with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass
registration/creation, please send the testcase to me directly.
llvm-svn: 116820
2010-10-19 17:21:58 +00:00
Owen Anderson
df7a4f2515
Now with fewer extraneous semicolons!
...
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson
a7aed18624
Reapply r110396, with fixes to appease the Linux buildbot gods.
...
llvm-svn: 110460
2010-08-06 18:33:48 +00:00
Owen Anderson
bda59bd247
Revert r110396 to fix buildbots.
...
llvm-svn: 110410
2010-08-06 00:23:35 +00:00
Owen Anderson
755aceb5d0
Don't use PassInfo* as a type identifier for passes. Instead, use the address of the static
...
ID member as the sole unique type identifier. Clean up APIs related to this change.
llvm-svn: 110396
2010-08-05 23:42:04 +00:00
Owen Anderson
a57b97e7e7
Fix batch of converting RegisterPass<> to INTIALIZE_PASS().
...
llvm-svn: 109045
2010-07-21 22:09:45 +00:00
Gabor Greif
782f62412f
cache dereferenced iterators
...
llvm-svn: 108138
2010-07-12 12:03:02 +00:00
Chris Lattner
c6c1523f59
fix a nice subtle reassociate bug which would only occur
...
in a very specific use pattern embodied in the carefully
reduced testcase.
llvm-svn: 97794
2010-03-05 07:18:54 +00:00
Duncan Sands
19d0b47b1f
There are two ways of checking for a given type, for example isa<PointerType>(T)
...
and T->isPointerTy(). Convert most instances of the first form to the second form.
Requested by Chris.
llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Duncan Sands
9dff9bec31
Uniformize the names of type predicates: rather than having isFloatTy and
...
isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris!
llvm-svn: 96223
2010-02-15 16:12:20 +00:00
Dan Gohman
4a618827de
Fix "the the" and similar typos.
...
llvm-svn: 95781
2010-02-10 16:03:48 +00:00
Bob Wilson
27dfb1e1a4
Do not reassociate expressions with i1 type. SimplifyCFG converts some
...
short-circuited conditions to AND/OR expressions, and those expressions
are often converted back to a short-circuited form in code gen. The
original source order may have been optimized to take advantage of the
expected values, and if we reassociate them, we change the order and
subvert that optimization. Radar 7497329.
llvm-svn: 95333
2010-02-04 23:32:37 +00:00
Chris Lattner
ab7087ad66
only factor from expressions whose uses are empty and whose
...
base is the right expression type. This fixes PR5981.
llvm-svn: 93045
2010-01-09 06:01:36 +00:00
Duncan Sands
4a8b15dc74
Suppress an unused variable warning when assertions are off;
...
remove some trailing whitespace while there.
llvm-svn: 93008
2010-01-08 17:51:48 +00:00
Chris Lattner
f741d72b84
fix an infinite loop in reassociate building emacs.
...
llvm-svn: 92679
2010-01-05 04:55:35 +00:00
David Greene
d17c3916d0
Change errs() to dbgs().
...
llvm-svn: 92617
2010-01-05 01:27:24 +00:00
Chris Lattner
e199d2df80
theoretically the negate we find could be in a different function, check
...
for this case.
llvm-svn: 92425
2010-01-02 21:46:33 +00:00
Chris Lattner
0c59ac3f41
When factoring multiply expressions across adds, factor both
...
positive and negative forms of constants together. This
allows us to compile:
int foo(int x, int y) {
return (x-y) + (x-y) + (x-y);
}
into:
_foo: ## @foo
subl %esi, %edi
leal (%rdi,%rdi,2), %eax
ret
instead of (where the 3 and -3 were not factored):
_foo:
imull $-3, 8(%esp), %ecx
imull $3, 4(%esp), %eax
addl %ecx, %eax
ret
this started out as:
movl 12(%ebp), %ecx
imull $3, 8(%ebp), %eax
subl %ecx, %eax
subl %ecx, %eax
subl %ecx, %eax
ret
This comes from PR5359.
llvm-svn: 92381
2010-01-01 01:13:15 +00:00
Chris Lattner
a552683fd4
clean up some comments.
...
llvm-svn: 92377
2010-01-01 00:04:26 +00:00
Chris Lattner
17229a7cb8
switch from std::map to DenseMap for rank data structures.
...
llvm-svn: 92375
2010-01-01 00:01:34 +00:00
Chris Lattner
fed3397654
reuse negates where possible instead of always creating them from scratch.
...
This allows us to optimize test12 into:
define i32 @test12(i32 %X) {
%factor = mul i32 %X, -3 ; <i32> [#uses=1]
%Z = add i32 %factor, 6 ; <i32> [#uses=1]
ret i32 %Z
}
instead of:
define i32 @test12(i32 %X) {
%Y = sub i32 6, %X ; <i32> [#uses=1]
%C = sub i32 %Y, %X ; <i32> [#uses=1]
%Z = sub i32 %C, %X ; <i32> [#uses=1]
ret i32 %Z
}
llvm-svn: 92373
2009-12-31 20:34:32 +00:00
Chris Lattner
60c2ca743d
we don't need a smallptrset to detect duplicates, the values are
...
sorted, so we can just do a linear scan.
llvm-svn: 92372
2009-12-31 19:49:01 +00:00
Chris Lattner
1d8979422a
make reassociate more careful about not leaving around dead mul's
...
llvm-svn: 92370
2009-12-31 19:34:45 +00:00
Chris Lattner
ed18917665
remove debug
...
llvm-svn: 92369
2009-12-31 19:25:19 +00:00
Chris Lattner
60b71b5c4d
teach reassociate to factor x+x+x -> x*3. While I'm at it,
...
fix RemoveDeadBinaryOp to actually do something.
llvm-svn: 92368
2009-12-31 19:24:52 +00:00
Chris Lattner
38abecbad0
change reassociate to use SmallVector for its key datastructures
...
instead of std::vector.
llvm-svn: 92366
2009-12-31 18:40:32 +00:00
Chris Lattner
ac61550504
change an if to an assert, fix comment.
...
llvm-svn: 92364
2009-12-31 18:18:46 +00:00
Chris Lattner
177140ad12
move the rest of the add optimization code out to OptimizeAdd,
...
improve some comments, simplify a bit of code.
llvm-svn: 92363
2009-12-31 18:17:13 +00:00
Chris Lattner
ba1f36aa99
factor statistic updating better.
...
llvm-svn: 92362
2009-12-31 17:51:05 +00:00
Chris Lattner
4e3a5678af
simple fix for an incorrect factoring which causes a
...
miscompilation, PR5458.
llvm-svn: 92354
2009-12-31 08:33:49 +00:00
Chris Lattner
5f8a005d38
factor code out into helper functions.
...
llvm-svn: 92347
2009-12-31 07:59:34 +00:00
Chris Lattner
f5c2b8b8d7
switch some std::vector's to smallvector. Reduce nesting.
...
llvm-svn: 92346
2009-12-31 07:48:51 +00:00
Chris Lattner
9039ff8912
use more modern datastructures.
...
llvm-svn: 92344
2009-12-31 07:33:14 +00:00
Chris Lattner
bc1512c8d1
clean up -debug output.
...
llvm-svn: 92343
2009-12-31 07:17:37 +00:00
Nick Lewycky
7935bcb0fe
Remove LLVMContext from reassociate. It was threaded through every function but
...
ultimately never used.
llvm-svn: 88763
2009-11-14 07:25:54 +00:00
Victor Hernandez
be9e179104
Make changes to rev 84292 as requested by Chris Lattner.
...
Most changes are cleanup, but there is 1 correctness fix:
I fixed InstCombine so that the icmp is removed only if the malloc call is removed (which requires explicit removal because the Worklist won't DCE any calls since they can have side-effects).
llvm-svn: 84772
2009-10-21 19:11:40 +00:00
Victor Hernandez
a3aaf85e23
Remove MallocInst from LLVM Instructions.
...
llvm-svn: 84299
2009-10-17 01:18:07 +00:00
Victor Hernandez
c7d6a8327c
Autoupgrade malloc insts to malloc calls.
...
Update testcases that rely on malloc insts being present.
Also prematurely remove MallocInst handling from IndMemRemoval and RaiseAllocations to help pass tests in this incremental step.
llvm-svn: 84292
2009-10-17 00:00:19 +00:00
Chris Lattner
8b4d3dfbbf
calls are already unmovable, malloc doesn't need a special case.
...
llvm-svn: 82933
2009-09-27 21:36:19 +00:00
Victor Hernandez
5d034499ad
Enhance transform passes so that they apply the same tranforms to malloc calls as to MallocInst.
...
Reviewed by Dan Gohman.
llvm-svn: 82300
2009-09-18 22:35:49 +00:00
Chris Lattner
2dd09dbdf7
eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861
...
llvm-svn: 80766
2009-09-02 06:11:42 +00:00
Chris Lattner
3924bb5792
remove the std::ostream version of module and type printing.
...
llvm-svn: 79823
2009-08-23 04:52:46 +00:00
Chris Lattner
b25de3ff60
eliminate the "Value" printing methods that print to a std::ostream.
...
This required converting a bunch of stuff off DOUT and other cleanups.
llvm-svn: 79819
2009-08-23 04:37:46 +00:00
Dan Gohman
8dd69f88ea
Fix debug output to include a newline after printing a Value, now
...
that Value's operator<< doesn't include one.
llvm-svn: 79240
2009-08-17 15:25:05 +00:00
Dan Gohman
5476cfdb15
Remove a bunch more now-unnecessary Context arguments.
...
llvm-svn: 78809
2009-08-12 16:23:25 +00:00
Owen Anderson
5a1acd9912
Move a few more APIs back to 2.5 forms. The only remaining ones left to change back are
...
metadata related, which I'm waiting on to avoid conflicting with Devang.
llvm-svn: 77721
2009-07-31 20:28:14 +00:00
Owen Anderson
b292b8ce70
Move more code back to 2.5 APIs.
...
llvm-svn: 77635
2009-07-30 23:03:37 +00:00