[llvm-commits] [llvm] r124044 - /llvm/trunk/lib/Analysis/InlineCost.cpp

Nick Lewycky nicholas at mxc.ca
Sat Jan 22 13:32:46 PST 2011


On 01/22/2011 01:17 PM, Eric Christopher wrote:
> Author: echristo
> Date: Sat Jan 22 15:17:33 2011
> New Revision: 124044
>
> URL: http://llvm.org/viewvc/llvm-project?rev=124044&view=rev
> Log:
> Only apply the devirtualization bonus once instead of per-call site in the
> target function.

Hi Eric, I'm curious about this change. Surely it's better to 
devirtualize a function with 100 indirect calls in a row than one that 
has one, right? Could you tell me a bit about what's motivating this?

Nick

>
> Fixes part of rdar://8546196
>
> Modified:
>      llvm/trunk/lib/Analysis/InlineCost.cpp
>
> Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=124044&r1=124043&r2=124044&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
> +++ llvm/trunk/lib/Analysis/InlineCost.cpp Sat Jan 22 15:17:33 2011
> @@ -146,17 +146,18 @@
>   // performance boost we can expect if the specified value is constant.
>   unsigned CodeMetrics::CountBonusForConstant(Value *V) {
>     unsigned Bonus = 0;
> +  bool indirectCallBonus = false;
>     for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){
>       User *U = *UI;
>       if (CallInst *CI = dyn_cast<CallInst>(U)) {
>         // Turning an indirect call into a direct call is a BIG win
>         if (CI->getCalledValue() == V)
> -        Bonus += InlineConstants::IndirectCallBonus;
> +        indirectCallBonus = true;
>       }
>       else if (InvokeInst *II = dyn_cast<InvokeInst>(U)) {
>         // Turning an indirect call into a direct call is a BIG win
>         if (II->getCalledValue() == V)
> -        Bonus += InlineConstants::IndirectCallBonus;
> +        indirectCallBonus = true;
>       }
>       // FIXME: Eliminating conditional branches and switches should
>       // also yield a per-call performance boost.
> @@ -187,6 +188,9 @@
>           Bonus += CountBonusForConstant(&Inst);
>       }
>     }
> +
> +  if (indirectCallBonus) Bonus += InlineConstants::IndirectCallBonus;
> +
>     return Bonus;
>   }
>
>
>
> _______________________________________________
> 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