Chris Lattner
d8345001fa
Do not clone arbitrary condition instructions.
...
llvm-svn: 13316
2004-05-02 05:19:36 +00:00
Chris Lattner
da2d746a3b
Do not infinitely "unroll" single BB loops.
...
llvm-svn: 13315
2004-05-02 05:02:03 +00:00
Chris Lattner
5f393764c8
Dont' merge terminators that are needed to select PHI node values.
...
llvm-svn: 13312
2004-05-02 01:00:44 +00:00
Chris Lattner
bd705d7776
Implement SimplifyCFG/branch-cond-merge.ll
...
Turning "if (A < B && B < C)" into "if (A < B & B < C)"
llvm-svn: 13311
2004-05-01 23:35:43 +00:00
Chris Lattner
911e21e8ca
Fix my missing parens
...
llvm-svn: 13307
2004-05-01 22:41:51 +00:00
Chris Lattner
82278b599b
Implement SimplifyCFG/branch-cond-prop.ll
...
llvm-svn: 13306
2004-05-01 22:36:37 +00:00
Misha Brukman
144b5572e1
* Allow aggregating extracted function arguments (controlled by flag)
...
* Commandline option (for now) controls that flag that is passed in
llvm-svn: 13141
2004-04-23 23:54:17 +00:00
Alkis Evlogimenos
904f4f9a21
Include cerrno (gcc-3.4 fix)
...
llvm-svn: 13091
2004-04-21 16:11:40 +00:00
Chris Lattner
6d5decd7d4
Add support for evaluation of exp/log/log10/pow
...
llvm-svn: 13011
2004-04-16 22:35:33 +00:00
Brian Gaeke
4b9f67c638
Include <cmath> for compatibility with gcc 3.0.x (the system compiler on
...
Debian.)
llvm-svn: 12986
2004-04-16 15:57:32 +00:00
Chris Lattner
06eda01d1b
Fix Inline/2004-04-15-InlineDeletesCall.ll
...
Basically we were using SimplifyCFG as a huge sledgehammer for a simple
optimization. Because simplifycfg does so many things, we can't use it
for this purpose.
llvm-svn: 12977
2004-04-16 05:17:59 +00:00
Chris Lattner
778f09027f
Add a simple call constant propagation interface.
...
llvm-svn: 12919
2004-04-13 19:28:52 +00:00
Chris Lattner
8ccddbd123
Fold code like:
...
if (C)
V1 |= V2;
into:
Vx = V1 | V2;
V1 = select C, V1, Vx
when the expression can be evaluated unconditionally and is *cheap* to
execute. This limited form of if conversion is quite handy in lots of cases.
For example, it turns this testcase into straight-line code:
int in0 ; int in1 ; int in2 ; int in3 ;
int in4 ; int in5 ; int in6 ; int in7 ;
int in8 ; int in9 ; int in10; int in11;
int in12; int in13; int in14; int in15;
long output;
void mux(void) {
output =
(in0 ? 0x00000001 : 0) | (in1 ? 0x00000002 : 0) |
(in2 ? 0x00000004 : 0) | (in3 ? 0x00000008 : 0) |
(in4 ? 0x00000010 : 0) | (in5 ? 0x00000020 : 0) |
(in6 ? 0x00000040 : 0) | (in7 ? 0x00000080 : 0) |
(in8 ? 0x00000100 : 0) | (in9 ? 0x00000200 : 0) |
(in10 ? 0x00000400 : 0) | (in11 ? 0x00000800 : 0) |
(in12 ? 0x00001000 : 0) | (in13 ? 0x00002000 : 0) |
(in14 ? 0x00004000 : 0) | (in15 ? 0x00008000 : 0) ;
}
llvm-svn: 12798
2004-04-09 22:50:22 +00:00
Chris Lattner
d8efae05fe
Implement ScalarRepl/select_promote.ll
...
llvm-svn: 12779
2004-04-08 19:59:34 +00:00
Chris Lattner
3f202e3a54
Fix the obvious bug in my previous checkin
...
llvm-svn: 12618
2004-04-02 18:15:10 +00:00
Chris Lattner
bca948c99d
Implement Transforms/SimplifyCFG/return-merge.ll
...
This actually causes us to turn code like:
return C ? A : B;
into a select instruction.
llvm-svn: 12617
2004-04-02 18:13:43 +00:00
Chris Lattner
973cb73b4f
Fix PR310 and TailDup/2004-04-01-DemoteRegToStack.llx
...
llvm-svn: 12597
2004-04-01 20:28:45 +00:00
Chris Lattner
1c0ddbfb7d
Fix linking of constant expr casts due to type resolution changes. With
...
this and the other patches 253.perlbmk links again.
llvm-svn: 12565
2004-03-31 02:58:28 +00:00
Chris Lattner
145aea5c4c
Now that all the code generators support the select instruction, and the instcombine
...
pass can eliminate many nasty cases of them, start generating them in the optimizers
llvm-svn: 12545
2004-03-30 19:44:05 +00:00
Chris Lattner
0f0a253571
Fix bug: CodeExtractor/2004-03-17-MissedLiveIns.ll
...
With this fix we now successfully extract all 149 loops from 256.bzip2 without
crashing or miscompiling the program!
llvm-svn: 12493
2004-03-18 05:56:32 +00:00
Chris Lattner
b1bc514730
Fix CodeExtractor/2004-03-17-UpdatePHIsOutsideRegion.ll
...
llvm-svn: 12489
2004-03-18 05:38:31 +00:00
Chris Lattner
69fdd9f14a
Seriously simplify and correct the PHI node handling code.
...
llvm-svn: 12487
2004-03-18 05:28:49 +00:00
Chris Lattner
345cf6f177
Fix CodeExtractor/2004-03-17-OutputMismatch.ll
...
llvm-svn: 12486
2004-03-18 04:12:05 +00:00
Chris Lattner
0d233c03fc
Fix several bugs in the extractor:
...
1. Names were not put on the new arguments created (ok, this just helps sanity :)
2. Fix outgoing pointer values
3. Do not insert stores for values that had not been computed
4. Fix some wierd problems with the outset calculation
This fixes CodeExtractor/2004-03-14-DominanceProblem.ll, making the extractor
work on at least one simple case!
llvm-svn: 12484
2004-03-18 03:49:40 +00:00
Chris Lattner
7c0d39dcd6
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 :)
llvm-svn: 12481
2004-03-18 03:15:29 +00:00
Chris Lattner
849234af99
Fix compilation of mesa, which I broke earlier today
...
llvm-svn: 12465
2004-03-17 02:02:47 +00:00
Chris Lattner
e04883605a
This code was both incredibly complex and incredibly broken. Fix it.
...
llvm-svn: 12456
2004-03-16 23:23:11 +00:00
Chris Lattner
2175b35b46
Do not copy gigantic switch instructions
...
llvm-svn: 12441
2004-03-16 19:45:22 +00:00
Chris Lattner
781ede7382
Mostly cosmetic improvements. Do fix the bug where a global value was considered an input.
...
llvm-svn: 12406
2004-03-15 01:26:44 +00:00
Chris Lattner
3933f4660f
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.
llvm-svn: 12405
2004-03-15 01:18:23 +00:00
Chris Lattner
cfe9af750b
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
llvm-svn: 12402
2004-03-14 23:43:24 +00:00
Chris Lattner
17c2c776c3
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.
llvm-svn: 12401
2004-03-14 23:05:49 +00:00
Chris Lattner
f8d6c1a252
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.
llvm-svn: 12400
2004-03-14 22:34:55 +00:00
Chris Lattner
e52c176a7c
Minor random cleanups
...
llvm-svn: 12382
2004-03-14 04:01:47 +00:00
Chris Lattner
b23b38259a
Verify functions as they are produced if -debug is specified. Reduce
...
curly braceage
llvm-svn: 12378
2004-03-14 03:17:22 +00:00
Chris Lattner
1685a3af78
Move to the IPO library. Utils shouldn't contain passes.
...
llvm-svn: 12372
2004-03-14 02:32:27 +00:00
Chris Lattner
5003f9e473
DemoteRegToStack got moved from DemoteRegToStack.h to Local.h
...
llvm-svn: 12368
2004-03-14 02:13:38 +00:00
Chris Lattner
76457c9c13
Add constant folding wrapper support for select instructions.
...
llvm-svn: 12319
2004-03-12 05:53:03 +00:00
Misha Brukman
c58f772803
Implement ExtractCodeRegion()
...
llvm-svn: 12070
2004-03-02 00:20:57 +00:00
Misha Brukman
8a60e317f0
Make a note that this is usually used via bugpoint.
...
llvm-svn: 12068
2004-03-02 00:19:09 +00:00
Misha Brukman
f93e6ab769
* Add implementation of ExtractBasicBlock()
...
* Add comments to ExtractLoop()
llvm-svn: 12053
2004-03-01 18:28:34 +00:00
Chris Lattner
9736130083
Fix bug: test/Regression/Transforms/LowerInvoke/2004-02-29-PHICrash.llx
...
... which tickled the lowerinvoke pass because it used the BCE routines.
llvm-svn: 12012
2004-02-29 22:24:41 +00:00
Chris Lattner
a854ddd528
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.
llvm-svn: 11964
2004-02-28 21:28:10 +00:00
Misha Brukman
0b846ae65c
Right, it's really Extractor, not Extraction.
...
llvm-svn: 11939
2004-02-28 03:37:58 +00:00
Misha Brukman
f14fbb1a0b
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.
llvm-svn: 11936
2004-02-28 03:33:01 +00:00
Misha Brukman
26e90f8776
A generic code extractor: given a list of BasicBlocks, it will rip them out into
...
a new function, taking care of inputs and outputs.
llvm-svn: 11935
2004-02-28 03:26:20 +00:00
Chris Lattner
e07d786aa6
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.
llvm-svn: 11870
2004-02-26 07:13:46 +00:00
Chris Lattner
7845e4f7f0
If a block is made dead, make sure to promptly remove it.
...
llvm-svn: 11799
2004-02-24 16:09:21 +00:00
Chris Lattner
d678669018
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)
llvm-svn: 11797
2004-02-24 07:23:58 +00:00
Chris Lattner
1293e1d00c
Rearrange code a bit
...
llvm-svn: 11793
2004-02-24 05:54:22 +00:00
Chris Lattner
e5db7dc4c6
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.
llvm-svn: 11792
2004-02-24 05:38:11 +00:00
Chris Lattner
4fa2e7a67f
Fix PR245: Linking weak and strong global variables is dependent on link order
...
llvm-svn: 11565
2004-02-17 21:56:04 +00:00
Chris Lattner
f51bbb7eec
Implement test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll,
...
see the testcase for the reasoning.
llvm-svn: 11496
2004-02-16 06:35:48 +00:00
Chris Lattner
28131460da
Adjustments to support the new ConstantAggregateZero class
...
llvm-svn: 11474
2004-02-15 05:55:15 +00:00
Chris Lattner
2265790f9f
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!
llvm-svn: 11384
2004-02-13 16:47:35 +00:00
Chris Lattner
4418633216
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.
llvm-svn: 11307
2004-02-11 03:36:04 +00:00
Chris Lattner
754914b142
The hasConstantReferences predicate always returns false.
...
llvm-svn: 11301
2004-02-11 01:17:07 +00:00
Chris Lattner
68fdb35576
rename the "exceptional" destination of an invoke instruction to the 'unwind' dest
...
llvm-svn: 11202
2004-02-08 21:44:31 +00:00
Chris Lattner
342b7276d6
Minor speedup, don't query ValueMap each time through the loop
...
llvm-svn: 11123
2004-02-04 21:44:26 +00:00
Chris Lattner
cbe1dd55f4
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%)
llvm-svn: 11118
2004-02-04 21:33:42 +00:00
Chris Lattner
790d7321b4
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.
llvm-svn: 11116
2004-02-04 04:17:06 +00:00
Chris Lattner
8f0a362cd4
More refactoring. Move alloca instructions and handle invoke instructions
...
before we delete the original call site, allowing slight simplifications of
code, but nothing exciting.
llvm-svn: 11109
2004-02-04 02:51:48 +00:00
Chris Lattner
ab01a0e982
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.
llvm-svn: 11108
2004-02-04 01:41:09 +00:00
Chris Lattner
aa44b4de3e
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.
llvm-svn: 11107
2004-02-04 01:19:43 +00:00
Chris Lattner
2998d508b0
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.
llvm-svn: 11100
2004-02-03 22:34:12 +00:00
Chris Lattner
eee884cc98
Handle extremely trivial cases extremely efficiently. This speeds up
...
SRoA/mem2reg from 41.2s to 27.5s on the testcase in PR209.
llvm-svn: 11099
2004-02-03 22:00:33 +00:00
Chris Lattner
7bfaf8bba8
Clean up #includes
...
llvm-svn: 10799
2004-01-12 19:56:36 +00:00
Chris Lattner
47e9056669
Remove use of ConstantExpr::getShift
...
llvm-svn: 10792
2004-01-12 19:10:58 +00:00
Chris Lattner
23da5dbed6
Remove use of ConstantHandling
...
llvm-svn: 10789
2004-01-12 18:35:03 +00:00
Chris Lattner
7242f6af5f
Move llvm::ConstantFoldInstruction from VMCore to here, next to ConstantFoldTerminator
...
llvm-svn: 10785
2004-01-12 18:25:22 +00:00
Chris Lattner
40c667e0bc
Implement Transforms/ScalarRepl/phinodepromote.ll, which is an important
...
case that the C/C++ front-end generates.
llvm-svn: 10761
2004-01-12 01:18:32 +00:00
Chris Lattner
031bd7e9f3
Finegrainify namespacification
...
llvm-svn: 10727
2004-01-09 06:12:26 +00:00
Chris Lattner
c1952a1fd6
Add new function
...
llvm-svn: 10529
2003-12-19 05:56:28 +00:00
Chris Lattner
2b7309dd1c
Minor cleanups and simplifications
...
llvm-svn: 10127
2003-11-21 16:52:05 +00:00
Chris Lattner
feeb3261f2
Start using the nicer terminator auto-insertion API
...
llvm-svn: 10111
2003-11-20 18:25:24 +00:00
Chris Lattner
071bf19ef5
Spew symbolic types!
...
llvm-svn: 10110
2003-11-20 18:23:14 +00:00
Brian Gaeke
d25f86d683
Put all LLVM code into the llvm namespace, as per bug 109.
...
llvm-svn: 9903
2003-11-11 22:41:34 +00:00
Chris Lattner
7dd63c59d1
Reorganize code for locality, improve comments
...
llvm-svn: 9857
2003-11-10 04:42:42 +00:00
Chris Lattner
e0d83d79e4
Adjust to new critical edge interface
...
llvm-svn: 9853
2003-11-10 04:10:50 +00:00
Chris Lattner
8e2385eb4d
Various cleanups and efficiency improvements
...
llvm-svn: 9753
2003-11-06 19:46:29 +00:00
Chris Lattner
a8d3699eb3
Yet more fixes for constant expr shifts
...
llvm-svn: 9739
2003-11-05 20:43:58 +00:00
Chris Lattner
dba798775b
Further fixes for PR93
...
llvm-svn: 9738
2003-11-05 20:37:01 +00:00
John Criswell
3e30e40801
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.
llvm-svn: 9693
2003-11-04 15:22:26 +00:00
Chris Lattner
00fed59c28
Fix test: Linker/2003-10-27-LinkOncePromote.ll
...
Fix PR58
llvm-svn: 9530
2003-10-27 16:39:39 +00:00
Chris Lattner
4fb1540128
Get the list of PHI node values before the basic block is split. Also, add
...
PHI node entries for unwind instructions just like for call instructions which
became invokes! This fixes PR57, tested by
Inline/2003-10-26-InlineInvokeExceptionDestPhi.ll
llvm-svn: 9526
2003-10-27 05:33:09 +00:00
Chris Lattner
1519122fa7
Fix bug: Linker/2003-10-21-ConflictingTypesTolerance.ll
...
llvm-svn: 9357
2003-10-21 22:46:38 +00:00
Chris Lattner
4f65be9ac3
Fix message to make more sense and confuse Chris less
...
llvm-svn: 9354
2003-10-21 21:52:20 +00:00
John Criswell
de34542f41
Added LLVM copyright header.
...
llvm-svn: 9321
2003-10-21 15:17:13 +00:00
John Criswell
71d2894956
Added LLVM copyright notice to Makefiles.
...
llvm-svn: 9312
2003-10-20 22:26:57 +00:00
John Criswell
b402729b30
Added LLVM project notice to the top of every C++ source file.
...
Header files will be on the way.
llvm-svn: 9298
2003-10-20 19:43:21 +00:00
Chris Lattner
e4a69325ff
Fix PR#50
...
llvm-svn: 9227
2003-10-18 06:14:59 +00:00
Chris Lattner
f46c45682a
Add support for 'weak' linkage.
...
llvm-svn: 9171
2003-10-16 18:29:00 +00:00
Chris Lattner
c6778e91f4
Cleanup
...
llvm-svn: 9133
2003-10-15 16:42:21 +00:00
Chris Lattner
a567862e89
Do not move variable sized allocations to the top of the caller, which might
...
break dominance relationships, and is otherwise bad. This fixes bug:
Inline/2003-10-13-AllocaDominanceProblem.ll. This also fixes miscompilation
of 3 176.gcc source files (reload1.c, global.c, flow.c)
llvm-svn: 9109
2003-10-14 01:11:07 +00:00
Chris Lattner
f4ca01758d
Rename loop preheaders pass to loop simplify
...
llvm-svn: 9061
2003-10-12 21:52:28 +00:00
Misha Brukman
868eac95dd
Fix spelling.
...
llvm-svn: 9027
2003-10-10 17:57:28 +00:00
Chris Lattner
5b814e067a
Avoid doing pointless work. Amazingly, this makes us go faster.
...
Running the inliner on 252.eon used to take 48.4763s, now it takes 14.4148s.
In release mode, it went from taking 25.8741s to taking 11.5712s.
This also fixes a FIXME.
llvm-svn: 8890
2003-10-06 15:23:43 +00:00
Chris Lattner
87f1ce9b96
This changes the PromoteMemToReg function to create "pruned" SSA form, not
...
"minimal" SSA form (in other words, it doesn't insert dead PHIs). This
speeds up the mem2reg pass very significantly because it doesn't have to
do a lot of frivolous work in many common cases.
In the 252.eon function I have been playing with, this doesn't even insert
the 120 PHI nodes that it used to which were trivially dead (in the process
of promoting 356 alloca instructions overall). This speeds up the mem2reg
pass from 1.2459s to 0.1284s. More significantly, the DCE pass used to take
2.4138s to remove the 120 dead PHI nodes that mem2reg constructed, now it
takes 0.0134s (which is the time to scan the function and decide that there
is nothing dead). So overall, on this one function, we speed things up a
total of 3.5179s, which is a 24.8x speedup! :)
This change is tested by the Mem2Reg/2003-10-05-DeadPHIInsertion.ll test,
which now passes.
llvm-svn: 8884
2003-10-05 22:19:20 +00:00
Chris Lattner
d1c3f771f8
Change the interface to PromoteMemToReg to also take a DominatorTree
...
llvm-svn: 8883
2003-10-05 21:20:13 +00:00
Chris Lattner
47c12a2771
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.
llvm-svn: 8881
2003-10-05 20:54:03 +00:00
Chris Lattner
ada012bfcd
The first PHI node may be null, scan for the first non-null one
...
llvm-svn: 8865
2003-10-05 05:34:39 +00:00
Chris Lattner
a5fd39ee21
The VersionNumbers vector is only used during PHI placement. Turn it into an argument, allowing us to get rid of the vector.
...
llvm-svn: 8864
2003-10-05 04:33:22 +00:00
Chris Lattner
4877c37b80
* 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. :)
llvm-svn: 8863
2003-10-05 04:26:39 +00:00
Chris Lattner
baba417853
Simplify the loop a bit
...
llvm-svn: 8862
2003-10-05 03:45:44 +00:00
Chris Lattner
59281d3581
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.
llvm-svn: 8861
2003-10-05 03:39:10 +00:00
Chris Lattner
5958d93c95
The PhiNodes 2D vector is only used during PHI node placement. It doesn't
...
need to be an instance variable!
llvm-svn: 8860
2003-10-05 03:26:25 +00:00
Chris Lattner
91d69f2693
* Document instance vars better
...
* Fuse two parallel loops
* Use a more specific type for AllocaLookup
llvm-svn: 8859
2003-10-05 03:16:07 +00:00
Chris Lattner
773a1c4474
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
llvm-svn: 8858
2003-10-05 02:37:36 +00:00
Chris Lattner
9f0a542057
* 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.
llvm-svn: 8857
2003-10-05 01:52:53 +00:00
Chris Lattner
253c5f582e
Fix bugs in the last change
...
llvm-svn: 8667
2003-09-22 23:30:59 +00:00
Chris Lattner
7ff5b8a024
Fix bug: Inline/2003-09-22-PHINodesInNormalInvokeDest.ll
...
llvm-svn: 8666
2003-09-22 22:35:39 +00:00
Chris Lattner
2cb1e9f0a6
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.
llvm-svn: 8664
2003-09-22 21:59:27 +00:00
Chris Lattner
fabd2617fc
Minor cleanups, no functional changes
...
Rename Function::getEntryNode -> getEntryBlock
llvm-svn: 8623
2003-09-20 14:36:23 +00:00
Chris Lattner
7a55e0b56d
Fix bug: Inline/2003-09-14-InlineValue.ll
...
llvm-svn: 8514
2003-09-15 02:10:16 +00:00
Chris Lattner
ee577bdc08
Expand the pass to unify all of the unwind blocks as well
...
llvm-svn: 8456
2003-09-10 20:34:51 +00:00
Chris Lattner
e8ae7bf114
Eliminate support for the llvm.unwind intrinisic, using the Unwind instruction instead
...
llvm-svn: 8411
2003-09-08 19:44:26 +00:00
Chris Lattner
5f9de6e523
Should invokify is always true
...
llvm-svn: 8409
2003-09-08 19:00:30 +00:00
Chris Lattner
a295c0d706
Fix bug where we considered function types equivalent even if they had differing numbers of arguments
...
llvm-svn: 8178
2003-08-28 16:42:50 +00:00
Chris Lattner
399ad7c300
Remove special casing
...
llvm-svn: 8144
2003-08-25 22:34:15 +00:00
Chris Lattner
bca7655aa9
Fix bug: Linker/2003-08-23-GlobalVarLinking.ll
...
llvm-svn: 8130
2003-08-24 19:30:20 +00:00
Chris Lattner
64c658e617
Implement: Linker/2003-08-24-InheritPtrSize.ll
...
llvm-svn: 8129
2003-08-24 19:26:42 +00:00
Chris Lattner
a0203709f4
Implement SimplifyCFG/InvokeEliminate.ll
...
llvm-svn: 8126
2003-08-24 18:36:16 +00:00
Chris Lattner
7e3e38b76d
rethrow is really the language independent primitive here. "throw" can be written
...
in terms of it and llvm.exc.setcurrent.
Rework the intrinsics.
llvm-svn: 8111
2003-08-24 12:24:11 +00:00
Chris Lattner
d5be33fded
*** Implement inlining of Invoke instructions!
...
llvm-svn: 8106
2003-08-24 06:59:16 +00:00
Chris Lattner
b3db526a4f
Implement: Inline/cfg_preserve_test.ll
...
llvm-svn: 8099
2003-08-24 04:06:56 +00:00
Chris Lattner
c499f5486f
Implement SimplifyCFG/2003-08-17-FoldSwitch.ll:test5
...
llvm-svn: 8093
2003-08-23 23:18:19 +00:00
Chris Lattner
9274d2d21a
Do not consider any types that exist in the global symbol table!
...
llvm-svn: 8084
2003-08-23 21:32:24 +00:00
Chris Lattner
c94a7e8904
Fix bug: Linker/2003-08-23-RecursiveOpaqueTypeResolve.ll
...
llvm-svn: 8083
2003-08-23 21:25:54 +00:00
Chris Lattner
f063146af6
Implement Linker/2003-08-23-GlobalVarLinking.ll, which should fix 176.gcc
...
llvm-svn: 8080
2003-08-23 20:31:10 +00:00
Chris Lattner
d6bf205b7d
Fix typeo
...
llvm-svn: 8059
2003-08-22 20:16:48 +00:00
Chris Lattner
fafb0d5a3c
The process of linking types can cause their addresses to become invalid. For this reason, we must use TypeHandles!
...
llvm-svn: 8057
2003-08-22 19:12:55 +00:00
Chris Lattner
b382d33401
Implement Linker/2003-08-20-OpaqueTypeResolve.ll
...
Hopefully this will fix the 176.gcc spec test as well.
llvm-svn: 8051
2003-08-22 06:07:12 +00:00
Misha Brukman
56f7db4178
Spell `necessary' correctly.
...
llvm-svn: 7944
2003-08-18 14:43:39 +00:00
Chris Lattner
382a3a3708
Implement folding of switch instructions.
...
Implements SimplifyCFG/2003-08-17-FoldSwitch.ll
llvm-svn: 7923
2003-08-17 20:21:14 +00:00
Chris Lattner
1f5afd2a1c
Fix bug: SimplifyCFG/2003-08-17-BranchFoldOrdering.ll
...
llvm-svn: 7921
2003-08-17 19:41:53 +00:00
Chris Lattner
17f985bfa4
The fixme is irrelevant: if that happens, the LLVM bytecode is malformed.
...
This fixes testcase: SimplifyCFG/2003-08-17-BranchFold.ll
llvm-svn: 7919
2003-08-17 19:34:55 +00:00
Chris Lattner
488b0e52a8
Fix bug: SimplifyCFG/2003-08-05-InvokeCrash.ll
...
Fix bug: SimplifyCFG/2003-08-05-MishandleInvoke.ll
llvm-svn: 7599
2003-08-05 16:27:44 +00:00
Tanya Lattner
eaa01f0821
Fixed comment width, changed arg to be const, fixed indentation, removed unnecessary includes.
...
llvm-svn: 6476
2003-05-31 20:01:37 +00:00
Tanya Lattner
ce23a1f169
Added the CloneTrace function which clones traces. It takes a vector of basic blocks, removes
...
internal phi nodes, and returns a new vector of basic blocks.
llvm-svn: 6431
2003-05-30 15:50:18 +00:00
Chris Lattner
01cbfa9317
Eliminate unnecessary ->get calls that are now automatically handled.
...
llvm-svn: 6397
2003-05-29 15:12:27 +00:00
Chris Lattner
24947af013
* Separate all of the grunt work of inlining out into the Utils library.
...
* Make the function inliner _significantly_ smarter. :)
llvm-svn: 6396
2003-05-29 15:11:31 +00:00
Chris Lattner
e58f6153f4
Remove using declarations
...
llvm-svn: 6306
2003-05-22 22:00:07 +00:00
Misha Brukman
825e174bf7
Hopefully, the final fix for `[Pp]ropogate'.
...
llvm-svn: 6251
2003-05-20 21:01:22 +00:00
Chris Lattner
d0f6311c43
Fix Bug: Linker/2003-05-15-TypeProblem.ll
...
llvm-svn: 6225
2003-05-15 16:30:55 +00:00
Chris Lattner
be0b81a4e9
Fix major problem with appending linkage changes
...
llvm-svn: 6185
2003-05-14 12:11:51 +00:00
Chris Lattner
576323e25e
Implement linkage of appending global variables!
...
llvm-svn: 6178
2003-05-13 21:33:43 +00:00
Chris Lattner
e1c995e9b6
Fix bug: mem2reg/2003-04-24-MultipleIdenticalSuccessors.ll
...
llvm-svn: 5919
2003-04-25 00:54:58 +00:00
Chris Lattner
043b4a7621
Fix iterator invalidation problem
...
llvm-svn: 5895
2003-04-24 17:52:20 +00:00
Chris Lattner
f0c01a508b
Make sure that the cloned module retains the type symbol table entries!
...
llvm-svn: 5894
2003-04-24 17:15:33 +00:00
Chris Lattner
868b3316c9
Make sure to preserve endiannes and pointer size when cloning modules!
...
llvm-svn: 5892
2003-04-24 15:54:40 +00:00