682a7dc653 
								
							 
						 
						
							
							
								
								Fix a bug compiling PR1978 (perhaps not the only one though) which  
							
							... 
							
							
							
							was incorrectly simplifying "x == (gep x, 1, i)" into false, even 
though i could be negative.  As it turns out, all the code to 
handle this already existed, we just need to disable the incorrect
optimization case and let the general case handle it.
llvm-svn: 46739 
							
						 
						
							2008-02-05 04:45:32 +00:00  
				
					
						
							
							
								 
						
							
								a82c9931f4 
								
							 
						 
						
							
							
								
								Be more precise when eliminating pointers bue to memcpy's.  This allows more  
							
							... 
							
							
							
							stores to be deleted in some cases.
llvm-svn: 46694 
							
						 
						
							2008-02-04 04:53:00 +00:00  
				
					
						
							
							
								 
						
							
								c4a7c41869 
								
							 
						 
						
							
							
								
								Allow GVN to hack on memcpy's, making them open to further optimization.  
							
							... 
							
							
							
							llvm-svn: 46693 
							
						 
						
							2008-02-04 02:59:58 +00:00  
				
					
						
							
							
								 
						
							
								3b59214320 
								
							 
						 
						
							
							
								
								There are some cases where icmp(add) can be folded into a new icmp. Handle them.  
							
							... 
							
							
							
							llvm-svn: 46687 
							
						 
						
							2008-02-03 16:33:09 +00:00  
				
					
						
							
							
								 
						
							
								c7a4ba044b 
								
							 
						 
						
							
							
								
								Hack on vectors too.  
							
							... 
							
							
							
							llvm-svn: 46684 
							
						 
						
							2008-02-03 08:19:11 +00:00  
				
					
						
							
							
								 
						
							
								e6e3a7f6ea 
								
							 
						 
						
							
							
								
								Fold away one multiply in instcombine. This would normally be caught in  
							
							... 
							
							
							
							reassociate anyways, but they could be generated during instcombine's run.
llvm-svn: 46683 
							
						 
						
							2008-02-03 07:42:09 +00:00  
				
					
						
							
							
								 
						
							
								9aa789fda3 
								
							 
						 
						
							
							
								
								Don't drop function/call return attributes like 'nounwind'.  
							
							... 
							
							
							
							llvm-svn: 46645 
							
						 
						
							2008-02-01 20:37:16 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								625e89c8b0 
								
							 
						 
						
							
							
								
								Use empty() instead of comparing size() with zero.  
							
							... 
							
							
							
							llvm-svn: 46554 
							
						 
						
							2008-01-30 07:54:16 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								ade0abb498 
								
							 
						 
						
							
							
								
								Don't let globalopt hack on volatile loads or stores.  
							
							... 
							
							
							
							llvm-svn: 46523 
							
						 
						
							2008-01-29 19:01:37 +00:00  
				
					
						
							
							
								 
						
							
								70de4cb1cd 
								
							 
						 
						
							
							
								
								Use empty() instead of comparing size() with zero.  
							
							... 
							
							
							
							llvm-svn: 46514 
							
						 
						
							2008-01-29 13:02:09 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								a8b4a56061 
								
							 
						 
						
							
							
								
								Transform calls to memcpy into llvm.memcpy calls, patch by Eli Friedman.  
							
							... 
							
							
							
							llvm-svn: 46433 
							
						 
						
							2008-01-28 04:41:43 +00:00  
				
					
						
							
							
								 
						
							
								8ea81e8ba4 
								
							 
						 
						
							
							
								
								Handle some more combinations of extend and icmp. Fixes PR1940.  
							
							... 
							
							
							
							llvm-svn: 46431 
							
						 
						
							2008-01-28 03:48:02 +00:00  
				
					
						
							
							
								 
						
							
								710b441174 
								
							 
						 
						
							
							
								
								Fix PR1932 by disabling an xform invalid for fdiv.  
							
							... 
							
							
							
							llvm-svn: 46429 
							
						 
						
							2008-01-28 00:58:18 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								efb16f7057 
								
							 
						 
						
							
							
								
								Be more careful modifying the use_list while also iterating through it.  
							
							... 
							
							
							
							llvm-svn: 46417 
							
						 
						
							2008-01-27 18:35:00 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								f52faf9a64 
								
							 
						 
						
							
							
								
								Do this more neatly.  
							
							... 
							
							
							
							llvm-svn: 46369 
							
						 
						
							2008-01-25 22:06:51 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								f069264164 
								
							 
						 
						
							
							
								
								Enable the fix I just checked in, silly me.  
							
							... 
							
							
							
							llvm-svn: 46247 
							
						 
						
							2008-01-22 05:42:02 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								afa84da4e0 
								
							 
						 
						
							
							
								
								Make sure the caller doesn't use freed memory.  
							
							... 
							
							
							
							Fixes PR1935.
llvm-svn: 46203 
							
						 
						
							2008-01-20 16:51:46 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								04af661b1f 
								
							 
						 
						
							
							
								
								DAE bug fix. Don't lose parameter attributes on vararg arguments.  
							
							... 
							
							
							
							llvm-svn: 46113 
							
						 
						
							2008-01-17 04:18:54 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								39f156183d 
								
							 
						 
						
							
							
								
								Handle attribute(used) global variables that are i8.  
							
							... 
							
							
							
							llvm-svn: 46090 
							
						 
						
							2008-01-16 21:35:43 +00:00  
				
					
						
							
							
								 
						
							
								b3696e4f14 
								
							 
						 
						
							
							
								
								Do not strip llvm.used values.  
							
							... 
							
							
							
							llvm-svn: 46045 
							
						 
						
							2008-01-16 03:33:05 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								9a6db18b04 
								
							 
						 
						
							
							
								
								The isNotSuitableForSRA property is now dead, don't compute it.  
							
							... 
							
							
							
							llvm-svn: 45948 
							
						 
						
							2008-01-14 01:32:52 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								ff70c5de69 
								
							 
						 
						
							
							
								
								Small simplification.  
							
							... 
							
							
							
							llvm-svn: 45932 
							
						 
						
							2008-01-13 08:12:17 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								b66fbdde42 
								
							 
						 
						
							
							
								
								Use smallptrset instead of std::set for efficiency.  
							
							... 
							
							
							
							llvm-svn: 45878 
							
						 
						
							2008-01-11 19:36:30 +00:00  
				
					
						
							
							
								 
						
							
								4a70261f00 
								
							 
						 
						
							
							
								
								a byval argument is guaranteed to be valid to load.  
							
							... 
							
							
							
							llvm-svn: 45877 
							
						 
						
							2008-01-11 19:34:32 +00:00  
				
					
						
							
							
								 
						
							
								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  
				
					
						
							
							
								 
						
							
								e736e55d3c 
								
							 
						 
						
							
							
								
								replace a loop with a constant time check.  
							
							... 
							
							
							
							llvm-svn: 45875 
							
						 
						
							2008-01-11 18:55:10 +00:00  
				
					
						
							
							
								 
						
							
								669e7054ca 
								
							 
						 
						
							
							
								
								another minor datastructure tweak.  
							
							... 
							
							
							
							llvm-svn: 45874 
							
						 
						
							2008-01-11 18:47:45 +00:00  
				
					
						
							
							
								 
						
							
								a8ba28f6e4 
								
							 
						 
						
							
							
								
								start using smallvector to avoid vector heap thrashing.  
							
							... 
							
							
							
							llvm-svn: 45873 
							
						 
						
							2008-01-11 18:43:58 +00:00  
				
					
						
							
							
								 
						
							
								908117bf69 
								
							 
						 
						
							
							
								
								When inlining a functino with a byval argument, make an explicit  
							
							... 
							
							
							
							copy of it in case the callee modifies the struct.
llvm-svn: 45853 
							
						 
						
							2008-01-11 06:09:30 +00:00  
				
					
						
							
							
								 
						
							
								2940c5c56d 
								
							 
						 
						
							
							
								
								Implement PR1795, an instcombine hack for forming GEPs with integer pointer arithmetic.  
							
							... 
							
							
							
							llvm-svn: 45745 
							
						 
						
							2008-01-08 07:23:51 +00:00  
				
					
						
							
							
								 
						
							
								b18c30acec 
								
							 
						 
						
							
							
								
								Small cleanup for handling of type/parameter attribute  
							
							... 
							
							
							
							incompatibility.
llvm-svn: 45704 
							
						 
						
							2008-01-07 17:16:06 +00:00  
				
					
						
							
							
								 
						
							
								efb08802ec 
								
							 
						 
						
							
							
								
								Deleting an empty file. Thanks, /usr/bin/patch!  
							
							... 
							
							
							
							llvm-svn: 45675 
							
						 
						
							2008-01-07 02:29:04 +00:00  
				
					
						
							
							
								 
						
							
								6047b6e140 
								
							 
						 
						
							
							
								
								With this patch, the LowerGC transformation becomes the  
							
							... 
							
							
							
							ShadowStackCollector, which additionally has reduced overhead with
no sacrifice in portability.
Considering a function @fun  with 8 loop-local roots,
ShadowStackCollector introduces the following overhead
(x86):
; shadowstack prologue
        movl    L_llvm_gc_root_chain$non_lazy_ptr, %eax
        movl    (%eax), %ecx
        movl    $___gc_fun, 20(%esp)
        movl    $0, 24(%esp)
        movl    $0, 28(%esp)
        movl    $0, 32(%esp)
        movl    $0, 36(%esp)
        movl    $0, 40(%esp)
        movl    $0, 44(%esp)
        movl    $0, 48(%esp)
        movl    $0, 52(%esp)
        movl    %ecx, 16(%esp)
        leal    16(%esp), %ecx
        movl    %ecx, (%eax)
; shadowstack loop overhead
        (none)
; shadowstack epilogue
        movl    48(%esp), %edx
        movl    %edx, (%ecx)
; shadowstack metadata
        .align  3
___gc_fun:                              # __gc_fun
        .long   8
        .space  4
In comparison to LowerGC:
; lowergc prologue
        movl    L_llvm_gc_root_chain$non_lazy_ptr, %eax
        movl    (%eax), %ecx
        movl    %ecx, 48(%esp)
        movl    $8, 52(%esp)
        movl    $0, 60(%esp)
        movl    $0, 56(%esp)
        movl    $0, 68(%esp)
        movl    $0, 64(%esp)
        movl    $0, 76(%esp)
        movl    $0, 72(%esp)
        movl    $0, 84(%esp)
        movl    $0, 80(%esp)
        movl    $0, 92(%esp)
        movl    $0, 88(%esp)
        movl    $0, 100(%esp)
        movl    $0, 96(%esp)
        movl    $0, 108(%esp)
        movl    $0, 104(%esp)
        movl    $0, 116(%esp)
        movl    $0, 112(%esp)
; lowergc loop overhead
        leal    44(%esp), %eax
        movl    %eax, 56(%esp)
        leal    40(%esp), %eax
        movl    %eax, 64(%esp)
        leal    36(%esp), %eax
        movl    %eax, 72(%esp)
        leal    32(%esp), %eax
        movl    %eax, 80(%esp)
        leal    28(%esp), %eax
        movl    %eax, 88(%esp)
        leal    24(%esp), %eax
        movl    %eax, 96(%esp)
        leal    20(%esp), %eax
        movl    %eax, 104(%esp)
        leal    16(%esp), %eax
        movl    %eax, 112(%esp)
; lowergc epilogue
        movl    48(%esp), %edx
        movl    %edx, (%ecx)
; lowergc metadata
        (none)
llvm-svn: 45670 
							
						 
						
							2008-01-07 01:30:53 +00:00  
				
					
						
							
							
								 
						
							
								404eb05247 
								
							 
						 
						
							
							
								
								The transform that tries to turn calls to bitcast functions into  
							
							... 
							
							
							
							direct calls bails out unless caller and callee have essentially
equivalent parameter attributes.  This is illogical - the callee's
attributes should be of no relevance here.  Rework the logic, which
incidentally fixes a crash when removed arguments have attributes.
llvm-svn: 45658 
							
						 
						
							2008-01-06 18:27:01 +00:00  
				
					
						
							
							
								 
						
							
								55e5090fe8 
								
							 
						 
						
							
							
								
								When transforming a call to a bitcast function into  
							
							... 
							
							
							
							a direct call with cast parameters and cast return
value (if any), instcombine was prepared to cast any
non-void return value into any other, whether castable
or not.  Add a new predicate for testing whether casting
is valid, and check it both for the return value and
(as a cleanup) for the parameters.
llvm-svn: 45657 
							
						 
						
							2008-01-06 10:12:28 +00:00  
				
					
						
							
							
								 
						
							
								e666bc272d 
								
							 
						 
						
							
							
								
								remove a couple more unsafe xforms in the face of overflow.  
							
							... 
							
							
							
							llvm-svn: 45613 
							
						 
						
							2008-01-05 01:22:42 +00:00  
				
					
						
							
							
								 
						
							
								db026d703b 
								
							 
						 
						
							
							
								
								remove the (x-y) < 0 comparison xform, it miscompiles  
							
							... 
							
							
							
							things that are not equality comparisons, for example:
   (2147479553+4096)-2147479553 < 0    !=   (2147479553+4096) < 2147479553
llvm-svn: 45612 
							
						 
						
							2008-01-05 01:18:20 +00:00  
				
					
						
							
							
								 
						
							
								30e434569e 
								
							 
						 
						
							
							
								
								fix typo  
							
							... 
							
							
							
							llvm-svn: 45594 
							
						 
						
							2008-01-04 20:02:18 +00:00  
				
					
						
							
							
								 
						
							
								bdd6acfb59 
								
							 
						 
						
							
							
								
								Fix PR1896  
							
							... 
							
							
							
							llvm-svn: 45568 
							
						 
						
							2008-01-04 05:04:53 +00:00  
				
					
						
							
							
								 
						
							
								f391883670 
								
							 
						 
						
							
							
								
								don't hoist FP additions into unconditional adds + selects.  This  
							
							... 
							
							
							
							could theoretically introduce a trap, but is also a performance issue.
This speeds up ptrdist/ks by 8%.
llvm-svn: 45533 
							
						 
						
							2008-01-03 07:25:26 +00:00  
				
					
						
							
							
								 
						
							
								d2b0e15535 
								
							 
						 
						
							
							
								
								add missing #include  
							
							... 
							
							
							
							llvm-svn: 45516 
							
						 
						
							2008-01-02 23:41:05 +00:00  
				
					
						
							
							
								 
						
							
								f3ebc3f3d2 
								
							 
						 
						
							
							
								
								Remove attribution from file headers, per discussion on llvmdev.  
							
							... 
							
							
							
							llvm-svn: 45418 
							
						 
						
							2007-12-29 20:36:04 +00:00  
				
					
						
							
							
								 
						
							
								a087a8d2ce 
								
							 
						 
						
							
							
								
								remove attribution from lib Makefiles.  
							
							... 
							
							
							
							llvm-svn: 45415 
							
						 
						
							2007-12-29 20:09:26 +00:00  
				
					
						
							
							
								 
						
							
								b053b80b79 
								
							 
						 
						
							
							
								
								Disable null pointer folding transforms for non-generic address spaces. This should probably be a target-specific predicate based on address space. That way for targets where this isn't applicable the predicate can be optimized away.  
							
							... 
							
							
							
							llvm-svn: 45403 
							
						 
						
							2007-12-29 07:56:53 +00:00  
				
					
						
							
							
								 
						
							
								e96658392d 
								
							 
						 
						
							
							
								
								dead calls to llvm.stacksave can be deleted, even though they  
							
							... 
							
							
							
							have potential side-effects.
llvm-svn: 45392 
							
						 
						
							2007-12-29 00:59:12 +00:00  
				
					
						
							
							
								 
						
							
								7363914ef7 
								
							 
						 
						
							
							
								
								Repair a transform that Chris noticed a bug in.  Thanks to Nicholas for pointing out my stupid mistakes when writing this patch. :-)  
							
							... 
							
							
							
							llvm-svn: 45384 
							
						 
						
							2007-12-28 07:42:12 +00:00  
				
					
						
							
							
								 
						
							
								5179819beb 
								
							 
						 
						
							
							
								
								disable this instcombine xform, it miscompiles:  
							
							... 
							
							
							
							define i32 @main() {
entry:
	%z = alloca i32		; <i32*> [#uses=2]
	store i32 0, i32* %z
	%tmp = load i32* %z		; <i32> [#uses=1]
	%sub = sub i32 %tmp, 1		; <i32> [#uses=1]
	%cmp = icmp ult i32 %sub, 0		; <i1> [#uses=1]
	%retval = select i1 %cmp, i32 1, i32 0		; <i32> [#uses=1]
	ret i32 %retval
}
into ret 1, instead of ret 0.
Christopher, please investigate.
llvm-svn: 45383 
							
						 
						
							2007-12-28 06:24:31 +00:00  
				
					
						
							
							
								 
						
							
								520e64c0c2 
								
							 
						 
						
							
							
								
								Fixing several transforms which would drop the collector attribute  
							
							... 
							
							
							
							when copying functions.
llvm-svn: 45356 
							
						 
						
							2007-12-25 22:16:06 +00:00  
				
					
						
							
							
								 
						
							
								ef1bbfc762 
								
							 
						 
						
							
							
								
								Don't break critical edges for single-bb loops, this helps with PR1877, though  
							
							... 
							
							
							
							it is only a partial fix.  This change is noise for most programs, but
speeds up Shootout-C++/matrix by 20%, Ptrdist/ks by 24%, smg2000 by 8%,
hexxagon by 9%, bzip2 by 9% (not sure I trust this), ackerman by 13%, etc.
OTOH, it slows down Shootout/fib2 by 40% (I'll update PR1877 with this info).
llvm-svn: 45354 
							
						 
						
							2007-12-25 19:06:45 +00:00  
				
					
						
							
							
								 
						
							
								b969c5981b 
								
							 
						 
						
							
							
								
								GC poses hazards to the inliner. Consider:  
							
							... 
							
							
							
							define void @f() {
            ...
            call i32 @g()
            ...
    }
    define void @g() {
            ...
    }
The hazards are:
  - @f  and @g have GC, but they differ GC. Inlining is invalid. This
    may never occur.
  - @f has no GC, but @g does. g's GC must be propagated to @f.
The other scenarios are safe:
  - @f and @g have the same GC.
  - @f and @g have no GC.
  - @g has no GC.
This patch adds inliner checks for the former two scenarios.
llvm-svn: 45351 
							
						 
						
							2007-12-25 03:10:07 +00:00  
				
					
						
							
							
								 
						
							
								62a806d565 
								
							 
						 
						
							
							
								
								add a -backedge-hack llc-beta option to codegenprepare.  
							
							... 
							
							
							
							When specified, don't split backedges of single-bb loops.
This helps address PR1877
llvm-svn: 45344 
							
						 
						
							2007-12-24 19:32:55 +00:00  
				
					
						
							
							
								 
						
							
								74b2ab59fd 
								
							 
						 
						
							
							
								
								implement InstCombine/shift-trunc-shift.ll.  This allows  
							
							... 
							
							
							
							us to compile:
#include <math.h>
int t1(double d) { return signbit(d); }
into:
_t1:
	movd	%xmm0, %rax
	shrq	$63, %rax
	ret
instead of:
_t1:
	movd	%xmm0, %rax
	shrq	$32, %rax
	shrl	$31, %eax
	ret
on x86-64.
llvm-svn: 45311 
							
						 
						
							2007-12-22 09:07:47 +00:00  
				
					
						
							
							
								 
						
							
								7a2c66b11e 
								
							 
						 
						
							
							
								
								If succ has succ itself as one of the predecessors then do  
							
							... 
							
							
							
							not merge current bb and succ even if bb's terminator is
unconditional branch to succ.
llvm-svn: 45305 
							
						 
						
							2007-12-22 01:32:53 +00:00  
				
					
						
							
							
								 
						
							
								6a7703ed63 
								
							 
						 
						
							
							
								
								Make DAE not wipe out attributes on calls, and not drop  
							
							... 
							
							
							
							return attributes on the floor.  In the case of a call
to a varargs function where the varargs arguments are
being removed, any call attributes on those arguments
need to be dropped.  I didn't do this because I plan to
make it illegal to have such attributes (see next patch).
With this change, compiling the gcc filter2 eh test at -O0
and then running opt -std-compile-opts on it results in
a correctly working program (compiling at -O1 or higher
results in the test failing due to a problem with how we
output eh info into the IR).
llvm-svn: 45285 
							
						 
						
							2007-12-21 19:16:16 +00:00  
				
					
						
							
							
								 
						
							
								7d82bc46b8 
								
							 
						 
						
							
							
								
								Implement review feedback, including additional transforms  
							
							... 
							
							
							
							(icmp slt (sub A B) 1) -> (icmp sle A B)
icmp sgt (sub A B) -1) -> (icmp sge A B)
and add testcase.
llvm-svn: 45256 
							
						 
						
							2007-12-20 07:21:11 +00:00  
				
					
						
							
							
								 
						
							
								26ee54eb05 
								
							 
						 
						
							
							
								
								Clean up previous patch: PHI uses should not prevent iv reuse if all other uses are addresses. This trades a constant multiply for one fewer iv.  
							
							... 
							
							
							
							llvm-svn: 45251 
							
						 
						
							2007-12-20 02:20:53 +00:00  
				
					
						
							
							
								 
						
							
								16a51da0e2 
								
							 
						 
						
							
							
								
								simplify this code with the new m_Zero() pattern.  Make sure the select only  
							
							... 
							
							
							
							has a single use, and generalize it to not require N to be a constant.
llvm-svn: 45250 
							
						 
						
							2007-12-20 01:56:58 +00:00  
				
					
						
							
							
								 
						
							
								e2a8ba7fec 
								
							 
						 
						
							
							
								
								Allow iv reuse if the user is a PHI node which is in turn used as addresses.  
							
							... 
							
							
							
							llvm-svn: 45230 
							
						 
						
							2007-12-19 23:33:23 +00:00  
				
					
						
							
							
								 
						
							
								aa31b92508 
								
							 
						 
						
							
							
								
								When inlining through an 'nounwind' call, mark inlined  
							
							... 
							
							
							
							calls 'nounwind'.  It is important for correct C++
exception handling that nounwind markings do not get
lost, so this transformation is actually needed for
correctness.
llvm-svn: 45218 
							
						 
						
							2007-12-19 21:13:37 +00:00  
				
					
						
							
							
								 
						
							
								f00ac6dd93 
								
							 
						 
						
							
							
								
								Fold subtracts into integer compares vs. zero. This improves generate code for this case on X86  
							
							... 
							
							
							
							from
_foo:
        movl    $99, %ecx
        movl    4(%esp), %eax
        subl    %eax, %ecx
        xorl    %edx, %edx
        testl   %ecx, %ecx
        cmovs   %edx, %eax
        ret
to
_foo:
        xorl    %ecx, %ecx
        movl    4(%esp), %eax
        cmpl    $99, %eax
        cmovg   %ecx, %eax
        ret
llvm-svn: 45173 
							
						 
						
							2007-12-18 21:32:20 +00:00  
				
					
						
							
							
								 
						
							
								b7016c53d1 
								
							 
						 
						
							
							
								
								Fix comments  
							
							... 
							
							
							
							llvm-svn: 45170 
							
						 
						
							2007-12-18 20:33:11 +00:00  
				
					
						
							
							
								 
						
							
								74dbad9216 
								
							 
						 
						
							
							
								
								Remove an orthogonal transformation of the selection condition from my most recent submission.  
							
							... 
							
							
							
							llvm-svn: 45169 
							
						 
						
							2007-12-18 20:30:28 +00:00  
				
					
						
							
							
								 
						
							
								3353ed09ac 
								
							 
						 
						
							
							
								
								Rename isNoReturn to doesNotReturn, and isNoUnwind to  
							
							... 
							
							
							
							doesNotThrow.
llvm-svn: 45160 
							
						 
						
							2007-12-18 09:59:50 +00:00  
				
					
						
							
							
								 
						
							
								30291f4a30 
								
							 
						 
						
							
							
								
								Fix typos.  
							
							... 
							
							
							
							llvm-svn: 45159 
							
						 
						
							2007-12-18 09:45:40 +00:00  
				
					
						
							
							
								 
						
							
								8b09a464b4 
								
							 
						 
						
							
							
								
								Fold certain additions through selects (and their compares) so as to eliminate subtractions. This code is often produced by the SMAX expansion in SCEV.  
							
							... 
							
							
							
							This implements test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll
llvm-svn: 45158 
							
						 
						
							2007-12-18 09:34:41 +00:00  
				
					
						
							
							
								 
						
							
								b5a79d0eaa 
								
							 
						 
						
							
							
								
								Make invokes of inline asm legal.  Teach codegen  
							
							... 
							
							
							
							how to lower them (with no attempt made to be
efficient, since they should only occur for
unoptimized code).
llvm-svn: 45108 
							
						 
						
							2007-12-17 18:08:19 +00:00  
				
					
						
							
							
								 
						
							
								71eae8a5ee 
								
							 
						 
						
							
							
								
								GLIBCXX_DEBUG fix.  std::vector<>::end() is invalidated by erase.  
							
							... 
							
							
							
							llvm-svn: 45101 
							
						 
						
							2007-12-17 17:42:03 +00:00  
				
					
						
							
							
								 
						
							
								c4a80fb574 
								
							 
						 
						
							
							
								
								Get rid of annoying spaces.  
							
							... 
							
							
							
							llvm-svn: 45100 
							
						 
						
							2007-12-17 17:40:29 +00:00