Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:11

0001 //===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_LINKER_LINKER_H
0010 #define LLVM_LINKER_LINKER_H
0011 
0012 #include "llvm/ADT/StringSet.h"
0013 #include "llvm/Linker/IRMover.h"
0014 
0015 namespace llvm {
0016 class Module;
0017 
0018 /// This class provides the core functionality of linking in LLVM. It keeps a
0019 /// pointer to the merged module so far. It doesn't take ownership of the
0020 /// module since it is assumed that the user of this class will want to do
0021 /// something with it after the linking.
0022 class Linker {
0023   IRMover Mover;
0024 
0025 public:
0026   enum Flags {
0027     None = 0,
0028     OverrideFromSrc = (1 << 0),
0029     LinkOnlyNeeded = (1 << 1),
0030   };
0031 
0032   Linker(Module &M);
0033 
0034   /// Link \p Src into the composite.
0035   ///
0036   /// Passing OverrideSymbols as true will have symbols from Src
0037   /// shadow those in the Dest.
0038   ///
0039   /// Passing InternalizeCallback will have the linker call the function with
0040   /// the new module and a list of global value names to be internalized by the
0041   /// callback.
0042   ///
0043   /// Returns true on error.
0044   bool linkInModule(std::unique_ptr<Module> Src, unsigned Flags = Flags::None,
0045                     std::function<void(Module &, const StringSet<> &)>
0046                         InternalizeCallback = {});
0047 
0048   static bool linkModules(Module &Dest, std::unique_ptr<Module> Src,
0049                           unsigned Flags = Flags::None,
0050                           std::function<void(Module &, const StringSet<> &)>
0051                               InternalizeCallback = {});
0052 };
0053 
0054 } // End llvm namespace
0055 
0056 #endif