X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FAnalysis%2FInlineCost.h;h=cac7cfe2455e943649aa90ac5fe0f23d1dd564de;hb=9a1581b9102511282ee823ab9a29819bc060e6a5;hp=84acd7d5fee979f29a6796873432cc2ceac1edd6;hpb=b5a158bab81b0b3f15d409fc433e706f8e885375;p=oota-llvm.git diff --git a/include/llvm/Analysis/InlineCost.h b/include/llvm/Analysis/InlineCost.h index 84acd7d5fee..cac7cfe2455 100644 --- a/include/llvm/Analysis/InlineCost.h +++ b/include/llvm/Analysis/InlineCost.h @@ -1,4 +1,4 @@ -//===- InlineCost.cpp - Cost analysis for inliner ---------------*- C++ -*-===// +//===- InlineCost.h - Cost analysis for inliner -----------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,8 +16,9 @@ #include #include -#include #include +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/ValueMap.h" namespace llvm { @@ -42,6 +43,9 @@ namespace llvm { /// is used to estimate the code size cost of inlining it. unsigned NumInsts, NumBlocks; + /// NumBBInsts - Keeps track of basic block code size estimates. + DenseMap NumBBInsts; + /// NumCalls - Keep track of the number of calls to 'big' functions. unsigned NumCalls; @@ -161,7 +165,9 @@ namespace llvm { void analyzeFunction(Function *F); }; - std::map CachedFunctionInfo; + // The Function* for a function can be changed (by ArgumentPromotion); + // the ValueMap will update itself when this happens. + ValueMap CachedFunctionInfo; public: @@ -170,6 +176,14 @@ namespace llvm { /// InlineCost getInlineCost(CallSite CS, SmallPtrSet &NeverInline); + /// 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. The + /// result assumes that the inlined version will always be used. You should + /// weight it yourself in cases where this callee will not always be called. + InlineCost getInlineCost(CallSite CS, + Function *Callee, + SmallPtrSet &NeverInline); /// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a /// higher threshold to determine if the function call should be inlined. @@ -179,7 +193,19 @@ namespace llvm { void resetCachedCostInfo(Function* Caller) { CachedFunctionInfo[Caller] = FunctionInfo(); } + + /// growCachedCostInfo - update the cached cost info for Caller after Callee + /// has been inlined. If Callee is NULL it means a dead call has been + /// eliminated. + void growCachedCostInfo(Function* Caller, Function* Callee); + + /// clear - empty the cache of inline costs + void clear(); }; + + /// callIsSmall - If a call is likely to lower to a single target instruction, + /// or is otherwise deemed small return true. + bool callIsSmall(const Function *Callee); } #endif