summaryrefslogtreecommitdiff
path: root/lib/Analysis/InlineCost.cpp
Commit message (Collapse)AuthorAge
* A FIXME about block addresses and indirectbr.Eli Friedman2011-10-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142569 91177308-0d34-0410-b5e6-96231b3b80d8
* Correct over-zealous removal of hack.Bill Wendling2011-10-17
| | | | | | | | Some code want to check that *any* call within a function has the 'returns twice' attribute, not just that the current function has one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142221 91177308-0d34-0410-b5e6-96231b3b80d8
* Now that we have the ReturnsTwice function attribute, this method isBill Wendling2011-10-17
| | | | | | | | obsolete. Check the attribute instead. <rdar://problem/8031714> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142212 91177308-0d34-0410-b5e6-96231b3b80d8
* Inlining and unrolling heuristics should be aware of free truncs.Andrew Trick2011-10-01
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140919 91177308-0d34-0410-b5e6-96231b3b80d8
* whitespaceAndrew Trick2011-10-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140916 91177308-0d34-0410-b5e6-96231b3b80d8
* Change condition for determining whether a function is small for inlining ↵Eli Friedman2011-05-24
| | | | | | | | | | metrics so that very long functions with few basic blocks are not re-analyzed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131994 91177308-0d34-0410-b5e6-96231b3b80d8
* Extra refactoring noticed by Eli Friedman.Rafael Espindola2011-05-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131405 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-15
| | | | | | | | Luis Felipe Strano Moraes! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove premature optimization that avoided calculating argument weightsEric Christopher2011-02-06
| | | | | | | | | | if we weren't going to inline the function. The rest of the code using this was removed. Fixes PR9154. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124991 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix cut and paste error spotted by Jakob.Eric Christopher2011-02-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124930 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite how the indirect call bonus is handled. This now works by:Eric Christopher2011-02-05
| | | | | | | | | | | | | | | | | | 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%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124916 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply 124275 since the Dragonegg failure was unreproducible.Eric Christopher2011-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124641 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily revert 124275 to see if it brings the dragonegg buildbot back.Eric Christopher2011-01-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124312 91177308-0d34-0410-b5e6-96231b3b80d8
* Separate out the constant bonus from the size reduction metrics. ReworkEric Christopher2011-01-26
| | | | | | | | | | a few loops accordingly. Should be no functional change. This is a step for more accurate cost/benefit analysis of devirt/inlining bonuses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124275 91177308-0d34-0410-b5e6-96231b3b80d8
* Coding style formatting changes.Eric Christopher2011-01-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124260 91177308-0d34-0410-b5e6-96231b3b80d8
* Reorganize this so that the early exit and special cases come earlyEric Christopher2011-01-25
| | | | | | | rather than interspersed. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124168 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a FIXME explaining the move to a single indirect call bonus per functionEric Christopher2011-01-22
| | | | | | | that we can change from indirect to direct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124045 91177308-0d34-0410-b5e6-96231b3b80d8
* Only apply the devirtualization bonus once instead of per-call site in theEric Christopher2011-01-22
| | | | | | | | | target function. Fixes part of rdar://8546196 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124044 91177308-0d34-0410-b5e6-96231b3b80d8
* Now using a variant of the existing inlining heuristics to decide whether to ↵Kenneth Uildriks2010-10-09
| | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116158 91177308-0d34-0410-b5e6-96231b3b80d8
* Start separating out code metrics into code size metrics and code ↵Kenneth Uildriks2010-10-08
| | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116057 91177308-0d34-0410-b5e6-96231b3b80d8
* What the loop unroller cares about, rather than just not unrolling loops ↵Owen Anderson2010-09-09
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113535 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor code-size reduction estimation methods out of InlineCostAnalyzer ↵Owen Anderson2010-09-09
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113499 91177308-0d34-0410-b5e6-96231b3b80d8
* use ImmutableCallSite for const-corrgoodnessGabor Greif2010-07-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109503 91177308-0d34-0410-b5e6-96231b3b80d8
* Pulled CodeMetrics out of InlineCost.h and made it a bit more general, so it ↵Kenneth Uildriks2010-06-09
| | | | | | can be reused from PartialSpecializationCost git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105725 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid counting InlineAsm as a call - it prevents loop unrolling.Jakob Stoklund Olesen2010-05-26
| | | | | | | PR7026 Patch by Pekka Jääskeläinen! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104780 91177308-0d34-0410-b5e6-96231b3b80d8
* Clear CachedFunctionInfo upon Pass::releaseMemory. Because ValueMap will abortNick Lewycky2010-05-12
| | | | | | | | | | | on RAUW of functions, this is a correctness issue instead of a mere memory usage problem. No testcase until the new MergeFunctions can land. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103653 91177308-0d34-0410-b5e6-96231b3b80d8
* Added a variant of InlineCostAnalyzer::getInlineCost() that takes the called ↵David Chisnall2010-05-01
| | | | | | function as an explicit argument, for use when inlining function pointers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102841 91177308-0d34-0410-b5e6-96231b3b80d8
* Dan recently disabled recursive inlining within a function, but weChris Lattner2010-04-30
| | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102798 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r101471. For tight recursive functions which have multipleDan Gohman2010-04-21
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101969 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR6858: a dangling pointer use bug which was causedChris Lattner2010-04-17
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101658 91177308-0d34-0410-b5e6-96231b3b80d8
* a bunch of cleanups and tweaks, no functionality changes.Chris Lattner2010-04-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101657 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable inlining of recursive calls. It can complicate tailcallelim andDan Gohman2010-04-16
| | | | | | | | dependent analyses, and increase code size, so doing it profitably would require more complex heuristics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101471 91177308-0d34-0410-b5e6-96231b3b80d8
* Make callIsSmall accessible as a utility function.Dan Gohman2010-04-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101463 91177308-0d34-0410-b5e6-96231b3b80d8
* performance: cache the dereferenced use_iteratorGabor Greif2010-04-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101265 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r99451 with a fix to move the NoInline check to the cost functionsEric Christopher2010-03-25
| | | | | | | instead of InlineFunction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99483 91177308-0d34-0410-b5e6-96231b3b80d8
* Treat copysignl like the other copysign functions.Duncan Sands2010-03-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98542 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not ignore arg_size() impact while counting bb instructions.Devang Patel2010-03-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98408 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove extra parameter.Devang Patel2010-03-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98403 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not overestimate code size reduction in presense of debug info.Devang Patel2010-03-13
| | | | | | | Use CodeMetrics.analyzeBasicBlock() to estimate BB size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98401 91177308-0d34-0410-b5e6-96231b3b80d8
* Try to keep the cached inliner costs around for a bit longer for big functions.Jakob Stoklund Olesen2010-03-09
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98099 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r98089, it was breaking a clang test.Jakob Stoklund Olesen2010-03-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98094 91177308-0d34-0410-b5e6-96231b3b80d8
* Try to keep the cached inliner costs around for a bit longer for big functions.Jakob Stoklund Olesen2010-03-09
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98089 91177308-0d34-0410-b5e6-96231b3b80d8
* Permit inlining into huge functions. This heuristic is ancient, and inliningJakob Stoklund Olesen2010-03-09
| | | | | | can sometimes help reduce function size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98088 91177308-0d34-0410-b5e6-96231b3b80d8
* There are two ways of checking for a given type, for example isa<PointerType>(T)Duncan Sands2010-02-16
| | | | | | | | and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96344 91177308-0d34-0410-b5e6-96231b3b80d8
* Update CodeMetrics to count 'big' function calls explicitly.Jakob Stoklund Olesen2010-02-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95453 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix inline cost predictions with SCIENCE.Jakob Stoklund Olesen2010-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94615 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert test polarity to match comment and desired outcome. Remove undeserved ↵Jakob Stoklund Olesen2010-01-26
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94591 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove dead code.Jakob Stoklund Olesen2010-01-26
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94590 91177308-0d34-0410-b5e6-96231b3b80d8
* Skip calculation of ArgumentWeights if it will never be used.Jakob Stoklund Olesen2010-01-26
| | | | | | | | Save a few bytes by allocating the correct size vector. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94589 91177308-0d34-0410-b5e6-96231b3b80d8
* Pad my commit stats by reducing indentation in this now separateEric Christopher2010-01-14
| | | | | | | commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93473 91177308-0d34-0410-b5e6-96231b3b80d8