Add InlineCost class for represent the estimated cost of inlining a

function.
 - This explicitly models the costs for functions which should
   "always" or "never" be inlined. This fixes bugs where such costs
   were not previously respected.

llvm-svn: 58450
This commit is contained in:
Daniel Dunbar
2008-10-30 19:26:59 +00:00
parent 0852f48d1d
commit 3933e66a89
8 changed files with 97 additions and 18 deletions

View File

@@ -107,16 +107,27 @@ void BasicInlinerImpl::inlineFunctions() {
--index;
continue;
}
int InlineCost = CA.getInlineCost(CS, NeverInline);
if (InlineCost >= (int) BasicInlineThreshold) {
DOUT << " NOT Inlining: cost = " << InlineCost
<< ", call: " << *CS.getInstruction();
InlineCost IC = CA.getInlineCost(CS, NeverInline);
if (IC.isAlways()) {
DOUT << " Inlining: cost=always"
<<", call: " << *CS.getInstruction();
} else if (IC.isNever()) {
DOUT << " NOT Inlining: cost=never"
<<", call: " << *CS.getInstruction();
continue;
} else {
int Cost = IC.getValue();
if (Cost >= BasicInlineThreshold) {
DOUT << " NOT Inlining: cost = " << Cost
<< ", call: " << *CS.getInstruction();
continue;
} else {
DOUT << " Inlining: cost = " << Cost
<< ", call: " << *CS.getInstruction();
}
}
DOUT << " Inlining: cost=" << InlineCost
<<", call: " << *CS.getInstruction();
// Inline
if (InlineFunction(CS, NULL, TD)) {
if (Callee->use_empty() && Callee->hasInternalLinkage())