Commit Graph

1158 Commits

Author SHA1 Message Date
Dan Gohman e525d9ddc0 Remove an unnnecessary LLVMContext argument in
ConstantFoldLoadThroughGEPConstantExpr.

llvm-svn: 83311
2009-10-05 16:36:26 +00:00
Evan Cheng bb4ed2394b Allow -inline-threshold override default threshold even if compiling to optimize for size.
llvm-svn: 83274
2009-10-04 06:13:54 +00:00
Dan Gohman 9a7320c711 Convert LoopSimplify and LoopExtractor from FunctionPass to LoopPass.
llvm-svn: 82990
2009-09-28 14:37:51 +00:00
Chris Lattner 43d0db70ac remove special handling of bitcast(malloc), it will be handled
when the loop inspects the bitcast operand.

llvm-svn: 82928
2009-09-27 21:29:28 +00:00
Chris Lattner a8627272c1 unlike the malloc instruction, "malloc" calls do not claim to be readonly, just nounwind.
llvm-svn: 82927
2009-09-27 21:23:38 +00:00
Torok Edwin 21bd8c9fc5 Constant propagating byval pointer is safe if function is readonly.
llvm-svn: 82700
2009-09-24 18:33:42 +00:00
Torok Edwin f95a450ef9 Don't constant propagate byval pointers, since they are not really pointers, but
rather structs passed by value.
This fixes PR5038.

llvm-svn: 82689
2009-09-24 09:47:18 +00:00
Daniel Dunbar 7d6781b0fe Tabs -> spaces, and remove trailing whitespace.
llvm-svn: 82355
2009-09-20 02:20:51 +00:00
Nick Lewycky 1303c0ab86 Remove the default value for ConstantStruct::get's isPacked parameter and
update the code which was broken by this.

llvm-svn: 82327
2009-09-19 20:30:26 +00:00
Victor Hernandez 5d034499ad Enhance transform passes so that they apply the same tranforms to malloc calls as to MallocInst.
Reviewed by Dan Gohman.

llvm-svn: 82300
2009-09-18 22:35:49 +00:00
Chris Lattner e0987215f0 add a new CallGraphNode::replaceCallEdge method and use it from
argpromote to avoid invalidating an iterator.  This fixes PR4977.
All clang tests now pass with expensive checking (on my system 
at least).

llvm-svn: 81843
2009-09-15 05:40:35 +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
Owen Anderson f0081db7e8 Fix PR4909, patch by Jakub Staszak.
llvm-svn: 81250
2009-09-08 19:53:15 +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
Nick Lewycky 88214fbd12 Remove VISIBILITY_HIDDEN from this file.
llvm-svn: 80903
2009-09-03 06:43:15 +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
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 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 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 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
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
Chris Lattner 0e8901803c finish a half formed thought :)
llvm-svn: 80334
2009-08-28 04:48:54 +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 b9d0a961f9 reduce header #include'age
llvm-svn: 80204
2009-08-27 04:32:07 +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
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 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
Devang Patel 02aac922b4 Update DebugInfo interface to use metadata, instead of special named llvm.dbg.... global variables, to encode debugging information in llvm IR. This is mostly a mechanical change that tests metadata support very well.
This change speeds up llvm-gcc by more then 6% at "-O0 -g" (measured by compiling InstructionCombining.cpp!)

llvm-svn: 79977
2009-08-25 05:24:07 +00:00
Dale Johannesen c221a55f58 Allow multiple occurrences of -inline-threshold on
the command line.  This gives llvm-gcc developers
a way to control inlining (documented as "not intended
for end users").

llvm-svn: 79966
2009-08-25 01:13:58 +00:00
Chris Lattner 06fa176862 prune the #includes in raw_ostream.h by moving a
member out of line. ftostr is not particularly speedy,
so that method is presumably not perf sensitive.

llvm-svn: 79885
2009-08-24 03:52:50 +00:00
Chris Lattner 4883d90396 convert LoopInfo.h and GraphWriter.h to use raw_ostream
llvm-svn: 79836
2009-08-23 07:19:13 +00:00
Chris Lattner 317dbbcfb1 eliminate uses of cerr()
llvm-svn: 79834
2009-08-23 07:05:07 +00:00
Chris Lattner 4dc3edde9f remove a few DOUTs here and there.
llvm-svn: 79832
2009-08-23 06:35:02 +00:00
Chris Lattner b25de3ff60 eliminate the "Value" printing methods that print to a std::ostream.
This required converting a bunch of stuff off DOUT and other cleanups.

llvm-svn: 79819
2009-08-23 04:37:46 +00:00
Dan Gohman 5d5bc6d000 Use hasDefinitiveInitializer() instead of testing the same thing
by hand, and fix a few places that were using hasInitializer() that
appear to depend on the initializer value.

llvm-svn: 79441
2009-08-19 18:20:44 +00:00
Dan Gohman 82ac81b1cc Fix a bug that caused globalopt to miscompile tramp3d: don't miss
unruly indices for arrays that are members of structs.

llvm-svn: 79337
2009-08-18 14:58:19 +00:00
Duncan Sands c4ce58d8fe Don't access the first element of a potentially empty
vector (&Formals[0]).  With this change llvm-gcc builds
with expensive checking enabled for C, C++ and Fortran.
While there, change a std::vector into a SmallVector.
This is partly gratuitous, but mostly because not all
STL vector implementations define the data method (and
it should be faster).

llvm-svn: 79237
2009-08-17 14:33:27 +00:00
Dan Gohman dbeb33936f Make TargetData optional in GlobalOpt and ArgumentPromotion.
llvm-svn: 78967
2009-08-14 00:11:03 +00:00
Owen Anderson 55f1c09e31 Push LLVMContexts through the IntegerType APIs.
llvm-svn: 78948
2009-08-13 21:58:54 +00:00
Dan Gohman 5476cfdb15 Remove a bunch more now-unnecessary Context arguments.
llvm-svn: 78809
2009-08-12 16:23:25 +00:00
Dan Gohman 38484ceec9 Remove unnecessary casts.
llvm-svn: 78664
2009-08-11 15:15:10 +00:00