aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/BasicInliner.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-10-30 19:26:59 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-10-30 19:26:59 +0000
commitc5e1ec47c719806fcc882470595960512edc7441 (patch)
tree41553d08ff1c9b421dd3f34977eb7403ba0d4bad /lib/Transforms/Utils/BasicInliner.cpp
parentfa7935fcb33436e200fd1e5aa99048ea227d2606 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58450 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/BasicInliner.cpp')
-rw-r--r--lib/Transforms/Utils/BasicInliner.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/Transforms/Utils/BasicInliner.cpp b/lib/Transforms/Utils/BasicInliner.cpp
index ba1fb3d9c4..73e8bd8467 100644
--- a/lib/Transforms/Utils/BasicInliner.cpp
+++ b/lib/Transforms/Utils/BasicInliner.cpp
@@ -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())