[llvm-commits] CVS: llvm/lib/Transforms/IPO/InlineSimple.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue May 17 21:30:52 PDT 2005



Changes in directory llvm/lib/Transforms/IPO:

InlineSimple.cpp updated: 1.70 -> 1.71
---
Log message:

teach the inliner about coldcc and noreturn functions


---
Diffs of the changes:  (+15 -0)

 InlineSimple.cpp |   15 +++++++++++++++
 1 files changed, 15 insertions(+)


Index: llvm/lib/Transforms/IPO/InlineSimple.cpp
diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.70 llvm/lib/Transforms/IPO/InlineSimple.cpp:1.71
--- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.70	Thu Apr 21 18:39:37 2005
+++ llvm/lib/Transforms/IPO/InlineSimple.cpp	Tue May 17 23:30:33 2005
@@ -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 @@
   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];
 






More information about the llvm-commits mailing list