summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/InlineCost.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-09-23 22:05:24 +0000
committerDale Johannesen <dalej@apple.com>2009-09-23 22:05:24 +0000
commitfb1b55bc9c41e843c3c96df5a25a2ee0112a8e95 (patch)
tree5900cb6174e629cdef69b2d62031c5f37895e0c8 /llvm/lib/Transforms/Utils/InlineCost.cpp
parentea406ed0a66729a4b63ee410a160de73d5f33521 (diff)
downloadbcm5719-llvm-fb1b55bc9c41e843c3c96df5a25a2ee0112a8e95.tar.gz
bcm5719-llvm-fb1b55bc9c41e843c3c96df5a25a2ee0112a8e95.zip
A minor improvment in accuracy to inline cost
computation, and some cosmetics. llvm-svn: 82660
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineCost.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineCost.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineCost.cpp b/llvm/lib/Transforms/Utils/InlineCost.cpp
index 7bf23661587..0eeec8cf371 100644
--- a/llvm/lib/Transforms/Utils/InlineCost.cpp
+++ b/llvm/lib/Transforms/Utils/InlineCost.cpp
@@ -104,7 +104,7 @@ unsigned InlineCostAnalyzer::FunctionInfo::
/// 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 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) {
if (GEPI->hasAllConstantIndices())
continue;
}
+
+ if (isa<ReturnInst>(II))
+ ++NumRets;
++NumInsts;
}
@@ -164,6 +167,11 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) {
++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 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
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 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
// 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;
OpenPOWER on IntegriCloud