InlinerPass.h revision ae73dc1448d25b02cabc7c64c86c64371453dda8
1//===- InlinerPass.h - Code common to all inliners --------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines a simple policy-based bottom-up inliner. This file 11// implements all of the boring mechanics of the bottom-up inlining, while the 12// subclass determines WHAT to inline, which is the much more interesting 13// component. 14// 15//===----------------------------------------------------------------------===// 16 17#ifndef INLINER_H 18#define INLINER_H 19 20#include "llvm/CallGraphSCCPass.h" 21 22namespace llvm { 23 class CallSite; 24 25/// Inliner - This class contains all of the helper code which is used to 26/// perform the inlining operations that does not depend on the policy. 27/// 28struct Inliner : public CallGraphSCCPass { 29 explicit Inliner(void *ID); 30 explicit Inliner(void *ID, int Threshold); 31 32 /// getAnalysisUsage - For this class, we declare that we require and preserve 33 /// the call graph. If the derived class implements this method, it should 34 /// always explicitly call the implementation here. 35 virtual void getAnalysisUsage(AnalysisUsage &Info) const; 36 37 // Main run interface method, this implements the interface required by the 38 // Pass class. 39 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC); 40 41 // doFinalization - Remove now-dead linkonce functions at the end of 42 // processing to avoid breaking the SCC traversal. 43 virtual bool doFinalization(CallGraph &CG); 44 45 46 /// This method returns the value specified by the -inline-threshold value, 47 /// specified on the command line. This is typically not directly needed. 48 /// 49 unsigned getInlineThreshold() const { return InlineThreshold; } 50 51 /// getInlineCost - This method must be implemented by the subclass to 52 /// determine the cost of inlining the specified call site. If the cost 53 /// returned is greater than the current inline threshold, the call site is 54 /// not inlined. 55 /// 56 virtual int getInlineCost(CallSite CS) = 0; 57 58 // getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a 59 // higher threshold to determine if the function call should be inlined. 60 /// 61 virtual float getInlineFudgeFactor(CallSite CS) = 0; 62 63private: 64 // InlineThreshold - Cache the value here for easy access. 65 unsigned InlineThreshold; 66}; 67 68} // End llvm namespace 69 70#endif 71