Home | History | Annotate | Download | only in IPO
      1 //===- llvm/Transforms/IPO/FunctionImport.h - ThinLTO importing -*- 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_FUNCTIONIMPORT_H
     11 #define LLVM_FUNCTIONIMPORT_H
     12 
     13 #include "llvm/ADT/StringMap.h"
     14 #include <functional>
     15 
     16 namespace llvm {
     17 class LLVMContext;
     18 class Module;
     19 class FunctionInfoIndex;
     20 
     21 /// The function importer is automatically importing function from other modules
     22 /// based on the provided summary informations.
     23 class FunctionImporter {
     24 
     25   /// The summaries index used to trigger importing.
     26   const FunctionInfoIndex &Index;
     27 
     28   /// Factory function to load a Module for a given identifier
     29   std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader;
     30 
     31 public:
     32   /// Create a Function Importer.
     33   FunctionImporter(
     34       const FunctionInfoIndex &Index,
     35       std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader)
     36       : Index(Index), ModuleLoader(ModuleLoader) {}
     37 
     38   /// Import functions in Module \p M based on the summary informations.
     39   bool importFunctions(Module &M);
     40 };
     41 }
     42 
     43 #endif // LLVM_FUNCTIONIMPORT_H
     44