1 //===- InlineCommon.h - Code common to all inliners -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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
15 //===----------------------------------------------------------------------===//
20 #define DEBUG_TYPE "inline"
21 #include "llvm/CallGraphSCCPass.h"
28 /// Inliner - This class contains all of the helper code which is used to
29 /// perform the inlining operations that does not depend on the policy.
31 struct Inliner : public CallGraphSCCPass {
34 // Main run interface method, this implements the interface required by the
36 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC);
38 // doFinalization - Remove now-dead linkonce functions at the end of
39 // processing to avoid breaking the SCC traversal.
40 virtual bool doFinalization(CallGraph &CG);
43 /// This method returns the value specified by the -inline-threshold value,
44 /// specified on the command line. This is typically not directly needed.
46 unsigned getInlineThreshold() const { return InlineThreshold; }
48 /// getInlineCost - This method must be implemented by the subclass to
49 /// determine the cost of inlining the specified call site. If the cost
50 /// returned is greater than the current inline threshold, the call site is
53 virtual int getInlineCost(CallSite CS) = 0;
55 /// getRecursiveInlineCost - This method can be implemented by subclasses if
56 /// it wants to treat calls to functions within the current SCC specially. If
57 /// this method is not overloaded, it just chains to getInlineCost().
59 virtual int getRecursiveInlineCost(CallSite CS);
62 // InlineThreshold - Cache the value here for easy access.
63 unsigned InlineThreshold;
66 } // End llvm namespace