diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/include/llvm/ExecutionEngine/JITLink/JITLink.h | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/ExecutionEngine/JITLink/JITLink.h')
-rw-r--r-- | contrib/libs/llvm12/include/llvm/ExecutionEngine/JITLink/JITLink.h | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/contrib/libs/llvm12/include/llvm/ExecutionEngine/JITLink/JITLink.h b/contrib/libs/llvm12/include/llvm/ExecutionEngine/JITLink/JITLink.h index e464ede4e5..43d567880a 100644 --- a/contrib/libs/llvm12/include/llvm/ExecutionEngine/JITLink/JITLink.h +++ b/contrib/libs/llvm12/include/llvm/ExecutionEngine/JITLink/JITLink.h @@ -402,10 +402,10 @@ public: return Name; } - /// Rename this symbol. The client is responsible for updating scope and - /// linkage if this name-change requires it. - void setName(StringRef Name) { this->Name = Name; } - + /// Rename this symbol. The client is responsible for updating scope and + /// linkage if this name-change requires it. + void setName(StringRef Name) { this->Name = Name; } + /// Returns true if this Symbol has content (potentially) defined within this /// object file (i.e. is anything but an external or absolute symbol). bool isDefined() const { @@ -793,48 +793,48 @@ public: Section::const_block_iterator, const Block *, getSectionConstBlocks>; - LinkGraph(std::string Name, const Triple &TT, unsigned PointerSize, + LinkGraph(std::string Name, const Triple &TT, unsigned PointerSize, support::endianness Endianness) - : Name(std::move(Name)), TT(TT), PointerSize(PointerSize), + : Name(std::move(Name)), TT(TT), PointerSize(PointerSize), Endianness(Endianness) {} /// Returns the name of this graph (usually the name of the original /// underlying MemoryBuffer). const std::string &getName() { return Name; } - /// Returns the target triple for this Graph. - const Triple &getTargetTriple() const { return TT; } - + /// Returns the target triple for this Graph. + const Triple &getTargetTriple() const { return TT; } + /// Returns the pointer size for use in this graph. unsigned getPointerSize() const { return PointerSize; } /// Returns the endianness of content in this graph. support::endianness getEndianness() const { return Endianness; } - /// Allocate a copy of the given string using the LinkGraph's allocator. - /// This can be useful when renaming symbols or adding new content to the - /// graph. - StringRef allocateString(StringRef Source) { - auto *AllocatedBuffer = Allocator.Allocate<char>(Source.size()); - llvm::copy(Source, AllocatedBuffer); - return StringRef(AllocatedBuffer, Source.size()); - } - - /// Allocate a copy of the given string using the LinkGraph's allocator. - /// This can be useful when renaming symbols or adding new content to the - /// graph. - /// - /// Note: This Twine-based overload requires an extra string copy and an - /// extra heap allocation for large strings. The StringRef overload should - /// be preferred where possible. - StringRef allocateString(Twine Source) { - SmallString<256> TmpBuffer; - auto SourceStr = Source.toStringRef(TmpBuffer); - auto *AllocatedBuffer = Allocator.Allocate<char>(SourceStr.size()); - llvm::copy(SourceStr, AllocatedBuffer); - return StringRef(AllocatedBuffer, SourceStr.size()); - } - + /// Allocate a copy of the given string using the LinkGraph's allocator. + /// This can be useful when renaming symbols or adding new content to the + /// graph. + StringRef allocateString(StringRef Source) { + auto *AllocatedBuffer = Allocator.Allocate<char>(Source.size()); + llvm::copy(Source, AllocatedBuffer); + return StringRef(AllocatedBuffer, Source.size()); + } + + /// Allocate a copy of the given string using the LinkGraph's allocator. + /// This can be useful when renaming symbols or adding new content to the + /// graph. + /// + /// Note: This Twine-based overload requires an extra string copy and an + /// extra heap allocation for large strings. The StringRef overload should + /// be preferred where possible. + StringRef allocateString(Twine Source) { + SmallString<256> TmpBuffer; + auto SourceStr = Source.toStringRef(TmpBuffer); + auto *AllocatedBuffer = Allocator.Allocate<char>(SourceStr.size()); + llvm::copy(SourceStr, AllocatedBuffer); + return StringRef(AllocatedBuffer, SourceStr.size()); + } + /// Create a section with the given name, protection flags, and alignment. Section &createSection(StringRef Name, sys::Memory::ProtectionFlags Prot) { std::unique_ptr<Section> Sec(new Section(Name, Prot, Sections.size())); @@ -997,7 +997,7 @@ public: Section &Sec = Sym.getBlock().getSection(); Sec.removeSymbol(Sym); } - Sym.makeExternal(createAddressable(0, false)); + Sym.makeExternal(createAddressable(0, false)); ExternalSymbols.insert(&Sym); } @@ -1057,7 +1057,7 @@ private: BumpPtrAllocator Allocator; std::string Name; - Triple TT; + Triple TT; unsigned PointerSize; support::endianness Endianness; SectionList Sections; @@ -1230,31 +1230,31 @@ struct PassConfiguration { /// Notable use cases: Building GOT, stub, and TLV symbols. LinkGraphPassList PostPrunePasses; - /// Post-allocation passes. - /// - /// These passes are called on the graph after memory has been allocated and - /// defined nodes have been assigned their final addresses, but before the - /// context has been notified of these addresses. At this point externals - /// have not been resolved, and symbol content has not yet been copied into - /// working memory. - /// - /// Notable use cases: Setting up data structures associated with addresses - /// of defined symbols (e.g. a mapping of __dso_handle to JITDylib* for the - /// JIT runtime) -- using a PostAllocationPass for this ensures that the - /// data structures are in-place before any query for resolved symbols - /// can complete. - LinkGraphPassList PostAllocationPasses; - + /// Post-allocation passes. + /// + /// These passes are called on the graph after memory has been allocated and + /// defined nodes have been assigned their final addresses, but before the + /// context has been notified of these addresses. At this point externals + /// have not been resolved, and symbol content has not yet been copied into + /// working memory. + /// + /// Notable use cases: Setting up data structures associated with addresses + /// of defined symbols (e.g. a mapping of __dso_handle to JITDylib* for the + /// JIT runtime) -- using a PostAllocationPass for this ensures that the + /// data structures are in-place before any query for resolved symbols + /// can complete. + LinkGraphPassList PostAllocationPasses; + /// Pre-fixup passes. /// /// These passes are called on the graph after memory has been allocated, - /// content copied into working memory, and all nodes (including externals) - /// have been assigned their final addresses, but before any fixups have been - /// applied. + /// content copied into working memory, and all nodes (including externals) + /// have been assigned their final addresses, but before any fixups have been + /// applied. /// /// Notable use cases: Late link-time optimizations like GOT and stub /// elimination. - LinkGraphPassList PreFixupPasses; + LinkGraphPassList PreFixupPasses; /// Post-fixup passes. /// @@ -1310,15 +1310,15 @@ class JITLinkContext { public: using LookupMap = DenseMap<StringRef, SymbolLookupFlags>; - /// Create a JITLinkContext. - JITLinkContext(const JITLinkDylib *JD) : JD(JD) {} - + /// Create a JITLinkContext. + JITLinkContext(const JITLinkDylib *JD) : JD(JD) {} + /// Destroy a JITLinkContext. virtual ~JITLinkContext(); - /// Return the JITLinkDylib that this link is targeting, if any. - const JITLinkDylib *getJITLinkDylib() const { return JD; } - + /// Return the JITLinkDylib that this link is targeting, if any. + const JITLinkDylib *getJITLinkDylib() const { return JD; } + /// Return the MemoryManager to be used for this link. virtual JITLinkMemoryManager &getMemoryManager() = 0; @@ -1336,11 +1336,11 @@ public: /// their final memory locations in the target process. At this point the /// LinkGraph can be inspected to build a symbol table, however the block /// content will not generally have been copied to the target location yet. - /// - /// If the client detects an error in the LinkGraph state (e.g. unexpected or - /// missing symbols) they may return an error here. The error will be - /// propagated to notifyFailed and the linker will bail out. - virtual Error notifyResolved(LinkGraph &G) = 0; + /// + /// If the client detects an error in the LinkGraph state (e.g. unexpected or + /// missing symbols) they may return an error here. The error will be + /// propagated to notifyFailed and the linker will bail out. + virtual Error notifyResolved(LinkGraph &G) = 0; /// Called by JITLink to notify the context that the object has been /// finalized (i.e. emitted to memory and memory permissions set). If all of @@ -1366,26 +1366,26 @@ public: /// Called by JITLink to modify the pass pipeline prior to linking. /// The default version performs no modification. virtual Error modifyPassConfig(const Triple &TT, PassConfiguration &Config); - -private: - const JITLinkDylib *JD = nullptr; + +private: + const JITLinkDylib *JD = nullptr; }; /// Marks all symbols in a graph live. This can be used as a default, /// conservative mark-live implementation. Error markAllSymbolsLive(LinkGraph &G); -/// Create a LinkGraph from the given object buffer. +/// Create a LinkGraph from the given object buffer. /// -/// Note: The graph does not take ownership of the underlying buffer, nor copy -/// its contents. The caller is responsible for ensuring that the object buffer -/// outlives the graph. -Expected<std::unique_ptr<LinkGraph>> -createLinkGraphFromObject(MemoryBufferRef ObjectBuffer); - -/// Link the given graph. -void link(std::unique_ptr<LinkGraph> G, std::unique_ptr<JITLinkContext> Ctx); - +/// Note: The graph does not take ownership of the underlying buffer, nor copy +/// its contents. The caller is responsible for ensuring that the object buffer +/// outlives the graph. +Expected<std::unique_ptr<LinkGraph>> +createLinkGraphFromObject(MemoryBufferRef ObjectBuffer); + +/// Link the given graph. +void link(std::unique_ptr<LinkGraph> G, std::unique_ptr<JITLinkContext> Ctx); + } // end namespace jitlink } // end namespace llvm |