summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/include/llvm/Transforms/IPO/FunctionImport.h
blob: d7707790a017909a66af1aaca496d6c7916556e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//===- llvm/Transforms/IPO/FunctionImport.h - ThinLTO importing -*- C++ -*-===//
//
//                      The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_FUNCTIONIMPORT_H
#define LLVM_FUNCTIONIMPORT_H

#include "llvm/ADT/StringMap.h"
#include <functional>

namespace llvm {
class LLVMContext;
class Module;
class FunctionInfoIndex;

/// The function importer is automatically importing function from other modules
/// based on the provided summary informations.
class FunctionImporter {

  /// The summaries index used to trigger importing.
  const FunctionInfoIndex &Index;

  /// Factory function to load a Module for a given identifier
  std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader;

public:
  /// Create a Function Importer.
  FunctionImporter(
      const FunctionInfoIndex &Index,
      std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader)
      : Index(Index), ModuleLoader(ModuleLoader) {}

  /// Import functions in Module \p M based on the summary informations.
  bool importFunctions(Module &M);
};
}

#endif // LLVM_FUNCTIONIMPORT_H
OpenPOWER on IntegriCloud