Jay Foad
557169d923
Implement and use new method Function::hasAddressTaken().
...
llvm-svn: 73164
2009-06-10 08:41:11 +00:00
Jay Foad
edea37d801
Remove an unused function SafeToDestroyConstant(). Rename an almost
...
identical function ConstantIsDead() to SafeToDestroyConstant(), to
emphasise the connection with Constant::destroyConstant().
llvm-svn: 73149
2009-06-09 21:37:11 +00:00
Jay Foad
e57ba2eab5
Use cast<> instead of dyn_cast<> for things that are known to be
...
Instructions.
llvm-svn: 73002
2009-06-06 17:49:35 +00:00
Evan Cheng
836894405f
Avoid infinite looping in AllGlobalLoadUsesSimpleEnoughForHeapSRA(). This can happen when PHI uses are recursively dependent on each other.
...
llvm-svn: 72710
2009-06-02 00:56:07 +00:00
Duncan Sands
af9eaa830a
Rename PaddedSize to AllocSize, in the hope that this
...
will make it more obvious what it represents, and stop
it being confused with the StoreSize.
llvm-svn: 71349
2009-05-09 07:06:46 +00:00
Nick Lewycky
431f97e4f0
Revert r70630. Go back to appending ".b" to internal globals when shrinking
...
them to bool.
llvm-svn: 70653
2009-05-03 03:49:08 +00:00
Nick Lewycky
462cd34332
Don't append ".b" to the names of globals that are being shrunk to booleans.
...
llvm-svn: 70630
2009-05-02 16:21:50 +00:00
Devang Patel
04852aa933
Ignore debug info while evaluating function.
...
llvm-svn: 66490
2009-03-09 23:04:12 +00:00
Chris Lattner
fee0a55c84
use MemTransferInst.
...
llvm-svn: 66362
2009-03-08 03:37:35 +00:00
Chris Lattner
e313283199
fix a serious pessimization that Tron on IRC pointed out where we would
...
"boolify" pointers, generating really awful code because getting the pointer
value requires a load itself. Before:
_foo:
movb $1, _X.b
ret
_get:
xorl %ecx, %ecx
movb _X.b, %al
testb %al, %al
movl $_Y, %eax
cmove %ecx, %eax
ret
With the xform disabled:
_foo:
movl $_Y, _X
ret
_get:
movl _X, %eax
ret
llvm-svn: 66351
2009-03-07 23:32:02 +00:00
Duncan Sands
ed7228319a
While thinking about the one-definition-rule and trying
...
to find a tiny mouse hole to squeeze through, it struck
me that globals without a name can be considered internal
since they can't be referenced from outside the current
module. This patch makes GlobalOpt give them internal
linkage. Also done for aliases even though they always
have names, since in my opinion anonymous aliases should
be allowed for consistency with global variables and
functions. So if that happens one day, this code is ready!
llvm-svn: 66267
2009-03-06 10:21:56 +00:00
Devang Patel
fc507a1f9c
Revert 66224.
...
llvm-svn: 66233
2009-03-06 01:39:36 +00:00
Devang Patel
d926aaa28f
Revert rev. 66167.
...
We are still not out of woods yet.
llvm-svn: 66232
2009-03-06 01:37:41 +00:00
Devang Patel
ab16577ade
Do not let debug info prevert globalopt from shriking a global vars to boolean.
...
llvm-svn: 66224
2009-03-06 00:21:00 +00:00
Devang Patel
709d6ac46d
GlobalOpt only process non constant local GVs while optimizing global vars.
...
If non constant local GV named A is used by a constant local GV named B (e.g. llvm.dbg.variable) and B is not used by anyone else then eliminate A as well as B.
In other words, debug info should not interfere in removal of unused GV.
--This life, and those below, will be ignored--
M test/Transforms/GlobalOpt/2009-03-03-dbg.ll
M lib/Transforms/IPO/GlobalOpt.cpp
llvm-svn: 66167
2009-03-05 18:12:02 +00:00
Bill Wendling
803da0db79
Temporarily revert r65994. It was causing rdar://6646455.
...
llvm-svn: 66083
2009-03-04 22:02:09 +00:00
Devang Patel
812459613b
If a global constant is dead then global's debug info should not prevent the optimizer in deleting the global. And while deleting global, delete global's debug info also.
...
llvm-svn: 65994
2009-03-04 01:22:23 +00:00
Duncan Sands
7a1db33e77
In theory the aliasee may have dead constant users
...
here. Since we only do the transform if there is
one use, strip off any such users in the hope of
making the transform fire more often.
llvm-svn: 64926
2009-02-18 17:55:38 +00:00
Duncan Sands
f974c5703c
This transform also applies to private linkage.
...
llvm-svn: 64773
2009-02-17 17:50:04 +00:00
Duncan Sands
46196aef82
Make this more useful for cleaning up after the
...
one-definition-rule llvm-gcc changes (coming soon
to a tree near you!).
llvm-svn: 64588
2009-02-15 11:54:49 +00:00
Duncan Sands
b3f27881a9
If the target of an alias has internal linkage, then the
...
alias can be morphed into the target. Implement this
transform, and fix a crash in the existing transform at
the same time.
llvm-svn: 64583
2009-02-15 09:56:08 +00:00
Gabor Greif
eb61fcf2a1
Simplify the logic of getting hold of a PHI predecessor block.
...
There is now a direct way from value-use-iterator to incoming block in PHINode's API.
This way we avoid the iterator->index->iterator trip, and especially the costly
getOperandNo() invocation. Additionally there is now an assertion that the iterator
really refers to one of the PHI's Uses.
llvm-svn: 62869
2009-01-23 19:40:15 +00:00
Rafael Espindola
6de96a1b5d
Add the private linkage.
...
llvm-svn: 62279
2009-01-15 20:18:42 +00:00
Chris Lattner
2538eb664c
rewrite OptimizeAwayTrappingUsesOfLoads to 1) avoid a temporary
...
vector and extraneous loop over it, 2) not delete globals used by
phis/selects etc which could actually be useful. This fixes PR3321.
Many thanks to Duncan for narrowing this down.
llvm-svn: 62201
2009-01-14 00:12:58 +00:00
Duncan Sands
944ccc5d6a
Correct a comment.
...
llvm-svn: 62165
2009-01-13 13:48:44 +00:00
Duncan Sands
dc020f9c3c
Rename getABITypeSize to getTypePaddedSize, as
...
suggested by Chris.
llvm-svn: 62099
2009-01-12 20:38:59 +00:00
Duncan Sands
0bcf085845
Whitespace - correct formatting.
...
llvm-svn: 61879
2009-01-07 20:01:06 +00:00
Chris Lattner
0cdf52310a
insert some sequence points and preincrement an iterator to avoid
...
iterator invalidation problems.
llvm-svn: 61124
2008-12-17 05:42:08 +00:00
Chris Lattner
222ef4c489
Enhance heap sra to be substantially more aggressive w.r.t PHI
...
nodes. This allows it to do fairly general phi insertion if a
load from a pointer global wants to be SRAd but the load is used
by (recursive) phi nodes. This fixes a pessimization on ppc
introduced by Load PRE.
llvm-svn: 61123
2008-12-17 05:28:49 +00:00
Chris Lattner
56b55387fc
Fix another crash found by inspection. If we have a PHI node merging
...
the load multiple times, make sure the check the uses of the PHI to
ensure they are transformable.
llvm-svn: 61102
2008-12-16 21:24:51 +00:00
Chris Lattner
06a456b3f4
fix a crash found by inspection.
...
llvm-svn: 61101
2008-12-16 21:04:51 +00:00
Chris Lattner
6ddde53783
switch some std::set/std::map to SmallPtrSet/DenseMap.
...
llvm-svn: 61081
2008-12-16 07:34:30 +00:00
Chris Lattner
49e3bdc165
enhance heap-sra to apply to fixed sized array allocations, not just
...
variable sized array allocations.
llvm-svn: 61051
2008-12-15 21:44:34 +00:00
Chris Lattner
1c731fa86f
Use stripPointerCasts.
...
llvm-svn: 61047
2008-12-15 21:20:32 +00:00
Chris Lattner
f0eb568021
minor tweaks for formatting, allow bitcast in ValueIsOnlyUsedLocallyOrStoredToOneGlobal.
...
llvm-svn: 61046
2008-12-15 21:08:54 +00:00
Chris Lattner
c4274a71d5
refactor some code into a new TryToOptimizeStoreOfMallocToGlobal function.
...
Use GetElementPtrInst::hasAllZeroIndices where possible.
llvm-svn: 61045
2008-12-15 21:02:25 +00:00
Devang Patel
4c758ea3e0
Large mechanical patch.
...
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g
This sets the stage
- to implement function notes as function attributes and
- to distinguish between function attributes and return value attributes.
This requires corresponding changes in llvm-gcc and clang.
llvm-svn: 56622
2008-09-25 21:00:45 +00:00
Anton Korobeynikov
1a1140429e
Make safer variant of alias resolution routine to be default
...
llvm-svn: 56005
2008-09-09 20:05:04 +00:00
Anton Korobeynikov
a9b60ee0fc
Resolve aliases, when possible
...
llvm-svn: 56001
2008-09-09 19:04:59 +00:00
Dan Gohman
a79db30d28
Tidy up several unbeseeming casts from pointer to intptr_t.
...
llvm-svn: 55779
2008-09-04 17:05:41 +00:00
Bill Wendling
f21a38700f
Remove tabs.
...
llvm-svn: 54707
2008-08-12 23:15:44 +00:00
Matthijs Kooijman
8b69d77a7a
Make GlobalOpt preserve address spaces when scalar replacing aggregate globals.
...
llvm-svn: 53716
2008-07-17 11:59:53 +00:00
Gabor Greif
3a9fba5a72
convert more operand loops to iterator formulation
...
llvm-svn: 51663
2008-05-29 01:59:18 +00:00
Dan Gohman
30ab45d01e
Use isSingleValueType instead of isFirstClassType to
...
exclude struct and array types.
llvm-svn: 51459
2008-05-23 00:17:26 +00:00
Gabor Greif
e1f6e4b21d
API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
...
llvm-svn: 51200
2008-05-16 19:29:10 +00:00
Gabor Greif
697e94cc22
Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.
...
llvm-svn: 51143
2008-05-15 10:04:30 +00:00
Dan Gohman
d78c400b5b
Clean up the use of static and anonymous namespaces. This turned up
...
several things that were neither in an anonymous namespace nor static
but not intended to be global.
llvm-svn: 51017
2008-05-13 00:00:25 +00:00
Chris Lattner
67ca6f6347
When SRoA'ing a global variable, make sure the new globals get the
...
appropriate alignment. This fixes a miscompilation of 252.eon on
x86-64 (rdar://5891920).
Bill, please pull this into Tak.
llvm-svn: 50308
2008-04-26 07:40:11 +00:00
Gabor Greif
e9ecc68d8f
API changes for class Use size reduction, wave 1.
...
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.
llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Dan Gohman
9988569af8
Don't include <map> in Pass.h, which doesn't need it. This requires
...
adding <map> to many files that actually do need it.
llvm-svn: 48667
2008-03-21 23:51:57 +00:00