1 //===- InlineCommon.h - Code common to all inliners -------------*- C++ -*-===//
3 // This file defines a simple policy-based bottom-up inliner. This file
4 // implements all of the boring mechanics of the bottom-up inlining, while the
5 // subclass determines WHAT to inline, which is the much more interesting
8 //===----------------------------------------------------------------------===//
13 #define DEBUG_TYPE "inline"
14 #include "llvm/CallGraphSCCPass.h"
18 /// Inliner - This class contains all of the helper code which is used to
19 /// perform the inlining operations that does not depend on the policy.
21 struct Inliner : public CallGraphSCCPass {
24 // Main run interface method, this implements the interface required by the
26 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC);
28 /// This method returns the value specified by the -inline-threshold value,
29 /// specified on the command line. This is typically not directly needed.
31 unsigned getInlineThreshold() const { return InlineThreshold; }
33 /// getInlineCost - This method must be implemented by the subclass to
34 /// determine the cost of inlining the specified call site. If the cost
35 /// returned is greater than the current inline threshold, the call site is
38 virtual int getInlineCost(CallSite CS) = 0;
40 /// getRecursiveInlineCost - This method can be implemented by subclasses if
41 /// it wants to treat calls to functions within the current SCC specially. If
42 /// this method is not overloaded, it just chains to getInlineCost().
44 virtual int getRecursiveInlineCost(CallSite CS);
47 unsigned InlineThreshold;
48 bool performInlining(CallSite CS, std::set<Function*> &SCC);