1 //===- InlinerPass.h - Code common to all inliners --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // 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 #include "llvm/CallGraphSCCPass.h"
21 #include "llvm/Transforms/Utils/InlineCost.h"
26 /// Inliner - This class contains all of the helper code which is used to
27 /// perform the inlining operations that do not depend on the policy.
29 struct Inliner : public CallGraphSCCPass {
30 explicit Inliner(void *ID);
31 explicit Inliner(void *ID, int Threshold);
33 /// getAnalysisUsage - For this class, we declare that we require and preserve
34 /// the call graph. If the derived class implements this method, it should
35 /// always explicitly call the implementation here.
36 virtual void getAnalysisUsage(AnalysisUsage &Info) const;
38 // Main run interface method, this implements the interface required by the
40 virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC);
42 // doFinalization - Remove now-dead linkonce functions at the end of
43 // processing to avoid breaking the SCC traversal.
44 virtual bool doFinalization(CallGraph &CG);
47 /// This method returns the value specified by the -inline-threshold value,
48 /// specified on the command line. This is typically not directly needed.
50 unsigned getInlineThreshold() const { return InlineThreshold; }
52 /// getInlineCost - This method must be implemented by the subclass to
53 /// determine the cost of inlining the specified call site. If the cost
54 /// returned is greater than the current inline threshold, the call site is
57 virtual InlineCost getInlineCost(CallSite CS) = 0;
59 // getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a
60 // higher threshold to determine if the function call should be inlined.
62 virtual float getInlineFudgeFactor(CallSite CS) = 0;
65 // InlineThreshold - Cache the value here for easy access.
66 unsigned InlineThreshold;
68 /// shouldInline - Return true if the inliner should attempt to
69 /// inline at the given CallSite.
70 bool shouldInline(CallSite CS);
73 } // End llvm namespace