Commit Graph

976 Commits

Author SHA1 Message Date
Chris Lattner
43f820d1f7 Change the interface to PromoteMemToReg to also take a DominatorTree
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8883 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 21:20:13 +00:00
Chris Lattner
24011be956 Speed up the mem2reg transform for allocas which are only read/written in a single
basic block.  This is amazingly common in code generated by the C/C++ front-ends.
This change makes it not have to insert ANY phi nodes, whereas before it would insert
a ton of dead ones which DCE would have to clean up.

Thus, this fix improves compile-time performance of these trivial allocas in two ways:
  1. It doesn't have to do the walking and book-keeping for renaming
  2. It does not insert dead phi nodes for them which would have to
     subsequently be cleaned up.

On my favorite testcase from 252.eon, this special case handles 305 out of
356 promoted allocas in the function.  It speeds up the mem2reg pass from 7.5256s
to 1.2505s.  It inserts 677 fewer dead PHI nodes, which speeds up a subsequent
-dce pass from 18.7524s to 2.4806s.

There are still 120 trivially dead PHI nodes being inserted for variables used
in multiple basic blocks, but they are not handled by this patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8881 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 20:54:03 +00:00
Chris Lattner
86e4445ec3 Initial checkin of the LLVM->LLVM transform to support code generators which
do not support stack unwinding yet


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8869 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 19:14:42 +00:00
Chris Lattner
b55803a9f4 simplify-cfg is really a function pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8868 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 19:14:16 +00:00
Chris Lattner
92e4975af4 The first PHI node may be null, scan for the first non-null one
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8865 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 05:34:39 +00:00
Chris Lattner
3c881cb4ce The VersionNumbers vector is only used during PHI placement. Turn it into an argument, allowing us to get rid of the vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8864 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 04:33:22 +00:00
Chris Lattner
afa060ea3f * Update file header comment
*** Revamp the code which handled unreachable code in the function.  Now the
    code is much more efficient for high-degree basic blocks, such as those
    that occur in the 252.eon SPEC benchmark.

For the interested, the time to promote a SINGLE alloca in _ZN7mrScene4ReadERSi
function used to be > 3.5s.  Now it is < .075s.  The function has a LOT of
allocas in it, so it appeared to be infinite looping, this should make it much
nicer.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8863 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 04:26:39 +00:00
Chris Lattner
521c16aadd Simplify the loop a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8862 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 03:45:44 +00:00
Chris Lattner
92581c24a3 There is no need for separate WriteSets and PhiNodeBlocks lists. It is just a
work-list of value definitions.  This allows elimination of the explicit
'iterative' step of the algorithm, and also reuses temporary memory better.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8861 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 03:39:10 +00:00
Chris Lattner
036f1e7478 The PhiNodes 2D vector is only used during PHI node placement. It doesn't
need to be an instance variable!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8860 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 03:26:25 +00:00
Chris Lattner
9e38fbf57f * Document instance vars better
* Fuse two parallel loops
* Use a more specific type for AllocaLookup


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8859 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 03:16:07 +00:00
Chris Lattner
9157f041ab Two small cleanups/speedups:
* Do not insert a new entry into NewPhiNodes during the rename pass if there are no PHIs in a block.
 * Do not compute WriteSets in parallel


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8858 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 02:37:36 +00:00
Chris Lattner
0fa157127f * Minor cleanups
* Eliminate the KillList instance variable, instead, just delete loads and
  stores as they are "renamed", and delete allocas when they are done
* Make the 'visited' set an instance variable to avoid passing it on the stack.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8857 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-05 01:52:53 +00:00
Chris Lattner
6b032052cc Implement InstCombine/add.ll:test17 & 18
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8817 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-02 15:11:26 +00:00
Chris Lattner
23ed9c1c97 Use global *_iterator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8703 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-24 22:07:33 +00:00
Chris Lattner
f8b5b6ddb4 Do not use BasicBlock::*_iterator, just use *_iterator itself.
Isn't updating copy and pasted code a joy


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8702 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-24 22:06:25 +00:00
Chris Lattner
332ae7f501 Fix bug: IndVarsSimplify/2003-09-23-NotAtTop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8689 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-23 20:26:48 +00:00
Chris Lattner
dd7036d19a Fix bugs in the last change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8667 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-22 23:30:59 +00:00
Chris Lattner
f98a084908 Fix bug: Inline/2003-09-22-PHINodesInNormalInvokeDest.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8666 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-22 22:35:39 +00:00
Chris Lattner
51d6816089 Fix bug: Inline/2003-09-22-PHINodesInExceptionDest.ll
... by making sure to update PHI nodes to take into consideration the
extra edges we get if we inline a call instruction through an invoke.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8664 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-22 21:59:27 +00:00
Misha Brukman
22b9aab760 Credits now go into the top-level CREDITS.TXT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8662 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-22 21:57:56 +00:00
Misha Brukman
763f5ae902 Credits are now in top-level CREDITS.TXT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8661 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-22 21:57:15 +00:00
Chris Lattner
021c190f8d Squelch warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8659 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-22 20:33:34 +00:00
Chris Lattner
a2d51afd79 Global variables with APPENDING linkage are very important to keep around!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8632 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-20 19:00:50 +00:00
Chris Lattner
02a3be020a Rename Function::getEntryNode -> getEntryBlock
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8625 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-20 14:39:18 +00:00
Chris Lattner
ab4536e353 Minor cleanups, no functional changes
Rename Function::getEntryNode -> getEntryBlock


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8623 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-20 14:36:23 +00:00
Chris Lattner
d452ebd0bf Fix a really obvious huge gaping bug, add a comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8620 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-20 05:24:00 +00:00
Chris Lattner
3fc6ef1bb9 Expose the TCE pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8619 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-20 05:14:13 +00:00
Chris Lattner
2240d2b3f7 New transformation: tail recursion elimination
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8618 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-20 05:03:31 +00:00
Chris Lattner
62a355cc6e Implement InstCombine/and.ll:test(15|16)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8607 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-19 19:05:02 +00:00
Chris Lattner
bd7b5fff82 pull a large nested conditional out into its own function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8605 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-19 17:17:26 +00:00
Chris Lattner
9d5890d435 Implement InstCombine/add.ll:test(15|16)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8604 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-19 15:35:42 +00:00
Chris Lattner
cc838348fc Fix bug raising allocations whose call sites were invoke instructions.
Thanks to brg for tracking down the problem so precisely!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8568 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-16 19:42:21 +00:00
Chris Lattner
1cbcd0fd48 This is effectively a complete rewrite of the globaldce algorithm, resulting
in it being both shorter and more effective.  It no longer depends on the
callgraph, so one FIXME has been fixed.

Additionally, this pass was not able to delete recursive (but dead) functions
if they were pointed to by global variables which were also dead.  In fact
this pass had a lot of problems deleting functions which were only pointed
to by dead globals and other stuff.

Fixing this means that the entire EH library should be stripped away now from
programs that don't use sjlj or exceptions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8567 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-16 19:27:31 +00:00
Chris Lattner
77b398cd5f Minor cleanups, give credit, remove code that should not be necessary, and
was a "major hack"  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8524 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-15 05:43:05 +00:00
Chris Lattner
6420f1cd50 Initial checkin of the Setjmp/Longjmp lowering/transformation pass,
contributed by the masterful Bill Wendling!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8520 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-15 04:56:27 +00:00
Chris Lattner
c9d3e5721b Ugh, a bug fix needed because of the bug in the CallGraph code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8519 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-15 04:52:00 +00:00
Chris Lattner
ad9b5f31ea Fix bug: PruneEH/2003-09-14-ExternalCall.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8516 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-15 02:22:50 +00:00
Chris Lattner
e07007c2bd Fix bug: Inline/2003-09-14-InlineValue.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8514 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-15 02:10:16 +00:00
Chris Lattner
a497748fb1 Make sure to cannonicalize loops before running indvar simplify
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8502 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-12 16:45:01 +00:00
Chris Lattner
8fce16ef1a Do not return success after checking only the FIRST USE of a gep instruction.
Instead, check all uses.
This fixes bug: ScalarRepl/2003-09-12-IncorrectPromote.ll
This also fixes the miscompilation of Ptrdist/bc


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8493 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-12 16:02:12 +00:00
Chris Lattner
fe7ea0da17 Minor optimization efficiency improvement:
- Run mem2reg promotion first
  - Only rerun passes if the previous thing changed something


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8490 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-12 15:36:03 +00:00
Chris Lattner
515c97c230 Simplify code
Implement InstCombine/mul.ll:test9


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8488 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-11 22:24:54 +00:00
Misha Brukman
3cfb6b13c0 Apostrophes are only used for possession and quoting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8473 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-11 16:58:31 +00:00
Chris Lattner
38aec32560 Integrate functionality of the mem2reg pass directly into this pass to make
the combination more effective


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8471 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-11 16:45:55 +00:00
Chris Lattner
c444a4228f Renamed DominatorTree::Node::getNode() -> getBlock()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8469 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-11 16:26:13 +00:00
Misha Brukman
352361b409 Spell `definite' correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8467 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-11 15:32:37 +00:00
Misha Brukman
7bc439a4b6 Spell `definitely' correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8466 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-11 15:31:17 +00:00
Chris Lattner
545a76ced8 Unwind instructions are intrinsically alive, just like returns
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8462 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-10 20:38:14 +00:00
Chris Lattner
1df2998451 Update for new UnifyFunction... API
Remove using decl


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8458 91177308-0d34-0410-b5e6-96231b3b80d8
2003-09-10 20:35:33 +00:00