summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO
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/IPO
parentfa7935fcb33436e200fd1e5aa99048ea227d2606 (diff)
downloadllvm-c5e1ec47c719806fcc882470595960512edc7441.tar.gz
llvm-c5e1ec47c719806fcc882470595960512edc7441.tar.bz2
llvm-c5e1ec47c719806fcc882470595960512edc7441.tar.xz
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/IPO')
-rw-r--r--lib/Transforms/IPO/InlineAlways.cpp2
-rw-r--r--lib/Transforms/IPO/InlineSimple.cpp2
-rw-r--r--lib/Transforms/IPO/Inliner.cpp15
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/InlineAlways.cpp b/lib/Transforms/IPO/InlineAlways.cpp
index 2799d6b22b..d809b5aed1 100644
--- a/lib/Transforms/IPO/InlineAlways.cpp
+++ b/lib/Transforms/IPO/InlineAlways.cpp
@@ -39,7 +39,7 @@ namespace {
// Use extremely low threshold.
AlwaysInliner() : Inliner(&ID, -2000000000) {}
static char ID; // Pass identification, replacement for typeid
- int getInlineCost(CallSite CS) {
+ InlineCost getInlineCost(CallSite CS) {
return CA.getInlineCost(CS, NeverInline);
}
float getInlineFudgeFactor(CallSite CS) {
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index 02cae2a6e6..8ae5235383 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -37,7 +37,7 @@ namespace {
SimpleInliner() : Inliner(&ID) {}
SimpleInliner(int Threshold) : Inliner(&ID, Threshold) {}
static char ID; // Pass identification, replacement for typeid
- int getInlineCost(CallSite CS) {
+ InlineCost getInlineCost(CallSite CS) {
return CA.getInlineCost(CS, NeverInline);
}
float getInlineFudgeFactor(CallSite CS) {
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index 74af18396d..2321047a37 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -76,9 +76,22 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
/// shouldInline - Return true if the inliner should attempt to inline
/// at the given CallSite.
bool Inliner::shouldInline(CallSite CS) {
- int Cost = getInlineCost(CS);
+ InlineCost IC = getInlineCost(CS);
float FudgeFactor = getInlineFudgeFactor(CS);
+ if (IC.isAlways()) {
+ DOUT << " Inlining: cost=always"
+ << ", Call: " << *CS.getInstruction();
+ return true;
+ }
+
+ if (IC.isNever()) {
+ DOUT << " NOT Inlining: cost=never"
+ << ", Call: " << *CS.getInstruction();
+ return false;
+ }
+
+ int Cost = IC.getValue();
int CurrentThreshold = InlineThreshold;
Function *Fn = CS.getCaller();
if (Fn && !Fn->isDeclaration()