1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

155 Commits

Author SHA1 Message Date
Dan Gohman
4dc130ea78 Fix reassociate to clear optional flags, such as nsw.
llvm-svn: 124712
2011-02-02 02:02:34 +00:00
Duncan Sands
e1912ca7e0 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
46990c17f7 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
69cbf2e8b7 Now with fewer extraneous semicolons!
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson
f2fea95f2f Reapply r110396, with fixes to appease the Linux buildbot gods.
llvm-svn: 110460
2010-08-06 18:33:48 +00:00
Owen Anderson
aadd8a89ca Revert r110396 to fix buildbots.
llvm-svn: 110410
2010-08-06 00:23:35 +00:00
Owen Anderson
b9762c07cb 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
f8addbb0a1 Fix batch of converting RegisterPass<> to INTIALIZE_PASS().
llvm-svn: 109045
2010-07-21 22:09:45 +00:00
Gabor Greif
8f93852b68 cache dereferenced iterators
llvm-svn: 108138
2010-07-12 12:03:02 +00:00
Chris Lattner
e457488032 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
1b33dd3c83 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
2acaf3609c 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
92b6122204 Fix "the the" and similar typos.
llvm-svn: 95781
2010-02-10 16:03:48 +00:00
Bob Wilson
c7e8107ff2 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
b142e13f84 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
c94f8aeb36 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
2ef4ba7cf5 fix an infinite loop in reassociate building emacs.
llvm-svn: 92679
2010-01-05 04:55:35 +00:00
David Greene
6c61de5712 Change errs() to dbgs().
llvm-svn: 92617
2010-01-05 01:27:24 +00:00
Chris Lattner
c67cde71b1 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
662a872e15 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
4a56803f29 clean up some comments.
llvm-svn: 92377
2010-01-01 00:04:26 +00:00
Chris Lattner
8812fc68ee switch from std::map to DenseMap for rank data structures.
llvm-svn: 92375
2010-01-01 00:01:34 +00:00
Chris Lattner
ebe5932016 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
bdf261d481 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
5551708ece make reassociate more careful about not leaving around dead mul's
llvm-svn: 92370
2009-12-31 19:34:45 +00:00
Chris Lattner
0e3d1bade8 remove debug
llvm-svn: 92369
2009-12-31 19:25:19 +00:00
Chris Lattner
59379f8bb0 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
333b35d45e 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
0c384066c0 change an if to an assert, fix comment.
llvm-svn: 92364
2009-12-31 18:18:46 +00:00
Chris Lattner
e8cca9664a 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
236f281971 factor statistic updating better.
llvm-svn: 92362
2009-12-31 17:51:05 +00:00
Chris Lattner
4870f6a384 simple fix for an incorrect factoring which causes a
miscompilation, PR5458.

llvm-svn: 92354
2009-12-31 08:33:49 +00:00
Chris Lattner
d8516bddb2 factor code out into helper functions.
llvm-svn: 92347
2009-12-31 07:59:34 +00:00
Chris Lattner
b4d616f2d4 switch some std::vector's to smallvector. Reduce nesting.
llvm-svn: 92346
2009-12-31 07:48:51 +00:00
Chris Lattner
fe111bf087 use more modern datastructures.
llvm-svn: 92344
2009-12-31 07:33:14 +00:00
Chris Lattner
3ebdd96db7 clean up -debug output.
llvm-svn: 92343
2009-12-31 07:17:37 +00:00
Nick Lewycky
316e082216 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
0996619220 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
a25a2890fa Remove MallocInst from LLVM Instructions.
llvm-svn: 84299
2009-10-17 01:18:07 +00:00
Victor Hernandez
4d7283f82c 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
e024fd6b47 calls are already unmovable, malloc doesn't need a special case.
llvm-svn: 82933
2009-09-27 21:36:19 +00:00
Victor Hernandez
fe5347d782 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
5f54c5bd1c eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861
llvm-svn: 80766
2009-09-02 06:11:42 +00:00
Chris Lattner
8500c36f86 remove the std::ostream version of module and type printing.
llvm-svn: 79823
2009-08-23 04:52:46 +00:00
Chris Lattner
01dae858b6 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
e8847ebe10 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
9a6b2f19e5 Remove a bunch more now-unnecessary Context arguments.
llvm-svn: 78809
2009-08-12 16:23:25 +00:00
Owen Anderson
1dc40e205b 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
93ccaf5c60 Move more code back to 2.5 APIs.
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Owen Anderson
0ce2151b36 Move ConstantExpr to 2.5 API.
llvm-svn: 77494
2009-07-29 18:55:55 +00:00