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 /// Cache of lazily loaded module for import.
26 StringMap<std::unique_ptr<Module>> ModuleMap;
28 /// The context that will be used for importing.
31 /// The summaries index used to trigger importing.
32 const FunctionInfoIndex &Index;
34 /// Diagnostic will be sent to this handler.
35 DiagnosticHandlerFunction DiagnosticHandler;
37 /// Retrieve a Module from the cache or lazily load it on demand.
38 Module &getOrLoadModule(StringRef FileName);
41 /// Create a Function Importer.
42 FunctionImporter(LLVMContext &Context, const FunctionInfoIndex &Index,
43 DiagnosticHandlerFunction DiagnosticHandler)
44 : Context(Context), Index(Index), DiagnosticHandler(DiagnosticHandler) {}
46 /// Import functions in Module \p M based on the summary informations.
47 bool importFunctions(Module &M);
51 #endif // LLVM_FUNCTIONIMPORT_H