aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Analysis/InlineCost.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-01-26 23:21:56 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-01-26 23:21:56 +0000
commit43cda021d9425f53443b3d56bcf81afe99353ee9 (patch)
tree4a63fa4bff7ce01f0fbe2b1f34b2fba25db053b6 /include/llvm/Analysis/InlineCost.h
parentb11caedd6f36afc6518cf0ea9bbff6500fd77334 (diff)
downloadexternal_llvm-43cda021d9425f53443b3d56bcf81afe99353ee9.zip
external_llvm-43cda021d9425f53443b3d56bcf81afe99353ee9.tar.gz
external_llvm-43cda021d9425f53443b3d56bcf81afe99353ee9.tar.bz2
Fix inline cost predictions with SCIENCE.
After running a batch of measurements, it is clear that the inliner metrics need some adjustments: Own argument bonus: 20 -> 5 Outgoing argument penalty: 0 -> 5 Alloca bonus: 10 -> 5 Constant instr bonus: 7 -> 5 Dead successor bonus: 40 -> 5*(avg instrs/block) The new cost metrics are generaly 25 points higher than before, so we may need to move thresholds. With this change, InlineConstants::CallPenalty becomes a political correction: if (!isa<IntrinsicInst>(II) && !callIsSmall(CS.getCalledFunction())) NumInsts += InlineConstants::CallPenalty + CS.arg_size(); The code size is accurately modelled by CS.arg_size(). CallPenalty is added because calls tend to take a long time, so it may not be worth it to inline a function with lots of calls. All of the political corrections are in the InlineConstants namespace: IndirectCallBonus, CallPenalty, LastCallToStaticBonus, ColdccPenalty, NoreturnPenalty. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/InlineCost.h')
-rw-r--r--include/llvm/Analysis/InlineCost.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/llvm/Analysis/InlineCost.h b/include/llvm/Analysis/InlineCost.h
index 7ce49d7..2d5142c 100644
--- a/include/llvm/Analysis/InlineCost.h
+++ b/include/llvm/Analysis/InlineCost.h
@@ -64,7 +64,9 @@ namespace llvm {
namespace InlineConstants {
// Various magic constants used to adjust heuristics.
- const int CallPenalty = 5;
+ const int InstrCost = 5;
+ const int IndirectCallBonus = 500;
+ const int CallPenalty = 5; // In instrs, so multiply by InstrCost.
const int LastCallToStaticBonus = -15000;
const int ColdccPenalty = 2000;
const int NoreturnPenalty = 10000;