LLVM  8.0.1
Linker.h
Go to the documentation of this file.
1 //===- Linker.h - Module Linker Interface -----------------------*- 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_LINKER_LINKER_H
11 #define LLVM_LINKER_LINKER_H
12 
13 #include "llvm/ADT/StringSet.h"
14 #include "llvm/Linker/IRMover.h"
15 
16 namespace llvm {
17 class Module;
18 class StructType;
19 class Type;
20 
21 /// This class provides the core functionality of linking in LLVM. It keeps a
22 /// pointer to the merged module so far. It doesn't take ownership of the
23 /// module since it is assumed that the user of this class will want to do
24 /// something with it after the linking.
25 class Linker {
26  IRMover Mover;
27 
28 public:
29  enum Flags {
30  None = 0,
31  OverrideFromSrc = (1 << 0),
32  LinkOnlyNeeded = (1 << 1),
33  };
34 
35  Linker(Module &M);
36 
37  /// Link \p Src into the composite.
38  ///
39  /// Passing OverrideSymbols as true will have symbols from Src
40  /// shadow those in the Dest.
41  ///
42  /// Passing InternalizeCallback will have the linker call the function with
43  /// the new module and a list of global value names to be internalized by the
44  /// callback.
45  ///
46  /// Returns true on error.
47  bool linkInModule(std::unique_ptr<Module> Src, unsigned Flags = Flags::None,
48  std::function<void(Module &, const StringSet<> &)>
49  InternalizeCallback = {});
50 
51  static bool linkModules(Module &Dest, std::unique_ptr<Module> Src,
52  unsigned Flags = Flags::None,
53  std::function<void(Module &, const StringSet<> &)>
54  InternalizeCallback = {});
55 };
56 
57 } // End llvm namespace
58 
59 #endif
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:49
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
Linker(Module &M)
static bool linkModules(Module &Dest, std::unique_ptr< Module > Src, unsigned Flags=Flags::None, std::function< void(Module &, const StringSet<> &)> InternalizeCallback={})
This function links two modules together, with the resulting Dest module modified to be the composite...
This class provides the core functionality of linking in LLVM.
Definition: Linker.h:25
bool linkInModule(std::unique_ptr< Module > Src, unsigned Flags=Flags::None, std::function< void(Module &, const StringSet<> &)> InternalizeCallback={})
Link Src into the composite.
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:28
print Print MemDeps of function