1 //===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LINKER_LINKER_H
10 #define LLVM_LINKER_LINKER_H
12 #include "llvm/ADT/StringSet.h"
13 #include "llvm/Linker/IRMover.h"
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.
30 OverrideFromSrc = (1 << 0),
31 LinkOnlyNeeded = (1 << 1),
36 /// Link \p Src into the composite.
38 /// Passing OverrideSymbols as true will have symbols from Src
39 /// shadow those in the Dest.
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
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 = {});
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 = {});
56 } // End llvm namespace