1 //===- llvm/Transforms/IPO/FunctionImport.h - ThinLTO importing -*- 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 #ifndef LLVM_FUNCTIONIMPORT_H
11 #define LLVM_FUNCTIONIMPORT_H
13 #include "llvm/IR/DiagnosticInfo.h"
14 #include "llvm/ADT/StringMap.h"
19 class FunctionInfoIndex;
21 /// The function importer is automatically importing function from other modules
22 /// based on the provided summary informations.
23 class FunctionImporter {
25 /// The summaries index used to trigger importing.
26 const FunctionInfoIndex &Index;
28 /// Diagnostic will be sent to this handler.
29 DiagnosticHandlerFunction DiagnosticHandler;
31 /// Factory function to load a Module for a given identifier
32 std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader;
35 /// Create a Function Importer.
37 const FunctionInfoIndex &Index,
38 DiagnosticHandlerFunction DiagnosticHandler,
39 std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader)
40 : Index(Index), DiagnosticHandler(DiagnosticHandler),
41 ModuleLoader(ModuleLoader) {}
43 /// Import functions in Module \p M based on the summary informations.
44 bool importFunctions(Module &M);
48 #endif // LLVM_FUNCTIONIMPORT_H