Commit Graph

2645 Commits

Author SHA1 Message Date
Chris Lattner
7b876e4644 make the build build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85319 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 21:43:39 +00:00
Chris Lattner
2688bcbee1 Random updates to passes for indbr, I need blockaddress before I can do much more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 21:27:42 +00:00
Victor Hernandez
f006b183e2 Rename MallocFreeHelper as MemoryBuiltins
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85286 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 20:05:49 +00:00
Victor Hernandez
f2becca90b Rename MallocHelper as MallocFreeHelper, since it now also identifies calls to free()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 23:58:56 +00:00
Victor Hernandez
046e78ce55 Remove FreeInst.
Remove LowerAllocations pass.
Update some more passes to treate free calls just like they were treating FreeInst.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 23:43:48 +00:00
Dan Gohman
6665b0ea68 Teach BasicAA how to analyze Select instructions, and make it more
aggressive on PHI instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85158 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 21:55:43 +00:00
Devang Patel
ac16d44e58 Add support to encode type info using llvm::Constant.
Patch by Talin!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85126 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 16:54:35 +00:00
Nick Lewycky
f5a86f45e7 Remove includes of Support/Compiler.h that are no longer needed after the
VISIBILITY_HIDDEN removal.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85043 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 06:57:41 +00:00
Nick Lewycky
6726b6d75a Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.
Chris claims we should never have visibility_hidden inside any .cpp file but
that's still not true even after this commit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85042 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 06:33:48 +00:00
Chris Lattner
93798daa3e Teach FoldBitCast to be able to handle bitcasts from (e.g.) i128 -> <4 x float>.
This allows us to simplify this:
union vec2d {
    double e[2];
    double v __attribute__((vector_size(16)));
};
typedef union vec2d vec2d;

static vec2d a={{1,2}}, b={{3,4}};
    
vec2d foo () {
    return (vec2d){ .v = a.v + b.v * (vec2d){{5,5}}.v };
}

down to:

define %0 @foo() nounwind ssp {
entry:
  %mrv5 = insertvalue %0 undef, double 1.600000e+01, 0 ; <%0> [#uses=1]
  %mrv6 = insertvalue %0 %mrv5, double 2.200000e+01, 1 ; <%0> [#uses=1]
  ret %0 %mrv6
}

instead of:

define %0 @foo() nounwind ssp {
entry:
  %mrv5 = insertvalue %0 undef, double extractelement (<2 x double> fadd (<2 x double> fmul (<2 x double> bitcast (<1 x i128> <i128 85174437667405312423031577302488055808> to <2 x double>), <2 x double> <double 3.000000e+00, double 4.000000e+00>), <2 x double> <double 1.000000e+00, double 2.000000e+00>), i32 0), 0 ; <%0> [#uses=1]
  %mrv6 = insertvalue %0 %mrv5, double extractelement (<2 x double> fadd (<2 x double> fmul (<2 x double> bitcast (<1 x i128> <i128 85174437667405312423031577302488055808> to <2 x double>), <2 x double> <double 3.000000e+00, double 4.000000e+00>), <2 x double> <double 1.000000e+00, double 2.000000e+00>), i32 1), 1 ; <%0> [#uses=1]
  ret %0 %mrv6
}



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85040 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 06:15:37 +00:00
Chris Lattner
6333c3959b move FoldBitCast earlier in the file, and use it instead of
ConstantExpr::getBitCast in various places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85039 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 06:08:26 +00:00
Chris Lattner
ea9d57bc9a refactor FoldBitCast to reduce nesting and to always return a constantexpr
instead of returning null on failure.  No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85038 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 06:02:57 +00:00
Chris Lattner
c7b1382e35 various cleanups suggested by Duncan
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84993 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 05:27:19 +00:00
Chris Lattner
c5af649758 fix PR5287, a serious regression from my previous patches. Thanks to
Duncan for the nice tiny testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84992 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 05:22:15 +00:00
Victor Hernandez
66284e063a Auto-upgrade free instructions to calls to the builtin free function.
Update all analysis passes and transforms to treat free calls just like FreeInst.
Remove RaiseAllocations and all its tests since FreeInst no longer needs to be raised.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 04:23:03 +00:00
Victor Hernandez
7b929dad59 Remove AllocationInst. Since MallocInst went away, AllocaInst is the only subclass of AllocationInst, so it no longer is necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 21:09:37 +00:00
Chris Lattner
17f0cd3cc1 teach libanalysis to simplify vector loads with bitcast sources. This
implements something out of Target/README.txt producing:

_foo:                                                       ## @foo
	movl	4(%esp), %eax
	movapd	LCPI1_0, %xmm0
	movapd	%xmm0, (%eax)
	ret	$4

instead of:

_foo:                                                       ## @foo
	movl	4(%esp), %eax
	movapd	_b, %xmm0
	mulpd	LCPI1_0, %xmm0
	addpd	_a, %xmm0
	movapd	%xmm0, (%eax)
	ret	$4



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84942 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 06:57:37 +00:00
Chris Lattner
739208a790 enhance FoldReinterpretLoadFromConstPtr to handle loads of up to 32
bytes (i256).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84941 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 06:50:36 +00:00
Chris Lattner
fe8c7c807c teach libanalysis to fold int and fp loads from almost arbitrary
non-type-safe constant initializers.  This sort of thing happens
quite a bit for 4-byte loads out of string constants, unions, 
bitfields, and an interesting endianness check from sqlite, which
is something like this:

const int sqlite3one = 1;
# define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)
# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)

all of these macros now constant fold away.

This implements PR3152 and is based on a patch started by Eli, but heavily
modified and extended.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 06:23:49 +00:00
Chris Lattner
e00c43fc35 move another load optimization from instcombine -> libanalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84841 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 06:44:07 +00:00
Chris Lattner
62d327e241 move 'loading i32 from string' optimization from instcombine
to libanalysis.  Instcombine shrinking... does this even 
make sense???


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84840 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 06:38:35 +00:00
Chris Lattner
878e494670 Move some constant folding logic for loads out of instcombine into
Analysis/ConstantFolding.cpp.  This doesn't change the behavior of
instcombine but makes other clients of ConstantFoldInstruction
able to handle loads.  This was partially extracted from Eli's patch
in PR3152.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84836 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 06:25:11 +00:00
Dan Gohman
eed9e5b833 Fix another place that calls Loop::contains a lot to construct a sorted
container of the blocks and do efficient lookups. This makes
isLoopSimplifyForm much faster on large loops, fixing a significant
compile-time issue in builds with assertions enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84673 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 20:41:13 +00:00
Chris Lattner
0ec5c32489 fix the other issue with ID's, hopefully really fixing the linux build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84403 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 04:58:34 +00:00
Chris Lattner
28717a8a60 fix some problems with ID definitions, which will hopefully fix the build bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84399 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 04:27:14 +00:00
Chris Lattner
b839c5577d add function passes for printing various dominator datastructures
accessible through opt.  Patch by Tobias Grosser!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84397 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 04:10:40 +00:00
Chris Lattner
88067b9133 make DOTGraphTraits public, patch by Tobias Grosser!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 04:09:11 +00:00
Chris Lattner
391d23b6c2 inline isGEP away.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84373 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 23:48:54 +00:00
Victor Hernandez
a276c603b8 Remove MallocInst from LLVM Instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84299 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 01:18:07 +00:00
Victor Hernandez
136526ce2d Invert isSafeToGetMallocArraySize check because we return NULL when we don't know the size.
Thanks to Duncan Sands for noticing this bug.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84261 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-16 18:08:17 +00:00
Evan Cheng
a846a8a1dc When checking aliases between phi sources and V2, we know the sources are not themselves phi nodes. However, V2 may be. Call aliasCheck with V2 first to potentially eliminate a std::swap call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84226 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-16 00:33:09 +00:00
Victor Hernandez
2491ce0353 Fix bug where array malloc with unexpected computation of the size argument resulted in MallocHelper
identifying the malloc as a non-array malloc.  This broke GlobalOpt's optimization of stores of mallocs 
to global variables.

The fix is to classify malloc's into 3 categories:
1. non-array mallocs
2. array mallocs whose array size can be determined
3. mallocs that cannot be determined to be of type 1 or 2 and cannot be optimized

getMallocArraySize() returns NULL for category 3, and all users of this function must avoid their 
malloc optimization if this function returns NULL.

Eventually, currently unexpected codegen for computing the malloc's size argument will be supported in
isArrayMalloc() and getMallocArraySize(), extending malloc optimizations to those examples.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 20:14:52 +00:00
Nick Lewycky
20312d0bb8 Add missing break statements! Thanks to Duncan Sands for pointing this out!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84191 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 18:48:58 +00:00
Nick Lewycky
6e9e010752 Teach basicaa about memcpy/memmove/memset. The length argument can be used to
improve alias results if constant, and the source pointer can't be modified.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84175 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 07:11:24 +00:00
Nick Lewycky
2d3820c29c Teach BasicAA to use the size parameter of the memory use marker intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84174 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 06:12:11 +00:00
Nick Lewycky
22c031296c Take advantage of TargetData when available; we know that the atomic intrinsics
only dereference the element they point to directly with no pointer arithmetic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84159 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 00:36:35 +00:00
Evan Cheng
f0429fd1ca Clear VisitedPHIs after use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84080 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 06:46:26 +00:00
Evan Cheng
681a33e26d Another BasicAA fix. If a value does not alias a GEP's base pointer, then it
cannot alias the GEP. GEP pointer alias rule states this clearly:
A pointer value formed from a getelementptr instruction is associated with the
addresses associated with the first operand of the getelementptr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84079 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 06:41:49 +00:00
Evan Cheng
d83c2ca336 More code clean up based on patch feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84074 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 05:22:03 +00:00
Evan Cheng
3dbe43b1b5 Change VisitedPHIs into an instance variable that's freed by each alias() call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 05:05:02 +00:00
Evan Cheng
50a5914e12 Teach basic AA about PHI nodes. If all operands of a phi NoAlias another value than it's safe to declare the PHI NoAlias the value. Ditto for MustAlias.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84038 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 22:02:20 +00:00
Dan Gohman
497f61940a Compute a full cost value even when a setjmp call is found.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84015 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 20:10:10 +00:00
Dan Gohman
e7f0ed5ace Split code not specific to Function inlining out into a separate class,
named CodeMetrics. Move it to be a non-nested class. Rename RegionInfo
back to FunctionInfo.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84013 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 19:58:07 +00:00
Benjamin Kramer
56bfa4d5d0 Update the other CMake file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84003 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 18:50:54 +00:00
Evan Cheng
094f04b429 Refactor some code. No functionality changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 18:42:04 +00:00
Dan Gohman
e4aeec003f Move the InlineCost code from Transforms/Utils to Analysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83998 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 18:30:07 +00:00
Devang Patel
549e81f7de "there is not any instruction with attached debug info in this module" does not mean "there is no debug info in this module". :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 17:35:35 +00:00
Nick Lewycky
5c9be67cff Teach BasicAA a little something about the atomic intrinsics: they can only
modify through the pointer they're given.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83959 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 07:48:38 +00:00
Victor Hernandez
5c78736f85 Memory dependence analysis was incorrectly stopping to scan for stores to a pointer at bitcast uses of a malloc call.
It should continue scanning until the malloc call, and this patch fixes that.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83931 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 01:42:53 +00:00
Dan Gohman
7a721956f8 Revert r83606 and add comments explaining why it isn't safe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83649 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-09 16:35:06 +00:00