[llvm-commits] [llvm] r82660 - /llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
Evan Cheng
evan.cheng at apple.com
Wed Sep 23 22:35:41 PDT 2009
On Sep 23, 2009, at 10:32 PM, Chris Lattner wrote:
>
> On Sep 23, 2009, at 3:05 PM, Dale Johannesen wrote:
>
>> Author: johannes
>> Date: Wed Sep 23 17:05:24 2009
>> New Revision: 82660
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=82660&view=rev
>> Log:
>> A minor improvment in accuracy to inline cost
>> computation, and some cosmetics.
>
> Am I missing something here? It looks like you compute NumRets but
> don't use it for anything...
It's used:
> + // A function with exactly one return has it removed during the
> inlining
> + // process (see InlineFunction), so don't count it.
> + if (NumRets==1)
> + --NumInsts;
Evan
>
> -Chris
>
>>
>>
>> Modified:
>> llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
>>
>> Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=82660&r1=82659&r2=82660&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Wed Sep 23
>> 17:05:24 2009
>> @@ -104,7 +104,7 @@
>> /// analyzeFunction - Fill in the current structure with information
>> gleaned
>> /// from the specified function.
>> void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) {
>> - unsigned NumInsts = 0, NumBlocks = 0, NumVectorInsts = 0;
>> + unsigned NumInsts = 0, NumBlocks = 0, NumVectorInsts = 0, NumRets
>> = 0;
>>
>> // Look at the size of the callee. Each basic block counts as 20
>> units, and
>> // each instruction counts as 5.
>> @@ -157,6 +157,9 @@
>> if (GEPI->hasAllConstantIndices())
>> continue;
>> }
>> +
>> + if (isa<ReturnInst>(II))
>> + ++NumRets;
>>
>> ++NumInsts;
>> }
>> @@ -164,6 +167,11 @@
>> ++NumBlocks;
>> }
>>
>> + // A function with exactly one return has it removed during the
>> inlining
>> + // process (see InlineFunction), so don't count it.
>> + if (NumRets==1)
>> + --NumInsts;
>> +
>> this->NumBlocks = NumBlocks;
>> this->NumInsts = NumInsts;
>> this->NumVectorInsts = NumVectorInsts;
>> @@ -186,11 +194,10 @@
>> Function *Callee = CS.getCalledFunction();
>> Function *Caller = TheCall->getParent()->getParent();
>>
>> - // Don't inline functions which can be redefined at link-time
>> to mean
>> - // something else.
>> - if (Callee->mayBeOverridden() ||
>> - // Don't inline functions marked noinline.
>> - Callee->hasFnAttr(Attribute::NoInline) || NeverInline.count
>> (Callee))
>> + // Don't inline functions which can be redefined at link-time to
>> mean
>> + // something else. Don't inline functions marked noinline.
>> + if (Callee->mayBeOverridden() ||
>> + Callee->hasFnAttr(Attribute::NoInline) || NeverInline.count
>> (Callee))
>> return llvm::InlineCost::getNever();
>>
>> // InlineCost - This value measures how good of an inline
>> candidate this call
>> @@ -291,6 +298,7 @@
>> // likely to be inlined, look at factors that make us not want to
>> inline it.
>>
>> // Don't inline into something too big, which would make it bigger.
>> + // "size" here is the number of basic blocks, not instructions.
>> //
>> InlineCost += Caller->size()/15;
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> 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