Nick Lewycky
6b016703a9
Remove a couple more cases of "getNumUses() == 0". No need to walk the linked
...
list just to see if whether the list is empty.
llvm-svn: 46555
2008-01-30 08:01:28 +00:00
Nick Lewycky
625e89c8b0
Use empty() instead of comparing size() with zero.
...
llvm-svn: 46554
2008-01-30 07:54:16 +00:00
Nick Lewycky
0e3a5cb14a
Don't DCE FreeInst's. We were using those! Patch from Owen Anderson.
...
llvm-svn: 46553
2008-01-30 07:45:37 +00:00
Owen Anderson
4e4b116750
Make DSE much more aggressive by performing DCE earlier. Update a testcase to reflect this increased aggressiveness.
...
llvm-svn: 46542
2008-01-30 01:24:47 +00:00
Chris Lattner
b9e5b8fb9e
Fix a bug where scalarrepl would discard offset if type would match.
...
In practice this can only happen on code with already undefined behavior,
but this is still a good thing to handle correctly.
llvm-svn: 46539
2008-01-30 00:39:15 +00:00
Chris Lattner
ade0abb498
Don't let globalopt hack on volatile loads or stores.
...
llvm-svn: 46523
2008-01-29 19:01:37 +00:00
Dan Gohman
70de4cb1cd
Use empty() instead of comparing size() with zero.
...
llvm-svn: 46514
2008-01-29 13:02:09 +00:00
Chris Lattner
17819d971e
eliminate additions of 0.0 when they are obviously dead. This has to be careful to
...
avoid turning -0.0 + 0.0 -> -0.0 which is incorrect.
llvm-svn: 46499
2008-01-29 06:52:45 +00:00
Owen Anderson
48d37806e2
Add support for eliminating memcpy's at the end of functions. Also fix some errors I noticed in
...
the handling of eliminating stores to byval arguments.
llvm-svn: 46494
2008-01-29 06:18:36 +00:00
Devang Patel
67fa0521b6
Filter loops that subtract induction variables.
...
These loops are not yet handled.
Fix PR 1912.
llvm-svn: 46484
2008-01-29 02:20:41 +00:00
Chris Lattner
a8b4a56061
Transform calls to memcpy into llvm.memcpy calls, patch by Eli Friedman.
...
llvm-svn: 46433
2008-01-28 04:41:43 +00:00
Nick Lewycky
8ea81e8ba4
Handle some more combinations of extend and icmp. Fixes PR1940.
...
llvm-svn: 46431
2008-01-28 03:48:02 +00:00
Chris Lattner
710b441174
Fix PR1932 by disabling an xform invalid for fdiv.
...
llvm-svn: 46429
2008-01-28 00:58:18 +00:00
Chris Lattner
1b706dd680
Fix PR1938 by forcing the code that uses an undefined value to branch one
...
way or the other. Rewriting the code itself prevents subsequent analysis
passes from making contradictory conclusions about the code that could
cause an infeasible path to be made feasible.
llvm-svn: 46427
2008-01-28 00:32:30 +00:00
Nick Lewycky
efb16f7057
Be more careful modifying the use_list while also iterating through it.
...
llvm-svn: 46417
2008-01-27 18:35:00 +00:00
Duncan Sands
053c9871cd
Revert r46393: readonly/readnone functions are no
...
longer allowed to write through byval arguments.
llvm-svn: 46416
2008-01-27 18:12:58 +00:00
Bill Wendling
60361a16f8
The CorrelatedExpressionElimination pass is known to be buggy. Remove it.
...
This fixes PR1769.
llvm-svn: 46408
2008-01-27 06:11:41 +00:00
Chris Lattner
fa1e7eef30
Fold fptrunc(add (fpextend x), (fpextend y)) -> add(x,y), as GCC does.
...
llvm-svn: 46406
2008-01-27 05:29:54 +00:00
Bill Wendling
5079483957
If there are no machine instructions emitted for a function, then insert
...
a "nop" instruction so that we don't have the function's label associated
with something that it's not supposed to be associated with.
llvm-svn: 46394
2008-01-26 06:51:24 +00:00
Duncan Sands
c4dc3dc3a2
Create an explicit copy for byval parameters even
...
when inlining a readonly function.
llvm-svn: 46393
2008-01-26 06:41:49 +00:00
Bill Wendling
0862e3421d
If we have a function like this:
...
void bork() {
int *address = 0;
*address = 0;
}
It's compiled into LLVM code that looks like this:
define void @bork() noreturn nounwind {
entry:
unreachable
}
This is bad on some platforms (like PPC) because it will generate the label for
the function but no body. The label could end up being associated with some
non-code related stuff, like a section. This places a "trap" instruction if the
SimplifyCFG pass removed all code from the function leaving only one
"unreachable" instruction.
llvm-svn: 46387
2008-01-26 01:43:44 +00:00
Duncan Sands
f52faf9a64
Do this more neatly.
...
llvm-svn: 46369
2008-01-25 22:06:51 +00:00
Owen Anderson
6af19fd1e2
DeadStoreElimination can treat byval parameters as if there were alloca's for the purpose of removing end-of-function stores.
...
llvm-svn: 46351
2008-01-25 10:10:33 +00:00
Nick Lewycky
f069264164
Enable the fix I just checked in, silly me.
...
llvm-svn: 46247
2008-01-22 05:42:02 +00:00
Nick Lewycky
78712e5b59
Multiply can be evaluated in a different type, so long as the target type has
...
a smaller bitwidth.
llvm-svn: 46244
2008-01-22 05:08:48 +00:00
Duncan Sands
afa84da4e0
Make sure the caller doesn't use freed memory.
...
Fixes PR1935.
llvm-svn: 46203
2008-01-20 16:51:46 +00:00
Duncan Sands
fe3bef091f
Initializing an unsigned with ~0UL causes the compiler
...
to complain on x86-64 (gcc 4.1). Use ~0U instead.
llvm-svn: 46197
2008-01-20 10:49:23 +00:00
Evan Cheng
04af661b1f
DAE bug fix. Don't lose parameter attributes on vararg arguments.
...
llvm-svn: 46113
2008-01-17 04:18:54 +00:00
Chris Lattner
5630c4f217
Fix arg promotion to propagate the correct attrs on the calls to
...
promoted functions. This is important for varargs calls in
particular. Thanks to duncan for providing a great testcase.
llvm-svn: 46108
2008-01-17 01:17:03 +00:00
Chris Lattner
39f156183d
Handle attribute(used) global variables that are i8.
...
llvm-svn: 46090
2008-01-16 21:35:43 +00:00
Devang Patel
b3696e4f14
Do not strip llvm.used values.
...
llvm-svn: 46045
2008-01-16 03:33:05 +00:00
Duncan Sands
b5ca2e9fcb
I noticed that the trampoline straightening transformation could
...
drop attributes on varargs call arguments. Also, it could generate
invalid IR if the transformed call already had the 'nest' attribute
somewhere (this can never happen for code coming from llvm-gcc,
but it's a theoretical possibility). Fix both problems.
llvm-svn: 45973
2008-01-14 19:52:09 +00:00
Chris Lattner
26fe7ebc03
Fix the miscompilation of MiBench/consumer-lame that was exposed by Evan's
...
byval work. This miscompilation is due to the program indexing an array out
of range and us doing a transformation that broke this.
llvm-svn: 45949
2008-01-14 02:09:12 +00:00
Chris Lattner
9a6db18b04
The isNotSuitableForSRA property is now dead, don't compute it.
...
llvm-svn: 45948
2008-01-14 01:32:52 +00:00
Chris Lattner
ab0537258f
Change SRAGlobal to not depend on isNotSuitableForSRA, which makes it very
...
difficult to understand the invariants.
llvm-svn: 45947
2008-01-14 01:31:05 +00:00
Chris Lattner
20bbac3435
Make the 'shrink global to bool' optimization more self contained, and thus
...
easier to show that its safe. No functionality change.
llvm-svn: 45946
2008-01-14 01:17:44 +00:00
Chris Lattner
92bd785323
Turn a memcpy from a double* into a load/store of double instead of
...
a load/store of i64. The later prevents promotion/scalarrepl of the
source and dest in many cases.
This fixes the 300% performance regression of the byval stuff on
stepanov_v1p2.
llvm-svn: 45945
2008-01-14 00:28:35 +00:00
Chris Lattner
57974c8d51
factor memcpy/memmove simplification out to its own SimplifyMemTransfer
...
method, no functionality change.
llvm-svn: 45944
2008-01-13 23:50:23 +00:00
Chris Lattner
8c5cdddfb9
simplify some code. If we can infer alignment for source and dest that are
...
greater than memcpy alignment, and if we lower to load/store, use the best
alignment info we have.
llvm-svn: 45943
2008-01-13 22:30:28 +00:00
Chris Lattner
5a86612d3f
simplify some code by adding a InsertBitCastBefore method,
...
make memmove->memcpy conversion a bit simpler.
llvm-svn: 45942
2008-01-13 22:23:22 +00:00
Chris Lattner
5bc253c8f2
Fix PR1907, a nasty miscompilation because instcombine didn't
...
realize that ne & sgt was a signed comparison (it was only
looking at whether the left compare was signed).
llvm-svn: 45937
2008-01-13 20:59:02 +00:00
Duncan Sands
ff70c5de69
Small simplification.
...
llvm-svn: 45932
2008-01-13 08:12:17 +00:00
Duncan Sands
781f6549db
When turning a call to a bitcast function into a direct call,
...
if this becomes a varargs call then deal correctly with any
parameter attributes on the newly vararg call arguments.
llvm-svn: 45931
2008-01-13 08:02:44 +00:00
Chris Lattner
4f6c81ac68
we don't have to make an explicit copy of a byval argument when
...
inlining a function if we know that the function does not write
to *any* memory. This implements test/Transforms/Inline/byval2.ll
llvm-svn: 45912
2008-01-12 18:54:29 +00:00
Chris Lattner
22ad7abdfe
Allow clients to specify the inline threshold when creating
...
the inliner pass. Patch by Robert Zeh.
llvm-svn: 45903
2008-01-12 06:49:13 +00:00
Duncan Sands
5b721fc21d
When DAE drops the varargs part of a function, ensure any
...
attributes on the vararg call arguments are also dropped.
llvm-svn: 45892
2008-01-11 23:13:45 +00:00
Chris Lattner
b5bd924e83
Teach argpromote to ruthlessly hack small byval structs when it can
...
get away with it, which exposes opportunities to eliminate the memory
objects entirely. For example, we now compile byval.ll to:
define internal void @f1(i32 %b.0, i64 %b.1) {
entry:
%tmp2 = add i32 %b.0, 1 ; <i32> [#uses=0]
ret void
}
define i32 @main() nounwind {
entry:
call void @f1( i32 1, i64 2 )
ret i32 0
}
This seems like it would trigger a lot for code that passes around small
structs (e.g. SDOperand's or _Complex)...
llvm-svn: 45886
2008-01-11 22:31:41 +00:00
Chris Lattner
b66fbdde42
Use smallptrset instead of std::set for efficiency.
...
llvm-svn: 45878
2008-01-11 19:36:30 +00:00
Chris Lattner
4a70261f00
a byval argument is guaranteed to be valid to load.
...
llvm-svn: 45877
2008-01-11 19:34:32 +00:00
Chris Lattner
4062a625e5
Update this code to use eraseFromParent where possible. Compute
...
whether an argument is byval and pass into isSafeToPromoteArgument.
llvm-svn: 45876
2008-01-11 19:20:39 +00:00