[llvm-commits] [llvm] r102841 - in /llvm/trunk: include/llvm/Analysis/InlineCost.h lib/Analysis/InlineCost.cpp
Chris Lattner
clattner at apple.com
Sat May 1 10:23:44 PDT 2010
On May 1, 2010, at 8:47 AM, David Chisnall wrote:
> Author: theraven
> Date: Sat May 1 10:47:41 2010
> New Revision: 102841
>
> URL: http://llvm.org/viewvc/llvm-project?rev=102841&view=rev
> Log:
> Added a variant of InlineCostAnalyzer::getInlineCost() that takes the called function as an explicit argument, for use when inlining function pointers.
Looks good, thanks.
-Chris
>
>
> Modified:
> llvm/trunk/include/llvm/Analysis/InlineCost.h
> llvm/trunk/lib/Analysis/InlineCost.cpp
>
> Modified: llvm/trunk/include/llvm/Analysis/InlineCost.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InlineCost.h?rev=102841&r1=102840&r2=102841&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Analysis/InlineCost.h (original)
> +++ llvm/trunk/include/llvm/Analysis/InlineCost.h Sat May 1 10:47:41 2010
> @@ -176,6 +176,14 @@
> ///
> InlineCost getInlineCost(CallSite CS,
> SmallPtrSet<const Function *, 16> &NeverInline);
> + /// getCalledFunction - The heuristic used to determine if we should inline
> + /// the function call or not. The callee is explicitly specified, to allow
> + /// you to calculate the cost of inlining a function via a pointer. The
> + /// result assumes that the inlined version will always be used. You should
> + /// weight it yourself in cases where this callee will not always be called.
> + InlineCost getInlineCost(CallSite CS,
> + Function *Callee,
> + SmallPtrSet<const Function *, 16> &NeverInline);
>
> /// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a
> /// higher threshold to determine if the function call should be inlined.
>
> Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=102841&r1=102840&r2=102841&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
> +++ llvm/trunk/lib/Analysis/InlineCost.cpp Sat May 1 10:47:41 2010
> @@ -259,9 +259,15 @@
> //
> InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
> SmallPtrSet<const Function*, 16> &NeverInline) {
> + return getInlineCost(CS, CS.getCalledFunction(), NeverInline);
> +}
> +
> +InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
> + Function *Callee,
> + SmallPtrSet<const Function*, 16> &NeverInline) {
> Instruction *TheCall = CS.getInstruction();
> - Function *Callee = CS.getCalledFunction();
> Function *Caller = TheCall->getParent()->getParent();
> + bool isDirectCall = CS.getCalledFunction() == Callee;
>
> // Don't inline functions which can be redefined at link-time to mean
> // something else. Don't inline functions marked noinline or call sites
> @@ -276,11 +282,11 @@
> // be inlined. This value may go negative.
> //
> int InlineCost = 0;
> -
> +
> // If there is only one call of the function, and it has internal linkage,
> // make it almost guaranteed to be inlined.
> //
> - if (Callee->hasLocalLinkage() && Callee->hasOneUse())
> + if (Callee->hasLocalLinkage() && Callee->hasOneUse() && isDirectCall)
> InlineCost += InlineConstants::LastCallToStaticBonus;
>
> // If this function uses the coldcc calling convention, prefer not to inline
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list