summaryrefslogtreecommitdiff
path: root/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-02-05 23:21:18 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-02-05 23:21:18 +0000
commitaa034fa2299e41b73f60d3993f5460260e239fab (patch)
treeae87e0e118529edfdf2ea353622b91e82367e5bb /lib/Analysis/InlineCost.cpp
parent6cda22eae404e25944dc29c59e9fc239e8c1891c (diff)
downloadllvm-aa034fa2299e41b73f60d3993f5460260e239fab.tar.gz
llvm-aa034fa2299e41b73f60d3993f5460260e239fab.tar.bz2
llvm-aa034fa2299e41b73f60d3993f5460260e239fab.tar.xz
Update CodeMetrics to count 'big' function calls explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95453 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InlineCost.cpp')
-rw-r--r--lib/Analysis/InlineCost.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Analysis/InlineCost.cpp b/lib/Analysis/InlineCost.cpp
index f74d712576..972d0349fd 100644
--- a/lib/Analysis/InlineCost.cpp
+++ b/lib/Analysis/InlineCost.cpp
@@ -163,10 +163,11 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) {
(F->getName() == "setjmp" || F->getName() == "_setjmp"))
NeverInline = true;
- // Each argument to a call takes on average one instruction to set up.
- // Add an extra penalty because calls can take a long time to execute.
- if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction()))
- NumInsts += InlineConstants::CallPenalty + CS.arg_size();
+ if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction())) {
+ // Each argument to a call takes on average one instruction to set up.
+ NumInsts += CS.arg_size();
+ ++NumCalls;
+ }
}
if (const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
@@ -347,7 +348,10 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
// Now that we have considered all of the factors that make the call site more
// likely to be inlined, look at factors that make us not want to inline it.
-
+
+ // Calls usually take a long time, so they make the inlining gain smaller.
+ InlineCost += CalleeFI.Metrics.NumCalls * InlineConstants::CallPenalty;
+
// Don't inline into something too big, which would make it bigger.
// "size" here is the number of basic blocks, not instructions.
//