Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:53

0001 //===- LazyObjectLinkingLayer.h - Link objects on first fn call -*- 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 // Link object files lazily on first call.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 #ifndef LLVM_EXECUTIONENGINE_ORC_LAZYOBJECTLINKINGLAYER_H
0013 #define LLVM_EXECUTIONENGINE_ORC_LAZYOBJECTLINKINGLAYER_H
0014 
0015 #include "llvm/ExecutionEngine/Orc/Core.h"
0016 #include "llvm/ExecutionEngine/Orc/Layer.h"
0017 
0018 namespace llvm::orc {
0019 
0020 class ObjectLinkingLayer;
0021 class LazyReexportsManager;
0022 class RedirectableSymbolManager;
0023 
0024 /// LazyObjectLinkingLayer is an adapter for ObjectLinkingLayer that builds
0025 /// lazy reexports for all function symbols in objects that are/ added to defer
0026 /// linking until the first call to a function defined in the object.
0027 ///
0028 /// Linking is performed by emitting the object file via the base
0029 /// ObjectLinkingLayer.
0030 ///
0031 /// No partitioning is performed: The first call to any function in the object
0032 /// will trigger linking of the whole object.
0033 ///
0034 /// References to data symbols are not lazy and will trigger immediate linking
0035 /// (same os ObjectlinkingLayer).
0036 class LazyObjectLinkingLayer : public ObjectLayer {
0037 public:
0038   LazyObjectLinkingLayer(ObjectLinkingLayer &BaseLayer,
0039                          LazyReexportsManager &LRMgr);
0040 
0041   /// Add an object file to the JITDylib targeted by the given tracker.
0042   llvm::Error add(llvm::orc::ResourceTrackerSP RT,
0043                   std::unique_ptr<MemoryBuffer> O,
0044                   MaterializationUnit::Interface I) override;
0045 
0046   void emit(std::unique_ptr<MaterializationResponsibility> R,
0047             std::unique_ptr<MemoryBuffer> O) override;
0048 
0049 private:
0050   class RenamerPlugin;
0051 
0052   ObjectLinkingLayer &BaseLayer;
0053   LazyReexportsManager &LRMgr;
0054 };
0055 
0056 } // namespace llvm::orc
0057 
0058 #endif // LLVM_EXECUTIONENGINE_ORC_LAZYOBJECTLINKINGLAYER_H