Reintroduce InlineCostAnalyzer::getInlineCost() variant with explicit callee
authorDavid Chisnall <csdavec@swan.ac.uk>
Fri, 6 Apr 2012 17:27:41 +0000 (17:27 +0000)
committerDavid Chisnall <csdavec@swan.ac.uk>
Fri, 6 Apr 2012 17:27:41 +0000 (17:27 +0000)
parameter until we have a more sensible API for doing the same thing.

Reviewed by Chandler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154180 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/InlineCost.h
lib/Analysis/InlineCost.cpp

index f5784a751c09b6de3f7adc4d1b9a596c59069de6..691c2d19be9a5ab42b96978173a1107d6259c3f2 100644 (file)
@@ -117,6 +117,15 @@ namespace llvm {
     /// bound the computation necessary to determine whether the cost is
     /// sufficiently low to warrant inlining.
     InlineCost getInlineCost(CallSite CS, int Threshold);
+    /// getCalledFunction - The heuristic used to determine if we should inline
+    /// the function call or not.  The callee is explicitly specified, to allow
+    /// you to calculate the cost of inlining a function via a pointer.  This
+    /// behaves exactly as the version with no explicit callee parameter in all
+    /// other respects.
+    //
+    //  Note: This is used by out-of-tree passes, please do not remove without
+    //  adding a replacement API.
+    InlineCost getInlineCost(CallSite CS, Function *Callee, int Threshold);
   };
 
   /// callIsSmall - If a call is likely to lower to a single target instruction,
index 246e679b21d2328927d83291d48f8736d9a92afa..c4599c805d6b77a6ebb229e5987c176f2d66d9b0 100644 (file)
@@ -988,8 +988,11 @@ void CallAnalyzer::dump() {
 }
 
 InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, int Threshold) {
-  Function *Callee = CS.getCalledFunction();
+  return getInlineCost(CS, CS.getCalledFunction(), Threshold);
+}
 
+InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, Function *Callee,
+                                             int Threshold) {
   // Don't inline functions which can be redefined at link-time to mean
   // something else.  Don't inline functions marked noinline or call sites
   // marked noinline.