summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-18 04:30:33 +0000
committerChris Lattner <sabre@nondot.org>2005-05-18 04:30:33 +0000
commit05deb04cb03990ac5c2c15c894b30699ef534ac7 (patch)
tree50e286c6c4df71e13a3315ca41a0a1785fb43f20 /llvm/lib/Transforms
parentadd85fc7f801cc18d6b5a43e87788ba949287d37 (diff)
downloadbcm5719-llvm-05deb04cb03990ac5c2c15c894b30699ef534ac7.tar.gz
bcm5719-llvm-05deb04cb03990ac5c2c15c894b30699ef534ac7.zip
teach the inliner about coldcc and noreturn functions
llvm-svn: 22113
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/InlineSimple.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index 4bbefa3aacb..0d579bc1ff3 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/lib/Transforms/IPO/InlineSimple.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "Inliner.h"
+#include "llvm/CallingConv.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Function.h"
@@ -196,6 +197,20 @@ int SimpleInliner::getInlineCost(CallSite CS) {
if (Callee->hasInternalLinkage() && Callee->hasOneUse())
InlineCost -= 30000;
+ // If this function uses the coldcc calling convention, prefer not to inline
+ // it.
+ if (Callee->getCallingConv() == CallingConv::Cold)
+ InlineCost += 2000;
+
+ // If the instruction after the call, or if the normal destination of the
+ // invoke is an unreachable instruction, the function is noreturn. As such,
+ // there is little point in inlining this.
+ if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
+ if (isa<UnreachableInst>(II->getNormalDest()->begin()))
+ InlineCost += 10000;
+ } else if (isa<UnreachableInst>(++BasicBlock::iterator(TheCall)))
+ InlineCost += 10000;
+
// Get information about the callee...
FunctionInfo &CalleeFI = CachedFunctionInfo[Callee];
OpenPOWER on IntegriCloud