diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-05 23:21:18 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-05 23:21:18 +0000 |
| commit | b0b2297066e2fa918474e911b1c76466327da9bb (patch) | |
| tree | 817eadbfc58e4c420ef83440e12987c884287f8c /llvm/lib/Analysis | |
| parent | d4be4ced766f8456ee70c7ff645c4be986525c60 (diff) | |
| download | bcm5719-llvm-b0b2297066e2fa918474e911b1c76466327da9bb.tar.gz bcm5719-llvm-b0b2297066e2fa918474e911b1c76466327da9bb.zip | |
Update CodeMetrics to count 'big' function calls explicitly.
llvm-svn: 95453
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index f74d712576e..972d0349fd0 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/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. // |

