Commit Graph

5670 Commits

Author SHA1 Message Date
Dan Gohman f9eafce3af When extending a memset range past the front, set the alignment of the
memset region to the alignment of the new start address.

llvm-svn: 81810
2009-09-14 23:39:10 +00:00
Dan Gohman 7190d48075 Factor out the code for checking that all indices in a getelementptr are
within the notional bounds of the static type of the getelementptr (which
is not the same as "inbounds") from GlobalOpt into a utility routine,
and use it in ConstantFold.cpp to check whether there are any mis-behaved
indices.

llvm-svn: 81478
2009-09-10 23:37:55 +00:00
Nick Lewycky dddf5dcdaf Correctly handle the case where a comparison is created in one BasicBlock and
used by a terminator in another.

llvm-svn: 81437
2009-09-10 07:02:09 +00:00
Evan Cheng 1d9d4bdc99 Add malloc call utility functions. Patch by Victor Hernandez.
llvm-svn: 81426
2009-09-10 04:36:43 +00:00
Dan Gohman ec4557f324 Fix SplitCriticalEdge to properly update LCSSA form when splitting a
loop exit edge -- new PHIs may be needed not only for the additional
splits that are made to preserve LoopSimplify form, but also for the
original split. Factor out the code that inserts new PHIs so that it
can be used for both. Remove LoopRotation.cpp's code for manually
updating LCSSA form, as it is now redundant. This fixes PR4934.

llvm-svn: 81363
2009-09-09 18:18:18 +00:00
Mike Stump deaf572ca8 Reflow comment.
llvm-svn: 81361
2009-09-09 17:57:16 +00:00
Andreas Neustifter 4c0b2847ef Preserve ProfileInfo.
llvm-svn: 81360
2009-09-09 17:53:39 +00:00
Dan Gohman c56af25c01 Fix an 80-column violation.
llvm-svn: 81354
2009-09-09 17:17:19 +00:00
Chris Lattner 9ded9ac8af revert r81335, which breaks the build.
llvm-svn: 81347
2009-09-09 16:00:57 +00:00
Andreas Neustifter 0bd472dc33 Updated ProfileInfo to have clean seperation between different sentinels.
llvm-svn: 81335
2009-09-09 12:48:26 +00:00
Owen Anderson f0081db7e8 Fix PR4909, patch by Jakub Staszak.
llvm-svn: 81250
2009-09-08 19:53:15 +00:00
Chris Lattner 9ce1781ef4 remove an extremely dubious instcombine transformation of
extractelement(load).

llvm-svn: 81239
2009-09-08 18:48:01 +00:00
Dan Gohman 3ddbc242fb Re-apply r80926, with fixes: keep the domtree informed of new blocks
that get created during loop unswitching, and fix SplitBlockPredecessors'
LCSSA updating code to create new PHIs instead of trying to just move
existing ones.

Also, optimize Loop::verifyLoop, since it gets called a lot. Use
searches on a sorted list of blocks instead of calling the "contains"
function, as is done in other places in the Loop class, since "contains"
does a linear search. Also, don't call verifyLoop from LoopSimplify or
LCSSA, as the PassManager is already calling verifyLoop as part of
LoopInfo's verifyAnalysis.

llvm-svn: 81221
2009-09-08 15:45:00 +00:00
Chris Lattner d1b21c6092 remove a turd
llvm-svn: 81186
2009-09-08 03:47:41 +00:00
Chris Lattner d3210e1a20 instcombine transforms vector loads that are only used by
extractelement operations into a bitcast of the pointer,
then a gep, then a scalar load.  Disable this when the vector
only has one element, because it leads to infinite loops in
instcombine (PR4908).

This transformation seems like a really bad idea to me, as it
will likely disable CSE of vector load/stores etc and can be
better done in the code generator when profitable.  This
goes all the way back to the first days of packed types,
r25299 specifically.

I'll let those people who care about the performance of vector
code decide what to do with this.

llvm-svn: 81185
2009-09-08 03:44:51 +00:00
Chris Lattner f2ab40a46f Fix PR4882, by making MemCpyOpt not dereference removed stores to get the
context for the newly created operations.
 
Patch by Jakub Staszak!

llvm-svn: 81175
2009-09-08 00:27:14 +00:00
Dan Gohman 1b84908f92 Reappy r80998, now that the GlobalOpt bug that it exposed on MiniSAT is fixed.
llvm-svn: 81172
2009-09-07 23:54:19 +00:00
Dan Gohman 161429fe7e Don't commit stores with addresses that have indices that are not
compile-time constant integers or that are out of bounds for their
corresponding static array types. These can cause aliasing that
GlobalOpt assumes won't happen.

llvm-svn: 81165
2009-09-07 22:44:55 +00:00
Dan Gohman 82e747580f Don't commit addresses of aggregate values. This avoids problems with
an aggregate store overlapping a different aggregate store, despite
the stores having distinct addresses.

llvm-svn: 81164
2009-09-07 22:42:05 +00:00
Dan Gohman beee35a277 Fix GlobalOpt to avoid committing a store if the address getelementptr
is missing the inbounds flag. This is slightly conservative, but it
avoids problems with two constants pointing to the same address but
getting distinct entries in the Memory DenseMap.

llvm-svn: 81163
2009-09-07 22:40:13 +00:00
Dan Gohman 19244eaa4a Preserve the InBounds flag when evaluating a getelementptr instruction
into a getelementptr ConstantExpr.

llvm-svn: 81162
2009-09-07 22:34:43 +00:00
Dan Gohman f7f3fb1133 Simplify this code by using hasDefinitiveInitializer().
llvm-svn: 81161
2009-09-07 22:31:26 +00:00
Eric Christopher 66d8555f7e Fix comment.
llvm-svn: 81138
2009-09-06 22:20:54 +00:00
Duncan Sands 89720bbd11 Remove some not-really-used variables, as warned
about by icc (#593, partial).  Patch by Erick Tryzelaar.

llvm-svn: 81115
2009-09-06 12:41:19 +00:00
Daniel Dunbar 86c6a6ef0f Fix a possible crash call setIsInBounds.
- I think there are more instances of this, but I think they are fixed in Dan's
   incoming patch. This one was preventing me from doing a bugpoint reduction
   though.

llvm-svn: 81103
2009-09-06 02:31:36 +00:00
Evan Cheng 904199547b Revert r80926. It causes loop unswitch assertion and slow down some JIT tests significantly.
llvm-svn: 81101
2009-09-06 02:26:10 +00:00
Daniel Dunbar 10ea8bb8e0 Revert "Include optional subclass flags, such as inbounds, nsw, etc., ...", this
breaks MiniSAT on x86_64.

llvm-svn: 81098
2009-09-06 00:11:24 +00:00
Andreas Neustifter 18156bd75c Converted MaximumSpanningTree algorithm to a generic template, this could go
into llvm/ADT.

llvm-svn: 81001
2009-09-04 12:34:44 +00:00
Dan Gohman 0c2477c26b Include optional subclass flags, such as inbounds, nsw, etc., in the
Constant uniquing tables. This allows distinct ConstantExpr objects
with the same operation and different flags.

Even though a ConstantExpr "a + b" is either always overflowing or
never overflowing (due to being a ConstantExpr), it's still necessary
to be able to represent it both with and without overflow flags at
the same time within the IR, because the safety of the flag may
depend on the context of the use. If the constant really does overflow,
it wouldn't ever be safe to use with the flag set, however the use
may be in code that is never actually executed.

This also makes it possible to merge all the flags tests into a single test.

llvm-svn: 80998
2009-09-04 12:08:11 +00:00
Dan Gohman 4c1bdcf5d7 Add a verifyAnalysis to LoopInfo, LoopSimplify, and LCSSA form that verify
that these passes are properly preserved.

Fix several transformation passes that claimed to preserve LoopSimplify
form but weren't.

llvm-svn: 80926
2009-09-03 16:31:42 +00:00
Dan Gohman 22571485b3 Change PHINode::hasConstantValue to have a DominatorTree argument
instead of a bool argument, and to do the dominator check itself.
This makes it eaiser to use when DominatorTree information is
available.

llvm-svn: 80920
2009-09-03 15:34:35 +00:00
Duncan Sands 0edc7100ba Keep track of how many memmove calls were turned into
memcpy calls.

llvm-svn: 80915
2009-09-03 13:37:16 +00:00
Andreas Neustifter 7e86c3856b Code Cleanup.
Removed inverted flag form MaximumSpanningTree, also do not handle so much
information to MaximumSpanningTree.

llvm-svn: 80911
2009-09-03 08:52:52 +00:00
Nick Lewycky 88214fbd12 Remove VISIBILITY_HIDDEN from this file.
llvm-svn: 80903
2009-09-03 06:43:15 +00:00
Chris Lattner 27266f164f In C++, code is not allowed to call main. In C it is, this
simplifylibcalls optimization is thus valid for C++ but not C.
It's not important enough to worry about for C++ apps, so just
remove it.

rdar://7191924

llvm-svn: 80887
2009-09-03 05:19:59 +00:00
Gabor Greif 2d60e1ec0c back out my recent commit (r80858), it seems to break self-hosting buildbot's stage 2 configure
llvm-svn: 80871
2009-09-03 02:02:59 +00:00
Gabor Greif 14dfba6d66 re-commit r66920 (which has been backed out in r66953) I may have more luck this time. I'll back out if needed...
llvm-svn: 80858
2009-09-03 00:18:58 +00:00
Andreas Neustifter ae866b0c66 Sort edges in MaximumSpanningTree more stable in case of equal weight.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090824/085890.html)

llvm-svn: 80789
2009-09-02 14:03:11 +00:00
Andreas Neustifter 964fa2bdac Changed set of BlocksToInstrument to set of InsertedBlocks that do not have to
be instrumented.

llvm-svn: 80788
2009-09-02 13:59:05 +00:00
Andreas Neustifter 4469c164d0 Code cleanups and added comments.
llvm-svn: 80781
2009-09-02 12:38:39 +00:00
Chris Lattner 4916267c97 fix PR4815: some cases where DeleteDeadInstruction can delete
the instruction BBI points to.

llvm-svn: 80768
2009-09-02 06:31:02 +00:00
Chris Lattner 09a79dcfdf clean up this code a bit.
llvm-svn: 80767
2009-09-02 06:15:37 +00:00
Chris Lattner 2dd09dbdf7 eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861
llvm-svn: 80766
2009-09-02 06:11:42 +00:00
Chris Lattner 64b5842986 fix PR4837, some bugs folding vector compares. These
return a vector of i1, not i1 itself.

llvm-svn: 80761
2009-09-02 05:12:37 +00:00
Andreas Neustifter 759094e323 OptimalEdgeProfiling: Creation of profiles.
This adds the instrumentation and runtime part of OptimalEdgeProfiling.

llvm-svn: 80712
2009-09-01 19:03:44 +00:00
Chris Lattner 9b463729d7 remove CallGraphNode::replaceCallSite, it is redundant with other APIs.
llvm-svn: 80708
2009-09-01 18:52:39 +00:00
Chris Lattner f61b0fb5d0 cleanup/simplify
llvm-svn: 80706
2009-09-01 18:50:55 +00:00
Chris Lattner 8900f3ec57 remove a bunch of explicit code previously needed to update the
callgraph.  This is now dead because RAUW does the job.

llvm-svn: 80703
2009-09-01 18:44:06 +00:00
Chris Lattner 1145e33bc6 enhance memcpy opt to turn memmoves into memcpy when the src/dest
don't alias.  Remove an old and poorly reduced testcase that fails
with this transform for reasons unrelated to the original test.

llvm-svn: 80693
2009-09-01 17:56:32 +00:00
Chris Lattner b5557a7b42 random code cleanups, no functionality change.
llvm-svn: 80682
2009-09-01 17:09:55 +00:00
Ted Kremenek 1543d133db Update CMake files.
llvm-svn: 80680
2009-09-01 17:01:02 +00:00
Andreas Neustifter eb5a9d34d6 Preparation for Optimal Edge Profiling:
Add statistics for regular edge profiling, this enables the comparation of the
number of edges inserted by regular and optimal edge profiling.

llvm-svn: 80668
2009-09-01 10:08:39 +00:00
Chris Lattner 063d06527e Change CallGraphNode to maintain it's Function as an AssertingVH
for sanity.  This didn't turn up any bugs.

Change CallGraphNode to maintain its "callsite" information in the 
call edges list as a WeakVH instead of as an instruction*.  This fixes
a broad class of dangling pointer bugs, and makes CallGraph have a number
of useful invariants again.  This fixes the class of problem indicated
by PR4029 and PR3601.

llvm-svn: 80663
2009-09-01 06:31:31 +00:00
Chris Lattner ff5f1e4d70 fix some cases where instcombine would change hte IR but not return true
from runOnFunction

llvm-svn: 80562
2009-08-31 06:57:37 +00:00
Chris Lattner 9e50747958 comment and simplify some code.
llvm-svn: 80540
2009-08-31 05:34:32 +00:00
Chris Lattner 70ebbc59f3 add -debug output
llvm-svn: 80539
2009-08-31 05:22:48 +00:00
Chris Lattner 19dd315e67 improve -debug output, so that -debug is more likely to print when
instcombine is changing stuff.

llvm-svn: 80538
2009-08-31 05:17:58 +00:00
Chris Lattner 4e3e930743 fix a bug I introduced with my 'instcombine builder' refactoring
changes: SimplifyDemandedBits can't use the builder yet because it
has the wrong insertion point.  This fixes a crash building
MultiSource/Benchmarks/PAQ8p

llvm-svn: 80537
2009-08-31 04:36:22 +00:00
Chris Lattner 2f2110affa simplify some code by making the SCCNodes set contain Function*'s
instead of CallGraphNode*'s.  This also papers over a callgraph
problem where a pass (in this case, MemCpyOpt) introduces a new
function into the module (llvm.memset.i64) but doesn't add it to
the call graph (nor should it, since it is a function pass).

While it might be a good idea for MemCpyOpt to not synthesize 
functions in a runOnFunction(), there is no need for FunctionAttrs
to be boneheaded, so fix it there.  This fixes an assertion building
176.gcc.

llvm-svn: 80535
2009-08-31 04:09:04 +00:00
Chris Lattner 081375bb08 Fix PR4834, a tricky case where the inliner would resolve an
indirect function pointer, inline it, then go to delete the body.
The problem is that the callgraph had other references to the function,
though the inliner had no way to know it, so we got a dangling pointer
and an invalid iterator out of the deal.

The fix to this is pretty simple: stop the inliner from deleting the
function by knowing that there are references to it.  Do this by making
CallGraphNodes contain a refcount.  This requires moving deletion of 
available_externally functions to the module-level cleanup sweep where
it belongs.

llvm-svn: 80533
2009-08-31 03:15:49 +00:00
Chris Lattner 305b115a87 Fix some nasty callgraph dangling pointer problems in
argpromotion and structretpromote.  Basically, when replacing
a function, they used the 'changeFunction' api which changes
the entry in the function map (and steals/reuses the callgraph
node).

This has some interesting effects: first, the problem is that it doesn't
update the "callee" edges in any callees of the function in the call graph.
Second, this covers for a major problem in all the CGSCC pass stuff, which 
is that it is completely broken when functions are deleted if they *don't*
reuse a CGN.  (there is a cute little fixme about this though :).

This patch changes the protocol that CGSCC passes must obey: now the CGSCC 
pass manager copies the SCC and preincrements its iterator to avoid passes
invalidating it.  This allows CGSCC passes to mutate the current SCC.  However
multiple passes may be run on that SCC, so if passes do this, they are now
required to *update* the SCC to be current when they return.

Other less interesting parts of this patch are that it makes passes update
the CG more directly, eliminates changeFunction, and requires clients of
replaceCallSite to specify the new callee CGN if they are changing it.

llvm-svn: 80527
2009-08-31 00:19:58 +00:00
Chris Lattner 73913f4cd3 Fix PR4748: don't fold gep(bitcast(x)) into bitcast(gep) when x
is itself a bitcast.  Since we have gep(bitcast(bitcast(y))) in this
case, just wait for the two bitcasts to get zapped.  This prevents
instcombine from confusing some aliasing stuff, and allows it to
directly eliminate the load in the testcase.

llvm-svn: 80508
2009-08-30 20:38:21 +00:00
Chris Lattner c2f2cf896e misc cleanup
llvm-svn: 80507
2009-08-30 20:36:46 +00:00
Chris Lattner a3e620caba add getPointerAddressSpace() to GEP instruction, use the method
in a few scalar xforms to simplify things.

llvm-svn: 80506
2009-08-30 20:06:40 +00:00
Chris Lattner c856539edf eliminate InsertCastBefore, use the builder instead.
llvm-svn: 80505
2009-08-30 20:01:10 +00:00
Chris Lattner 606da5fed8 eliminate InsertBitCastBefore, just use the builder instead.
llvm-svn: 80504
2009-08-30 19:47:22 +00:00
Chris Lattner 5966341a2e convert a bunch more calls to InsertNewInstBefore to use
the new Instcombine builder.

llvm-svn: 80501
2009-08-30 18:50:58 +00:00
Chris Lattner 8326d529da fix typo
llvm-svn: 80500
2009-08-30 17:53:59 +00:00
Chris Lattner 022a582de2 give instcombine a custom IRBuilder that adds new instructions to the
workslist and is set to insert new instructions before the current one.
Convert a bunch of stuff that used to call InsertNewInstBefore over to
use it, greatly simplifying code and making it more natural.

There is still a lot more to go, but this is a good start.

llvm-svn: 80492
2009-08-30 07:44:24 +00:00
Chris Lattner a0c89ee1da add a new InstCombineWorklist::AddValue method that works even
if the operand is not an instruction.

Simplify most uses of AddOperandsToWorkList to use AddValue and
inline it into the one remaining callsite.

llvm-svn: 80488
2009-08-30 06:27:41 +00:00
Chris Lattner bacd05c2eb move AddUsersToWorkList to the worklist processing class, make the
argument stronger typed.

llvm-svn: 80487
2009-08-30 06:22:51 +00:00
Chris Lattner 795bfdbb55 rename AddUsesToWorkList -> AddOperandsToWorkList. The
former looks too much like AddUsersToWorkList and keeps
confusing me.

Remove AddSoonDeadInstToWorklist and change its two callers
to do the same thing in a simpler way.

llvm-svn: 80486
2009-08-30 06:20:05 +00:00
Chris Lattner 905976b1db inline the trivial AddToWorkList/RemoveFromWorkList methods
into their callers.  simplify ReplaceInstUsesWith.  Make
EraseInstFromFunction only add operands to the worklist if
there aren't too many of them (this was a scalability win
for crazy programs that was only infrequently enforced).
Switch more code to using EraseInstFromFunction instead of
duplicating it inline.  Change some fcmp/icmp optimizations
to modify fcmp/icmp in place instead of creating a new one
and deleting the old one just to change the predicate.

llvm-svn: 80483
2009-08-30 06:13:40 +00:00
Chris Lattner 93ad6170fd fix a bug I introduced in r80478 found by the build bot.
llvm-svn: 80482
2009-08-30 05:56:44 +00:00
Chris Lattner 97fd3599e1 refactor instcombine's worklist processing stuff out to its own class.
llvm-svn: 80481
2009-08-30 05:55:36 +00:00
Chris Lattner b2995e1eb1 more cleanups: remove some redundant code, and simplify some
other places.

llvm-svn: 80478
2009-08-30 05:30:55 +00:00
Chris Lattner 06c687b59e eliminate the temporary SrcGEPOperands smallvector.
llvm-svn: 80477
2009-08-30 05:08:50 +00:00
Chris Lattner e26bf17423 simplify/detangle some control flow.
llvm-svn: 80476
2009-08-30 05:00:50 +00:00
Chris Lattner d7b6e913fe simplify and cleanup some code, remove some code that just
does constant folding of gep's: this is already handled in
a more general way.

No functionality change.

llvm-svn: 80475
2009-08-30 04:49:01 +00:00
Dan Gohman 0dfe73ac9e Remove an unnecessary Context argument.
llvm-svn: 80454
2009-08-29 23:39:38 +00:00
Benjamin Kramer b83f691931 Inline empty destructor.
llvm-svn: 80431
2009-08-29 13:38:21 +00:00
Bill Wendling 06a6057bbe Fix warning about non-virtual destructor.
llvm-svn: 80429
2009-08-29 12:31:38 +00:00
Devang Patel 80ae34974b Reapply 79977.
Use MDNodes to encode debug info in llvm IR.

llvm-svn: 80406
2009-08-28 23:24:31 +00:00
Andreas Neustifter 991beb9aaf Preparation for Optimal Edge Profiling:
This implements the maximum spanning tree algorithm on CFGs according to
weights given by the ProfileEstimator. This is then used to implement Optimal
Edge Profiling.

llvm-svn: 80358
2009-08-28 11:28:24 +00:00
Chris Lattner 0e8901803c finish a half formed thought :)
llvm-svn: 80334
2009-08-28 04:48:54 +00:00
Chris Lattner bda82c20f3 Fix PR3913, patch by Jakub Staszak!
llvm-svn: 80327
2009-08-28 00:43:14 +00:00
Chris Lattner d3374e8dfd Implement a new optimization in the inliner: if inlining multiple
calls into a function and if the calls bring in arrays, try to merge
them together to reduce stack size.  For example, in the testcase
we'd previously end up with 4 allocas, now we end up with 2 allocas.

As described in the comments, this is not really the ideal solution
to this problem, but it is surprisingly effective.  For example, on
176.gcc, we end up eliminating 67 arrays at "gccas" time and another
24 at "llvm-ld" time.

One piece of concern that I didn't look into: at -O0 -g with
forced inlining this will almost certainly result in worse debug
info.  I think this is acceptable though given that this is a case
of "debugging optimized code", and we don't want debug info to
prevent the optimizer from doing things anyway.

llvm-svn: 80215
2009-08-27 06:29:33 +00:00
Chris Lattner 1ce61b82ac unbreak the build, yay for symlinks + makefiles. :(
llvm-svn: 80205
2009-08-27 04:43:05 +00:00
Chris Lattner b9d0a961f9 reduce header #include'age
llvm-svn: 80204
2009-08-27 04:32:07 +00:00
Chris Lattner b1cba3f91e enhance InlineFunction to be able to optionally return
a the list of static allocas that it inlined.

llvm-svn: 80203
2009-08-27 04:20:52 +00:00
Chris Lattner d84dbb3443 smallvectorize the list of returns built by CloneAndPruneFunctionInto.
llvm-svn: 80202
2009-08-27 04:02:30 +00:00
Chris Lattner 9d0235dc6b remove CloneTrace, which appears to be dead since 2004.
llvm-svn: 80201
2009-08-27 03:56:43 +00:00
Chris Lattner 5eef6ad6a9 reduce inlining factor some stuff out to a static helper function,
and other code cleanups.  No functionality change.

llvm-svn: 80199
2009-08-27 03:51:50 +00:00
Owen Anderson 109ca5a14a Make this into a static method.
llvm-svn: 80170
2009-08-26 22:55:11 +00:00
Devang Patel f08e35d9dc Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.
llvm-svn: 80073
2009-08-26 05:01:18 +00:00
Dan Gohman 3b1938dda4 Remove unused variables.
llvm-svn: 80058
2009-08-26 00:13:22 +00:00
Dan Gohman ad1f0a1101 Eliminate the unused Context argument on one of the ICmpInst and FCmpInst
constructors.

llvm-svn: 80049
2009-08-25 23:17:54 +00:00
Dan Gohman c8a27f2a5c Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
and introduce a new Instruction::isIdenticalTo which tests for full
identity, including the SubclassOptionalData flags. Also, fix the
Instruction::clone implementations to preserve the SubclassOptionalData
flags. Finally, teach several optimizations how to handle
SubclassOptionalData correctly, given these changes.

This fixes the counterintuitive behavior of isIdenticalTo not comparing
the full value, and clone not returning an identical clone, as well as
some subtle bugs that could be caused by these.

Thanks to Nick Lewycky for reporting this, and for an initial patch!

llvm-svn: 80038
2009-08-25 22:11:20 +00:00
Dan Gohman 337d56110e Special-case static allocas in IndVarSimplify's loop invariant
sinking code, since they are special. If the loop preheader happens
to be the entry block of a function, don't sink static allocas
out of it. This fixes PR4775.

llvm-svn: 80010
2009-08-25 17:42:10 +00:00
Owen Anderson 4e9ac2a34b Comment-ify.
llvm-svn: 80009
2009-08-25 17:42:07 +00:00