1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 11:33:24 +02:00
Commit Graph

2612 Commits

Author SHA1 Message Date
Zhongxing Xu
45d8013f73 Explicitly convert to double to suppress Visual C++ 2008 build error C2668 pow is ambiguous call to overloaded function
llvm-svn: 85478
2009-10-29 03:43:06 +00:00
Victor Hernandez
917cf94b22 Extend getMallocArraySize() to determine the array size if the malloc argument is:
ArraySize * ElementSize
ElementSize * ArraySize
ArraySize << log2(ElementSize)
ElementSize << log2(ArraySize)

Refactor isArrayMallocHelper and delete isSafeToGetMallocArraySize, so that there is only 1 copy of the malloc array determining logic.
Update users of getMallocArraySize() to not bother calling isArrayMalloc() as well.

llvm-svn: 85421
2009-10-28 20:18:55 +00:00
Owen Anderson
cfb2c9edeb Treat lifetime begin/end markers as allocations/frees respectively for the
purposes for GVN/DSE.

llvm-svn: 85383
2009-10-28 07:05:35 +00:00
Owen Anderson
a2584a4c64 Be more careful about invariance reasoning on "store" queries. Stores still need
to depend on Ref and ModRef calls within the invariant region.

llvm-svn: 85380
2009-10-28 06:30:52 +00:00
Owen Anderson
6cf32f04df Add trivial support for the invariance intrinsics to memdep. This logic is
purely local for now.

llvm-svn: 85378
2009-10-28 06:18:42 +00:00
Chris Lattner
2bc8002f4c rename indbr -> indirectbr to appease the residents of #llvm.
llvm-svn: 85351
2009-10-28 00:19:10 +00:00
Chris Lattner
5bd76ffebb make the build build.
llvm-svn: 85319
2009-10-27 21:43:39 +00:00
Chris Lattner
665b9e2a3c Random updates to passes for indbr, I need blockaddress before I can do much more.
llvm-svn: 85316
2009-10-27 21:27:42 +00:00
Victor Hernandez
0f662a7acf Rename MallocFreeHelper as MemoryBuiltins
llvm-svn: 85286
2009-10-27 20:05:49 +00:00
Victor Hernandez
6c86b93663 Rename MallocHelper as MallocFreeHelper, since it now also identifies calls to free()
llvm-svn: 85181
2009-10-26 23:58:56 +00:00
Victor Hernandez
673c036bc7 Remove FreeInst.
Remove LowerAllocations pass.
Update some more passes to treate free calls just like they were treating FreeInst.

llvm-svn: 85176
2009-10-26 23:43:48 +00:00
Dan Gohman
c8468855a7 Teach BasicAA how to analyze Select instructions, and make it more
aggressive on PHI instructions.

llvm-svn: 85158
2009-10-26 21:55:43 +00:00
Devang Patel
9eb437047b Add support to encode type info using llvm::Constant.
Patch by Talin!

llvm-svn: 85126
2009-10-26 16:54:35 +00:00
Nick Lewycky
2b8400628d Remove includes of Support/Compiler.h that are no longer needed after the
VISIBILITY_HIDDEN removal.

llvm-svn: 85043
2009-10-25 06:57:41 +00:00
Nick Lewycky
711c726c97 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.

llvm-svn: 85042
2009-10-25 06:33:48 +00:00
Chris Lattner
d8db8b6952 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
}

llvm-svn: 85040
2009-10-25 06:15:37 +00:00
Chris Lattner
d80c1f61d2 move FoldBitCast earlier in the file, and use it instead of
ConstantExpr::getBitCast in various places.

llvm-svn: 85039
2009-10-25 06:08:26 +00:00
Chris Lattner
f6cb8d6b90 refactor FoldBitCast to reduce nesting and to always return a constantexpr
instead of returning null on failure.  No functionality change.

llvm-svn: 85038
2009-10-25 06:02:57 +00:00
Chris Lattner
5f456758c6 various cleanups suggested by Duncan
llvm-svn: 84993
2009-10-24 05:27:19 +00:00
Chris Lattner
9a1f5c9f90 fix PR5287, a serious regression from my previous patches. Thanks to
Duncan for the nice tiny testcase.

llvm-svn: 84992
2009-10-24 05:22:15 +00:00
Victor Hernandez
e8998896f5 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.

llvm-svn: 84987
2009-10-24 04:23:03 +00:00
Victor Hernandez
8428eb5720 Remove AllocationInst. Since MallocInst went away, AllocaInst is the only subclass of AllocationInst, so it no longer is necessary.
llvm-svn: 84969
2009-10-23 21:09:37 +00:00
Chris Lattner
4874f5bce5 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

llvm-svn: 84942
2009-10-23 06:57:37 +00:00
Chris Lattner
2ee1f0f0b5 enhance FoldReinterpretLoadFromConstPtr to handle loads of up to 32
bytes (i256).

llvm-svn: 84941
2009-10-23 06:50:36 +00:00
Chris Lattner
b1d2706a4c 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.

llvm-svn: 84936
2009-10-23 06:23:49 +00:00
Chris Lattner
cd80b1711b move another load optimization from instcombine -> libanalysis.
llvm-svn: 84841
2009-10-22 06:44:07 +00:00
Chris Lattner
3fb4c19b7d move 'loading i32 from string' optimization from instcombine
to libanalysis.  Instcombine shrinking... does this even 
make sense???

llvm-svn: 84840
2009-10-22 06:38:35 +00:00
Chris Lattner
2c8c8533b1 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.

llvm-svn: 84836
2009-10-22 06:25:11 +00:00
Dan Gohman
bc58eb97fe 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.

llvm-svn: 84673
2009-10-20 20:41:13 +00:00
Chris Lattner
5b8e288c5f fix the other issue with ID's, hopefully really fixing the linux build.
llvm-svn: 84403
2009-10-18 04:58:34 +00:00
Chris Lattner
a1aaf47423 fix some problems with ID definitions, which will hopefully fix the build bots.
llvm-svn: 84399
2009-10-18 04:27:14 +00:00
Chris Lattner
8851d6cf9c add function passes for printing various dominator datastructures
accessible through opt.  Patch by Tobias Grosser!

llvm-svn: 84397
2009-10-18 04:10:40 +00:00
Chris Lattner
f202995415 make DOTGraphTraits public, patch by Tobias Grosser!
llvm-svn: 84396
2009-10-18 04:09:11 +00:00
Chris Lattner
a72ccc6fee inline isGEP away.
llvm-svn: 84373
2009-10-17 23:48:54 +00:00
Victor Hernandez
a25a2890fa Remove MallocInst from LLVM Instructions.
llvm-svn: 84299
2009-10-17 01:18:07 +00:00
Victor Hernandez
6d11519b1f Invert isSafeToGetMallocArraySize check because we return NULL when we don't know the size.
Thanks to Duncan Sands for noticing this bug.

llvm-svn: 84261
2009-10-16 18:08:17 +00:00
Evan Cheng
54b34ff68d 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.
llvm-svn: 84226
2009-10-16 00:33:09 +00:00
Victor Hernandez
603a11de4e 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.

llvm-svn: 84199
2009-10-15 20:14:52 +00:00
Nick Lewycky
7ec7f1ce0f Add missing break statements! Thanks to Duncan Sands for pointing this out!
llvm-svn: 84191
2009-10-15 18:48:58 +00:00
Nick Lewycky
4ba7b77812 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.

llvm-svn: 84175
2009-10-15 07:11:24 +00:00
Nick Lewycky
14a06f7051 Teach BasicAA to use the size parameter of the memory use marker intrinsics.
llvm-svn: 84174
2009-10-15 06:12:11 +00:00
Nick Lewycky
a12f6e8f78 Take advantage of TargetData when available; we know that the atomic intrinsics
only dereference the element they point to directly with no pointer arithmetic.

llvm-svn: 84159
2009-10-15 00:36:35 +00:00
Evan Cheng
37a7a18748 Clear VisitedPHIs after use.
llvm-svn: 84080
2009-10-14 06:46:26 +00:00
Evan Cheng
907fd9c3fb 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.

llvm-svn: 84079
2009-10-14 06:41:49 +00:00
Evan Cheng
c1056d9269 More code clean up based on patch feedback.
llvm-svn: 84074
2009-10-14 05:22:03 +00:00
Evan Cheng
efc0f806a4 Change VisitedPHIs into an instance variable that's freed by each alias() call.
llvm-svn: 84072
2009-10-14 05:05:02 +00:00
Evan Cheng
3130aba687 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.
llvm-svn: 84038
2009-10-13 22:02:20 +00:00
Dan Gohman
c1e210fa10 Compute a full cost value even when a setjmp call is found.
llvm-svn: 84015
2009-10-13 20:10:10 +00:00
Dan Gohman
665e336185 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.

llvm-svn: 84013
2009-10-13 19:58:07 +00:00
Benjamin Kramer
679377c816 Update the other CMake file.
llvm-svn: 84003
2009-10-13 18:50:54 +00:00