Commit Graph

1484 Commits

Author SHA1 Message Date
Chris Lattner
369287bab5 The code extractor needs dominator info. Provide it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12483 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 03:48:06 +00:00
Chris Lattner
33e197b777 Prune #includes, moving the module interface to the front. Note that this
exposed the fact that the header was not self-contained.  There is a reason
we do things :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12481 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 03:15:29 +00:00
Chris Lattner
7acd1ccb8a Fix compilation of mesa, which I broke earlier today
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12465 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-17 02:02:47 +00:00
Chris Lattner
e911979650 Be more accurate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12464 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-17 01:59:27 +00:00
Chris Lattner
50eafbc828 Fix bug in previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12458 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:36:49 +00:00
Chris Lattner
24ad00db5a Okay, so there is no reasonable way for tail duplication to update SSA form,
as it is making effectively arbitrary modifications to the CFG and we don't
have a domset/domfrontier implementations that can handle the dynamic updates.
Instead of having a bunch of code that doesn't actually work in practice,
just demote any potentially tricky values to the stack (causing the problem
to go away entirely).  Later invocations of mem2reg will rebuild SSA for us.

This fixes all of the major performance regressions with tail duplication
from LLVM 1.1.  For example, this loop:

---
int popcount(int x) {
  int result = 0;
  while (x != 0) {
    result = result + (x & 0x1);
    x = x >> 1;
  }
  return result;
}
---
Used to be compiled into:

int %popcount(int %X) {
entry:
	br label %loopentry

loopentry:		; preds = %entry, %no_exit
	%x.0 = phi int [ %X, %entry ], [ %tmp.9, %no_exit ]		; <int> [#uses=3]
	%result.1.0 = phi int [ 0, %entry ], [ %tmp.6, %no_exit ]		; <int> [#uses=2]
	%tmp.1 = seteq int %x.0, 0		; <bool> [#uses=1]
	br bool %tmp.1, label %loopexit, label %no_exit

no_exit:		; preds = %loopentry
	%tmp.4 = and int %x.0, 1		; <int> [#uses=1]
	%tmp.6 = add int %tmp.4, %result.1.0		; <int> [#uses=1]
	%tmp.9 = shr int %x.0, ubyte 1		; <int> [#uses=1]
	br label %loopentry

loopexit:		; preds = %loopentry
	ret int %result.1.0
}

And is now compiled into:

int %popcount(int %X) {
entry:
        br label %no_exit

no_exit:                ; preds = %entry, %no_exit
        %x.0.0 = phi int [ %X, %entry ], [ %tmp.9, %no_exit ]          ; <int> [#uses=2]
        %result.1.0.0 = phi int [ 0, %entry ], [ %tmp.6, %no_exit ]             ; <int> [#uses=1]
        %tmp.4 = and int %x.0.0, 1              ; <int> [#uses=1]
        %tmp.6 = add int %tmp.4, %result.1.0.0          ; <int> [#uses=2]
        %tmp.9 = shr int %x.0.0, ubyte 1                ; <int> [#uses=2]
        %tmp.1 = seteq int %tmp.9, 0            ; <bool> [#uses=1]
        br bool %tmp.1, label %loopexit, label %no_exit

loopexit:               ; preds = %no_exit
        ret int %tmp.6
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12457 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:29:09 +00:00
Chris Lattner
c1a0623e86 This code was both incredibly complex and incredibly broken. Fix it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12456 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:23:11 +00:00
Chris Lattner
91408eba18 Punt if we see gigantic PHI nodes. This improves a huge interpreter loop
testcase from 32.5s in -raise to take .3s


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12443 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:52:53 +00:00
Chris Lattner
a2f652d420 Do not try to optimize PHI nodes with incredibly high degree. This reduces SCCP
time from 615s to 1.49s on a large testcase that has a gigantic switch statement
that all of the blocks in the function go to (an intepreter).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12442 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:49:59 +00:00
Chris Lattner
4bebf08d15 Do not copy gigantic switch instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12441 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:45:22 +00:00
Chris Lattner
85ebd541fa Fix a regression from this patch:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040308/013095.html

Basically, this patch only updated the immediate dominatees of the header node
to tell them that the preheader also dominated them.  In practice, ALL
dominatees of the header node are also dominated by the preheader.

This fixes: LoopSimplify/2004-03-15-IncorrectDomUpdate.
and PR293


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12434 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 06:00:15 +00:00
Chris Lattner
6dd196f762 Restore old inlining heuristic. As the comment indicates, this is a nasty
horrible hack.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12423 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 06:38:14 +00:00
Chris Lattner
46234fd97f Add counters for the number of calls elimianted
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12420 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 05:46:59 +00:00
Chris Lattner
118dd0ce3d Implement LICM of calls in simple cases. This is sufficient to move around
sin/cos/strlen calls and stuff.  This implements:
  LICM/call_sink_pure_function.ll
  LICM/call_sink_const_function.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12415 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 04:11:30 +00:00
Chris Lattner
15d443b566 Mostly cosmetic improvements. Do fix the bug where a global value was considered an input.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12406 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 01:26:44 +00:00
Chris Lattner
0de632bfae Assert that input blocks meet the invariants we expect
Simplify the input/output finder.  All elements of a basic block are
instructions.  Any used arguments are also inputs.  An instruction can only
be used by another instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12405 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 01:18:23 +00:00
Chris Lattner
5156c39d64 Fix several bugs in the loop extractor. In particular, subloops were never
extracted, and a function that contained a single top-level loop never had
the loop extracted, regardless of how much non-loop code there was.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12403 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 00:02:02 +00:00
Chris Lattner
65826bf435 No correctness fixes here, just minor qoi fixes:
* Don't insert a branch to the switch instruction after the call, just
  make it a single block.
* Insert the new alloca instructions in the entry block of the original
  function instead of having them execute dynamically
* Don't make the default edge of the switch instruction go back to the switch.
  The loop extractor shouldn't create new loops!
* Give meaningful names to the alloca slots and the reload instructions
* Some minor code simplifications


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12402 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 23:43:24 +00:00
Chris Lattner
12f390e9c0 Simplify code a bit, and fix bug CodeExtractor/2004-03-14-NoSwitchSupport.ll
This also implements a two minor improvements:
  * Don't insert live-out stores IN the region, insert them on the code path
    that exits the region
  * If the region is exited to the same block from multiple paths, share the
    switch statement entry, live-out store code, and the basic block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12401 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 23:05:49 +00:00
Chris Lattner
0e06674287 Simplify the code a bit by making the collection of basic blocks to extract
a member of the class.  While we're at it, turn the collection into a set
instead of a vector to improve efficiency and make queries simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12400 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 22:34:55 +00:00
Chris Lattner
41bc0b069c Split into two passes. Now there is the general loop extractor, usable on
the command line, and the single loop extractor, usable by bugpoint


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12390 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 20:01:36 +00:00
Chris Lattner
97836fad2c Passes don't print stuff!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12385 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:17:53 +00:00
Chris Lattner
bf9eaddfb0 Do not create empty basic blocks when the lowerswitch pass expects blocks to
be non-empty!  This fixes LowerSwitch/2004-03-13-SwitchIsDefaultCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12384 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:14:31 +00:00
Chris Lattner
bb41156c0c Minor random cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12382 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:01:47 +00:00
Chris Lattner
16d0eb0468 FunctionPass's should not define their own 'run' method.
Require 'simplified' loops, not just raw natural loops.  This fixes
CodeExtractor/2004-03-13-LoopExtractorCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12381 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:01:06 +00:00
Chris Lattner
2ef703ec42 If a block is dead, dominators will not be calculated for it. Because of this
loop information won't see it, and we could have unreachable blocks pointing to
the non-header node of blocks in a natural loop.  This isn't tidy, so have the
loopsimplify pass clean it up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12380 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 03:59:22 +00:00
Chris Lattner
ffada93273 Verify functions as they are produced if -debug is specified. Reduce
curly braceage


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12378 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 03:17:22 +00:00
Chris Lattner
1e3cb34753 Move prototype to IPO.h instead of Scalar.h
Make sure that the file interface header (IPO.h) is included first
remove dead #incldue


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12375 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:37:16 +00:00
Chris Lattner
efddcfa0df Indent anon namespace properly, add copyright block
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12373 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:34:07 +00:00
Chris Lattner
c3c8703c3b Move to the IPO library. Utils shouldn't contain passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12372 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:32:27 +00:00
Chris Lattner
a2dc727ac4 DemoteRegToStack got moved from DemoteRegToStack.h to Local.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12368 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 02:13:38 +00:00
Chris Lattner
0cea42a560 Add some debugging output
Fix InstCombine/2004-03-13-InstCombineInfLoop.ll which caused an infinite
loop compiling (I think) povray.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12365 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-13 23:54:27 +00:00
Chris Lattner
619d3544b1 This change makes two big adjustments.
* Be a lot more accurate about what the effects will be when inlining a call
   to a function when an argument is an alloca.
 * Dramatically reduce the penalty for inlining a call in a large function.
   This heuristic made it almost impossible to inline a function into a large
   function, no matter how small the callee is.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12363 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-13 23:15:45 +00:00
Chris Lattner
786c5646e9 This little patch speeds up the loop used to update the dominator set analysis.
On the testcase from GCC PR12440, which has a LOT of loops (1392 of which require
preheaders to be inserted), this speeds up the loopsimplify pass from 1.931s to
0.1875s.  The loop in question goes from 1.65s -> 0.0097s, which isn't bad. All of
these times are a debug build.

This adds a dependency on DominatorTree analysis that was not there before, but
we always had dominatortree available anyway, because LICM requires both loop
simplify and DT, so this doesn't add any extra analysis in practice.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12362 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-13 22:01:26 +00:00
Chris Lattner
bfe492b5c2 Implement sub.ll:test14
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12355 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-13 00:11:49 +00:00
Chris Lattner
9c2906744a Implement InstCombine/sub.ll:test12 & test13
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12353 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 23:53:13 +00:00
Chris Lattner
17fd273512 Add constant folding wrapper support for select instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12319 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 05:53:03 +00:00
Chris Lattner
6e32372fcd Add sccp support for select instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12318 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 05:52:44 +00:00
Chris Lattner
3d69f46d64 Add trivial optimizations for select instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12317 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 05:52:32 +00:00
Chris Lattner
b2f12a2c38 Initial support for edge profiling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12225 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-08 17:54:34 +00:00
Chris Lattner
467dd2ec61 Split utility functions out of BlockProfiling.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12224 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-08 17:06:13 +00:00
Chris Lattner
c51733c7b5 finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12221 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-08 16:45:53 +00:00
Chris Lattner
9440db8866 Implement ArgumentPromotion/aggregate-promote.ll
This allows pointers to aggregate objects, whose elements are only read, to
be promoted and passed in by element instead of by reference.  This can
enable a LOT of subsequent optimizations in the caller function.

It's worth pointing out that this stuff happens a LOT of C++ programs, because
objects in templates are generally passed around by reference.  When these
templates are instantiated on small aggregate or scalar types, however, it is
more efficient to pass them in by value than by reference.

This transformation triggers most on C++ codes (e.g. 334 times on eon), but
does happen on C codes as well.  For example, on mesa it triggers 72 times,
and on gcc it triggers 35 times.  this is amazingly good considering that
we are using 'basicaa' so far.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12202 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-08 01:04:36 +00:00
Chris Lattner
86a734bd40 Implement: ArgumentPromotion/chained.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12200 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 22:52:53 +00:00
Chris Lattner
7db5a6df78 Fix another minor bug, exposed by perlbmk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12198 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 22:43:27 +00:00
Chris Lattner
c76d80342e Since 'load null' is undefined, we can make it do whatever we want. Returning
a zero value is the most likely way to cause further simplification, so we do it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12197 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 22:16:24 +00:00
Chris Lattner
7e6f5090af Fix a minor bug and turn debug output into, well, debug output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12195 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 21:54:50 +00:00
Chris Lattner
ed570a7dca New LLVM pass: argument promotion. This version only handles simple scalar
variables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12193 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 21:29:54 +00:00
Chris Lattner
0a94348fb9 Don't emit things like malloc(16*1). Allocation instructions are fixed arity now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12086 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-03 01:40:53 +00:00
Misha Brukman
0256e4bbf9 Implement ExtractCodeRegion()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12070 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-02 00:20:57 +00:00
Misha Brukman
38b8fd1078 Make a note that this is usually used via bugpoint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12068 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-02 00:19:09 +00:00
Misha Brukman
b97fce5252 * Add implementation of ExtractBasicBlock()
* Add comments to ExtractLoop()


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12053 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-01 18:28:34 +00:00
Chris Lattner
99cca7d3aa Disable tail duplication in a case that breaks on Olden/tsp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12021 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-01 01:12:13 +00:00
Misha Brukman
99cc88bb64 * Remove function to find "main" in a Module, there's a method for that
* Removing extraneous empty space and empty comment lines


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12014 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-29 23:09:10 +00:00
Chris Lattner
06887c9a2a Fix bug: test/Regression/Transforms/LowerInvoke/2004-02-29-PHICrash.llx
... which tickled the lowerinvoke pass because it used the BCE routines.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12012 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-29 22:24:41 +00:00
Chris Lattner
4279f3c984 Fix PR255: [tailduplication] Single basic block loops are very rare
Note that this is a band-aid put over a band-aid.  This just undisables
tail duplication in on very specific case that it seems to work in.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11989 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-29 06:41:20 +00:00
Chris Lattner
542f149f00 Implement switch->br and br->switch folding by ripping out the switch->switch
and br->br code and generalizing it.  This allows us to compile code like this:

int test(Instruction *I) {
  if (isa<CastInst>(I))
    return foo(7);
  else if (isa<BranchInst>(I))
    return foo(123);
  else if (isa<UnwindInst>(I))
    return foo(1241);
  else if (isa<SetCondInst>(I))
    return foo(1);
  else if (isa<VAArgInst>(I))
    return foo(42);
  return foo(-1);
}

into:

int %_Z4testPN4llvm11InstructionE("struct.llvm::Instruction"* %I) {
entry:
        %tmp.1.i.i.i.i.i.i.i = getelementptr "struct.llvm::Instruction"* %I, long 0, ubyte 4            ; <uint*> [#uses=1]
        %tmp.2.i.i.i.i.i.i.i = load uint* %tmp.1.i.i.i.i.i.i.i          ; <uint> [#uses=2]
        %tmp.2.i.i.i.i.i.i = seteq uint %tmp.2.i.i.i.i.i.i.i, 27                ; <bool> [#uses=0]
        switch uint %tmp.2.i.i.i.i.i.i.i, label %endif.0 [
                 uint 27, label %then.0
                 uint 2, label %then.1
                 uint 5, label %then.2
                 uint 14, label %then.3
                 uint 15, label %then.3
                 uint 16, label %then.3
                 uint 17, label %then.3
                 uint 18, label %then.3
                 uint 19, label %then.3
                 uint 32, label %then.4
        ]
...

As well as handling the cases in 176.gcc and many other programs more effectively.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11964 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 21:28:10 +00:00
Chris Lattner
b99df4f8c2 if there is already a prototype for malloc/free, use it, even if it's incorrect.
Do not just inject a new prototype.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11951 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 18:51:45 +00:00
Chris Lattner
7bcc0e7fff Rename AddUsesToWorkList -> AddUsersToWorkList, as that is what it does.
Create a new AddUsesToWorkList method
optimize memmove/set/cpy of zero bytes to a noop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11941 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 05:22:00 +00:00
Chris Lattner
6160e85201 Turn 'free null' into nothing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11940 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 04:57:37 +00:00
Misha Brukman
9e4a642c03 Right, it's really Extractor, not Extraction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11939 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 03:37:58 +00:00
Misha Brukman
9401deb320 A pass that uses the generic CodeExtractor to rip out *every* loop in every
function, as long as the loop isn't the only one in that function. This should
help debugging passes easier with BugPoint.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11936 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 03:33:01 +00:00
Misha Brukman
e6336031b8 A generic code extractor: given a list of BasicBlocks, it will rip them out into
a new function, taking care of inputs and outputs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11935 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 03:26:20 +00:00
Chris Lattner
7d90a2738e setcond instructions don't have aliasing implications.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11919 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-27 18:09:25 +00:00
Chris Lattner
a0ebcebc06 Implement test/Regression/Transforms/InstCombine/canonicalize_branch.ll
This is a really minor thing, but might help out the 'switch statement induction'
code in simplifycfg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11900 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-27 06:27:46 +00:00
Chris Lattner
4f77caaa3d Since LLVM uses structure type equivalence, it isn't useful to keep around
multiple type names for the same structural type.  Make DTE eliminate all
but one of the type names


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11879 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-26 20:02:23 +00:00
Chris Lattner
f2dbf50efa turn things like:
if (X == 0 || X == 2)

...where the comparisons and branches are in different blocks... into a switch
instruction.  This comes up a lot in various programs, and works well with
the switch/switch merging code I checked earlier.  For example, this testcase:

int switchtest(int C) {
  return C == 0 ? f(123) :
         C == 1 ? f(3123) :
         C == 4 ? f(312) :
         C == 5 ? f(1234): f(444);
}

is converted into this:
        switch int %C, label %cond_false.3 [
                 int 0, label %cond_true.0
                 int 1, label %cond_true.1
                 int 4, label %cond_true.2
                 int 5, label %cond_true.3
        ]

instead of a whole bunch of conditional branches.

Admittedly the code is ugly, and incomplete.  To be complete, we need to add
br -> switch merging and switch -> br merging.  For example, this testcase:

struct foo { int Q, R, Z; };
#define A (X->Q+X->R * 123)
int test(struct foo *X) {
  return A  == 123 ? X1() :
        A == 12321 ? X2():
        (A == 111 || A == 222) ? X3() :
        A == 875 ? X4() : X5();
}

Gets compiled to this:
        switch int %tmp.7, label %cond_false.2 [
                 int 123, label %cond_true.0
                 int 12321, label %cond_true.1
                 int 111, label %cond_true.2
                 int 222, label %cond_true.2
        ]
...
cond_false.2:           ; preds = %entry
        %tmp.52 = seteq int %tmp.7, 875         ; <bool> [#uses=1]
        br bool %tmp.52, label %cond_true.3, label %cond_false.3

where the branch could be folded into the switch.

This kind of thing occurs *ALL OF THE TIME*, especially in programs like
176.gcc, which is a horrible mess of code.  It contains stuff like *shudder*:

#define SWITCH_TAKES_ARG(CHAR) \
  (   (CHAR) == 'D' \
   || (CHAR) == 'U' \
   || (CHAR) == 'o' \
   || (CHAR) == 'e' \
   || (CHAR) == 'u' \
   || (CHAR) == 'I' \
   || (CHAR) == 'm' \
   || (CHAR) == 'L' \
   || (CHAR) == 'A' \
   || (CHAR) == 'h' \
   || (CHAR) == 'z')

and

#define CONST_OK_FOR_LETTER_P(VALUE, C)                 \
  ((C) == 'I' ? SMALL_INTVAL (VALUE)                    \
   : (C) == 'J' ? SMALL_INTVAL (-(VALUE))               \
   : (C) == 'K' ? (unsigned)(VALUE) < 32                \
   : (C) == 'L' ? ((VALUE) & 0xffff) == 0               \
   : (C) == 'M' ? integer_ok_for_set (VALUE)            \
   : (C) == 'N' ? (VALUE) < 0                           \
   : (C) == 'O' ? (VALUE) == 0                          \
   : (C) == 'P' ? (VALUE) >= 0                          \
   : 0)

and

#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                     \
{                                                               \
  if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
    (X) = gen_rtx (PLUS, SImode, XEXP (X, 0),                   \
                   copy_to_mode_reg (SImode, XEXP (X, 1)));     \
  if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
    (X) = gen_rtx (PLUS, SImode, XEXP (X, 1),                   \
                   copy_to_mode_reg (SImode, XEXP (X, 0)));     \
  if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT)   \
    (X) = gen_rtx (PLUS, SImode, XEXP (X, 1),                   \
                   force_operand (XEXP (X, 0), 0));             \
  if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT)   \
    (X) = gen_rtx (PLUS, SImode, XEXP (X, 0),                   \
                   force_operand (XEXP (X, 1), 0));             \
  if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS)   \
    (X) = gen_rtx (PLUS, Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
                   XEXP (X, 1));                                \
  if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS)   \
    (X) = gen_rtx (PLUS, Pmode, XEXP (X, 0),                    \
                   force_operand (XEXP (X, 1), NULL_RTX));      \
  if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST       \
           || GET_CODE (X) == LABEL_REF)                        \
    (X) = legitimize_address (flag_pic, X, 0, 0);               \
  if (memory_address_p (MODE, X))                               \
    goto WIN; }

and others.  These macros get used multiple times of course.  These are such
lovely candidates for macros, aren't they?  :)

This code also nicely handles LLVM constructs that look like this:

  if (isa<CastInst>(I))
   ...
  else if (isa<BranchInst>(I))
   ...
  else if (isa<SetCondInst>(I))
   ...
  else if (isa<UnwindInst>(I))
   ...
  else if (isa<VAArgInst>(I))
   ...

where the isa can obviously be a dyn_cast as well.  Switch instructions are a
good thing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11870 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-26 07:13:46 +00:00
Chris Lattner
079236d1c9 My faith in programmers has been found to be totally misplaced. One would
assume that if they don't intend to write to a global variable, that they
would mark it as constant.  However, there are people that don't understand
that the compiler can do nice things for them if they give it the information
it needs.

This pass looks for blatently obvious globals that are only ever read from.
Though it uses a trivially simple "alias analysis" of sorts, it is still able
to do amazing things to important benchmarks.  253.perlbmk, for example,
contains several ***GIANT*** function pointer tables that are not marked
constant and should be.  Marking them constant allows the optimizer to turn
a whole bunch of indirect calls into direct calls.  Note that only a link-time
optimizer can do this transformation, but perlbmk does have several strings
and other minor globals that can be marked constant by this pass when run
from GCCAS.

176.gcc has a ton of strings and large tables that are marked constant, both
at compile time (38 of them) and at link time (48 more).  Other benchmarks
give similar results, though it seems like big ones have disproportionally
more than small ones.

This pass is extremely quick and does good things.  I'm going to enable it
in gccas & gccld.  Not bad for 50 SLOC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11836 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-25 21:34:36 +00:00
Chris Lattner
940ff563f7 Fix incorrect debug code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11821 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-25 15:15:04 +00:00
Chris Lattner
d38f208cd9 Fix a faulty optimization on FP values
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11801 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-24 18:10:14 +00:00
Chris Lattner
8e509dd5e8 If a block is made dead, make sure to promptly remove it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11799 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-24 16:09:21 +00:00
Chris Lattner
d52c261cf8 Implement SimplifyCFG/switch_switch_fold.ll
This case occurs many times in various benchmarks, especially when combined
with the previous patch.  This allows it to get stuff like:
  if (X == 4 || X == 3)
    if (X == 5 || X == 8)

and

switch (X) {
case 4: case 5: case 6:
  if (X == 4 || X == 5)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11797 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-24 07:23:58 +00:00
Chris Lattner
e14ea0804a Rearrange code a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11793 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-24 05:54:22 +00:00
Chris Lattner
0d56008f53 Implement: test/Regression/Transforms/SimplifyCFG/switch_create.ll
This turns code like this:
  if (X == 4 | X == 7)
and
  if (X != 4 & X != 7)
into switch instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11792 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-24 05:38:11 +00:00
Chris Lattner
d8864ce766 Generate much more efficient code in programs like pifft
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11775 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 21:46:58 +00:00
Chris Lattner
077a373791 Fix a small typeo in my checkin last night that broke vortex and other programs :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11774 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 21:46:42 +00:00
Chris Lattner
8adac75298 Fix InstCombine/2004-02-23-ShiftShiftOverflow.ll
Also, turn 'shr int %X, 1234' into 'shr int %X, 31'


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11768 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 20:30:06 +00:00
Chris Lattner
c5943fb186 Implement cast.ll::test14/15
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11742 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 07:16:20 +00:00
Chris Lattner
4cb170cc6e Refactor some code. In the mul - setcc folding case, we really care about
whether this is the sign bit or not, so check unsigned comparisons as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11740 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 06:38:22 +00:00
Chris Lattner
fed58fd72e Implement mul.ll:test11
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11737 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 06:00:11 +00:00
Chris Lattner
45aaafef49 Implement "strength reduction" of X <= C and X >= C
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11735 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 05:47:48 +00:00
Chris Lattner
fb54b2b744 Implement InstCombine/mul.ll:test10, which is a case that occurs when dealing
with "predication"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11734 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 05:39:21 +00:00
Chris Lattner
c6bd195336 Implement Transforms/InstCombine/cast.ll:test13, a case which occurs in a
hot 164.gzip loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11702 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-22 05:25:17 +00:00
Chris Lattner
57cb9883aa Fix PR245: Linking weak and strong global variables is dependent on link order
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11565 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-17 21:56:04 +00:00
Chris Lattner
19831ec853 Implement test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll,
see the testcase for the reasoning.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11496 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 06:35:48 +00:00
Chris Lattner
7059f2e76b Fold PHI nodes of constants which are only used by a single cast. This implements
phi.ll:test4


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11494 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 05:07:08 +00:00
Chris Lattner
26ca7e145e Teach LLVM to unravel the "swap idiom". This implements:
Regression/Transforms/InstCombine/xor.ll:test20


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11492 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 03:54:20 +00:00
Chris Lattner
c317d39887 Implement Transforms/InstCombine/xor.ll:test19
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11490 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 01:20:27 +00:00
Chris Lattner
860a16143c Instead of producing calls to setjmp/longjmp, produce uses of the
llvm.setjmp/llvm.longjmp intrinsics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11482 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-15 22:24:27 +00:00
Chris Lattner
de512b5b2e Adjustments to support the new ConstantAggregateZero class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11474 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-15 05:55:15 +00:00
Chris Lattner
04d1fb6df9 Remove dependence on return type of ConstantStruct::get
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11466 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-15 04:07:32 +00:00
Chris Lattner
371064481a Remove dependence on the return type of ConstantArray::get
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11463 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-15 04:05:58 +00:00
Chris Lattner
494b6920b0 Fix compilation of 126.gcc: intrinsic functions cannot throw, so they are not
allowed in invoke instructions.  Thus, if we are inlining a call to an intrinsic
function into an invoke site, we don't need to turn the call into an invoke!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11384 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-13 16:47:35 +00:00
Chris Lattner
0db085baec Intrinsic functions cannot throw
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11383 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-13 16:46:46 +00:00
Chris Lattner
cefc18e7d9 Expose a pass ID that can be 'required'
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11376 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-13 16:16:16 +00:00
Chris Lattner
5f55aaf0f0 Remove obsolete comment. Unreachable blocks will automatically be left at the
end of the function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11313 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-11 05:20:50 +00:00
Chris Lattner
206805e172 Add an _embarassingly simple_ implementation of basic block layout. This is
more of a testcase for profiling information than anything that should reasonably
be used, but it's a starting point.  When I have more time I will whip this into
better shape.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11311 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-11 04:53:20 +00:00
Chris Lattner
723c66d4c0 Implement SimplifyCFG/PhiEliminate.ll
Having a proper 'select' instruction would allow the elimination of a lot
of the special case cruft in this patch, but we don't have one yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11307 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-11 03:36:04 +00:00
Chris Lattner
2355f948c5 The hasConstantReferences predicate always returns false.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11301 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-11 01:17:07 +00:00
Chris Lattner
81d1a2207d initialization calls now return argc. If the program uses the argc value
passed into main, make sure they use the return value of the init call
instead of the one passed in.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11262 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-10 17:41:01 +00:00
Chris Lattner
f1d0d3519f Only add the global variable with the abort message if an unwind actually
occurs in the program.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11249 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 22:48:47 +00:00
Chris Lattner
68b86f4f41 Don't depend on auto data conversion
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11229 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 05:16:30 +00:00
Chris Lattner
d21cd809b6 Adjust to the changed StructType interface. In particular, getElementTypes() is gone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11228 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 04:37:31 +00:00
Chris Lattner
d5d8996720 Start using the new and improve interface to FunctionType arguments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11224 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 04:14:01 +00:00
Chris Lattner
99d6b8ec95 The ConstantExpr::getCast call can cause a CPR to be generated. If so,
strip it off.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11213 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-09 00:20:55 +00:00
Misha Brukman
b9806e0101 Fix grammar-o.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11210 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 22:27:33 +00:00
Chris Lattner
501825e08a Improve compatibility with programs that already have a prototype for 'write',
even if it is wierd in some way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11207 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 22:14:44 +00:00
Chris Lattner
aeb2a1d708 rename the "exceptional" destination of an invoke instruction to the 'unwind' dest
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11202 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 21:44:31 +00:00
Chris Lattner
e0def04e43 Fix PR225: [pruneeh] -pruneeh pass removes invoke instructions it shouldn't
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11200 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 21:15:59 +00:00
Chris Lattner
edb1cf0c19 splitBasicBlock "does the right thing" now, no reason to reposition it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11199 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 20:49:07 +00:00
Chris Lattner
6d78457f17 Implement proper invoke/unwind lowering.
This fixed PR16 "[lowerinvoke] The -lowerinvoke pass does not insert calls to setjmp/longjmp"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11195 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 19:53:56 +00:00
Chris Lattner
e1c09309f2 Add a call to 'write' right before the call to abort() in the unwind path.
This causes the JIT, or LLC'd program to print out a nice message, explaining
WHY the program aborted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11184 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 07:30:29 +00:00
Chris Lattner
99dcc1da86 Fix another dominator update bug. These bugs keep getting exposed because GCSE
keeps finding more code motion opportunities now that the dominators are correct!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11142 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-05 23:20:59 +00:00
Chris Lattner
3e0b870def Fix bug updating dominators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11140 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-05 22:33:26 +00:00
Chris Lattner
79fc865ccb Add debug output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11139 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-05 22:33:19 +00:00
Chris Lattner
4f02fc28eb Fix PR223: Loopsimplify incorrectly updates dominator information
The problem is that the dominator update code didn't "realize" that it's
possible for the newly inserted basic block to dominate anything.  Because
it IS possible, stuff was getting updated wrong.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11137 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-05 21:12:24 +00:00
Chris Lattner
a33ceaa2d4 Minor speedup, don't query ValueMap each time through the loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11123 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 21:44:26 +00:00
Chris Lattner
c1df7e1799 Two changes:
1. Don't scan to the end of alloca instructions in the caller function to
     insert inlined allocas, just insert at the top.  This saves a lot of
     time inlining into functions with a lot of allocas.
  2. Use splice to move the alloca instructions over, instead of remove/insert.
     This allows us to transfer a block at a time, and eliminates a bunch of
     silly symbol table manipulations.

This speeds up the inliner on the testcase in PR209 from 1.73s -> 1.04s (67%)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11118 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 21:33:42 +00:00
Chris Lattner
44a6807f4f Optimize the case where we are inlining a function that contains only one basic block,
and that basic block ends with a return instruction.  In this case, we can just splice
the cloned "body" of the function directly into the source basic block, avoiding a lot
of rearrangement and splitBasicBlock's linear scan over the split block.  This speeds up
the inliner on the testcase in PR209 from 2.3s to 1.7s, a 35% reduction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11116 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 04:17:06 +00:00
Chris Lattner
c24a076c6a Adjust to the new BasicBlock ctor, which requires a function parameter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11114 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 03:58:28 +00:00
Chris Lattner
3b332fd376 Remove unneeded code now that splitBasicBlock does the "right thing"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11111 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 03:21:51 +00:00
Chris Lattner
5e923dee60 More refactoring. Move alloca instructions and handle invoke instructions
before we delete the original call site, allowing slight simplifications of
code, but nothing exciting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11109 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 02:51:48 +00:00
Chris Lattner
5052c911ec Move the cloning of the function body much earlier in the inlinefunction
process.  The only optimization we did so far is to avoid creating a
PHI node, then immediately destroying it in the common case where the
callee has one return statement.  Instead, we just don't create the return
value.  This has no noticable performance impact, but paves the way for
future improvements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11108 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 01:41:09 +00:00
Chris Lattner
23b4c68f46 Give CloneBasicBlock an optional function argument to specify which function
to add the cloned block to.  This allows the block to be added to the function
immediately, and all of the instructions to be immediately added to the function
symbol table, which speeds up the inliner from 3.7 -> 3.38s on the PR209.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11107 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 01:19:43 +00:00
Chris Lattner
e47f78ed12 Bunch up all locally used allocas by the block they are allocated in, and
process them all as a group.  This speeds up SRoA/mem2reg from 28.46s to
0.62s on the testcase from PR209.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11100 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-03 22:34:12 +00:00
Chris Lattner
7fecc2e5e2 Handle extremely trivial cases extremely efficiently. This speeds up
SRoA/mem2reg from 41.2s to 27.5s on the testcase in PR209.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11099 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-03 22:00:33 +00:00
Chris Lattner
0517e72096 Disable (x - (y - z)) => (x + (z - y)) optimization for floating point.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11083 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-02 20:09:56 +00:00
Chris Lattner
529429224c Update comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11082 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-02 20:09:22 +00:00
Brian Gaeke
09ca4115ee Make deadarghaX0r warning louder.
(I just love typing haX0r.   haX0r haX0r haX0r.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11079 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-02 19:32:27 +00:00
Chris Lattner
c23396e8de Disable tail duplication in any "hard" cases, where it might break SSA form.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11052 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-01 06:32:28 +00:00
Chris Lattner
e400a0976f Fix the count of the number of instructions removed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11049 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-01 05:15:07 +00:00
Misha Brukman
7c791ed0a4 Hyphenate `target-dependent'
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11003 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-28 20:43:01 +00:00
Chris Lattner
f78616b339 Fix InstCombine/2004-01-13-InstCombineInvokePHI.ll, which also fixes lots
of C++ programs in Shootout-C++, including lists1 and moments, etc


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10845 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-14 06:06:08 +00:00
Chris Lattner
7822c2ae07 Clean up #includes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10799 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 19:56:36 +00:00
Chris Lattner
76f7fe25d9 Fix bug in previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10798 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 19:47:05 +00:00
Chris Lattner
7c4049c5a0 Eliminate use of ConstantHandling and ConstantExpr::getShift interfaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10796 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 19:35:11 +00:00
Chris Lattner
b6ac8bc586 Add header file I accidentally removed in teh shuffle
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10795 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 19:15:20 +00:00
Chris Lattner
5585b335e5 Remove use of the ConstantHandling interfaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10793 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 19:12:50 +00:00
Chris Lattner
c6646ebdb9 Remove use of ConstantExpr::getShift
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10792 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 19:10:58 +00:00
Chris Lattner
b16689b647 Don't use ConstantExpr::getShift anymore
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10791 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 19:08:43 +00:00
Chris Lattner
81ebc30089 Remove use of ConstantHandling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10789 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 18:35:03 +00:00
Chris Lattner
e5d4f1b9e7 Remove unneeded #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10788 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 18:33:54 +00:00
Chris Lattner
8f90b005d6 Move llvm::ConstantFoldInstruction from VMCore to here, next to ConstantFoldTerminator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10785 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 18:25:22 +00:00
Chris Lattner
ccd3a878d0 Remove uses of ConstantHandling itf
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10783 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 18:12:44 +00:00
Chris Lattner
b7a5d3edee Use constantexprs for casts. Eliminate use of the ConstantHandling interfaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10779 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 17:43:40 +00:00
Chris Lattner
84831642e4 Fix fairly severe bug in my last checking where we treated all unfoldable
constants as being "true" when evaluating branches.  This was introduced
because we now create constantexprs for the constants instead of failing the
fold.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10778 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 17:40:36 +00:00
Chris Lattner
c6a4d6a066 * Implement minor performance optimization for the getelementptr case
* Implement SCCP of load instructions, implementing Transforms/SCCP/loadtest.ll
  This allows us to fold expressions like "foo"[2], even if the pointer is only
  a conditional constant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10767 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 04:29:41 +00:00
Chris Lattner
5f16a13896 Do not hack on volatile loads. I'm not sure what the point of a volatile load
from constant memory is, but lets not take chances.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10765 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 04:13:56 +00:00
Chris Lattner
1daee8b010 Implement SCCP/phitest.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10763 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 03:57:30 +00:00
Chris Lattner
2d11f167e6 Implement Transforms/ScalarRepl/phinodepromote.ll, which is an important
case that the C/C++ front-end generates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10761 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 01:18:32 +00:00
Chris Lattner
2cacc0a306 Update obsolete comments
Fix iterator invalidation problems which was causing -mstrip to miss some
entries, and read free'd memory.  This shrinks the symbol table of 254.gap
from 333 to 284 bytes!  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10751 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-10 21:36:49 +00:00
Chris Lattner
f7703df496 Finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10727 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-09 06:12:26 +00:00
Chris Lattner
21949d9088 Remove dependence on structure index type. s/MT/FT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10726 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-09 06:02:51 +00:00
Chris Lattner
d745602662 Finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10725 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-09 06:02:20 +00:00
Chris Lattner
559d519549 Finegrainify namespacification
add flags for PR82


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10724 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-09 05:53:38 +00:00
Chris Lattner
63a917bbc2 Inching towards fixing PR82
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10722 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-09 05:44:50 +00:00
Chris Lattner
329c1c6c94 Improve encapsulation in the Loop and LoopInfo classes by eliminating the
getSubLoops/getTopLevelLoops methods, replacing them with iterator-based
accessors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10714 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-08 00:09:44 +00:00
Chris Lattner
0898c78a52 Merging constants can cause further room for improvement. Iterate until
we converge


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10618 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-28 07:19:08 +00:00
Chris Lattner
9a0a41f224 rename ClassifyExpression -> ClassifyExpr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10592 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-23 08:04:08 +00:00
Chris Lattner
15cad759fe More minor non-functional changes. This now computes the exit condition, though
it doesn't do anything with it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10590 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-23 07:47:09 +00:00
Chris Lattner
e799902fbb Remove extraneous #include
finegrainify namespacification


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10589 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-23 07:43:38 +00:00
Chris Lattner
b97238079d Fix memory corruption bug PR193
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10586 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-22 23:49:36 +00:00
Chris Lattner
500597a1c3 Don't mind me, I'm just refactoring away. This patch makes room for LFTR, but
contains no functionality changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10583 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-22 09:53:29 +00:00
Chris Lattner
18b3c97bc7 Implement IndVarsSimplify/pointer-indvars.ll, transforming pointer
arithmetic into "array subscripts"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10580 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-22 05:02:01 +00:00
Chris Lattner
3324e718bc Fix PR194
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10573 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-22 03:58:44 +00:00
Chris Lattner
bd1a90ecc7 Fix ADCE/2003-12-19-MergeReturn.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10539 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-19 09:08:34 +00:00
Chris Lattner
a3df8a964a Remove the wierd "Operands" loop, by traversing basicblocks in reverse order
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10536 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-19 08:18:16 +00:00
Chris Lattner
e4365b2e8c Implement LICM/sink_multiple.ll, by sinking all possible instructions in the
loop before hoisting any.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10534 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-19 07:22:45 +00:00
Chris Lattner
0f98e75adf Generalize a special case to fix PR187
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10531 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-19 06:27:08 +00:00
Chris Lattner
60921c9aa1 Factor code out into the Utils library
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10530 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-19 05:58:40 +00:00
Chris Lattner
abbc2dd779 Add new function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10529 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-19 05:56:28 +00:00
John Criswell
47df12d80d Reverted back to previous revision - this was previously merged
according to the CVS log messages.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10517 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-18 17:19:19 +00:00
John Criswell
d000e1dc2f Merged in RELEASE_11.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10516 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-18 16:43:17 +00:00
Chris Lattner
ba7df4c482 When we delete instructions from the loop, make sure to remove them from the
AliasSetTracker as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10507 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-18 08:12:32 +00:00
Chris Lattner
9e45d2e0e8 Fix for PR185 & IndVarsSimplify/2003-12-15-Crash.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10473 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-15 17:34:02 +00:00
Chris Lattner
d64152a708 Refactor code just a little bit, allowing us to implement TailCallElim/return_constant.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10467 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-14 23:57:39 +00:00
Chris Lattner
00ad4a2d17 Do not promote volatile alias sets into registers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10458 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-14 04:52:31 +00:00
Chris Lattner
ea9403f2aa Fix LICM/2003-12-11-SinkingToPHI.ll, and quite possibly all of the other known problems in the universe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10409 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-11 22:23:32 +00:00
Chris Lattner
1301515197 verifyFunction depends on dominator info, which levelraise does not declare
that it needs.  This is pretty scary code!  This fixes

Regression.Transforms.LevelRaise.2002-07-16-SourceAndDestCrash
Regression.Transforms.LevelRaise.2002-07-31-AssertionFailure


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10406 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-11 21:47:37 +00:00
Chris Lattner
7d3ced934f Fix bug: LICM/sink_multiple_exits.ll
Thanks for pointing this out John  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10387 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 22:35:56 +00:00
Chris Lattner
df45bd3803 Don't allow dead instructions to stop sinking early.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10386 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 20:43:29 +00:00
Chris Lattner
88369d214f Fix bug: IndVarsSimplify/2003-12-10-RemoveInstrCrash.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10385 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 20:43:04 +00:00
Chris Lattner
dead99325c Finegrainify namespacification
Fix bug: LowerInvoke/2003-12-10-Crash.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10382 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 20:22:42 +00:00
Chris Lattner
ba4f3f6a41 Finegrainify namespacification
Reorder #includes
Implement: IndVarsSimplify/2003-12-10-IndVarDeadCode.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10376 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 18:06:47 +00:00
Chris Lattner
66ea98e85c Finegrainify namespacification
Fix bug: LoopSimplify/2003-12-10-ExitBlocksProblem.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10373 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 17:20:35 +00:00
Chris Lattner
e3cfe8d563 Simplify code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10371 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 16:58:24 +00:00
Chris Lattner
f594a03197 Avoid performing two identical lookups when one will suffice
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10370 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 16:57:24 +00:00
Chris Lattner
0ed2da9ac7 Make LICM itself a bit more efficient, and make the generated code more efficient too: don't insert a store in every exit block, because a particular block may be exited to more than once by a loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10369 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 15:56:24 +00:00
Chris Lattner
a2706518f9 Implement instruction sinking out of loops. This still can do a little bit
better job, but this is the majority of the work.  This implements
LICM/sink*.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10358 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-10 06:41:05 +00:00
Chris Lattner
010ba10032 Do not insert one entry PHI nodes in split exit blocks!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10348 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-09 23:12:55 +00:00
Chris Lattner
ed6dfc2856 Refactor code a little bit, eliminating the gratuitous InstVisitor, which
should make subsequent changes simpler.  This also allows us to hoist vaarg
and vanext instructions


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10342 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-09 19:32:44 +00:00
Chris Lattner
92094b4d92 Fine grainify namespacification
Code cleanups
Make LICM::SafeToHoist marginally more efficient


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10341 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-09 17:18:00 +00:00
Chris Lattner
cf2f89251d Implement: TailCallElim/accum_recursion_constant_arg.ll
Also make sure to clean up any PHI nodes that are inserted which are pointless.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10333 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-08 23:37:35 +00:00
Chris Lattner
543d622ef7 Implement: test/Regression/Transforms/TailCallElim/accum_recursion.ll
We now insert accumulator variables as necessary to eliminate tail recursion
more aggressively.  This is still fairly limited, but allows us to transform
fib/factorial, and other functions into nice happy loops.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10332 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-08 23:19:26 +00:00
Chris Lattner
7152da38ef Cleanup and restructure the code to make it easier to read and maintain.
The only functionality change is that we now implement:
  Regression/Transforms/TailCallElim/intervening-inst.ll

Which is really kinda pointless, because it means that trivially dead code
does not interfere with -tce, but trivially dead code probably wouldn't be
around anytime when this pass is run anyway.

The point of including this change it to support other more aggressive
transformations when we have the analysis capabilities to do so.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10312 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-08 05:34:54 +00:00
Chris Lattner
eb12cd67dd Implement RaiseAllocations/FreeCastConstantExpr.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10305 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-07 01:42:08 +00:00
Chris Lattner
67b1e1b89f * Finegrainify namespacification
* Transform: free <ty>* (cast <ty2>* X to <ty>*) into free <ty2>* X


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10303 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-07 01:24:23 +00:00
Chris Lattner
d866473094 Finegrainify namespacification
Fix regressions ScalarRepl/basictest.ll & arraytest.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10287 91177308-0d34-0410-b5e6-96231b3b80d8
2003-12-02 17:43:55 +00:00
Chris Lattner
3607f4d217 Fix test: Transforms/LevelRaise/2003-11-28-IllegalTypeConversion.ll
Some gep generalization changes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10252 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-29 05:31:25 +00:00
Chris Lattner
be883a23ed Do not use index type to determine what it is indexing into!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10226 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-25 21:09:18 +00:00
Chris Lattner
ab25f5a6c1 Delete dead line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10164 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-22 02:26:17 +00:00
Chris Lattner
3788c242be Fix bug: Transforms/PruneEH/2003-11-21-PHIUpdate.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10163 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-22 02:20:36 +00:00
Chris Lattner
c8ecd22037 Do not crash when deleing a region with a dead invoke instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10161 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-22 02:13:08 +00:00
Chris Lattner
35bb52f8b1 Finegrainify namespacification
The module stripping pass should not strip symbols on external globals


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10157 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-22 01:29:35 +00:00
Chris Lattner
6d1db01284 Considering that CI is not even IN SCOPE here, I wooda thought the compiler
would have caught this.  *sigh*


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10142 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-21 21:57:29 +00:00
Chris Lattner
1e2385b941 Finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10138 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-21 21:54:22 +00:00
Chris Lattner
1192283096 Get rid of using decls, finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10137 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-21 21:52:10 +00:00
Chris Lattner
869adc283c * Finegrainify namespacification
* Make the cost metric for passing constants in as arguments to functions MUCH
  more accurate, by actually estimating the amount of code that will be constant
  propagated away.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10136 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-21 21:46:09 +00:00
Chris Lattner
a51bcb50b0 Finegrainify namespacification
Print out the costs for functions that AREN'T inlined as well


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10135 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-21 21:45:31 +00:00
Chris Lattner
108e4ab159 Minor cleanups and simplifications
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10127 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-21 16:52:05 +00:00
Chris Lattner
03fb8b2a42 * Finegrainify namespacification
* Implement FuncResolve/2003-11-20-BogusResolveWarning.ll
   ... which eliminates a large number of annoying warnings.  I know misha
   will miss them though!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10123 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-20 21:21:31 +00:00
Chris Lattner
f8485c6434 Start using the nicer terminator auto-insertion API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10111 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-20 18:25:24 +00:00
Chris Lattner
adbc0b5287 Spew symbolic types!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10110 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-20 18:23:14 +00:00
Chris Lattner
143df9a1bb When spewing out warnings during function resolution, do not vomit out pages
and pages of non-symbolic types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10109 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-20 18:19:35 +00:00
Misha Brukman
444fdea19d This file was somehow missing a top-level comment line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10055 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-17 19:35:17 +00:00
Chris Lattner
faa45ce300 Fix PR116
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10032 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-16 21:39:27 +00:00
Chris Lattner
917e804253 Implement feature: InstCombine/2003-11-13-ConstExprCastCall.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9981 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-13 19:17:02 +00:00
Brian Gaeke
d0fde30ce8 Put all LLVM code into the llvm namespace, as per bug 109.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9903 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-11 22:41:34 +00:00
Chris Lattner
363ca610d1 Reorganize code for locality, improve comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9857 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-10 04:42:42 +00:00
Chris Lattner
d23520cd94 Adjust to new critical edge interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9853 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-10 04:10:50 +00:00
Chris Lattner
d77922f1a2 Do NOT inline self recursive calls into other functions. This is causing the
pool allocator no end of trouble, and doesn't make a lot of sense anyway.  This
does not solve the problem with mutually recursive functions, but they are much less common.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9828 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-09 05:05:36 +00:00
Chris Lattner
b045e14111 Untypo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9827 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-09 05:04:25 +00:00
Misha Brukman
ed1f7c81aa Declare FunctionPasses as such so that they can be used in FunctionPassManager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9768 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-07 17:20:18 +00:00
Chris Lattner
0c7e8e17ff Various cleanups and efficiency improvements
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9753 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-06 19:46:29 +00:00
Chris Lattner
d7222ec801 Fix bug: PR93
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9752 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-06 19:18:49 +00:00
Chris Lattner
b6e0631a94 Fix the problem with running cleanups in bugpoint: We were deleting arguments
of intrinsic functions, causing the verifier to fail.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9745 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-05 21:53:41 +00:00
Chris Lattner
fdcc3acb7b Split behavior into two pieces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9741 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-05 21:43:02 +00:00
Chris Lattner
e7a6663eb1 Yet more fixes for constant expr shifts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9739 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-05 20:43:58 +00:00
Chris Lattner
d981f8af79 Further fixes for PR93
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9738 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-05 20:37:01 +00:00
Chris Lattner
1bcc70d240 Fix flawed logic that was breaking several SPEC benchmarks, including gzip and crafty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9731 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-05 17:31:36 +00:00
Chris Lattner
646f8d7457 Be gcc 3.4 clean
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9725 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-05 06:12:18 +00:00
Chris Lattner
d65460f133 Fix bug with previous implementation:
-      // ~(c-X) == X-(c-1) == X+(-c+1)
+      // ~(c-X) == X-c-1 == X+(-c-1)

Implement: C - ~X == X + (1+C)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9715 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-05 01:06:05 +00:00
Chris Lattner
ad5b4fb6b7 Minor cleanup, plus implement InstCombine/xor.ll:test17
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9711 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-04 23:50:51 +00:00
Chris Lattner
689d24b6ed Implement InstCombine/xor.ll:test(15|16)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9708 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-04 23:37:10 +00:00
John Criswell
700867bb69 Checking in Chris's suggestions:
Added assert() to ensure symbol table is well formed.
Added code to remember the value that was found; resolving types can change
the symbol table and invalidate the value of the iterator.
Added comments to the ResolveTypes() function (mainly for my own benefit).
Please feel free to correct the comments if they are not accurate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9693 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-04 15:22:26 +00:00
Chris Lattner
6870805117 Implement InstCombine/cast-set.ll:test6[a]. This improves code generated for
a hot function in em3d


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9673 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-03 05:17:03 +00:00
Chris Lattner
de90b76670 Implement InstCombine/cast-set.ll: test1, test2, test7
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9670 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-03 04:25:02 +00:00
Chris Lattner
8ee9204309 Fix bug with zero sized casts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9667 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-03 01:29:41 +00:00
Chris Lattner
fc07a3473a Fix bug in previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9656 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-02 06:54:48 +00:00
Chris Lattner
bc61e661bd Implement transmogriphication of allocation instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9654 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-02 05:57:39 +00:00
Chris Lattner
d6d0d8c18d Fix PR78
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9648 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-02 02:06:27 +00:00
Chris Lattner
bb9ae1512e Strip off CPR's manually, because if we don't, the inliner doesn't delete dead
functions.  GRR


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9641 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-31 21:05:58 +00:00
Chris Lattner
bb60904469 Fix bug: 2003-10-29-CallSiteResolve.ll & PR70
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9600 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-30 00:46:41 +00:00
Chris Lattner
942457564d Refactor code, initial implementation of -insert-block-profiling pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9593 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-29 21:24:22 +00:00
Chris Lattner
546fc40d69 Fix PR66 & ScalarRepl/2003-10-29-ArrayProblem.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9585 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-29 17:55:44 +00:00
Chris Lattner
6ace4daa57 Fix bug: ConstantMerge/2003-10-28-MergeExternalConstants.ll & PR64
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9579 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-29 06:01:26 +00:00
Chris Lattner
fe2143d87d Check in statistifying patch for Bill
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9572 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-28 23:14:59 +00:00
Chris Lattner
c0204e0b73 Pass in argc & argv
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9563 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-28 22:42:24 +00:00
Chris Lattner
baa2007fae Initial checkin of profiling instrumentation pass. So far, despite the
file name, we only support function profiling.  This will be fixed in the
near future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9547 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-28 18:59:04 +00:00
Chris Lattner
7b6dd2950f Eliminate using declarations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9543 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-27 21:44:09 +00:00