diff options
author | Chris Lattner <sabre@nondot.org> | 2005-05-18 04:30:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-05-18 04:30:33 +0000 |
commit | 49fbff45685c21d7f42aca7a104fc841cdbd5d43 (patch) | |
tree | 8ef63634a48b7eab1ac8bd407a03112b629a74d7 | |
parent | b6f4afbc562b5ec9b6314f6ed5309430555af7e3 (diff) | |
download | external_llvm-49fbff45685c21d7f42aca7a104fc841cdbd5d43.zip external_llvm-49fbff45685c21d7f42aca7a104fc841cdbd5d43.tar.gz external_llvm-49fbff45685c21d7f42aca7a104fc841cdbd5d43.tar.bz2 |
teach the inliner about coldcc and noreturn functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22113 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 4bbefa3..0d579bc 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/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]; |