LCOV - code coverage report
Current view: top level - include/llvm/Transforms/IPO - Inliner.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 3 3 100.0 %
Date: 2018-10-20 13:21:21 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- Inliner.h - Inliner pass and infrastructure --------------*- 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             : #ifndef LLVM_TRANSFORMS_IPO_INLINER_H
      11             : #define LLVM_TRANSFORMS_IPO_INLINER_H
      12             : 
      13             : #include "llvm/Analysis/CGSCCPassManager.h"
      14             : #include "llvm/Analysis/CallGraphSCCPass.h"
      15             : #include "llvm/Analysis/InlineCost.h"
      16             : #include "llvm/Analysis/LazyCallGraph.h"
      17             : #include "llvm/IR/CallSite.h"
      18             : #include "llvm/IR/PassManager.h"
      19             : #include "llvm/Transforms/Utils/ImportedFunctionsInliningStatistics.h"
      20             : #include <utility>
      21             : 
      22             : namespace llvm {
      23             : 
      24             : class AssumptionCacheTracker;
      25             : class CallGraph;
      26             : class ProfileSummaryInfo;
      27             : 
      28             : /// This class contains all of the helper code which is used to perform the
      29             : /// inlining operations that do not depend on the policy. It contains the core
      30             : /// bottom-up inlining infrastructure that specific inliner passes use.
      31             : struct LegacyInlinerBase : public CallGraphSCCPass {
      32             :   explicit LegacyInlinerBase(char &ID);
      33             :   explicit LegacyInlinerBase(char &ID, bool InsertLifetime);
      34             : 
      35             :   /// For this class, we declare that we require and preserve the call graph.
      36             :   /// If the derived class implements this method, it should always explicitly
      37             :   /// call the implementation here.
      38             :   void getAnalysisUsage(AnalysisUsage &Info) const override;
      39             : 
      40             :   bool doInitialization(CallGraph &CG) override;
      41             : 
      42             :   /// Main run interface method, this implements the interface required by the
      43             :   /// Pass class.
      44             :   bool runOnSCC(CallGraphSCC &SCC) override;
      45             : 
      46             :   using llvm::Pass::doFinalization;
      47             : 
      48             :   /// Remove now-dead linkonce functions at the end of processing to avoid
      49             :   /// breaking the SCC traversal.
      50             :   bool doFinalization(CallGraph &CG) override;
      51             : 
      52             :   /// This method must be implemented by the subclass to determine the cost of
      53             :   /// inlining the specified call site.  If the cost returned is greater than
      54             :   /// the current inline threshold, the call site is not inlined.
      55             :   virtual InlineCost getInlineCost(CallSite CS) = 0;
      56             : 
      57             :   /// Remove dead functions.
      58             :   ///
      59             :   /// This also includes a hack in the form of the 'AlwaysInlineOnly' flag
      60             :   /// which restricts it to deleting functions with an 'AlwaysInline'
      61             :   /// attribute. This is useful for the InlineAlways pass that only wants to
      62             :   /// deal with that subset of the functions.
      63             :   bool removeDeadFunctions(CallGraph &CG, bool AlwaysInlineOnly = false);
      64             : 
      65             :   /// This function performs the main work of the pass.  The default of
      66             :   /// Inlinter::runOnSCC() calls skipSCC() before calling this method, but
      67             :   /// derived classes which cannot be skipped can override that method and call
      68             :   /// this function unconditionally.
      69             :   bool inlineCalls(CallGraphSCC &SCC);
      70             : 
      71             : private:
      72             :   // Insert @llvm.lifetime intrinsics.
      73             :   bool InsertLifetime = true;
      74             : 
      75             : protected:
      76             :   AssumptionCacheTracker *ACT;
      77             :   ProfileSummaryInfo *PSI;
      78             :   ImportedFunctionsInliningStatistics ImportedFunctionsStats;
      79             : };
      80             : 
      81             : /// The inliner pass for the new pass manager.
      82             : ///
      83             : /// This pass wires together the inlining utilities and the inline cost
      84             : /// analysis into a CGSCC pass. It considers every call in every function in
      85             : /// the SCC and tries to inline if profitable. It can be tuned with a number of
      86             : /// parameters to control what cost model is used and what tradeoffs are made
      87             : /// when making the decision.
      88             : ///
      89             : /// It should be noted that the legacy inliners do considerably more than this
      90             : /// inliner pass does. They provide logic for manually merging allocas, and
      91             : /// doing considerable DCE including the DCE of dead functions. This pass makes
      92             : /// every attempt to be simpler. DCE of functions requires complex reasoning
      93             : /// about comdat groups, etc. Instead, it is expected that other more focused
      94             : /// passes be composed to achieve the same end result.
      95             : class InlinerPass : public PassInfoMixin<InlinerPass> {
      96             : public:
      97             :   InlinerPass(InlineParams Params = getInlineParams())
      98         200 :       : Params(std::move(Params)) {}
      99             :   ~InlinerPass();
     100             :   InlinerPass(InlinerPass &&Arg)
     101         417 :       : Params(std::move(Arg.Params)),
     102         417 :         ImportedFunctionsStats(std::move(Arg.ImportedFunctionsStats)) {}
     103             : 
     104             :   PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
     105             :                         LazyCallGraph &CG, CGSCCUpdateResult &UR);
     106             : 
     107             : private:
     108             :   InlineParams Params;
     109             :   std::unique_ptr<ImportedFunctionsInliningStatistics> ImportedFunctionsStats;
     110             : };
     111             : 
     112             : } // end namespace llvm
     113             : 
     114             : #endif // LLVM_TRANSFORMS_IPO_INLINER_H

Generated by: LCOV version 1.13