1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 12:02:58 +02:00
Commit Graph

64 Commits

Author SHA1 Message Date
Eli Friedman
0c3b1df94e A FIXME about block addresses and indirectbr.
llvm-svn: 142569
2011-10-20 04:05:33 +00:00
Bill Wendling
584c5f9c62 Correct over-zealous removal of hack.
Some code want to check that *any* call within a function has the 'returns
twice' attribute, not just that the current function has one.

llvm-svn: 142221
2011-10-17 18:43:40 +00:00
Bill Wendling
2ee7de36b8 Now that we have the ReturnsTwice function attribute, this method is
obsolete. Check the attribute instead.
<rdar://problem/8031714>

llvm-svn: 142212
2011-10-17 18:22:52 +00:00
Andrew Trick
0489c5410d Inlining and unrolling heuristics should be aware of free truncs.
We want heuristics to be based on accurate data, but more importantly
we don't want llvm to behave randomly. A benign trunc inserted by an
upstream pass should not cause a wild swings in optimization
level. See PR11034. It's a general problem with threshold-based
heuristics, but we can make it less bad.

llvm-svn: 140919
2011-10-01 01:39:05 +00:00
Andrew Trick
a1161d94f5 whitespace
llvm-svn: 140916
2011-10-01 01:27:56 +00:00
Eli Friedman
654dd382bc Change condition for determining whether a function is small for inlining metrics so that very long functions
with few basic blocks are not re-analyzed.

llvm-svn: 131994
2011-05-24 20:22:24 +00:00
Rafael Espindola
1f7c831e4f Extra refactoring noticed by Eli Friedman.
llvm-svn: 131405
2011-05-16 15:48:45 +00:00
Chris Lattner
0304b82f80 Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Eric Christopher
b81307b728 Remove premature optimization that avoided calculating argument weights
if we weren't going to inline the function. The rest of the code using
this was removed.

Fixes PR9154.

llvm-svn: 124991
2011-02-06 21:27:46 +00:00
Eric Christopher
6dbf0c6bbe Fix cut and paste error spotted by Jakob.
llvm-svn: 124930
2011-02-05 02:48:47 +00:00
Eric Christopher
ddc2157034 Rewrite how the indirect call bonus is handled. This now works by:
a) Making it a per call site bonus for functions that we can move from
indirect to direct calls.
b) Reduces the bonus from 500 to 100 per call site.
c) Subtracts the size of the possible newly inlineable call from the
bonus to only add a bonus if we can inline a small function to devirtualize
it.

Also changes the bonus from a positive that's subtracted to a negative
that's added.

Fixes the remainder of rdar://8546196 by reducing the object file size
after inlining by 84%.

llvm-svn: 124916
2011-02-05 00:49:15 +00:00
Eric Christopher
f8b2388751 Reapply 124275 since the Dragonegg failure was unreproducible.
llvm-svn: 124641
2011-02-01 01:16:32 +00:00
Eric Christopher
54f709d970 Temporarily revert 124275 to see if it brings the dragonegg buildbot back.
llvm-svn: 124312
2011-01-26 19:40:31 +00:00
Eric Christopher
cb32adbd3f Separate out the constant bonus from the size reduction metrics. Rework
a few loops accordingly. Should be no functional change.

This is a step for more accurate cost/benefit analysis of devirt/inlining
bonuses.

llvm-svn: 124275
2011-01-26 02:58:39 +00:00
Eric Christopher
45e584b1b7 Coding style formatting changes.
llvm-svn: 124260
2011-01-26 01:09:59 +00:00
Eric Christopher
8c76a85e48 Reorganize this so that the early exit and special cases come early
rather than interspersed. No functional change.

llvm-svn: 124168
2011-01-25 01:34:31 +00:00
Eric Christopher
ee9652eceb Add a FIXME explaining the move to a single indirect call bonus per function
that we can change from indirect to direct.

llvm-svn: 124045
2011-01-22 21:56:53 +00:00
Eric Christopher
5da99702ec Only apply the devirtualization bonus once instead of per-call site in the
target function.

Fixes part of rdar://8546196

llvm-svn: 124044
2011-01-22 21:17:33 +00:00
Kenneth Uildriks
e9771f15f7 Now using a variant of the existing inlining heuristics to decide whether to create a given specialization of a function in PartialSpecialization. If the total performance bonus across all callsites passing the same constant exceeds the specialization cost, we create the specialization.
llvm-svn: 116158
2010-10-09 22:06:36 +00:00
Kenneth Uildriks
0545afa8fd Start separating out code metrics into code size metrics and code performance metrics. Partial Specialization will apply the former to function specializations, and the latter to all callsites that can use a specialization, in order to decide whether to create a specialization
llvm-svn: 116057
2010-10-08 13:57:31 +00:00
Owen Anderson
f7276d42d3 What the loop unroller cares about, rather than just not unrolling loops with calls, is
not unrolling loops that contain calls that would be better off getting inlined.  This mostly
comes up when an interleaved devirtualization pass has devirtualized a call which the inliner
will inline on a future pass.  Thus, rather than blocking all loops containing calls, add
a metric for "inline candidate calls" and block loops containing those instead.

llvm-svn: 113535
2010-09-09 20:32:23 +00:00
Owen Anderson
9a194c80c4 Refactor code-size reduction estimation methods out of InlineCostAnalyzer and into CodeMetrics. They
don't use any InlineCostAnalyzer state, and are useful for other clients who don't necessarily want to use
all of InlineCostAnalyzer's logic, some of which is fairly inlining-specific.

No intended functionality change.

llvm-svn: 113499
2010-09-09 16:56:42 +00:00
Gabor Greif
aaf68e2e5a use ImmutableCallSite for const-corrgoodness
llvm-svn: 109503
2010-07-27 14:15:29 +00:00
Kenneth Uildriks
2c6b68924d Pulled CodeMetrics out of InlineCost.h and made it a bit more general, so it can be reused from PartialSpecializationCost
llvm-svn: 105725
2010-06-09 15:11:37 +00:00
Jakob Stoklund Olesen
2803135445 Avoid counting InlineAsm as a call - it prevents loop unrolling.
PR7026
Patch by Pekka Jääskeläinen!

llvm-svn: 104780
2010-05-26 22:40:28 +00:00
Nick Lewycky
b5bf752087 Clear CachedFunctionInfo upon Pass::releaseMemory. Because ValueMap will abort
on RAUW of functions, this is a correctness issue instead of a mere memory
usage problem.


No testcase until the new MergeFunctions can land.

llvm-svn: 103653
2010-05-12 21:48:15 +00:00
David Chisnall
52a91e993b Added a variant of InlineCostAnalyzer::getInlineCost() that takes the called function as an explicit argument, for use when inlining function pointers.
llvm-svn: 102841
2010-05-01 15:47:41 +00:00
Chris Lattner
3eb6a9f076 Dan recently disabled recursive inlining within a function, but we
were still inlining self-recursive functions into other functions.

Inlining a recursive function into itself has the potential to
reduce recursion depth by a factor of 2, inlining a recursive
function into something else reduces recursion depth by exactly 
1.  Since inlining a recursive function into something else is a
weird form of loop peeling, turn this off.

The deleted testcase was added by Dale in r62107, since then
we're leaning towards not inlining recursive stuff ever.  In any
case, if we like inlining recursive stuff, it should be done 
within the recursive function itself to get the algorithm 
recursion depth win.

llvm-svn: 102798
2010-04-30 22:37:22 +00:00
Dan Gohman
4d1724c3e8 Revert r101471. For tight recursive functions which have multiple
recursive callsites, inlining can reduce the number of calls by
exponential factors, as it does in
MultiSource/Benchmarks/Olden/treeadd. More involved heuristics
will be needed.

llvm-svn: 101969
2010-04-21 00:43:30 +00:00
Chris Lattner
a5eb6419eb fix PR6858: a dangling pointer use bug which was caused
by switching CachedFunctionInfo from a std::map to a 
ValueMap (which is implemented in terms of a DenseMap).

DenseMap has different iterator invalidation semantics
than std::map.

This should hopefully fix the dragonegg builder.

llvm-svn: 101658
2010-04-17 17:57:56 +00:00
Chris Lattner
d506ae2617 a bunch of cleanups and tweaks, no functionality changes.
llvm-svn: 101657
2010-04-17 17:55:00 +00:00
Dan Gohman
58add81e7d Disable inlining of recursive calls. It can complicate tailcallelim and
dependent analyses, and increase code size, so doing it profitably would
require more complex heuristics.

llvm-svn: 101471
2010-04-16 16:01:18 +00:00
Dan Gohman
f754ff8ee9 Make callIsSmall accessible as a utility function.
llvm-svn: 101463
2010-04-16 15:14:50 +00:00
Gabor Greif
8cbd9638a9 performance: cache the dereferenced use_iterator
llvm-svn: 101265
2010-04-14 18:13:29 +00:00
Eric Christopher
b3abae8852 Reapply r99451 with a fix to move the NoInline check to the cost functions
instead of InlineFunction.

llvm-svn: 99483
2010-03-25 04:49:10 +00:00
Duncan Sands
70e2bb5875 Treat copysignl like the other copysign functions.
llvm-svn: 98542
2010-03-15 14:01:44 +00:00
Devang Patel
e0b931e0ed Do not ignore arg_size() impact while counting bb instructions.
llvm-svn: 98408
2010-03-13 01:05:02 +00:00
Devang Patel
40477c7760 Remove extra parameter.
llvm-svn: 98403
2010-03-13 00:45:31 +00:00
Devang Patel
882e43e3cc Do not overestimate code size reduction in presense of debug info.
Use CodeMetrics.analyzeBasicBlock() to estimate BB size.

llvm-svn: 98401
2010-03-13 00:10:20 +00:00
Jakob Stoklund Olesen
189a55cc16 Try to keep the cached inliner costs around for a bit longer for big functions.
The Caller cost info would be reset everytime a callee was inlined. If the
caller has lots of calls and there is some mutual recursion going on, the
caller cost info could be calculated many times.

This patch reduces inliner runtime from 240s to 0.5s for a function with 20000
small function calls.

This is a more conservative version of r98089 that doesn't break the clang
test CodeGenCXX/temp-order.cpp. That test relies on rather extreme inlining
for constant folding.

llvm-svn: 98099
2010-03-09 23:02:17 +00:00
Jakob Stoklund Olesen
24bdfeee51 Revert r98089, it was breaking a clang test.
llvm-svn: 98094
2010-03-09 22:43:37 +00:00
Jakob Stoklund Olesen
0e8f00292c Try to keep the cached inliner costs around for a bit longer for big functions.
The Caller cost info would be reset everytime a callee was inlined. If the
caller has lots of calls and there is some mutual recursion going on, the
caller cost info could be calculated many times.

This patch reduces inliner runtime from 240s to 0.5s for a function with 20000
small function calls.

llvm-svn: 98089
2010-03-09 22:17:11 +00:00
Jakob Stoklund Olesen
aade5b423a Permit inlining into huge functions. This heuristic is ancient, and inlining
can sometimes help reduce function size.

llvm-svn: 98088
2010-03-09 22:17:06 +00:00
Duncan Sands
1b33dd3c83 There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.

llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Jakob Stoklund Olesen
039cd8ab3a Update CodeMetrics to count 'big' function calls explicitly.
llvm-svn: 95453
2010-02-05 23:21:18 +00:00
Jakob Stoklund Olesen
5d298fdb4c Fix inline cost predictions with SCIENCE.
After running a batch of measurements, it is clear that the inliner metrics
need some adjustments:

Own argument bonus:       20 -> 5
Outgoing argument penalty: 0 -> 5
Alloca bonus:             10 -> 5
Constant instr bonus:      7 -> 5
Dead successor bonus:     40 -> 5*(avg instrs/block)

The new cost metrics are generaly 25 points higher than before, so we may need
to move thresholds.

With this change, InlineConstants::CallPenalty becomes a political correction:

if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction()))
  NumInsts += InlineConstants::CallPenalty + CS.arg_size();

The code size is accurately modelled by CS.arg_size(). CallPenalty is added
because calls tend to take a long time, so it may not be worth it to inline a
function with lots of calls.

All of the political corrections are in the InlineConstants namespace:
IndirectCallBonus, CallPenalty, LastCallToStaticBonus, ColdccPenalty,
NoreturnPenalty.

llvm-svn: 94615
2010-01-26 23:21:56 +00:00
Jakob Stoklund Olesen
1218f1331f Revert test polarity to match comment and desired outcome. Remove undeserved bonus.
A GEP with all constant indices is already considered free by
analyzeBasicBlock(), so don't give it an extra bonus in
CountCodeReductionForAlloca().

This patch should remove a small positive bias toward inlining functions with
variable-index GEPs, and remove a smaller negative bias from functions with
all-constant index GEPs.

llvm-svn: 94591
2010-01-26 21:31:35 +00:00
Jakob Stoklund Olesen
f4b32e1185 Remove dead code.
Functions containing indirectbr are marked NeverInline by analyzeBasicBlock(),
so there is no point in giving indirectbr special treatment in
CountCodeReductionForConstant. It is never called.

No functional change intended.

llvm-svn: 94590
2010-01-26 21:31:30 +00:00
Jakob Stoklund Olesen
509e8f1ec8 Skip calculation of ArgumentWeights if it will never be used.
Save a few bytes by allocating the correct size vector.

No functional change intended.

llvm-svn: 94589
2010-01-26 21:31:24 +00:00
Eric Christopher
9230a37bb0 Pad my commit stats by reducing indentation in this now separate
commit.

llvm-svn: 93473
2010-01-14 23:00:10 +00:00