LLVM  14.0.0git
Linker.h
Go to the documentation of this file.
1 //===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LINKER_LINKER_H
10 #define LLVM_LINKER_LINKER_H
11 
12 #include "llvm/ADT/StringSet.h"
13 #include "llvm/Linker/IRMover.h"
14 
15 namespace llvm {
16 class Module;
17 class StructType;
18 class Type;
19 
20 /// This class provides the core functionality of linking in LLVM. It keeps a
21 /// pointer to the merged module so far. It doesn't take ownership of the
22 /// module since it is assumed that the user of this class will want to do
23 /// something with it after the linking.
24 class Linker {
25  IRMover Mover;
26 
27 public:
28  enum Flags {
29  None = 0,
30  OverrideFromSrc = (1 << 0),
31  LinkOnlyNeeded = (1 << 1),
32  };
33 
34  Linker(Module &M);
35 
36  /// Link \p Src into the composite.
37  ///
38  /// Passing OverrideSymbols as true will have symbols from Src
39  /// shadow those in the Dest.
40  ///
41  /// Passing InternalizeCallback will have the linker call the function with
42  /// the new module and a list of global value names to be internalized by the
43  /// callback.
44  ///
45  /// Returns true on error.
46  bool linkInModule(std::unique_ptr<Module> Src, unsigned Flags = Flags::None,
47  std::function<void(Module &, const StringSet<> &)>
48  InternalizeCallback = {});
49 
50  static bool linkModules(Module &Dest, std::unique_ptr<Module> Src,
51  unsigned Flags = Flags::None,
52  std::function<void(Module &, const StringSet<> &)>
53  InternalizeCallback = {});
54 };
55 
56 } // End llvm namespace
57 
58 #endif
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::Linker::None
@ None
Definition: Linker.h:29
llvm::Linker::LinkOnlyNeeded
@ LinkOnlyNeeded
Definition: Linker.h:31
llvm::Linker::linkModules
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...
Definition: LinkModules.cpp:620
llvm::None
const NoneType None
Definition: None.h:23
llvm::IRMover
Definition: IRMover.h:25
TemplateParamKind::Type
@ Type
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
IRMover.h
llvm::Linker
This class provides the core functionality of linking in LLVM.
Definition: Linker.h:24
llvm::Linker::Linker
Linker(Module &M)
Definition: LinkModules.cpp:601
llvm::StringSet
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:22
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
StringSet.h
llvm::Linker::Flags
Flags
Definition: Linker.h:28
llvm::Linker::OverrideFromSrc
@ OverrideFromSrc
Definition: Linker.h:30
llvm::Linker::linkInModule
bool linkInModule(std::unique_ptr< Module > Src, unsigned Flags=Flags::None, std::function< void(Module &, const StringSet<> &)> InternalizeCallback={})
Link Src into the composite.
Definition: LinkModules.cpp:603