Use diagnostic handler in the LLVMContext
[oota-llvm.git] / include / llvm / Transforms / IPO / FunctionImport.h
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
15 namespace llvm {
16 class LLVMContext;
17 class Module;
18 class FunctionInfoIndex;
19
20 /// The function importer is automatically importing function from other modules
21 /// based on the provided summary informations.
22 class FunctionImporter {
23
24   /// The summaries index used to trigger importing.
25   const FunctionInfoIndex &Index;
26
27   /// Factory function to load a Module for a given identifier
28   std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader;
29
30 public:
31   /// Create a Function Importer.
32   FunctionImporter(
33       const FunctionInfoIndex &Index,
34       std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader)
35       : Index(Index), ModuleLoader(ModuleLoader) {}
36
37   /// Import functions in Module \p M based on the summary informations.
38   bool importFunctions(Module &M);
39 };
40 }
41
42 #endif // LLVM_FUNCTIONIMPORT_H