[llvm] Move a lot of symbol code to use the symbol string pool (PR #115796)
Jared Wyles via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 17:15:14 PST 2024
https://github.com/jaredwy created https://github.com/llvm/llvm-project/pull/115796
Largely just feeding the Symbol pool through various points it needs to go. This is a first phase to get it in, going to dig in and start to use the pool in further patches.
>From 877353c66efda71d1b3066387139ff17389b92f5 Mon Sep 17 00:00:00 2001
From: jared w <jared.wyles at gmail.com>
Date: Thu, 30 Mar 2023 10:02:04 +1100
Subject: [PATCH] WIP: Symbolpool-switch
---
.gitignore | 2 +
.../llvm/ExecutionEngine/JITLink/COFF.h | 3 +-
.../ExecutionEngine/JITLink/COFF_x86_64.h | 4 +-
.../llvm/ExecutionEngine/JITLink/ELF.h | 3 +-
.../ExecutionEngine/JITLink/ELF_aarch32.h | 4 +-
.../ExecutionEngine/JITLink/ELF_aarch64.h | 4 +-
.../llvm/ExecutionEngine/JITLink/ELF_i386.h | 3 +-
.../ExecutionEngine/JITLink/ELF_loongarch.h | 4 +-
.../llvm/ExecutionEngine/JITLink/ELF_ppc64.h | 7 +-
.../llvm/ExecutionEngine/JITLink/ELF_riscv.h | 3 +-
.../llvm/ExecutionEngine/JITLink/ELF_x86_64.h | 3 +-
.../llvm/ExecutionEngine/JITLink/JITLink.h | 163 ++++++++++++------
.../llvm/ExecutionEngine/JITLink/MachO.h | 3 +-
.../ExecutionEngine/JITLink/MachO_arm64.h | 4 +-
.../ExecutionEngine/JITLink/MachO_x86_64.h | 4 +-
.../ExecutionEngine/JITLink/TableManager.h | 4 +-
llvm/include/llvm/ExecutionEngine/Orc/Core.h | 4 +-
.../llvm/ExecutionEngine/RuntimeDyldChecker.h | 3 +-
llvm/lib/ExecutionEngine/JITLink/COFF.cpp | 5 +-
.../JITLink/COFFLinkGraphBuilder.cpp | 85 +++++----
.../JITLink/COFFLinkGraphBuilder.h | 20 ++-
.../ExecutionEngine/JITLink/COFF_x86_64.cpp | 27 +--
.../DefineExternalSectionStartAndEndSymbols.h | 18 +-
.../JITLink/EHFrameSupport.cpp | 6 +-
llvm/lib/ExecutionEngine/JITLink/ELF.cpp | 21 +--
.../JITLink/ELFLinkGraphBuilder.h | 14 +-
.../ExecutionEngine/JITLink/ELF_aarch32.cpp | 15 +-
.../ExecutionEngine/JITLink/ELF_aarch64.cpp | 28 +--
llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp | 14 +-
.../ExecutionEngine/JITLink/ELF_loongarch.cpp | 18 +-
.../lib/ExecutionEngine/JITLink/ELF_ppc64.cpp | 35 ++--
.../lib/ExecutionEngine/JITLink/ELF_riscv.cpp | 14 +-
.../ExecutionEngine/JITLink/ELF_x86_64.cpp | 17 +-
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp | 37 ++--
.../JITLink/JITLinkGeneric.cpp | 5 +-
.../JITLink/JITLinkMemoryManager.cpp | 5 +-
llvm/lib/ExecutionEngine/JITLink/MachO.cpp | 7 +-
.../JITLink/MachOLinkGraphBuilder.cpp | 21 +--
.../JITLink/MachOLinkGraphBuilder.h | 7 +-
.../ExecutionEngine/JITLink/MachO_arm64.cpp | 11 +-
.../ExecutionEngine/JITLink/MachO_x86_64.cpp | 9 +-
.../JITLink/PerGraphGOTAndPLTStubsBuilder.h | 8 +-
llvm/lib/ExecutionEngine/JITLink/aarch32.cpp | 8 +-
llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp | 6 +-
.../Orc/Debugging/DebuggerSupportPlugin.cpp | 4 +-
.../Orc/Debugging/PerfSupportPlugin.cpp | 4 +-
.../Orc/Debugging/VTuneSupportPlugin.cpp | 2 +-
.../ExecutionEngine/Orc/ELFNixPlatform.cpp | 31 ++--
.../ExecutionEngine/Orc/ExecutionUtils.cpp | 10 +-
.../ExecutionEngine/Orc/IndirectionUtils.cpp | 2 +-
.../Orc/JITLinkRedirectableSymbolManager.cpp | 10 +-
.../lib/ExecutionEngine/Orc/MachOPlatform.cpp | 32 ++--
.../Orc/ObjectFileInterface.cpp | 2 +-
.../Orc/ObjectLinkingLayer.cpp | 57 +++---
llvm/lib/ExecutionEngine/Orc/SectCreate.cpp | 1 +
.../RuntimeDyld/RuntimeDyldELF.cpp | 1 +
.../RuntimeDyld/RuntimeDyldImpl.h | 1 +
llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 50 +++---
llvm/tools/llvm-jitlink/llvm-jitlink.h | 7 +-
.../JITLink/AArch32ErrorTests.cpp | 10 +-
.../JITLink/EHFrameSupportTests.cpp | 10 +-
.../JITLink/JITLinkTestUtils.cpp | 7 +-
.../JITLink/LinkGraphTests.cpp | 49 ++++--
.../JITLink/MachOLinkGraphTests.cpp | 6 +-
.../JITLink/MemoryManagerErrorTests.cpp | 7 +-
.../ExecutionEngine/JITLink/StubsTests.cpp | 17 +-
.../Orc/ObjectLinkingLayerTest.cpp | 51 +++---
67 files changed, 611 insertions(+), 446 deletions(-)
diff --git a/.gitignore b/.gitignore
index 0e7c6c79001338..a84268a7f68632 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,6 +59,8 @@ autoconf/autom4te.cache
# VS2017 and VSCode config files.
.vscode
.vs
+#zed config files
+.zed
# pythonenv for github Codespaces
pythonenv*
# clangd index. (".clangd" is a config file now, thus trailing slash)
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/COFF.h b/llvm/include/llvm/ExecutionEngine/JITLink/COFF.h
index 87d3648d37e8ba..33b661933ace83 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/COFF.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/COFF.h
@@ -24,7 +24,8 @@ namespace jitlink {
/// its contents. The caller is responsible for ensuring that the object buffer
/// outlives the graph.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromCOFFObject(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromCOFFObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// Link the given graph.
///
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/COFF_x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/COFF_x86_64.h
index fff32d6d960933..2072ae9dfdbe70 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/COFF_x86_64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/COFF_x86_64.h
@@ -23,8 +23,8 @@ namespace jitlink {
/// 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>>
-createLinkGraphFromCOFFObject_x86_64(MemoryBufferRef ObjectBuffer);
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromCOFFObject_x86_64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be a COFF x86-64 object file.
void link_COFF_x86_64(std::unique_ptr<LinkGraph> G,
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF.h
index 038591f9add055..3decba65f380cb 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF.h
@@ -24,7 +24,8 @@ namespace jitlink {
/// its contents. The caller is responsible for ensuring that the object buffer
/// outlives the graph.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromELFObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// Link the given graph.
///
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch32.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch32.h
index 25d1c3aac2c26e..b865414e520c29 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch32.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch32.h
@@ -24,8 +24,8 @@ namespace jitlink {
/// 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>>
-createLinkGraphFromELFObject_aarch32(MemoryBufferRef ObjectBuffer);
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_aarch32(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be an ELF arm/thumb object
/// file.
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch64.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch64.h
index 50eb598139ea0b..45a7a0100593f3 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch64.h
@@ -25,8 +25,8 @@ namespace jitlink {
/// 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>>
-createLinkGraphFromELFObject_aarch64(MemoryBufferRef ObjectBuffer);
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_aarch64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be a ELF aarch64 relocatable
/// object file.
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h
index 44ebd969946113..0752f214d9d582 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_i386.h
@@ -26,7 +26,8 @@ namespace jitlink {
/// its contents. The caller is responsible for ensuring that the object buffer
/// outlives the graph.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be a ELF i386 relocatable
/// object file.
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_loongarch.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_loongarch.h
index 4d7655c4b988b7..7e5d0f1f918521 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_loongarch.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_loongarch.h
@@ -25,8 +25,8 @@ namespace jitlink {
/// 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>>
-createLinkGraphFromELFObject_loongarch(MemoryBufferRef ObjectBuffer);
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_loongarch(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be an ELF loongarch object
/// file.
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_ppc64.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_ppc64.h
index 8db986a4a9fa15..c5049a54cdf1d5 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_ppc64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_ppc64.h
@@ -25,15 +25,16 @@ namespace llvm::jitlink {
///
/// WARNING: The big-endian backend has not been tested yet.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// Create a LinkGraph from an ELF/ppc64le relocatable object.
///
/// 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>>
-createLinkGraphFromELFObject_ppc64le(MemoryBufferRef ObjectBuffer);
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_ppc64le(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be a ELF ppc64le object file.
///
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h
index a0e573baca066f..d00b5c2868baf6 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_riscv.h
@@ -26,7 +26,8 @@ namespace jitlink {
/// its contents. The caller is responsible for ensuring that the object buffer
/// outlives the graph.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_riscv(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromELFObject_riscv(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be a ELF riscv object file.
void link_ELF_riscv(std::unique_ptr<LinkGraph> G,
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
index fbe5765438d240..140dad7b82e002 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
@@ -24,7 +24,8 @@ namespace jitlink {
/// its contents. The caller is responsible for ensuring that the object buffer
/// outlives the graph.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_x86_64(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromELFObject_x86_64(MemoryBufferRef ObjectBuffe,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be a ELF x86-64 object file.
void link_ELF_x86_64(std::unique_ptr<LinkGraph> G,
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index 9844214c537a06..7d74b622108f9c 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -23,6 +23,7 @@
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamWriter.h"
@@ -35,6 +36,7 @@
#include "llvm/TargetParser/Triple.h"
#include <optional>
+#include <cstring>
#include <map>
#include <string>
#include <system_error>
@@ -422,10 +424,11 @@ class Symbol {
friend class LinkGraph;
private:
- Symbol(Addressable &Base, orc::ExecutorAddrDiff Offset, StringRef Name,
- orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsLive,
- bool IsCallable)
- : Name(Name), Base(&Base), Offset(Offset), WeakRef(0), Size(Size) {
+ Symbol(Addressable &Base, orc::ExecutorAddrDiff Offset,
+ orc::SymbolStringPtr &&Name, orc::ExecutorAddrDiff Size, Linkage L,
+ Scope S, bool IsLive, bool IsCallable)
+ : Name(std::move(Name)), Base(&Base), Offset(Offset), WeakRef(0),
+ Size(Size) {
assert(Offset <= MaxOffset && "Offset out of range");
setLinkage(L);
setScope(S);
@@ -434,27 +437,45 @@ class Symbol {
setTargetFlags(TargetFlagsType{});
}
+ static Symbol &constructCommon(BumpPtrAllocator &Allocator, Block &Base,
+ orc::SymbolStringPtr &&Name,
+ orc::ExecutorAddrDiff Size, Scope S,
+ bool IsLive) {
+ assert(Name && "Common symbol name cannot be empty");
+ assert(Base.isDefined() &&
+ "Cannot create common symbol from undefined block");
+ assert(static_cast<Block &>(Base).getSize() == Size &&
+ "Common symbol size should match underlying block size");
+ auto *Sym = Allocator.Allocate<Symbol>();
+ new (Sym)
+ Symbol(Base, 0, std::move(Name), Size, Linkage::Weak, S, IsLive, false);
+ return *Sym;
+ }
+
static Symbol &constructExternal(BumpPtrAllocator &Allocator,
- Addressable &Base, StringRef Name,
+ Addressable &Base,
+ orc::SymbolStringPtr &&Name,
orc::ExecutorAddrDiff Size, Linkage L,
bool WeaklyReferenced) {
assert(!Base.isDefined() &&
"Cannot create external symbol from defined block");
- assert(!Name.empty() && "External symbol name cannot be empty");
+ assert(Name && "External symbol name cannot be empty");
auto *Sym = Allocator.Allocate<Symbol>();
- new (Sym) Symbol(Base, 0, Name, Size, L, Scope::Default, false, false);
+ new (Sym)
+ Symbol(Base, 0, std::move(Name), Size, L, Scope::Default, false, false);
Sym->setWeaklyReferenced(WeaklyReferenced);
return *Sym;
}
static Symbol &constructAbsolute(BumpPtrAllocator &Allocator,
- Addressable &Base, StringRef Name,
+ Addressable &Base,
+ orc::SymbolStringPtr &&Name,
orc::ExecutorAddrDiff Size, Linkage L,
Scope S, bool IsLive) {
assert(!Base.isDefined() &&
"Cannot create absolute symbol from a defined block");
auto *Sym = Allocator.Allocate<Symbol>();
- new (Sym) Symbol(Base, 0, Name, Size, L, S, IsLive, false);
+ new (Sym) Symbol(Base, 0, std::move(Name), Size, L, S, IsLive, false);
return *Sym;
}
@@ -465,20 +486,22 @@ class Symbol {
assert((Offset + Size) <= Base.getSize() &&
"Symbol extends past end of block");
auto *Sym = Allocator.Allocate<Symbol>();
- new (Sym) Symbol(Base, Offset, StringRef(), Size, Linkage::Strong,
- Scope::Local, IsLive, IsCallable);
+ new (Sym) Symbol(Base, Offset, orc::SymbolStringPtr(nullptr), Size,
+ Linkage::Strong, Scope::Local, IsLive, IsCallable);
return *Sym;
}
static Symbol &constructNamedDef(BumpPtrAllocator &Allocator, Block &Base,
- orc::ExecutorAddrDiff Offset, StringRef Name,
+ orc::ExecutorAddrDiff Offset,
+ orc::SymbolStringPtr Name,
orc::ExecutorAddrDiff Size, Linkage L,
Scope S, bool IsLive, bool IsCallable) {
assert((Offset + Size) <= Base.getSize() &&
"Symbol extends past end of block");
- assert(!Name.empty() && "Name cannot be empty");
+ assert(Name && "Name cannot be empty");
auto *Sym = Allocator.Allocate<Symbol>();
- new (Sym) Symbol(Base, Offset, Name, Size, L, S, IsLive, IsCallable);
+ new (Sym)
+ Symbol(Base, Offset, std::move(Name), Size, L, S, IsLive, IsCallable);
return *Sym;
}
@@ -495,18 +518,19 @@ class Symbol {
Symbol &operator=(Symbol &&) = delete;
/// Returns true if this symbol has a name.
- bool hasName() const { return !Name.empty(); }
+ bool hasName() const { return Name != nullptr; }
/// Returns the name of this symbol (empty if the symbol is anonymous).
- StringRef getName() const {
- assert((!Name.empty() || getScope() == Scope::Local) &&
+ const orc::SymbolStringPtr &getName() const {
+ assert((Name || getScope() == Scope::Local) &&
"Anonymous symbol has non-local scope");
+
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; }
+ void setName(const orc::SymbolStringPtr 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).
@@ -613,7 +637,7 @@ class Symbol {
/// Set the linkage for this Symbol.
void setLinkage(Linkage L) {
- assert((L == Linkage::Strong || (!Base->isAbsolute() && !Name.empty())) &&
+ assert((L == Linkage::Strong || (!Base->isAbsolute() && Name)) &&
"Linkage can only be applied to defined named symbols");
this->L = static_cast<uint8_t>(L);
}
@@ -623,7 +647,7 @@ class Symbol {
/// Set the visibility for this Symbol.
void setScope(Scope S) {
- assert((!Name.empty() || S == Scope::Local) &&
+ assert((Name || S == Scope::Local) &&
"Can not set anonymous symbol to non-local scope");
assert((S != Scope::Local || Base->isDefined() || Base->isAbsolute()) &&
"Invalid visibility for symbol type");
@@ -675,8 +699,7 @@ class Symbol {
static constexpr uint64_t MaxOffset = (1ULL << 59) - 1;
- // FIXME: A char* or SymbolStringPtr may pack better.
- StringRef Name;
+ orc::SymbolStringPtr Name;
Addressable *Base = nullptr;
uint64_t Offset : 57;
uint64_t L : 1;
@@ -1001,22 +1024,23 @@ class LinkGraph {
using GetEdgeKindNameFunction = const char *(*)(Edge::Kind);
- LinkGraph(std::string Name, const Triple &TT, SubtargetFeatures Features,
- unsigned PointerSize, llvm::endianness Endianness,
+ LinkGraph(std::string Name, std::shared_ptr<orc::SymbolStringPool> SSP,
+ const Triple &TT, SubtargetFeatures Features, unsigned PointerSize,
+ llvm::endianness Endianness,
GetEdgeKindNameFunction GetEdgeKindName)
- : Name(std::move(Name)), TT(TT), Features(std::move(Features)),
+ : Name(std::move(Name)), SSP(SSP), TT(TT), Features(std::move(Features)),
PointerSize(PointerSize), Endianness(Endianness),
GetEdgeKindName(std::move(GetEdgeKindName)) {}
- LinkGraph(std::string Name, const Triple &TT, unsigned PointerSize,
- llvm::endianness Endianness,
+ LinkGraph(std::string Name, std::shared_ptr<orc::SymbolStringPool> SSP,
+ const Triple &TT, unsigned PointerSize, llvm::endianness Endianness,
GetEdgeKindNameFunction GetEdgeKindName)
- : LinkGraph(std::move(Name), TT, SubtargetFeatures(), PointerSize,
+ : LinkGraph(std::move(Name), SSP, TT, SubtargetFeatures(), PointerSize,
Endianness, GetEdgeKindName) {}
- LinkGraph(std::string Name, const Triple &TT,
- GetEdgeKindNameFunction GetEdgeKindName)
- : LinkGraph(std::move(Name), TT, SubtargetFeatures(),
+ LinkGraph(std::string Name, std::shared_ptr<orc::SymbolStringPool> SSP,
+ const Triple &TT, GetEdgeKindNameFunction GetEdgeKindName)
+ : LinkGraph(std::move(Name), SSP, TT, SubtargetFeatures(),
Triple::getArchPointerBitWidth(TT.getArch()) / 8,
TT.isLittleEndian() ? endianness::little : endianness::big,
GetEdgeKindName) {
@@ -1028,6 +1052,7 @@ class LinkGraph {
LinkGraph &operator=(const LinkGraph &) = delete;
LinkGraph(LinkGraph &&) = delete;
LinkGraph &operator=(LinkGraph &&) = delete;
+ ~LinkGraph();
/// Returns the name of this graph (usually the name of the original
/// underlying MemoryBuffer).
@@ -1047,6 +1072,8 @@ class LinkGraph {
const char *getEdgeKindName(Edge::Kind K) const { return GetEdgeKindName(K); }
+ std::shared_ptr<orc::SymbolStringPool> getSymbolStringPool() { return SSP; }
+
/// Allocate a mutable buffer of the given size using the LinkGraph's
/// allocator.
MutableArrayRef<char> allocateBuffer(size_t Size) {
@@ -1260,6 +1287,10 @@ class LinkGraph {
return splitBlockImpl(std::move(Blocks), Cache);
}
+ //
+ orc::SymbolStringPtr intern(StringRef SymbolName) {
+ return SSP->intern(SymbolName);
+ }
/// Add an external symbol.
/// Some formats (e.g. ELF) allow Symbols to have sizes. For Symbols whose
/// size is not known, you should substitute '0'.
@@ -1268,18 +1299,25 @@ class LinkGraph {
/// found or an error will be emitted. Externals that are weakly referenced
/// are permitted to be undefined, in which case they are assigned an address
/// of 0.
- Symbol &addExternalSymbol(StringRef Name, orc::ExecutorAddrDiff Size,
+ Symbol &addExternalSymbol(orc::SymbolStringPtr &&Name,
+ orc::ExecutorAddrDiff Size,
bool IsWeaklyReferenced) {
- assert(!ExternalSymbols.contains(Name) && "Duplicate external symbol");
+ assert(!ExternalSymbols.contains(*Name) && "Duplicate external symbol");
auto &Sym = Symbol::constructExternal(
- Allocator, createAddressable(orc::ExecutorAddr(), false), Name, Size,
- Linkage::Strong, IsWeaklyReferenced);
- ExternalSymbols.insert({Sym.getName(), &Sym});
+ Allocator, createAddressable(orc::ExecutorAddr(), false),
+ std::move(Name), Size, Linkage::Strong, IsWeaklyReferenced);
+ ExternalSymbols.insert({*Sym.getName(), &Sym});
return Sym;
}
+ Symbol &addExternalSymbol(StringRef Name, orc::ExecutorAddrDiff Size,
+ bool IsWeaklyReferenced) {
+ return addExternalSymbol(SSP->intern(Name), Size, IsWeaklyReferenced);
+ }
+
/// Add an absolute symbol.
- Symbol &addAbsoluteSymbol(StringRef Name, orc::ExecutorAddr Address,
+ Symbol &addAbsoluteSymbol(orc::SymbolStringPtr Name,
+ orc::ExecutorAddr Address,
orc::ExecutorAddrDiff Size, Linkage L, Scope S,
bool IsLive) {
assert((S == Scope::Local || llvm::count_if(AbsoluteSymbols,
@@ -1288,11 +1326,18 @@ class LinkGraph {
}) == 0) &&
"Duplicate absolute symbol");
auto &Sym = Symbol::constructAbsolute(Allocator, createAddressable(Address),
- Name, Size, L, S, IsLive);
+ std::move(Name), Size, L, S, IsLive);
AbsoluteSymbols.insert(&Sym);
return Sym;
}
+ Symbol &addAbsoluteSymbol(StringRef Name, orc::ExecutorAddr Address,
+ orc::ExecutorAddrDiff Size, Linkage L, Scope S,
+ bool IsLive) {
+
+ return addAbsoluteSymbol(SSP->intern(Name), Address, Size, L, S, IsLive);
+ }
+
/// Add an anonymous symbol.
Symbol &addAnonymousSymbol(Block &Content, orc::ExecutorAddrDiff Offset,
orc::ExecutorAddrDiff Size, bool IsCallable,
@@ -1307,13 +1352,22 @@ class LinkGraph {
Symbol &addDefinedSymbol(Block &Content, orc::ExecutorAddrDiff Offset,
StringRef Name, orc::ExecutorAddrDiff Size,
Linkage L, Scope S, bool IsCallable, bool IsLive) {
+ return addDefinedSymbol(Content, Offset, SSP->intern(Name), Size, L, S,
+ IsCallable, IsLive);
+ }
+
+ Symbol &addDefinedSymbol(Block &Content, orc::ExecutorAddrDiff Offset,
+ orc::SymbolStringPtr Name,
+ orc::ExecutorAddrDiff Size, Linkage L, Scope S,
+ bool IsCallable, bool IsLive) {
assert((S == Scope::Local || llvm::count_if(defined_symbols(),
[&](const Symbol *Sym) {
return Sym->getName() == Name;
}) == 0) &&
"Duplicate defined symbol");
- auto &Sym = Symbol::constructNamedDef(Allocator, Content, Offset, Name,
- Size, L, S, IsLive, IsCallable);
+ auto &Sym =
+ Symbol::constructNamedDef(Allocator, Content, Offset, std::move(Name),
+ Size, L, S, IsLive, IsCallable);
Content.getSection().addSymbol(Sym);
return Sym;
}
@@ -1398,7 +1452,7 @@ class LinkGraph {
Sec.removeSymbol(Sym);
Sym.makeExternal(createAddressable(orc::ExecutorAddr(), false));
}
- ExternalSymbols.insert({Sym.getName(), &Sym});
+ ExternalSymbols.insert({*Sym.getName(), &Sym});
}
/// Make the given symbol an absolute with the given address (must not already
@@ -1412,10 +1466,10 @@ class LinkGraph {
void makeAbsolute(Symbol &Sym, orc::ExecutorAddr Address) {
assert(!Sym.isAbsolute() && "Symbol is already absolute");
if (Sym.isExternal()) {
- assert(ExternalSymbols.contains(Sym.getName()) &&
+ assert(ExternalSymbols.contains(*Sym.getName()) &&
"Sym is not in the absolute symbols set");
assert(Sym.getOffset() == 0 && "External is not at offset 0");
- ExternalSymbols.erase(Sym.getName());
+ ExternalSymbols.erase(*Sym.getName());
auto &A = Sym.getAddressable();
A.setAbsolute(true);
A.setAddress(Address);
@@ -1440,9 +1494,9 @@ class LinkGraph {
"Symbol is not in the absolutes set");
AbsoluteSymbols.erase(&Sym);
} else {
- assert(ExternalSymbols.contains(Sym.getName()) &&
+ assert(ExternalSymbols.contains(*Sym.getName()) &&
"Symbol is not in the externals set");
- ExternalSymbols.erase(Sym.getName());
+ ExternalSymbols.erase(*Sym.getName());
}
Addressable &OldBase = *Sym.Base;
Sym.setBlock(Content);
@@ -1527,9 +1581,9 @@ class LinkGraph {
void removeExternalSymbol(Symbol &Sym) {
assert(!Sym.isDefined() && !Sym.isAbsolute() &&
"Sym is not an external symbol");
- assert(ExternalSymbols.contains(Sym.getName()) &&
+ assert(ExternalSymbols.contains(*Sym.getName()) &&
"Symbol is not in the externals set");
- ExternalSymbols.erase(Sym.getName());
+ ExternalSymbols.erase(*Sym.getName());
Addressable &Base = *Sym.Base;
assert(llvm::none_of(external_symbols(),
[&](Symbol *AS) { return AS->Base == &Base; }) &&
@@ -1600,6 +1654,7 @@ class LinkGraph {
BumpPtrAllocator Allocator;
std::string Name;
+ std::shared_ptr<orc::SymbolStringPool> SSP;
Triple TT;
SubtargetFeatures Features;
unsigned PointerSize;
@@ -1828,7 +1883,8 @@ enum class SymbolLookupFlags { RequiredSymbol, WeaklyReferencedSymbol };
raw_ostream &operator<<(raw_ostream &OS, const SymbolLookupFlags &LF);
/// A map of symbol names to resolved addresses.
-using AsyncLookupResult = DenseMap<StringRef, orc::ExecutorSymbolDef>;
+using AsyncLookupResult =
+ DenseMap<orc::SymbolStringPtr, orc::ExecutorSymbolDef>;
/// A function object to call with a resolved symbol map (See AsyncLookupResult)
/// or an error if resolution failed.
@@ -1861,7 +1917,7 @@ createLookupContinuation(Continuation Cont) {
/// Holds context for a single jitLink invocation.
class JITLinkContext {
public:
- using LookupMap = DenseMap<StringRef, SymbolLookupFlags>;
+ using LookupMap = DenseMap<orc::SymbolStringPtr, SymbolLookupFlags>;
/// Create a JITLinkContext.
JITLinkContext(const JITLinkDylib *JD) : JD(JD) {}
@@ -1994,11 +2050,14 @@ void visitExistingEdges(LinkGraph &G, VisitorTs &&...Vs) {
/// its contents. The caller is responsible for ensuring that the object buffer
/// outlives the graph.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromObject(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// Create a \c LinkGraph defining the given absolute symbols.
-std::unique_ptr<LinkGraph> absoluteSymbolsLinkGraph(const Triple &TT,
- orc::SymbolMap Symbols);
+std::unique_ptr<LinkGraph>
+absoluteSymbolsLinkGraph(const Triple &TT,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ orc::SymbolMap Symbols);
/// Link the given graph.
void link(std::unique_ptr<LinkGraph> G, std::unique_ptr<JITLinkContext> Ctx);
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h b/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h
index bb8da0ab9db27a..2010b32cdf7660 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/MachO.h
@@ -25,7 +25,8 @@ namespace jitlink {
/// its contents. The caller is responsible for ensuring that the object buffer
/// outlives the graph.
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer);
+createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given ObjBuffer, which must be a MachO object file.
///
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/MachO_arm64.h b/llvm/include/llvm/ExecutionEngine/JITLink/MachO_arm64.h
index 31721bf999ec18..31770c2a601e56 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/MachO_arm64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/MachO_arm64.h
@@ -23,8 +23,8 @@ namespace jitlink {
/// 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>>
-createLinkGraphFromMachOObject_arm64(MemoryBufferRef ObjectBuffer);
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromMachOObject_arm64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given object buffer, which must be a MachO arm64 object file.
///
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
index 6aee8c354f91e6..72e9883ba18b8f 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/MachO_x86_64.h
@@ -23,8 +23,8 @@ namespace jitlink {
/// 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>>
-createLinkGraphFromMachOObject_x86_64(MemoryBufferRef ObjectBuffer);
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromMachOObject_x86_64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP);
/// jit-link the given LinkGraph.
///
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/TableManager.h b/llvm/include/llvm/ExecutionEngine/JITLink/TableManager.h
index 7ab8ae3e53cec2..d20c9c94d38067 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/TableManager.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/TableManager.h
@@ -39,7 +39,7 @@ template <typename TableManagerImplT> class TableManager {
auto &Entry = impl().createEntry(G, Target);
DEBUG_WITH_TYPE("jitlink", {
dbgs() << " Created " << impl().getSectionName() << " entry for "
- << Target.getName() << ": " << Entry << "\n";
+ << *Target.getName() << ": " << Entry << "\n";
});
EntryI = Entries.insert(std::make_pair(Target.getName(), &Entry)).first;
}
@@ -69,7 +69,7 @@ template <typename TableManagerImplT> class TableManager {
private:
TableManagerImplT &impl() { return static_cast<TableManagerImplT &>(*this); }
- DenseMap<StringRef, Symbol *> Entries;
+ DenseMap<orc::SymbolStringPtr, Symbol *> Entries;
};
} // namespace jitlink
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
index f578455905f210..81b66038baeb1a 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -502,7 +502,7 @@ class MissingSymbolDefinitions : public ErrorInfo<MissingSymbolDefinitions> {
MissingSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
std::string ModuleName, SymbolNameVector Symbols)
- : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
+ : SSP(SSP), ModuleName(std::move(ModuleName)),
Symbols(std::move(Symbols)) {}
std::error_code convertToErrorCode() const override;
void log(raw_ostream &OS) const override;
@@ -525,7 +525,7 @@ class UnexpectedSymbolDefinitions : public ErrorInfo<UnexpectedSymbolDefinitions
UnexpectedSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
std::string ModuleName, SymbolNameVector Symbols)
- : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
+ : SSP(SSP), ModuleName(std::move(ModuleName)),
Symbols(std::move(Symbols)) {}
std::error_code convertToErrorCode() const override;
void log(raw_ostream &OS) const override;
diff --git a/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h b/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h
index 034c134a13731d..afcad9fbc58af5 100644
--- a/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h
+++ b/llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h
@@ -10,6 +10,7 @@
#define LLVM_EXECUTIONENGINE_RUNTIMEDYLDCHECKER_H
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/Support/Endian.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include "llvm/TargetParser/Triple.h"
@@ -150,7 +151,7 @@ class RuntimeDyldChecker {
using IsSymbolValidFunction = std::function<bool(StringRef Symbol)>;
using GetSymbolInfoFunction =
- std::function<Expected<MemoryRegionInfo>(StringRef SymbolName)>;
+ std::function<Expected<MemoryRegionInfo>(StringRef Symbol)>;
using GetSectionInfoFunction = std::function<Expected<MemoryRegionInfo>(
StringRef FileName, StringRef SectionName)>;
using GetStubInfoFunction = std::function<Expected<MemoryRegionInfo>(
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFF.cpp b/llvm/lib/ExecutionEngine/JITLink/COFF.cpp
index f4701bc830d664..84b5284c9c6e9f 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFF.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFF.cpp
@@ -42,7 +42,8 @@ static StringRef getMachineName(uint16_t Machine) {
}
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromCOFFObject(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromCOFFObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
StringRef Data = ObjectBuffer.getBuffer();
// Check magic
@@ -110,7 +111,7 @@ createLinkGraphFromCOFFObject(MemoryBufferRef ObjectBuffer) {
switch (Machine) {
case COFF::IMAGE_FILE_MACHINE_AMD64:
- return createLinkGraphFromCOFFObject_x86_64(ObjectBuffer);
+ return createLinkGraphFromCOFFObject_x86_64(ObjectBuffer, SSP);
default:
return make_error<JITLinkError>(
"Unsupported target machine architecture in COFF object " +
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
index 92630650ec9372..840b6266a129cc 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
@@ -11,6 +11,8 @@
//===----------------------------------------------------------------------===//
#include "COFFLinkGraphBuilder.h"
+#include <memory>
+
#define DEBUG_TYPE "jitlink"
static const char *CommonSectionName = "__common";
@@ -24,12 +26,15 @@ static Triple createTripleWithCOFFFormat(Triple T) {
}
COFFLinkGraphBuilder::COFFLinkGraphBuilder(
- const object::COFFObjectFile &Obj, Triple TT, SubtargetFeatures Features,
+ const object::COFFObjectFile &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
+ SubtargetFeatures Features,
LinkGraph::GetEdgeKindNameFunction GetEdgeKindName)
- : Obj(Obj), G(std::make_unique<LinkGraph>(
- Obj.getFileName().str(), createTripleWithCOFFFormat(TT),
- std::move(Features), getPointerSize(Obj),
- getEndianness(Obj), std::move(GetEdgeKindName))) {
+ : Obj(Obj),
+ G(std::make_unique<LinkGraph>(
+ Obj.getFileName().str(), SSP, createTripleWithCOFFFormat(TT),
+ std::move(Features), getPointerSize(Obj), getEndianness(Obj),
+ std::move(GetEdgeKindName))) {
LLVM_DEBUG({
dbgs() << "Created COFFLinkGraphBuilder for \"" << Obj.getFileName()
<< "\"\n";
@@ -226,18 +231,19 @@ Error COFFLinkGraphBuilder::graphifySymbols() {
" (" + toString(SecOrErr.takeError()) + ")");
Sec = *SecOrErr;
}
+ auto InternedSymbolName = G->intern(std::move(SymbolName));
// Create jitlink symbol
jitlink::Symbol *GSym = nullptr;
if (Sym->isFileRecord())
LLVM_DEBUG({
dbgs() << " " << SymIndex << ": Skipping FileRecord symbol \""
- << SymbolName << "\" in "
+ << *InternedSymbolName << "\" in "
<< getCOFFSectionName(SectionIndex, Sec, *Sym)
<< " (index: " << SectionIndex << ") \n";
});
else if (Sym->isUndefined()) {
- GSym = createExternalSymbol(SymIndex, SymbolName, *Sym, Sec);
+ GSym = createExternalSymbol(SymIndex, InternedSymbolName, *Sym, Sec);
} else if (Sym->isWeakExternal()) {
auto *WeakExternal = Sym->getAux<object::coff_aux_weak_external>();
COFFSymbolIndex TagIndex = WeakExternal->TagIndex;
@@ -246,7 +252,7 @@ Error COFFLinkGraphBuilder::graphifySymbols() {
{SymIndex, TagIndex, Characteristics, SymbolName});
} else {
Expected<jitlink::Symbol *> NewGSym =
- createDefinedSymbol(SymIndex, SymbolName, *Sym, Sec);
+ createDefinedSymbol(SymIndex, InternedSymbolName, *Sym, Sec);
if (!NewGSym)
return NewGSym.takeError();
GSym = *NewGSym;
@@ -254,7 +260,7 @@ Error COFFLinkGraphBuilder::graphifySymbols() {
LLVM_DEBUG({
dbgs() << " " << SymIndex
<< ": Creating defined graph symbol for COFF symbol \""
- << SymbolName << "\" in "
+ << *InternedSymbolName << "\" in "
<< getCOFFSectionName(SectionIndex, Sec, *Sym)
<< " (index: " << SectionIndex << ") \n";
dbgs() << " " << *GSym << "\n";
@@ -293,14 +299,13 @@ Error COFFLinkGraphBuilder::handleDirectiveSection(StringRef Str) {
if (From.empty() || To.empty())
return make_error<JITLinkError>(
"Invalid COFF /alternatename directive");
- AlternateNames[From] = To;
+ AlternateNames[G->intern(From)] = G->intern(To);
break;
}
case COFF_OPT_incl: {
- auto DataCopy = G->allocateContent(S);
- StringRef StrCopy(DataCopy.data(), DataCopy.size());
- ExternalSymbols[StrCopy] = &G->addExternalSymbol(StrCopy, 0, false);
- ExternalSymbols[StrCopy]->setLive(true);
+ auto Symbol = &G->addExternalSymbol(S, 0, false);
+ Symbol->setLive(true);
+ ExternalSymbols[Symbol->getName()] = Symbol;
break;
}
case COFF_OPT_export:
@@ -332,8 +337,8 @@ Error COFFLinkGraphBuilder::flushWeakAliasRequests() {
? Scope::Default
: Scope::Local;
- auto NewSymbol =
- createAliasSymbol(WeakExternal.SymbolName, Linkage::Weak, S, *Target);
+ auto NewSymbol = createAliasSymbol(G->intern(WeakExternal.SymbolName),
+ Linkage::Weak, S, *Target);
if (!NewSymbol)
return NewSymbol.takeError();
setGraphSymbol(AliasSymbol->getSectionNumber(), WeakExternal.Alias,
@@ -354,37 +359,44 @@ Error COFFLinkGraphBuilder::flushWeakAliasRequests() {
}
Error COFFLinkGraphBuilder::handleAlternateNames() {
- for (auto &KeyValue : AlternateNames)
- if (DefinedSymbols.count(KeyValue.second) &&
- ExternalSymbols.count(KeyValue.first)) {
- auto *Target = DefinedSymbols[KeyValue.second];
- auto *Alias = ExternalSymbols[KeyValue.first];
+ for (auto &KeyValue : AlternateNames) {
+ auto DefinedSymbolName = KeyValue.second;
+ auto ExternalSymbolsName = KeyValue.first;
+ if (DefinedSymbols.count(DefinedSymbolName) &&
+ ExternalSymbols.count(ExternalSymbolsName)) {
+ auto *Target = DefinedSymbols[DefinedSymbolName];
+ auto *Alias = ExternalSymbols[ExternalSymbolsName];
G->makeDefined(*Alias, Target->getBlock(), Target->getOffset(),
Target->getSize(), Linkage::Weak, Scope::Local, false);
}
+ }
return Error::success();
}
Symbol *COFFLinkGraphBuilder::createExternalSymbol(
- COFFSymbolIndex SymIndex, StringRef SymbolName,
+ COFFSymbolIndex SymIndex, orc::SymbolStringPtr SymbolName,
object::COFFSymbolRef Symbol, const object::coff_section *Section) {
- if (!ExternalSymbols.count(SymbolName))
- ExternalSymbols[SymbolName] =
- &G->addExternalSymbol(SymbolName, Symbol.getValue(), false);
+ llvm::jitlink::Symbol *sym = nullptr;
+ if (!ExternalSymbols.count(SymbolName)) {
+ sym = &G->addExternalSymbol(*SymbolName, Symbol.getValue(), false);
+ ExternalSymbols[sym->getName()] = sym;
+ } else {
+ sym = ExternalSymbols[SymbolName];
+ }
LLVM_DEBUG({
dbgs() << " " << SymIndex
<< ": Creating external graph symbol for COFF symbol \""
- << SymbolName << "\" in "
+ << *sym->getName() << "\" in "
<< getCOFFSectionName(Symbol.getSectionNumber(), Section, Symbol)
<< " (index: " << Symbol.getSectionNumber() << ") \n";
});
- return ExternalSymbols[SymbolName];
+ return sym;
}
-Expected<Symbol *> COFFLinkGraphBuilder::createAliasSymbol(StringRef SymbolName,
- Linkage L, Scope S,
- Symbol &Target) {
+Expected<Symbol *>
+COFFLinkGraphBuilder::createAliasSymbol(orc::SymbolStringPtr SymbolName,
+ Linkage L, Scope S, Symbol &Target) {
if (!Target.isDefined()) {
// FIXME: Support this when there's a way to handle this.
return make_error<JITLinkError>("Weak external symbol with external "
@@ -460,8 +472,9 @@ Error COFFLinkGraphBuilder::calculateImplicitSizeOfSymbols() {
}
Expected<Symbol *> COFFLinkGraphBuilder::createDefinedSymbol(
- COFFSymbolIndex SymIndex, StringRef SymbolName,
+ COFFSymbolIndex SymIndex, orc::SymbolStringPtr SymbolName,
object::COFFSymbolRef Symbol, const object::coff_section *Section) {
+
if (Symbol.isCommon()) {
// FIXME: correct alignment
return &G->addDefinedSymbol(
@@ -470,6 +483,7 @@ Expected<Symbol *> COFFLinkGraphBuilder::createDefinedSymbol(
0, SymbolName, Symbol.getValue(), Linkage::Weak, Scope::Default,
false, false);
}
+
if (Symbol.isAbsolute())
return &G->addAbsoluteSymbol(SymbolName,
orc::ExecutorAddr(Symbol.getValue()), 0,
@@ -486,7 +500,7 @@ Expected<Symbol *> COFFLinkGraphBuilder::createDefinedSymbol(
dbgs() << " " << SymIndex
<< ": Skipping graph symbol since section was not created for "
"COFF symbol \""
- << SymbolName << "\" in section " << Symbol.getSectionNumber()
+ << *SymbolName << "\" in section " << Symbol.getSectionNumber()
<< "\n";
});
return nullptr;
@@ -603,7 +617,7 @@ Expected<Symbol *> COFFLinkGraphBuilder::createCOMDATExportRequest(
// Process the second symbol of COMDAT sequence.
Expected<Symbol *>
COFFLinkGraphBuilder::exportCOMDATSymbol(COFFSymbolIndex SymIndex,
- StringRef SymbolName,
+ orc::SymbolStringPtr SymbolName,
object::COFFSymbolRef Symbol) {
Block *B = getGraphBlock(Symbol.getSectionNumber());
auto &PendingComdatExport = PendingComdatExports[Symbol.getSectionNumber()];
@@ -616,8 +630,9 @@ COFFLinkGraphBuilder::exportCOMDATSymbol(COFFSymbolIndex SymIndex,
false);
LLVM_DEBUG({
dbgs() << " " << SymIndex
- << ": Exporting COMDAT graph symbol for COFF symbol \"" << SymbolName
- << "\" in section " << Symbol.getSectionNumber() << "\n";
+ << ": Exporting COMDAT graph symbol for COFF symbol \""
+ << *SymbolName << "\" in section " << Symbol.getSectionNumber()
+ << "\n";
dbgs() << " " << *GSym << "\n";
});
setGraphSymbol(Symbol.getSectionNumber(), PendingComdatExport->SymbolIndex,
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
index e5f3ce8c53f5ee..def0d94dda4684 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
@@ -37,7 +37,8 @@ class COFFLinkGraphBuilder {
using COFFSectionIndex = int32_t;
using COFFSymbolIndex = int32_t;
- COFFLinkGraphBuilder(const object::COFFObjectFile &Obj, Triple TT,
+ COFFLinkGraphBuilder(const object::COFFObjectFile &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
SubtargetFeatures Features,
LinkGraph::GetEdgeKindNameFunction GetEdgeKindName);
@@ -134,20 +135,21 @@ class COFFLinkGraphBuilder {
Section &getCommonSection();
- Symbol *createExternalSymbol(COFFSymbolIndex SymIndex, StringRef SymbolName,
+ Symbol *createExternalSymbol(COFFSymbolIndex SymIndex,
+ orc::SymbolStringPtr SymbolName,
object::COFFSymbolRef Symbol,
const object::coff_section *Section);
- Expected<Symbol *> createAliasSymbol(StringRef SymbolName, Linkage L, Scope S,
- Symbol &Target);
+ Expected<Symbol *> createAliasSymbol(orc::SymbolStringPtr SymbolName,
+ Linkage L, Scope S, Symbol &Target);
Expected<Symbol *> createDefinedSymbol(COFFSymbolIndex SymIndex,
- StringRef SymbolName,
+ orc::SymbolStringPtr SymbolName,
object::COFFSymbolRef Symbol,
const object::coff_section *Section);
Expected<Symbol *> createCOMDATExportRequest(
COFFSymbolIndex SymIndex, object::COFFSymbolRef Symbol,
const object::coff_aux_section_definition *Definition);
Expected<Symbol *> exportCOMDATSymbol(COFFSymbolIndex SymIndex,
- StringRef SymbolName,
+ orc::SymbolStringPtr SymbolName,
object::COFFSymbolRef Symbol);
Error handleDirectiveSection(StringRef Str);
@@ -176,9 +178,9 @@ class COFFLinkGraphBuilder {
std::vector<Block *> GraphBlocks;
std::vector<Symbol *> GraphSymbols;
- DenseMap<StringRef, StringRef> AlternateNames;
- DenseMap<StringRef, Symbol *> ExternalSymbols;
- DenseMap<StringRef, Symbol *> DefinedSymbols;
+ DenseMap<orc::SymbolStringPtr, orc::SymbolStringPtr> AlternateNames;
+ DenseMap<orc::SymbolStringPtr, Symbol *> ExternalSymbols;
+ DenseMap<orc::SymbolStringPtr, Symbol *> DefinedSymbols;
};
template <typename RelocHandlerFunction>
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
index 3257a2ae94f66d..9e73a67324a34c 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
@@ -148,6 +148,7 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
SectionIdx = getObject().getNumberOfSections() + 1;
else
SectionIdx = COFFSymbol.getSectionNumber();
+
auto *AbsSym = &getGraph().addAbsoluteSymbol(
"secidx", orc::ExecutorAddr(SectionIdx), 2, Linkage::Strong,
Scope::Local, false);
@@ -181,14 +182,20 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
}
public:
- COFFLinkGraphBuilder_x86_64(const object::COFFObjectFile &Obj, const Triple T,
- const SubtargetFeatures Features)
- : COFFLinkGraphBuilder(Obj, std::move(T), std::move(Features),
+ COFFLinkGraphBuilder_x86_64(const object::COFFObjectFile &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ const Triple T, const SubtargetFeatures Features)
+ : COFFLinkGraphBuilder(Obj, std::move(SSP), std::move(T),
+ std::move(Features),
getCOFFX86RelocationKindName) {}
};
class COFFLinkGraphLowering_x86_64 {
public:
+ COFFLinkGraphLowering_x86_64(std::shared_ptr<orc::SymbolStringPool> SSP)
+ : SSP(SSP) {
+ imageBaseName = SSP->intern("__ImageBase");
+ }
// Lowers COFF x86_64 specific edges to generic x86_64 edges.
Error lowerCOFFRelocationEdges(LinkGraph &G, JITLinkContext &Ctx) {
for (auto *B : G.blocks()) {
@@ -230,8 +237,7 @@ class COFFLinkGraphLowering_x86_64 {
}
private:
- static StringRef getImageBaseSymbolName() { return "__ImageBase"; }
-
+ orc::SymbolStringPtr getImageBaseSymbolName() { return this->imageBaseName; }
orc::ExecutorAddr getSectionStart(Section &Sec) {
if (!SectionStartCache.count(&Sec)) {
SectionRange Range(Sec);
@@ -271,12 +277,13 @@ class COFFLinkGraphLowering_x86_64 {
DenseMap<Section *, orc::ExecutorAddr> SectionStartCache;
orc::ExecutorAddr ImageBase;
+ std::shared_ptr<orc::SymbolStringPool> SSP;
+ orc::SymbolStringPtr imageBaseName = nullptr;
};
Error lowerEdges_COFF_x86_64(LinkGraph &G, JITLinkContext *Ctx) {
LLVM_DEBUG(dbgs() << "Lowering COFF x86_64 edges:\n");
- COFFLinkGraphLowering_x86_64 GraphLowering;
-
+ COFFLinkGraphLowering_x86_64 GraphLowering(G.getSymbolStringPool());
if (auto Err = GraphLowering.lowerCOFFRelocationEdges(G, *Ctx))
return Err;
@@ -305,8 +312,8 @@ const char *getCOFFX86RelocationKindName(Edge::Kind R) {
}
}
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromCOFFObject_x86_64(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromCOFFObject_x86_64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -320,7 +327,7 @@ createLinkGraphFromCOFFObject_x86_64(MemoryBufferRef ObjectBuffer) {
if (!Features)
return Features.takeError();
- return COFFLinkGraphBuilder_x86_64(**COFFObj, (*COFFObj)->makeTriple(),
+ return COFFLinkGraphBuilder_x86_64(**COFFObj, SSP, (*COFFObj)->makeTriple(),
std::move(*Features))
.buildGraph();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/DefineExternalSectionStartAndEndSymbols.h b/llvm/lib/ExecutionEngine/JITLink/DefineExternalSectionStartAndEndSymbols.h
index 49cfc5dec25bb5..c7a2f071c29f32 100644
--- a/llvm/lib/ExecutionEngine/JITLink/DefineExternalSectionStartAndEndSymbols.h
+++ b/llvm/lib/ExecutionEngine/JITLink/DefineExternalSectionStartAndEndSymbols.h
@@ -112,13 +112,13 @@ identifyELFSectionStartAndEndSymbols(LinkGraph &G, Symbol &Sym) {
constexpr StringRef EndSymbolPrefix = "__stop_";
auto SymName = Sym.getName();
- if (SymName.starts_with(StartSymbolPrefix)) {
- if (auto *Sec =
- G.findSectionByName(SymName.drop_front(StartSymbolPrefix.size())))
+ if ((*SymName).starts_with(StartSymbolPrefix)) {
+ if (auto *Sec = G.findSectionByName(
+ (*SymName).drop_front(StartSymbolPrefix.size())))
return {*Sec, true};
- } else if (SymName.starts_with(EndSymbolPrefix)) {
+ } else if ((*SymName).starts_with(EndSymbolPrefix)) {
if (auto *Sec =
- G.findSectionByName(SymName.drop_front(EndSymbolPrefix.size())))
+ G.findSectionByName((*SymName).drop_front(EndSymbolPrefix.size())))
return {*Sec, false};
}
return {};
@@ -131,15 +131,15 @@ identifyMachOSectionStartAndEndSymbols(LinkGraph &G, Symbol &Sym) {
constexpr StringRef EndSymbolPrefix = "section$end$";
auto SymName = Sym.getName();
- if (SymName.starts_with(StartSymbolPrefix)) {
+ if ((*SymName).starts_with(StartSymbolPrefix)) {
auto [SegName, SecName] =
- SymName.drop_front(StartSymbolPrefix.size()).split('$');
+ (*SymName).drop_front(StartSymbolPrefix.size()).split('$');
std::string SectionName = (SegName + "," + SecName).str();
if (auto *Sec = G.findSectionByName(SectionName))
return {*Sec, true};
- } else if (SymName.starts_with(EndSymbolPrefix)) {
+ } else if ((*SymName).starts_with(EndSymbolPrefix)) {
auto [SegName, SecName] =
- SymName.drop_front(EndSymbolPrefix.size()).split('$');
+ (*SymName).drop_front(EndSymbolPrefix.size()).split('$');
std::string SectionName = (SegName + "," + SecName).str();
if (auto *Sec = G.findSectionByName(SectionName))
return {*Sec, false};
diff --git a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
index f0cf551ffae5ab..3cd335b3185c31 100644
--- a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
@@ -372,7 +372,7 @@ Error EHFrameEdgeFixer::processFDE(ParseContext &PC, Block &B,
dbgs() << " WARNING: Not adding keep-alive edge to FDE at "
<< RecordAddress << ", which points to "
<< ((*PCBegin)->isExternal() ? "external" : "absolute")
- << " symbol \"" << (*PCBegin)->getName()
+ << " symbol \"" << *(*PCBegin)->getName()
<< "\" -- FDE must be kept alive manually or it will be "
<< "dead stripped.\n";
});
@@ -525,7 +525,7 @@ Expected<Symbol *> EHFrameEdgeFixer::getOrCreateEncodedPointerEdge(
<< (BlockToFix.getAddress() + PointerFieldOffset) << " to "
<< FieldName << " at " << EdgeI->second.Target->getAddress();
if (EdgeI->second.Target->hasName())
- dbgs() << " (" << EdgeI->second.Target->getName() << ")";
+ dbgs() << " (" << *EdgeI->second.Target->getName() << ")";
dbgs() << "\n";
});
if (auto Err = skipEncodedPointer(PointerEncoding, RecordReader))
@@ -591,7 +591,7 @@ Expected<Symbol *> EHFrameEdgeFixer::getOrCreateEncodedPointerEdge(
<< (BlockToFix.getAddress() + PointerFieldOffset) << " to "
<< FieldName << " at " << TargetSym->getAddress();
if (TargetSym->hasName())
- dbgs() << " (" << TargetSym->getName() << ")";
+ dbgs() << " (" << *TargetSym->getName() << ")";
dbgs() << "\n";
});
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
index fdcce20cd2d102..45bb6c7a5b34da 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF.cpp
@@ -71,7 +71,8 @@ Expected<uint16_t> readTargetMachineArch(StringRef Buffer) {
}
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromELFObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
StringRef Buffer = ObjectBuffer.getBuffer();
if (Buffer.size() < ELF::EI_NIDENT)
return make_error<JITLinkError>("Truncated ELF buffer");
@@ -86,23 +87,23 @@ createLinkGraphFromELFObject(MemoryBufferRef ObjectBuffer) {
switch (*TargetMachineArch) {
case ELF::EM_AARCH64:
- return createLinkGraphFromELFObject_aarch64(ObjectBuffer);
+ return createLinkGraphFromELFObject_aarch64(ObjectBuffer, SSP);
case ELF::EM_ARM:
- return createLinkGraphFromELFObject_aarch32(ObjectBuffer);
- case ELF::EM_LOONGARCH:
- return createLinkGraphFromELFObject_loongarch(ObjectBuffer);
+ return createLinkGraphFromELFObject_aarch32(ObjectBuffer, SSP);
case ELF::EM_PPC64: {
if (DataEncoding == ELF::ELFDATA2LSB)
- return createLinkGraphFromELFObject_ppc64le(ObjectBuffer);
+ return createLinkGraphFromELFObject_ppc64le(ObjectBuffer, SSP);
else
- return createLinkGraphFromELFObject_ppc64(ObjectBuffer);
+ return createLinkGraphFromELFObject_ppc64(ObjectBuffer, SSP);
}
+ case ELF::EM_LOONGARCH:
+ return createLinkGraphFromELFObject_loongarch(ObjectBuffer, SSP);
case ELF::EM_RISCV:
- return createLinkGraphFromELFObject_riscv(ObjectBuffer);
+ return createLinkGraphFromELFObject_riscv(ObjectBuffer, SSP);
case ELF::EM_X86_64:
- return createLinkGraphFromELFObject_x86_64(ObjectBuffer);
+ return createLinkGraphFromELFObject_x86_64(ObjectBuffer, SSP);
case ELF::EM_386:
- return createLinkGraphFromELFObject_i386(ObjectBuffer);
+ return createLinkGraphFromELFObject_i386(ObjectBuffer, SSP);
default:
return make_error<JITLinkError>(
"Unsupported target machine architecture in ELF object " +
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
index c05961c64837ce..fbe40fe5f75716 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
@@ -58,7 +58,8 @@ class ELFLinkGraphBuilder : public ELFLinkGraphBuilderBase {
using ELFFile = object::ELFFile<ELFT>;
public:
- ELFLinkGraphBuilder(const object::ELFFile<ELFT> &Obj, Triple TT,
+ ELFLinkGraphBuilder(const object::ELFFile<ELFT> &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
SubtargetFeatures Features, StringRef FileName,
LinkGraph::GetEdgeKindNameFunction GetEdgeKindName);
@@ -189,12 +190,13 @@ class ELFLinkGraphBuilder : public ELFLinkGraphBuilderBase {
template <typename ELFT>
ELFLinkGraphBuilder<ELFT>::ELFLinkGraphBuilder(
- const ELFFile &Obj, Triple TT, SubtargetFeatures Features,
- StringRef FileName, LinkGraph::GetEdgeKindNameFunction GetEdgeKindName)
+ const ELFFile &Obj, std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
+ SubtargetFeatures Features, StringRef FileName,
+ LinkGraph::GetEdgeKindNameFunction GetEdgeKindName)
: ELFLinkGraphBuilderBase(std::make_unique<LinkGraph>(
- FileName.str(), Triple(std::move(TT)), std::move(Features),
- ELFT::Is64Bits ? 8 : 4, llvm::endianness(ELFT::Endianness),
- std::move(GetEdgeKindName))),
+ FileName.str(), std::move(SSP), Triple(std::move(TT)),
+ std::move(Features), ELFT::Is64Bits ? 8 : 4,
+ llvm::endianness(ELFT::Endianness), std::move(GetEdgeKindName))),
Obj(Obj) {
LLVM_DEBUG(
{ dbgs() << "Created ELFLinkGraphBuilder for \"" << FileName << "\""; });
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
index 866de2cb227c35..f2cd09c2e59721 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
@@ -219,10 +219,11 @@ class ELFLinkGraphBuilder_aarch32
public:
ELFLinkGraphBuilder_aarch32(StringRef FileName,
- const llvm::object::ELFFile<ELFT> &Obj, Triple TT,
- SubtargetFeatures Features,
+ const llvm::object::ELFFile<ELFT> &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ Triple TT, SubtargetFeatures Features,
aarch32::ArmConfig ArmCfg)
- : ELFLinkGraphBuilder<ELFT>(Obj, std::move(TT), std::move(Features),
+ : ELFLinkGraphBuilder<ELFT>(Obj, SSP, std::move(TT), std::move(Features),
FileName, getELFAArch32EdgeKindName),
ArmCfg(std::move(ArmCfg)) {}
};
@@ -239,8 +240,8 @@ Error buildTables_ELF_aarch32(LinkGraph &G) {
return Error::success();
}
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_aarch32(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_aarch32(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -273,7 +274,7 @@ createLinkGraphFromELFObject_aarch32(MemoryBufferRef ObjectBuffer) {
case Triple::thumb: {
auto &ELFFile = cast<ELFObjectFile<ELF32LE>>(**ELFObj).getELFFile();
return ELFLinkGraphBuilder_aarch32<llvm::endianness::little>(
- (*ELFObj)->getFileName(), ELFFile, TT, std::move(*Features),
+ (*ELFObj)->getFileName(), ELFFile, SSP, TT, std::move(*Features),
ArmCfg)
.buildGraph();
}
@@ -281,7 +282,7 @@ createLinkGraphFromELFObject_aarch32(MemoryBufferRef ObjectBuffer) {
case Triple::thumbeb: {
auto &ELFFile = cast<ELFObjectFile<ELF32BE>>(**ELFObj).getELFFile();
return ELFLinkGraphBuilder_aarch32<llvm::endianness::big>(
- (*ELFObj)->getFileName(), ELFFile, TT, std::move(*Features),
+ (*ELFObj)->getFileName(), ELFFile, SSP, TT, std::move(*Features),
ArmCfg)
.buildGraph();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
index 86e50548907995..dbda0338caabba 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
@@ -52,10 +52,13 @@ class ELFJITLinker_aarch64 : public JITLinker<ELFJITLinker_aarch64> {
}
Error getOrCreateGOTSymbol(LinkGraph &G) {
+ auto InteredGOTSymbolName =
+ G.getSymbolStringPool()->intern(ELFGOTSymbolName);
+
auto DefineExternalGOTSymbolIfPresent =
createDefineExternalSectionStartAndEndSymbolsPass(
[&](LinkGraph &LG, Symbol &Sym) -> SectionRangeSymbolDesc {
- if (Sym.getName() == ELFGOTSymbolName)
+ if (*Sym.getName() == ELFGOTSymbolName)
if (auto *GOTSection = G.findSectionByName(
aarch64::GOTTableManager::getSectionName())) {
GOTSymbol = &Sym;
@@ -81,7 +84,7 @@ class ELFJITLinker_aarch64 : public JITLinker<ELFJITLinker_aarch64> {
// Check for an existing defined symbol.
for (auto *Sym : GOTSection->symbols())
- if (Sym->getName() == ELFGOTSymbolName) {
+ if (Sym->getName() == InteredGOTSymbolName) {
GOTSymbol = Sym;
return Error::success();
}
@@ -90,11 +93,12 @@ class ELFJITLinker_aarch64 : public JITLinker<ELFJITLinker_aarch64> {
SectionRange SR(*GOTSection);
if (SR.empty())
GOTSymbol =
- &G.addAbsoluteSymbol(ELFGOTSymbolName, orc::ExecutorAddr(), 0,
+ // FIXME: we should only do this once
+ &G.addAbsoluteSymbol(InteredGOTSymbolName, orc::ExecutorAddr(), 0,
Linkage::Strong, Scope::Local, true);
else
GOTSymbol =
- &G.addDefinedSymbol(*SR.getFirstBlock(), 0, ELFGOTSymbolName, 0,
+ &G.addDefinedSymbol(*SR.getFirstBlock(), 0, InteredGOTSymbolName, 0,
Linkage::Strong, Scope::Local, false, true);
}
@@ -103,7 +107,7 @@ class ELFJITLinker_aarch64 : public JITLinker<ELFJITLinker_aarch64> {
// we just need to point the GOT symbol at some address in this graph.
if (!GOTSymbol) {
for (auto *Sym : G.external_symbols()) {
- if (Sym->getName() == ELFGOTSymbolName) {
+ if (*Sym->getName() == ELFGOTSymbolName) {
auto Blocks = G.blocks();
if (!Blocks.empty()) {
G.makeAbsolute(*Sym, (*Blocks.begin())->getAddress());
@@ -525,9 +529,11 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
public:
ELFLinkGraphBuilder_aarch64(StringRef FileName,
- const object::ELFFile<ELFT> &Obj, Triple TT,
- SubtargetFeatures Features)
- : ELFLinkGraphBuilder<ELFT>(Obj, std::move(TT), std::move(Features),
+ const object::ELFFile<ELFT> &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ Triple TT, SubtargetFeatures Features)
+
+ : ELFLinkGraphBuilder<ELFT>(Obj, SSP, std::move(TT), std::move(Features),
FileName, aarch64::getEdgeKindName) {}
};
@@ -665,8 +671,8 @@ Error buildTables_ELF_aarch64(LinkGraph &G) {
namespace llvm {
namespace jitlink {
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_aarch64(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_aarch64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -685,7 +691,7 @@ createLinkGraphFromELFObject_aarch64(MemoryBufferRef ObjectBuffer) {
auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF64LE>>(**ELFObj);
return ELFLinkGraphBuilder_aarch64<object::ELF64LE>(
- (*ELFObj)->getFileName(), ELFObjFile.getELFFile(),
+ (*ELFObj)->getFileName(), ELFObjFile.getELFFile(), SSP,
(*ELFObj)->makeTriple(), std::move(*Features))
.buildGraph();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
index 2d5f28cad1cc6d..e1c0957d089737 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
@@ -56,7 +56,8 @@ class ELFJITLinker_i386 : public JITLinker<ELFJITLinker_i386> {
auto DefineExternalGOTSymbolIfPresent =
createDefineExternalSectionStartAndEndSymbolsPass(
[&](LinkGraph &LG, Symbol &Sym) -> SectionRangeSymbolDesc {
- if (Sym.getName() == ELFGOTSymbolName)
+ if (Sym.getName() != nullptr &&
+ *Sym.getName() == ELFGOTSymbolName)
if (auto *GOTSection = G.findSectionByName(
i386::GOTTableManager::getSectionName())) {
GOTSymbol = &Sym;
@@ -82,7 +83,7 @@ class ELFJITLinker_i386 : public JITLinker<ELFJITLinker_i386> {
// Check for an existing defined symbol.
for (auto *Sym : GOTSection->symbols())
- if (Sym->getName() == ELFGOTSymbolName) {
+ if (Sym->getName() != nullptr && *Sym->getName() == ELFGOTSymbolName) {
GOTSymbol = Sym;
return Error::success();
}
@@ -224,13 +225,15 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<ELFT> {
public:
ELFLinkGraphBuilder_i386(StringRef FileName, const object::ELFFile<ELFT> &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
Triple TT, SubtargetFeatures Features)
- : ELFLinkGraphBuilder<ELFT>(Obj, std::move(TT), std::move(Features),
+ : ELFLinkGraphBuilder<ELFT>(Obj, SSP, std::move(TT), std::move(Features),
FileName, i386::getEdgeKindName) {}
};
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -248,8 +251,9 @@ createLinkGraphFromELFObject_i386(MemoryBufferRef ObjectBuffer) {
"Only i386 (little endian) is supported for now");
auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF32LE>>(**ELFObj);
+
return ELFLinkGraphBuilder_i386<object::ELF32LE>(
- (*ELFObj)->getFileName(), ELFObjFile.getELFFile(),
+ (*ELFObj)->getFileName(), ELFObjFile.getELFFile(), SSP,
(*ELFObj)->makeTriple(), std::move(*Features))
.buildGraph();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp
index aa9385fcb183dd..f5ba455e4211f4 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp
@@ -129,10 +129,12 @@ class ELFLinkGraphBuilder_loongarch : public ELFLinkGraphBuilder<ELFT> {
public:
ELFLinkGraphBuilder_loongarch(StringRef FileName,
- const object::ELFFile<ELFT> &Obj, Triple TT,
- SubtargetFeatures Features)
- : ELFLinkGraphBuilder<ELFT>(Obj, std::move(TT), std::move(Features),
- FileName, loongarch::getEdgeKindName) {}
+ const object::ELFFile<ELFT> &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ Triple TT, SubtargetFeatures Features)
+ : ELFLinkGraphBuilder<ELFT>(Obj, std::move(SSP), std::move(TT),
+ std::move(Features), FileName,
+ loongarch::getEdgeKindName) {}
};
Error buildTables_ELF_loongarch(LinkGraph &G) {
@@ -149,8 +151,8 @@ Error buildTables_ELF_loongarch(LinkGraph &G) {
namespace llvm {
namespace jitlink {
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_loongarch(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_loongarch(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -167,7 +169,7 @@ createLinkGraphFromELFObject_loongarch(MemoryBufferRef ObjectBuffer) {
if ((*ELFObj)->getArch() == Triple::loongarch64) {
auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF64LE>>(**ELFObj);
return ELFLinkGraphBuilder_loongarch<object::ELF64LE>(
- (*ELFObj)->getFileName(), ELFObjFile.getELFFile(),
+ (*ELFObj)->getFileName(), ELFObjFile.getELFFile(), SSP,
(*ELFObj)->makeTriple(), std::move(*Features))
.buildGraph();
}
@@ -176,7 +178,7 @@ createLinkGraphFromELFObject_loongarch(MemoryBufferRef ObjectBuffer) {
"Invalid triple for LoongArch ELF object file");
auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF32LE>>(**ELFObj);
return ELFLinkGraphBuilder_loongarch<object::ELF32LE>(
- (*ELFObj)->getFileName(), ELFObjFile.getELFFile(),
+ (*ELFObj)->getFileName(), ELFObjFile.getELFFile(), SSP,
(*ELFObj)->makeTriple(), std::move(*Features))
.buildGraph();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
index 3b86250b60a44c..964d9fed19e56f 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
@@ -106,14 +106,14 @@ Symbol &createELFGOTHeader(LinkGraph &G,
Symbol *TOCSymbol = nullptr;
for (Symbol *Sym : G.defined_symbols())
- if (LLVM_UNLIKELY(Sym->getName() == ELFTOCSymbolName)) {
+ if (LLVM_UNLIKELY(Sym->hasName() && *Sym->getName() == ELFTOCSymbolName)) {
TOCSymbol = Sym;
break;
}
if (LLVM_LIKELY(TOCSymbol == nullptr)) {
for (Symbol *Sym : G.external_symbols())
- if (Sym->getName() == ELFTOCSymbolName) {
+ if (Sym->hasName() && *Sym->getName() == ELFTOCSymbolName) {
TOCSymbol = Sym;
break;
}
@@ -393,10 +393,12 @@ class ELFLinkGraphBuilder_ppc64
public:
ELFLinkGraphBuilder_ppc64(StringRef FileName,
- const object::ELFFile<ELFT> &Obj, Triple TT,
- SubtargetFeatures Features)
- : ELFLinkGraphBuilder<ELFT>(Obj, std::move(TT), std::move(Features),
- FileName, ppc64::getEdgeKindName) {}
+ const object::ELFFile<ELFT> &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ Triple TT, SubtargetFeatures Features)
+ : ELFLinkGraphBuilder<ELFT>(Obj, std::move(SSP), std::move(TT),
+ std::move(Features), FileName,
+ ppc64::getEdgeKindName) {}
};
template <llvm::endianness Endianness>
@@ -417,7 +419,8 @@ class ELFJITLinker_ppc64 : public JITLinker<ELFJITLinker_ppc64<Endianness>> {
Error defineTOCBase(LinkGraph &G) {
for (Symbol *Sym : G.defined_symbols()) {
- if (LLVM_UNLIKELY(Sym->getName() == ELFTOCSymbolName)) {
+ if (LLVM_UNLIKELY(Sym->hasName() &&
+ *Sym->getName() == ELFTOCSymbolName)) {
TOCSymbol = Sym;
return Error::success();
}
@@ -427,7 +430,7 @@ class ELFJITLinker_ppc64 : public JITLinker<ELFJITLinker_ppc64<Endianness>> {
"TOCSymbol should not be defined at this point");
for (Symbol *Sym : G.external_symbols()) {
- if (Sym->getName() == ELFTOCSymbolName) {
+ if (Sym->hasName() && *Sym->getName() == ELFTOCSymbolName) {
TOCSymbol = Sym;
break;
}
@@ -463,7 +466,8 @@ class ELFJITLinker_ppc64 : public JITLinker<ELFJITLinker_ppc64<Endianness>> {
template <llvm::endianness Endianness>
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -480,7 +484,7 @@ createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer) {
using ELFT = object::ELFType<Endianness, true>;
auto &ELFObjFile = cast<object::ELFObjectFile<ELFT>>(**ELFObj);
return ELFLinkGraphBuilder_ppc64<Endianness>(
- (*ELFObj)->getFileName(), ELFObjFile.getELFFile(),
+ (*ELFObj)->getFileName(), ELFObjFile.getELFFile(), SSP,
(*ELFObj)->makeTriple(), std::move(*Features))
.buildGraph();
}
@@ -517,15 +521,16 @@ void link_ELF_ppc64(std::unique_ptr<LinkGraph> G,
}
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
return createLinkGraphFromELFObject_ppc64<llvm::endianness::big>(
- std::move(ObjectBuffer));
+ std::move(ObjectBuffer), SSP);
}
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_ppc64le(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_ppc64le(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
return createLinkGraphFromELFObject_ppc64<llvm::endianness::little>(
- std::move(ObjectBuffer));
+ std::move(ObjectBuffer), SSP);
}
/// jit-link the given object buffer, which must be a ELF ppc64 object file.
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
index 0cf548ede93890..d9c85c8a0b8a6f 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
@@ -927,14 +927,16 @@ class ELFLinkGraphBuilder_riscv : public ELFLinkGraphBuilder<ELFT> {
public:
ELFLinkGraphBuilder_riscv(StringRef FileName,
- const object::ELFFile<ELFT> &Obj, Triple TT,
- SubtargetFeatures Features)
- : ELFLinkGraphBuilder<ELFT>(Obj, std::move(TT), std::move(Features),
+ const object::ELFFile<ELFT> &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ Triple TT, SubtargetFeatures Features)
+ : ELFLinkGraphBuilder<ELFT>(Obj, SSP, std::move(TT), std::move(Features),
FileName, riscv::getEdgeKindName) {}
};
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_riscv(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromELFObject_riscv(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -951,7 +953,7 @@ createLinkGraphFromELFObject_riscv(MemoryBufferRef ObjectBuffer) {
if ((*ELFObj)->getArch() == Triple::riscv64) {
auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF64LE>>(**ELFObj);
return ELFLinkGraphBuilder_riscv<object::ELF64LE>(
- (*ELFObj)->getFileName(), ELFObjFile.getELFFile(),
+ (*ELFObj)->getFileName(), ELFObjFile.getELFFile(), SSP,
(*ELFObj)->makeTriple(), std::move(*Features))
.buildGraph();
} else {
@@ -959,7 +961,7 @@ createLinkGraphFromELFObject_riscv(MemoryBufferRef ObjectBuffer) {
"Invalid triple for RISCV ELF object file");
auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF32LE>>(**ELFObj);
return ELFLinkGraphBuilder_riscv<object::ELF32LE>(
- (*ELFObj)->getFileName(), ELFObjFile.getELFFile(),
+ (*ELFObj)->getFileName(), ELFObjFile.getELFFile(), SSP,
(*ELFObj)->makeTriple(), std::move(*Features))
.buildGraph();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index 44122726fb5c08..b3479e32b30a0f 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -238,9 +238,10 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
public:
ELFLinkGraphBuilder_x86_64(StringRef FileName,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
const object::ELFFile<object::ELF64LE> &Obj,
SubtargetFeatures Features)
- : ELFLinkGraphBuilder(Obj, Triple("x86_64-unknown-linux"),
+ : ELFLinkGraphBuilder(Obj, SSP, Triple("x86_64-unknown-linux"),
std::move(Features), FileName,
x86_64::getEdgeKindName) {}
};
@@ -261,12 +262,12 @@ class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
private:
Symbol *GOTSymbol = nullptr;
-
Error getOrCreateGOTSymbol(LinkGraph &G) {
auto DefineExternalGOTSymbolIfPresent =
createDefineExternalSectionStartAndEndSymbolsPass(
[&](LinkGraph &LG, Symbol &Sym) -> SectionRangeSymbolDesc {
- if (Sym.getName() == ELFGOTSymbolName)
+ if (Sym.getName() != nullptr &&
+ *Sym.getName() == ELFGOTSymbolName)
if (auto *GOTSection = G.findSectionByName(
x86_64::GOTTableManager::getSectionName())) {
GOTSymbol = &Sym;
@@ -292,7 +293,7 @@ class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
// Check for an existing defined symbol.
for (auto *Sym : GOTSection->symbols())
- if (Sym->getName() == ELFGOTSymbolName) {
+ if (Sym->getName() != nullptr && *Sym->getName() == ELFGOTSymbolName) {
GOTSymbol = Sym;
return Error::success();
}
@@ -314,7 +315,7 @@ class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
// we just need to point the GOT symbol at some address in this graph.
if (!GOTSymbol) {
for (auto *Sym : G.external_symbols()) {
- if (Sym->getName() == ELFGOTSymbolName) {
+ if (*Sym->getName() == ELFGOTSymbolName) {
auto Blocks = G.blocks();
if (!Blocks.empty()) {
G.makeAbsolute(*Sym, (*Blocks.begin())->getAddress());
@@ -333,8 +334,8 @@ class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
}
};
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromELFObject_x86_64(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromELFObject_x86_64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
LLVM_DEBUG({
dbgs() << "Building jitlink graph for new input "
<< ObjectBuffer.getBufferIdentifier() << "...\n";
@@ -349,7 +350,7 @@ createLinkGraphFromELFObject_x86_64(MemoryBufferRef ObjectBuffer) {
return Features.takeError();
auto &ELFObjFile = cast<object::ELFObjectFile<object::ELF64LE>>(**ELFObj);
- return ELFLinkGraphBuilder_x86_64((*ELFObj)->getFileName(),
+ return ELFLinkGraphBuilder_x86_64((*ELFObj)->getFileName(), SSP,
ELFObjFile.getELFFile(),
std::move(*Features))
.buildGraph();
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
index ef382c3ce695a9..c5da9ff9fed89f 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
@@ -125,7 +125,7 @@ raw_ostream &operator<<(raw_ostream &OS, const Symbol &Sym) {
<< ", linkage: " << formatv("{0:6}", getLinkageName(Sym.getLinkage()))
<< ", scope: " << formatv("{0:8}", getScopeName(Sym.getScope())) << ", "
<< (Sym.isLive() ? "live" : "dead") << " - "
- << (Sym.hasName() ? Sym.getName() : "<anonymous symbol>");
+ << (Sym.hasName() ? *Sym.getName() : "<anonymous symbol>");
return OS;
}
@@ -137,7 +137,7 @@ void printEdge(raw_ostream &OS, const Block &B, const Edge &E,
auto &TargetSym = E.getTarget();
if (TargetSym.hasName())
- OS << TargetSym.getName();
+ OS << *TargetSym.getName();
else {
auto &TargetBlock = TargetSym.getBlock();
auto &TargetSec = TargetBlock.getSection();
@@ -167,6 +167,16 @@ Section::~Section() {
B->~Block();
}
+LinkGraph::~LinkGraph() {
+ for (auto *Sym : AbsoluteSymbols) {
+ Sym->~Symbol();
+ }
+ for (auto *Sym : external_symbols()) {
+ Sym->~Symbol();
+ }
+ ExternalSymbols.clear();
+}
+
std::vector<Block *> LinkGraph::splitBlockImpl(std::vector<Block *> Blocks,
SplitBlockCache *Cache) {
assert(!Blocks.empty() && "Blocks must at least contain the original block");
@@ -341,7 +351,7 @@ void LinkGraph::dump(raw_ostream &OS) {
OS << formatv("-{0:x8}", -E.getAddend());
OS << ", kind = " << getEdgeKindName(E.getKind()) << ", target = ";
if (E.getTarget().hasName())
- OS << E.getTarget().getName();
+ OS << *E.getTarget().getName();
else
OS << "addressable@"
<< formatv("{0:x16}", E.getTarget().getAddress()) << "+"
@@ -412,7 +422,7 @@ Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B,
ErrStream << "In graph " << G.getName() << ", section " << Sec.getName()
<< ": relocation target ";
if (E.getTarget().hasName()) {
- ErrStream << "\"" << E.getTarget().getName() << "\"";
+ ErrStream << "\"" << *E.getTarget().getName() << "\"";
} else
ErrStream << E.getTarget().getBlock().getSection().getName() << " + "
<< formatv("{0:x}", E.getOffset());
@@ -429,7 +439,7 @@ Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B,
BestSymbolForBlock = Sym;
if (BestSymbolForBlock)
- ErrStream << BestSymbolForBlock->getName() << ", ";
+ ErrStream << *BestSymbolForBlock->getName() << ", ";
else
ErrStream << "<anonymous block> @ ";
@@ -481,22 +491,25 @@ PointerJumpStubCreator getPointerJumpStubCreator(const Triple &TT) {
}
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromObject(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
auto Magic = identify_magic(ObjectBuffer.getBuffer());
switch (Magic) {
case file_magic::macho_object:
- return createLinkGraphFromMachOObject(ObjectBuffer);
+ return createLinkGraphFromMachOObject(ObjectBuffer, SSP);
case file_magic::elf_relocatable:
- return createLinkGraphFromELFObject(ObjectBuffer);
+ return createLinkGraphFromELFObject(ObjectBuffer, SSP);
case file_magic::coff_object:
- return createLinkGraphFromCOFFObject(ObjectBuffer);
+ return createLinkGraphFromCOFFObject(ObjectBuffer, SSP);
default:
return make_error<JITLinkError>("Unsupported file format");
};
}
-std::unique_ptr<LinkGraph> absoluteSymbolsLinkGraph(const Triple &TT,
- orc::SymbolMap Symbols) {
+std::unique_ptr<LinkGraph>
+absoluteSymbolsLinkGraph(const Triple &TT,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
+ orc::SymbolMap Symbols) {
unsigned PointerSize;
endianness Endianness =
TT.isLittleEndian() ? endianness::little : endianness::big;
@@ -518,7 +531,7 @@ std::unique_ptr<LinkGraph> absoluteSymbolsLinkGraph(const Triple &TT,
static std::atomic<uint64_t> Counter = {0};
auto Index = Counter.fetch_add(1, std::memory_order_relaxed);
auto G = std::make_unique<LinkGraph>(
- "<Absolute Symbols " + std::to_string(Index) + ">", TT, PointerSize,
+ "<Absolute Symbols " + std::to_string(Index) + ">", SSP, TT, PointerSize,
Endianness, /*GetEdgeKindName=*/nullptr);
for (auto &[Name, Def] : Symbols) {
auto &Sym =
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
index 01144763ac4ca5..25fa0467bee9ed 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
@@ -214,8 +214,7 @@ JITLinkContext::LookupMap JITLinkerBase::getExternalSymbolNames() const {
for (auto *Sym : G->external_symbols()) {
assert(!Sym->getAddress() &&
"External has already been assigned an address");
- assert(Sym->getName() != StringRef() && Sym->getName() != "" &&
- "Externals must be named");
+ assert(Sym->hasName() && "Externals must be named");
SymbolLookupFlags LookupFlags =
Sym->isWeaklyReferenced() ? SymbolLookupFlags::WeaklyReferencedSymbol
: SymbolLookupFlags::RequiredSymbol;
@@ -245,7 +244,7 @@ void JITLinkerBase::applyLookupResult(AsyncLookupResult Result) {
LLVM_DEBUG({
dbgs() << "Externals after applying lookup result:\n";
for (auto *Sym : G->external_symbols()) {
- dbgs() << " " << Sym->getName() << ": "
+ dbgs() << " " << *Sym->getName() << ": "
<< formatv("{0:x16}", Sym->getAddress().getValue());
switch (Sym->getLinkage()) {
case Linkage::Strong:
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
index 42a77a52beef05..7ea9233364f9ad 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
@@ -155,8 +155,9 @@ void SimpleSegmentAlloc::Create(JITLinkMemoryManager &MemMgr,
"__---.finalize", "__R--.finalize", "__-W-.finalize", "__RW-.finalize",
"__--X.finalize", "__R-X.finalize", "__-WX.finalize", "__RWX.finalize"};
- auto G = std::make_unique<LinkGraph>("", Triple(), 0,
- llvm::endianness::native, nullptr);
+ auto G = std::make_unique<LinkGraph>(
+ "", std::shared_ptr<orc::SymbolStringPool>(), Triple(), 0,
+ llvm::endianness::native, nullptr);
orc::AllocGroupSmallMap<Block *> ContentBlocks;
orc::ExecutorAddr NextAddr(0x100000);
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO.cpp
index 40086ccf2b66f2..fd76eac361d427 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO.cpp
@@ -27,7 +27,8 @@ namespace llvm {
namespace jitlink {
Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer) {
+createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer,
+ std::shared_ptr<orc::SymbolStringPool> SSP) {
StringRef Data = ObjectBuffer.getBuffer();
if (Data.size() < 4)
return make_error<JITLinkError>("Truncated MachO buffer \"" +
@@ -63,9 +64,9 @@ createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer) {
switch (CPUType) {
case MachO::CPU_TYPE_ARM64:
- return createLinkGraphFromMachOObject_arm64(ObjectBuffer);
+ return createLinkGraphFromMachOObject_arm64(ObjectBuffer, SSP);
case MachO::CPU_TYPE_X86_64:
- return createLinkGraphFromMachOObject_x86_64(ObjectBuffer);
+ return createLinkGraphFromMachOObject_x86_64(ObjectBuffer, SSP);
}
return make_error<JITLinkError>("MachO-64 CPU type not valid");
} else
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
index 15d679bcbb5df8..d800f013d87a2e 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
@@ -49,10 +49,12 @@ Expected<std::unique_ptr<LinkGraph>> MachOLinkGraphBuilder::buildGraph() {
}
MachOLinkGraphBuilder::MachOLinkGraphBuilder(
- const object::MachOObjectFile &Obj, Triple TT, SubtargetFeatures Features,
+ const object::MachOObjectFile &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
+ SubtargetFeatures Features,
LinkGraph::GetEdgeKindNameFunction GetEdgeKindName)
: Obj(Obj),
- G(std::make_unique<LinkGraph>(std::string(Obj.getFileName()),
+ G(std::make_unique<LinkGraph>(std::string(Obj.getFileName()), SSP,
std::move(TT), std::move(Features),
getPointerSize(Obj), getEndianness(Obj),
std::move(GetEdgeKindName))) {
@@ -319,9 +321,8 @@ Error MachOLinkGraphBuilder::createNormalizedSymbols() {
}
}
- IndexToSymbol[SymbolIndex] =
- &createNormalizedSymbol(*Name, Value, Type, Sect, Desc,
- getLinkage(Desc), getScope(*Name, Type));
+ IndexToSymbol[SymbolIndex] = &createNormalizedSymbol(
+ Name, Value, Type, Sect, Desc, getLinkage(Desc), getScope(*Name, Type));
}
return Error::success();
@@ -587,7 +588,7 @@ Symbol &MachOLinkGraphBuilder::createStandardGraphSymbol(NormalizedSymbol &NSym,
if (!NSym.Name)
dbgs() << "<anonymous symbol>";
else
- dbgs() << NSym.Name;
+ dbgs() << *NSym.Name;
if (IsText)
dbgs() << " [text]";
if (IsNoDeadStrip)
@@ -726,7 +727,7 @@ Error MachOLinkGraphBuilder::graphifyCStringSection(
LLVM_DEBUG({
dbgs() << " Adding symbol for c-string block " << B.getRange()
<< ": "
- << (Sym.hasName() ? Sym.getName() : "<anonymous symbol>")
+ << (Sym.hasName() ? *Sym.getName() : "<anonymous symbol>")
<< " at offset " << formatv("{0:x}", Sym.getOffset()) << "\n";
});
@@ -825,8 +826,8 @@ Error CompactUnwindSplitter::operator()(LinkGraph &G) {
if (E.getOffset() == 0) {
LLVM_DEBUG({
dbgs() << " Updating compact unwind record at "
- << CURec->getAddress() << " to point to "
- << (E.getTarget().hasName() ? E.getTarget().getName()
+ << formatv("{0:x16}", CURec->getAddress()) << " to point to "
+ << (E.getTarget().hasName() ? *E.getTarget().getName()
: StringRef())
<< " (at " << E.getTarget().getAddress() << ")\n";
});
@@ -835,7 +836,7 @@ Error CompactUnwindSplitter::operator()(LinkGraph &G) {
return make_error<JITLinkError>(
"Error adding keep-alive edge for compact unwind record at " +
formatv("{0:x}", CURec->getAddress()) + ": target " +
- E.getTarget().getName() + " is an external symbol");
+ *E.getTarget().getName() + " is an external symbol");
auto &TgtBlock = E.getTarget().getBlock();
auto &CURecSym =
G.addAnonymousSymbol(*CURec, 0, CURecordSize, false, false);
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h
index a4ae0ac1ecfc09..92754d3f5a6c0d 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h
@@ -35,8 +35,6 @@ class MachOLinkGraphBuilder {
struct NormalizedSymbol {
friend class MachOLinkGraphBuilder;
-
- private:
NormalizedSymbol(std::optional<StringRef> Name, uint64_t Value,
uint8_t Type, uint8_t Sect, uint16_t Desc, Linkage L,
Scope S)
@@ -45,6 +43,7 @@ class MachOLinkGraphBuilder {
assert((!Name || !Name->empty()) && "Name must be none or non-empty");
}
+ private:
public:
NormalizedSymbol(const NormalizedSymbol &) = delete;
NormalizedSymbol &operator=(const NormalizedSymbol &) = delete;
@@ -83,10 +82,10 @@ class MachOLinkGraphBuilder {
using SectionParserFunction = std::function<Error(NormalizedSection &S)>;
- MachOLinkGraphBuilder(const object::MachOObjectFile &Obj, Triple TT,
+ MachOLinkGraphBuilder(const object::MachOObjectFile &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP, Triple TT,
SubtargetFeatures Features,
LinkGraph::GetEdgeKindNameFunction GetEdgeKindName);
-
LinkGraph &getGraph() const { return *G; }
const object::MachOObjectFile &getObject() const { return Obj; }
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
index 125c6373f82d9f..c081e2b64f2ebc 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
@@ -27,8 +27,9 @@ namespace {
class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
public:
MachOLinkGraphBuilder_arm64(const object::MachOObjectFile &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
SubtargetFeatures Features)
- : MachOLinkGraphBuilder(Obj, Triple("arm64-apple-darwin"),
+ : MachOLinkGraphBuilder(Obj, SSP, Triple("arm64-apple-darwin"),
std::move(Features), aarch64::getEdgeKindName),
NumSymbols(Obj.getSymtabLoadCommand().nsyms) {}
@@ -558,8 +559,8 @@ class MachOJITLinker_arm64 : public JITLinker<MachOJITLinker_arm64> {
uint64_t NullValue = 0;
};
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromMachOObject_arm64(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromMachOObject_arm64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
auto MachOObj = object::ObjectFile::createMachOObjectFile(ObjectBuffer);
if (!MachOObj)
return MachOObj.takeError();
@@ -568,7 +569,7 @@ createLinkGraphFromMachOObject_arm64(MemoryBufferRef ObjectBuffer) {
if (!Features)
return Features.takeError();
- return MachOLinkGraphBuilder_arm64(**MachOObj, std::move(*Features))
+ return MachOLinkGraphBuilder_arm64(**MachOObj, SSP, std::move(*Features))
.buildGraph();
}
@@ -588,7 +589,7 @@ void link_MachO_arm64(std::unique_ptr<LinkGraph> G,
Config.PrePrunePasses.push_back(
CompactUnwindSplitter("__LD,__compact_unwind"));
- // Add eh-frame passes.
+ // Add eh-frame passses.
// FIXME: Prune eh-frames for which compact-unwind is available once
// we support compact-unwind registration with libunwind.
Config.PrePrunePasses.push_back(createEHFrameSplitterPass_MachO_arm64());
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
index 2c69d61316a8ad..a0ae614fefe46a 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
@@ -27,8 +27,9 @@ namespace {
class MachOLinkGraphBuilder_x86_64 : public MachOLinkGraphBuilder {
public:
MachOLinkGraphBuilder_x86_64(const object::MachOObjectFile &Obj,
+ std::shared_ptr<orc::SymbolStringPool> SSP,
SubtargetFeatures Features)
- : MachOLinkGraphBuilder(Obj, Triple("x86_64-apple-darwin"),
+ : MachOLinkGraphBuilder(Obj, SSP, Triple("x86_64-apple-darwin"),
std::move(Features), x86_64::getEdgeKindName) {}
private:
@@ -483,8 +484,8 @@ class MachOJITLinker_x86_64 : public JITLinker<MachOJITLinker_x86_64> {
}
};
-Expected<std::unique_ptr<LinkGraph>>
-createLinkGraphFromMachOObject_x86_64(MemoryBufferRef ObjectBuffer) {
+Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromMachOObject_x86_64(
+ MemoryBufferRef ObjectBuffer, std::shared_ptr<orc::SymbolStringPool> SSP) {
auto MachOObj = object::ObjectFile::createMachOObjectFile(ObjectBuffer);
if (!MachOObj)
return MachOObj.takeError();
@@ -493,7 +494,7 @@ createLinkGraphFromMachOObject_x86_64(MemoryBufferRef ObjectBuffer) {
if (!Features)
return Features.takeError();
- return MachOLinkGraphBuilder_x86_64(**MachOObj, std::move(*Features))
+ return MachOLinkGraphBuilder_x86_64(**MachOObj, SSP, std::move(*Features))
.buildGraph();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/PerGraphGOTAndPLTStubsBuilder.h b/llvm/lib/ExecutionEngine/JITLink/PerGraphGOTAndPLTStubsBuilder.h
index 6e325f92bafbe4..89098c33b30a0c 100644
--- a/llvm/lib/ExecutionEngine/JITLink/PerGraphGOTAndPLTStubsBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/PerGraphGOTAndPLTStubsBuilder.h
@@ -76,7 +76,7 @@ class PerGraphGOTAndPLTStubsBuilder {
if (GOTEntryI == GOTEntries.end()) {
auto &GOTEntry = impl().createGOTEntry(Target);
LLVM_DEBUG({
- dbgs() << " Created GOT entry for " << Target.getName() << ": "
+ dbgs() << " Created GOT entry for " << *Target.getName() << ": "
<< GOTEntry << "\n";
});
GOTEntryI =
@@ -97,7 +97,7 @@ class PerGraphGOTAndPLTStubsBuilder {
if (StubI == PLTStubs.end()) {
auto &StubSymbol = impl().createPLTStub(Target);
LLVM_DEBUG({
- dbgs() << " Created PLT stub for " << Target.getName() << ": "
+ dbgs() << " Created PLT stub for " << *Target.getName() << ": "
<< StubSymbol << "\n";
});
StubI =
@@ -114,8 +114,8 @@ class PerGraphGOTAndPLTStubsBuilder {
private:
BuilderImplT &impl() { return static_cast<BuilderImplT &>(*this); }
- DenseMap<StringRef, Symbol *> GOTEntries;
- DenseMap<StringRef, Symbol *> PLTStubs;
+ DenseMap<orc::SymbolStringPtr, Symbol *> GOTEntries;
+ DenseMap<orc::SymbolStringPtr, Symbol *> PLTStubs;
};
} // end namespace jitlink
diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
index 00be2f57d06640..9022652f634f71 100644
--- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
@@ -854,14 +854,14 @@ bool StubsManager_prev7::visitEdge(LinkGraph &G, Block *B, Edge &E) {
Symbol &Target = E.getTarget();
assert(Target.hasName() && "Edge cannot point to anonymous target");
- auto [Slot, NewStub] = getStubMapSlot(Target.getName());
+ auto [Slot, NewStub] = getStubMapSlot(*Target.getName());
if (NewStub) {
if (!StubsSection)
StubsSection = &G.createSection(getSectionName(),
orc::MemProt::Read | orc::MemProt::Exec);
LLVM_DEBUG({
- dbgs() << " Created stub entry for " << Target.getName() << " in "
+ dbgs() << " Created stub entry for " << *Target.getName() << " in "
<< StubsSection->getName() << "\n";
});
Slot->B = &createStubPrev7(G, *StubsSection, Target);
@@ -898,7 +898,7 @@ bool StubsManager_v7::visitEdge(LinkGraph &G, Block *B, Edge &E) {
Symbol &Target = E.getTarget();
assert(Target.hasName() && "Edge cannot point to anonymous target");
- Symbol *&StubSymbol = getStubSymbolSlot(Target.getName(), MakeThumb);
+ Symbol *&StubSymbol = getStubSymbolSlot(*Target.getName(), MakeThumb);
if (!StubSymbol) {
if (!StubsSection)
@@ -912,7 +912,7 @@ bool StubsManager_v7::visitEdge(LinkGraph &G, Block *B, Edge &E) {
LLVM_DEBUG({
dbgs() << " Created " << (MakeThumb ? "Thumb" : "Arm") << " entry for "
- << Target.getName() << " in " << StubsSection->getName() << ": "
+ << *Target.getName() << " in " << StubsSection->getName() << ": "
<< *StubSymbol << "\n";
});
}
diff --git a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
index f46cb906bb7556..29b9a1aef03d0a 100644
--- a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
@@ -67,8 +67,8 @@ class COFFHeaderMaterializationUnit : public MaterializationUnit {
}
auto G = std::make_unique<jitlink::LinkGraph>(
- "<COFFHeaderMU>", TT, PointerSize, Endianness,
- jitlink::getGenericEdgeKindName);
+ "<COFFHeaderMU>", CP.getExecutionSession().getSymbolStringPool(), TT,
+ PointerSize, Endianness, jitlink::getGenericEdgeKindName);
auto &HeaderSection = G->createSection("__header", MemProt::Read);
auto &HeaderBlock = createHeaderBlock(*G, HeaderSection);
@@ -791,7 +791,7 @@ Error COFFPlatform::COFFPlatformPlugin::associateJITDylibHeaderSymbol(
jitlink::LinkGraph &G, MaterializationResponsibility &MR,
bool IsBootstraping) {
auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
- return Sym->getName() == *CP.COFFHeaderStartSymbol;
+ return *Sym->getName() == *CP.COFFHeaderStartSymbol;
});
assert(I != G.defined_symbols().end() && "Missing COFF header start symbol");
diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
index e387b06ee9346b..c08e52e943c924 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
@@ -214,8 +214,8 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
Builder.addSymbol("", MachO::N_BNSYM, 1, 0, 0);
StabSymbols.push_back(
- {*Sym, Builder.addSymbol(Sym->getName(), SymType, 1, 0, 0),
- Builder.addSymbol(Sym->getName(), SymType, 0, 0, 0)});
+ {*Sym, Builder.addSymbol(*Sym->getName(), SymType, 1, 0, 0),
+ Builder.addSymbol(*Sym->getName(), SymType, 0, 0, 0)});
Builder.addSymbol("", MachO::N_ENSYM, 1, 0, 0);
}
}
diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.cpp
index fffecfc9781442..f7a08d2b778fb1 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.cpp
@@ -87,7 +87,7 @@ constexpr StringRef RegisterPerfImplSymbolName =
static PerfJITCodeLoadRecord
getCodeLoadRecord(const Symbol &Sym, std::atomic<uint64_t> &CodeIndex) {
PerfJITCodeLoadRecord Record;
- auto Name = Sym.getName();
+ auto Name = *Sym.getName();
auto Addr = Sym.getAddress();
auto Size = Sym.getSize();
Record.Prefix.Id = PerfJITRecordType::JIT_CODE_LOAD;
@@ -118,7 +118,7 @@ getDebugInfoRecord(const Symbol &Sym, DWARFContext &DC) {
auto Addr = Sym.getAddress();
auto Size = Sym.getSize();
auto SAddr = object::SectionedAddress{Addr.getValue(), Section.getOrdinal()};
- LLVM_DEBUG(dbgs() << "Getting debug info for symbol " << Sym.getName()
+ LLVM_DEBUG(dbgs() << "Getting debug info for symbol " << *Sym.getName()
<< " at address " << Addr.getValue() << " with size "
<< Size << "\n"
<< "Section ordinal: " << Section.getOrdinal() << "\n");
diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp
index de02a20524b9cb..9715a503629bf5 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp
@@ -56,7 +56,7 @@ static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) {
Method.ParentMI = 0;
Method.LoadAddr = Sym->getAddress();
Method.LoadSize = Sym->getSize();
- Method.NameSI = GetStringIdx(Sym->getName());
+ Method.NameSI = GetStringIdx(*Sym->getName());
Method.ClassFileSI = 0;
Method.SourceFileSI = 0;
diff --git a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
index 6cea9845a3403b..ef086709ef43d4 100644
--- a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
@@ -69,9 +69,9 @@ std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(ELFNixPlatform &MOP,
llvm_unreachable("Unrecognized architecture");
}
- return std::make_unique<jitlink::LinkGraph>(std::move(Name), TT, PointerSize,
- Endianness,
- jitlink::getGenericEdgeKindName);
+ return std::make_unique<jitlink::LinkGraph>(
+ std::move(Name), MOP.getExecutionSession().getSymbolStringPool(), TT,
+ PointerSize, Endianness, jitlink::getGenericEdgeKindName);
}
// Creates a Bootstrap-Complete LinkGraph to run deferred actions.
@@ -192,8 +192,8 @@ class DSOHandleMaterializationUnit : public MaterializationUnit {
// void *__dso_handle = &__dso_handle;
auto G = std::make_unique<jitlink::LinkGraph>(
- "<DSOHandleMU>", TT, PointerSize, Endianness,
- jitlink::getGenericEdgeKindName);
+ "<DSOHandleMU>", ENP.getExecutionSession().getSymbolStringPool(), TT,
+ PointerSize, Endianness, jitlink::getGenericEdgeKindName);
auto &DSOHandleSection =
G->createSection(".data.__dso_handle", MemProt::Read);
auto &DSOHandleBlock = G->createContentBlock(
@@ -667,14 +667,14 @@ Error ELFNixPlatform::ELFNixPlatformPlugin::
for (auto *Sym : G.defined_symbols()) {
for (auto &RTSym : RuntimeSymbols) {
- if (Sym->hasName() && Sym->getName() == RTSym.first) {
+ if (Sym->hasName() && *Sym->getName() == RTSym.first) {
if (*RTSym.second)
return make_error<StringError>(
"Duplicate " + RTSym.first +
" detected during ELFNixPlatform bootstrap",
inconvertibleErrorCode());
- if (Sym->getName() == *MP.DSOHandleSymbol)
+ if (*Sym->getName() == *MP.DSOHandleSymbol)
RegisterELFNixHeader = true;
*RTSym.second = Sym->getAddress();
@@ -802,7 +802,7 @@ void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
Config.PostAllocationPasses.push_back([this, &JD = MR.getTargetJITDylib()](
jitlink::LinkGraph &G) -> Error {
auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
- return Sym->getName() == *MP.DSOHandleSymbol;
+ return Sym->getName() == MP.DSOHandleSymbol;
});
assert(I != G.defined_symbols().end() && "Missing DSO handle symbol");
{
@@ -1001,12 +1001,17 @@ Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
jitlink::LinkGraph &G, JITDylib &JD) {
-
+ auto TLSGetAddrSymbolName = G.intern("__tls_get_addr");
+ auto TLSDescResolveSymbolName = G.intern("__tlsdesc_resolver");
for (auto *Sym : G.external_symbols()) {
- if (Sym->getName() == "__tls_get_addr") {
- Sym->setName("___orc_rt_elfnix_tls_get_addr");
- } else if (Sym->getName() == "__tlsdesc_resolver") {
- Sym->setName("___orc_rt_elfnix_tlsdesc_resolver");
+ if (Sym->getName() == TLSGetAddrSymbolName) {
+ auto TLSGetAddr =
+ MP.getExecutionSession().intern("___orc_rt_elfnix_tls_get_addr");
+ Sym->setName(std::move(TLSGetAddr));
+ } else if (Sym->getName() == TLSDescResolveSymbolName) {
+ auto TLSGetAddr =
+ MP.getExecutionSession().intern("___orc_rt_elfnix_tlsdesc_resolver");
+ Sym->setName(std::move(TLSGetAddr));
}
}
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index 1dcf91443d55db..1cf284815be4f9 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -12,6 +12,7 @@
#include "llvm/ExecutionEngine/Orc/LoadLinkableFile.h"
#include "llvm/ExecutionEngine/Orc/MachO.h"
#include "llvm/ExecutionEngine/Orc/ObjectFileInterface.h"
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
@@ -559,8 +560,8 @@ DLLImportDefinitionGenerator::createStubsGraph(const SymbolMap &Resolved) {
return Endianness.takeError();
auto G = std::make_unique<jitlink::LinkGraph>(
- "<DLLIMPORT_STUBS>", TT, *PointerSize, *Endianness,
- jitlink::getGenericEdgeKindName);
+ "<DLLIMPORT_STUBS>", ES.getSymbolStringPool(), TT, *PointerSize,
+ *Endianness, jitlink::getGenericEdgeKindName);
jitlink::Section &Sec =
G->createSection(getSectionName(), MemProt::Read | MemProt::Exec);
@@ -572,9 +573,8 @@ DLLImportDefinitionGenerator::createStubsGraph(const SymbolMap &Resolved) {
// Create __imp_ symbol
jitlink::Symbol &Ptr =
jitlink::x86_64::createAnonymousPointer(*G, Sec, &Target);
- auto NameCopy = G->allocateContent(Twine(getImpPrefix()) + *KV.first);
- StringRef NameCopyRef = StringRef(NameCopy.data(), NameCopy.size());
- Ptr.setName(NameCopyRef);
+ auto name = getImpPrefix() + *KV.first;
+ Ptr.setName(G->intern(name.getSingleStringRef()));
Ptr.setLinkage(jitlink::Linkage::Strong);
Ptr.setScope(jitlink::Scope::Default);
diff --git a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
index 5724f96c2d5685..0383db858be6e5 100644
--- a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
@@ -401,7 +401,7 @@ Error addFunctionPointerRelocationsToCurrentSymbol(jitlink::Symbol &Sym,
auto SymSize = Sym.getSize() ? Sym.getSize() : B.getSize() - Sym.getOffset();
auto Content = ArrayRef(SymStartInBlock, SymSize);
- LLVM_DEBUG(dbgs() << "Adding self-relocations to " << Sym.getName() << "\n");
+ LLVM_DEBUG(dbgs() << "Adding self-relocations to " << *Sym.getName() << "\n");
SmallDenseSet<uintptr_t, 8> ExistingRelocations;
for (auto &E : B.edges()) {
diff --git a/llvm/lib/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.cpp b/llvm/lib/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.cpp
index c186a947b3bb54..ef805c5232fab6 100644
--- a/llvm/lib/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.cpp
@@ -29,8 +29,8 @@ void JITLinkRedirectableSymbolManager::emitRedirectableSymbols(
Triple TT = ES.getTargetTriple();
auto G = std::make_unique<jitlink::LinkGraph>(
- ("<INDIRECT STUBS #" + Twine(++StubGraphIdx) + ">").str(), TT,
- TT.isArch64Bit() ? 8 : 4,
+ ("<INDIRECT STUBS #" + Twine(++StubGraphIdx) + ">").str(),
+ ES.getSymbolStringPool(), TT, TT.isArch64Bit() ? 8 : 4,
TT.isLittleEndian() ? endianness::little : endianness::big,
jitlink::getGenericEdgeKindName);
auto &PointerSection =
@@ -48,12 +48,12 @@ void JITLinkRedirectableSymbolManager::emitRedirectableSymbols(
auto PtrName = ES.intern((*Name + StubSuffix).str());
auto &Ptr = AnonymousPtrCreator(*G, PointerSection, TargetSym, 0);
- Ptr.setName(*PtrName);
+ Ptr.setName(PtrName);
Ptr.setScope(jitlink::Scope::Hidden);
auto &Stub = PtrJumpStubCreator(*G, StubsSection, Ptr);
- Stub.setName(*Name);
+ Stub.setName(Stub.getName());
Stub.setScope(jitlink::Scope::Default);
- NewSymbols[std::move(PtrName)] = JITSymbolFlags();
+ NewSymbols[PtrName] = JITSymbolFlags();
}
// Try to claim responsibility for the new stub symbols.
diff --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
index e5609053c74d7b..ae806dc0e39b2f 100644
--- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
@@ -111,9 +111,9 @@ std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(MachOPlatform &MOP,
llvm_unreachable("Unrecognized architecture");
}
- return std::make_unique<jitlink::LinkGraph>(std::move(Name), TT, PointerSize,
- Endianness,
- jitlink::getGenericEdgeKindName);
+ return std::make_unique<jitlink::LinkGraph>(
+ std::move(Name), MOP.getExecutionSession().getSymbolStringPool(), TT,
+ PointerSize, Endianness, jitlink::getGenericEdgeKindName);
}
// Creates a Bootstrap-Complete LinkGraph to run deferred actions.
@@ -896,14 +896,14 @@ Error MachOPlatform::MachOPlatformPlugin::
for (auto *Sym : G.defined_symbols()) {
for (auto &RTSym : RuntimeSymbols) {
- if (Sym->hasName() && Sym->getName() == RTSym.first) {
+ if (Sym->hasName() && *Sym->getName() == RTSym.first) {
if (*RTSym.second)
return make_error<StringError>(
"Duplicate " + RTSym.first +
" detected during MachOPlatform bootstrap",
inconvertibleErrorCode());
- if (Sym->getName() == *MP.MachOHeaderStartSymbol)
+ if (Sym->getName() == MP.MachOHeaderStartSymbol)
RegisterMachOHeader = true;
*RTSym.second = Sym->getAddress();
@@ -939,7 +939,7 @@ Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineEnd(
Error MachOPlatform::MachOPlatformPlugin::associateJITDylibHeaderSymbol(
jitlink::LinkGraph &G, MaterializationResponsibility &MR) {
auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
- return Sym->getName() == *MP.MachOHeaderStartSymbol;
+ return Sym->getName() == MP.MachOHeaderStartSymbol;
});
assert(I != G.defined_symbols().end() && "Missing MachO header start symbol");
@@ -1178,11 +1178,13 @@ Error MachOPlatform::MachOPlatformPlugin::mergeImageInfoFlags(
Error MachOPlatform::MachOPlatformPlugin::fixTLVSectionsAndEdges(
jitlink::LinkGraph &G, JITDylib &JD) {
-
+ auto TLVBootStrapSymbolName = G.intern("__tlv_bootstrap");
// Rename external references to __tlv_bootstrap to ___orc_rt_tlv_get_addr.
for (auto *Sym : G.external_symbols())
- if (Sym->getName() == "__tlv_bootstrap") {
- Sym->setName("___orc_rt_macho_tlv_get_addr");
+ if (Sym->getName() == TLVBootStrapSymbolName) {
+ auto TLSGetADDR =
+ MP.getExecutionSession().intern("___orc_rt_macho_tlv_get_addr");
+ Sym->setName(std::move(TLSGetADDR));
break;
}
@@ -1502,19 +1504,19 @@ Error MachOPlatform::MachOPlatformPlugin::populateObjCRuntimeObject(
// Look for an existing __objc_imageinfo symbol.
jitlink::Symbol *ObjCImageInfoSym = nullptr;
for (auto *Sym : G.external_symbols())
- if (Sym->getName() == ObjCImageInfoSymbolName) {
+ if (Sym->hasName() && *Sym->getName() == ObjCImageInfoSymbolName) {
ObjCImageInfoSym = Sym;
break;
}
if (!ObjCImageInfoSym)
for (auto *Sym : G.absolute_symbols())
- if (Sym->getName() == ObjCImageInfoSymbolName) {
+ if (Sym->hasName() && *Sym->getName() == ObjCImageInfoSymbolName) {
ObjCImageInfoSym = Sym;
break;
}
if (!ObjCImageInfoSym)
for (auto *Sym : G.defined_symbols())
- if (Sym->hasName() && Sym->getName() == ObjCImageInfoSymbolName) {
+ if (Sym->hasName() && *Sym->getName() == ObjCImageInfoSymbolName) {
ObjCImageInfoSym = Sym;
std::optional<uint32_t> Flags;
{
@@ -1655,11 +1657,11 @@ Error MachOPlatform::MachOPlatformPlugin::prepareSymbolTableRegistration(
if (!Sym->hasName())
continue;
- auto I = ExistingStrings.find(Sym->getName());
+ auto I = ExistingStrings.find(*Sym->getName());
if (I == ExistingStrings.end()) {
auto &NameBlock = G.createMutableContentBlock(
- *CStringSec, G.allocateCString(Sym->getName()), orc::ExecutorAddr(),
- 1, 0);
+ *CStringSec, G.allocateCString(*Sym->getName()),
+ orc::ExecutorAddr(), 1, 0);
auto &SymbolNameSym = G.addAnonymousSymbol(
NameBlock, 0, NameBlock.getSize(), false, true);
JITSymTabInfo.push_back({Sym, &SymbolNameSym});
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
index 0286b0c931974b..19972da353f2fc 100644
--- a/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
@@ -133,7 +133,7 @@ getELFObjectFileSymbolInfo(ExecutionSession &ES,
if (Sym.getBinding() == ELF::STB_GNU_UNIQUE)
*SymFlags |= JITSymbolFlags::Weak;
- I.SymbolFlags[ES.intern(*Name)] = std::move(*SymFlags);
+ I.SymbolFlags[ES.intern(std::move(*Name))] = std::move(*SymFlags);
}
SymbolStringPtr InitSymbol;
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
index 86c08cbdee5f32..0671ca2c4c7d07 100644
--- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
@@ -100,8 +100,7 @@ class LinkGraphMaterializationUnit : public MaterializationUnit {
return;
assert(Sym->hasName() && "Anonymous non-local symbol?");
- LGI.SymbolFlags[ES.intern(Sym->getName())] =
- getJITSymbolFlagsForSymbol(*Sym);
+ LGI.SymbolFlags[Sym->getName()] = getJITSymbolFlagsForSymbol(*Sym);
};
for (auto *Sym : G.defined_symbols())
@@ -129,7 +128,7 @@ class LinkGraphMaterializationUnit : public MaterializationUnit {
void discard(const JITDylib &JD, const SymbolStringPtr &Name) override {
for (auto *Sym : G->defined_symbols())
- if (Sym->getName() == *Name) {
+ if (Sym->getName() == Name) {
assert(Sym->getLinkage() == Linkage::Weak &&
"Discarding non-weak definition");
G->makeExternal(*Sym);
@@ -204,7 +203,7 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
LookupFlags = orc::SymbolLookupFlags::WeaklyReferencedSymbol;
break;
}
- LookupSet.add(ES.intern(KV.first), LookupFlags);
+ LookupSet.add(KV.first, LookupFlags);
}
// OnResolve -- De-intern the symbols and pass the result to the linker.
@@ -215,7 +214,7 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
else {
AsyncLookupResult LR;
for (auto &KV : *Result)
- LR[*KV.first] = KV.second;
+ LR[KV.first] = KV.second;
LookupContinuation->run(std::move(LR));
}
};
@@ -231,7 +230,6 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
}
Error notifyResolved(LinkGraph &G) override {
- auto &ES = Layer.getExecutionSession();
SymbolFlagsMap ExtraSymbolsToClaim;
bool AutoClaim = Layer.AutoClaimObjectSymbols;
@@ -239,27 +237,25 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
SymbolMap InternedResult;
for (auto *Sym : G.defined_symbols())
if (Sym->hasName() && Sym->getScope() != Scope::Local) {
- auto InternedName = ES.intern(Sym->getName());
auto Ptr = getJITSymbolPtrForSymbol(*Sym, G.getTargetTriple());
auto Flags = getJITSymbolFlagsForSymbol(*Sym);
- InternedResult[InternedName] = {Ptr, Flags};
- if (AutoClaim && !MR->getSymbols().count(InternedName)) {
- assert(!ExtraSymbolsToClaim.count(InternedName) &&
+ InternedResult[Sym->getName()] = {Ptr, Flags};
+ if (AutoClaim && !MR->getSymbols().count(Sym->getName())) {
+ assert(!ExtraSymbolsToClaim.count(Sym->getName()) &&
"Duplicate symbol to claim?");
- ExtraSymbolsToClaim[InternedName] = Flags;
+ ExtraSymbolsToClaim[Sym->getName()] = Flags;
}
}
for (auto *Sym : G.absolute_symbols())
if (Sym->hasName() && Sym->getScope() != Scope::Local) {
- auto InternedName = ES.intern(Sym->getName());
auto Ptr = getJITSymbolPtrForSymbol(*Sym, G.getTargetTriple());
auto Flags = getJITSymbolFlagsForSymbol(*Sym);
- InternedResult[InternedName] = {Ptr, Flags};
- if (AutoClaim && !MR->getSymbols().count(InternedName)) {
- assert(!ExtraSymbolsToClaim.count(InternedName) &&
+ InternedResult[Sym->getName()] = {Ptr, Flags};
+ if (AutoClaim && !MR->getSymbols().count(Sym->getName())) {
+ assert(!ExtraSymbolsToClaim.count(Sym->getName()) &&
"Duplicate symbol to claim?");
- ExtraSymbolsToClaim[InternedName] = Flags;
+ ExtraSymbolsToClaim[Sym->getName()] = Flags;
}
}
@@ -381,19 +377,16 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
private:
Error claimOrExternalizeWeakAndCommonSymbols(LinkGraph &G) {
- auto &ES = Layer.getExecutionSession();
-
SymbolFlagsMap NewSymbolsToClaim;
std::vector<std::pair<SymbolStringPtr, Symbol *>> NameToSym;
auto ProcessSymbol = [&](Symbol *Sym) {
if (Sym->hasName() && Sym->getLinkage() == Linkage::Weak &&
Sym->getScope() != Scope::Local) {
- auto Name = ES.intern(Sym->getName());
- if (!MR->getSymbols().count(ES.intern(Sym->getName()))) {
- NewSymbolsToClaim[Name] =
+ if (!MR->getSymbols().count(Sym->getName())) {
+ NewSymbolsToClaim[Sym->getName()] =
getJITSymbolFlagsForSymbol(*Sym) | JITSymbolFlags::Weak;
- NameToSym.push_back(std::make_pair(std::move(Name), Sym));
+ NameToSym.push_back(std::make_pair(Sym->getName(), Sym));
}
}
};
@@ -423,9 +416,8 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
}
Error markResponsibilitySymbolsLive(LinkGraph &G) const {
- auto &ES = Layer.getExecutionSession();
for (auto *Sym : G.defined_symbols())
- if (Sym->hasName() && MR->getSymbols().count(ES.intern(Sym->getName())))
+ if (Sym->hasName() && MR->getSymbols().count(Sym->getName()))
Sym->setLive(true);
return Error::success();
}
@@ -560,15 +552,6 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
// SymbolDependenceGroups (in the SymbolDepGroups member), ready for use in
// the upcoming notifyFinalized call.
auto &TargetJD = MR->getTargetJITDylib();
- auto &ES = TargetJD.getExecutionSession();
-
- DenseMap<Symbol *, SymbolStringPtr> InternedNames;
- auto GetInternedName = [&](Symbol *S) {
- auto &Name = InternedNames[S];
- if (!Name)
- Name = ES.intern(S->getName());
- return Name;
- };
for (auto &[B, BI] : BlockInfos) {
if (!BI.Defs.empty()) {
@@ -576,10 +559,10 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
auto &SDG = SymbolDepGroups.back();
for (auto *Def : BI.Defs)
- SDG.Symbols.insert(GetInternedName(Def));
+ SDG.Symbols.insert(Def->getName());
for (auto *Dep : BI.SymbolDeps) {
- auto DepName = GetInternedName(Dep);
+ auto DepName = Dep->getName();
if (Dep->isDefined())
SDG.Dependencies[&TargetJD].insert(std::move(DepName));
else {
@@ -645,8 +628,8 @@ void ObjectLinkingLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
auto Ctx = std::make_unique<ObjectLinkingLayerJITLinkContext>(
*this, std::move(R), std::move(O));
-
- if (auto G = createLinkGraphFromObject(ObjBuffer)) {
+ if (auto G = createLinkGraphFromObject(
+ ObjBuffer, getExecutionSession().getSymbolStringPool())) {
Ctx->notifyMaterializing(**G);
link(std::move(*G), std::move(Ctx));
} else {
diff --git a/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp b/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp
index 4f28b8bda529b9..4ed05ef3573f85 100644
--- a/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp
@@ -18,6 +18,7 @@ void SectCreateMaterializationUnit::materialize(
std::unique_ptr<MaterializationResponsibility> R) {
auto G = std::make_unique<LinkGraph>(
"orc_sectcreate_" + SectName,
+ ObjLinkingLayer.getExecutionSession().getSymbolStringPool(),
ObjLinkingLayer.getExecutionSession().getTargetTriple(),
getGenericEdgeKindName);
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index 5f8dc414335646..1f732ba8613c32 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -16,6 +16,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Endian.h"
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
index de7630b9747ea4..24b03a058981a0 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
@@ -15,6 +15,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 261daae5e67f94..ca7a560faf824d 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -354,7 +354,7 @@ static raw_ostream &
operator<<(raw_ostream &OS, const Session::SymbolInfoMap &SIM) {
OS << "Symbols:\n";
for (auto &SKV : SIM)
- OS << " \"" << SKV.first() << "\" " << SKV.second << "\n";
+ OS << " \"" << *(SKV.first) << "\" " << SKV.second << "\n";
return OS;
}
@@ -398,29 +398,29 @@ static Error applyHarnessPromotions(Session &S, LinkGraph &G) {
continue;
if (Sym->getLinkage() == Linkage::Weak) {
- if (!S.CanonicalWeakDefs.count(Sym->getName()) ||
- S.CanonicalWeakDefs[Sym->getName()] != G.getName()) {
+ if (!S.CanonicalWeakDefs.count(*Sym->getName()) ||
+ S.CanonicalWeakDefs[*Sym->getName()] != G.getName()) {
LLVM_DEBUG({
- dbgs() << " Externalizing weak symbol " << Sym->getName() << "\n";
+ dbgs() << " Externalizing weak symbol " << *Sym->getName() << "\n";
});
DefinitionsToRemove.push_back(Sym);
} else {
LLVM_DEBUG({
- dbgs() << " Making weak symbol " << Sym->getName() << " strong\n";
+ dbgs() << " Making weak symbol " << *Sym->getName() << " strong\n";
});
- if (S.HarnessExternals.count(Sym->getName()))
+ if (S.HarnessExternals.count(*Sym->getName()))
Sym->setScope(Scope::Default);
else
Sym->setScope(Scope::Hidden);
Sym->setLinkage(Linkage::Strong);
}
- } else if (S.HarnessExternals.count(Sym->getName())) {
- LLVM_DEBUG(dbgs() << " Promoting " << Sym->getName() << "\n");
+ } else if (S.HarnessExternals.count(*Sym->getName())) {
+ LLVM_DEBUG(dbgs() << " Promoting " << *Sym->getName() << "\n");
Sym->setScope(Scope::Default);
Sym->setLive(true);
continue;
- } else if (S.HarnessDefinitions.count(Sym->getName())) {
- LLVM_DEBUG(dbgs() << " Externalizing " << Sym->getName() << "\n");
+ } else if (S.HarnessDefinitions.count(*Sym->getName())) {
+ LLVM_DEBUG(dbgs() << " Externalizing " << *Sym->getName() << "\n");
DefinitionsToRemove.push_back(Sym);
}
}
@@ -1240,9 +1240,9 @@ Error Session::FileInfo::registerGOTEntry(
auto TS = GetSymbolTarget(G, Sym.getBlock());
if (!TS)
return TS.takeError();
- GOTEntryInfos[TS->getName()] = {Sym.getSymbolContent(),
- Sym.getAddress().getValue(),
- Sym.getTargetFlags()};
+ GOTEntryInfos[*TS->getName()] = {Sym.getSymbolContent(),
+ Sym.getAddress().getValue(),
+ Sym.getTargetFlags()};
return Error::success();
}
@@ -1256,7 +1256,7 @@ Error Session::FileInfo::registerStubEntry(
if (!TS)
return TS.takeError();
- SmallVectorImpl<MemoryRegionInfo> &Entry = StubInfos[TS->getName()];
+ SmallVectorImpl<MemoryRegionInfo> &Entry = StubInfos[*TS->getName()];
Entry.insert(Entry.begin(),
{Sym.getSymbolContent(), Sym.getAddress().getValue(),
Sym.getTargetFlags()});
@@ -1274,7 +1274,7 @@ Error Session::FileInfo::registerMultiStubEntry(
if (!Target)
return Target.takeError();
- SmallVectorImpl<MemoryRegionInfo> &Entry = StubInfos[Target->getName()];
+ SmallVectorImpl<MemoryRegionInfo> &Entry = StubInfos[*Target->getName()];
Entry.emplace_back(Sym.getSymbolContent(), Sym.getAddress().getValue(),
Sym.getTargetFlags());
@@ -1419,15 +1419,16 @@ Session::findGOTEntryInfo(StringRef FileName, StringRef TargetName) {
return GOTInfoItr->second;
}
-bool Session::isSymbolRegistered(StringRef SymbolName) {
+bool Session::isSymbolRegistered(const orc::SymbolStringPtr SymbolName) {
return SymbolInfos.count(SymbolName);
}
Expected<Session::MemoryRegionInfo &>
-Session::findSymbolInfo(StringRef SymbolName, Twine ErrorMsgStem) {
+Session::findSymbolInfo(const orc::SymbolStringPtr SymbolName,
+ Twine ErrorMsgStem) {
auto SymInfoItr = SymbolInfos.find(SymbolName);
if (SymInfoItr == SymbolInfos.end())
- return make_error<StringError>(ErrorMsgStem + ": symbol " + SymbolName +
+ return make_error<StringError>(ErrorMsgStem + ": symbol " + *SymbolName +
" not found",
inconvertibleErrorCode());
return SymInfoItr->second;
@@ -1648,12 +1649,13 @@ static Error addAbsoluteSymbols(Session &S,
AbsDefStmt + "\"",
inconvertibleErrorCode());
ExecutorSymbolDef AbsDef(ExecutorAddr(Addr), JITSymbolFlags::Exported);
- if (auto Err = JD.define(absoluteSymbols({{S.ES.intern(Name), AbsDef}})))
+ auto intern_name = S.ES.intern(Name);
+ if (auto Err = JD.define(absoluteSymbols({{intern_name, AbsDef}})))
return Err;
// Register the absolute symbol with the session symbol infos.
- S.SymbolInfos[Name] = {ArrayRef<char>(), Addr,
- AbsDef.getFlags().getTargetFlags()};
+ S.SymbolInfos[intern_name] = {ArrayRef<char>(), Addr,
+ AbsDef.getFlags().getTargetFlags()};
}
return Error::success();
@@ -2244,11 +2246,13 @@ static Error runChecks(Session &S, Triple TT, SubtargetFeatures Features) {
LLVM_DEBUG(dbgs() << "Running checks...\n");
auto IsSymbolValid = [&S](StringRef Symbol) {
- return S.isSymbolRegistered(Symbol);
+ auto InternedSymbol = S.ES.getSymbolStringPool()->intern(Symbol);
+ return S.isSymbolRegistered(InternedSymbol);
};
auto GetSymbolInfo = [&S](StringRef Symbol) {
- return S.findSymbolInfo(Symbol, "Can not get symbol info");
+ auto InternedSymbol = S.ES.getSymbolStringPool()->intern(Symbol);
+ return S.findSymbolInfo(InternedSymbol, "Can not get symbol info");
};
auto GetSectionInfo = [&S](StringRef FileName, StringRef SectionName) {
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.h b/llvm/tools/llvm-jitlink/llvm-jitlink.h
index 07b56680719f69..cf052957f7041e 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.h
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.h
@@ -56,7 +56,6 @@ struct Session {
using LinkGraph = jitlink::LinkGraph;
using GetSymbolTargetFunction =
unique_function<Expected<Symbol &>(LinkGraph &G, jitlink::Block &)>;
-
Error registerGOTEntry(LinkGraph &G, Symbol &Sym,
GetSymbolTargetFunction GetSymbolTarget);
Error registerStubEntry(LinkGraph &G, Symbol &Sym,
@@ -66,7 +65,7 @@ struct Session {
};
using DynLibJDMap = std::map<std::string, orc::JITDylib *, std::less<>>;
- using SymbolInfoMap = StringMap<MemoryRegionInfo>;
+ using SymbolInfoMap = DenseMap<orc::SymbolStringPtr, MemoryRegionInfo>;
using FileInfoMap = StringMap<FileInfo>;
Expected<orc::JITDylib *> getOrLoadDynamicLibrary(StringRef LibPath);
@@ -81,8 +80,8 @@ struct Session {
Expected<MemoryRegionInfo &> findGOTEntryInfo(StringRef FileName,
StringRef TargetName);
- bool isSymbolRegistered(StringRef Name);
- Expected<MemoryRegionInfo &> findSymbolInfo(StringRef SymbolName,
+ bool isSymbolRegistered(const orc::SymbolStringPtr Name);
+ Expected<MemoryRegionInfo &> findSymbolInfo(const orc::SymbolStringPtr Name,
Twine ErrorMsgStem);
DynLibJDMap DynLibJDs;
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index f07ddddd5fe9c6..59b222144ba311 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include <llvm/ExecutionEngine/JITLink/aarch32.h>
-
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
+#include <llvm/ExecutionEngine/JITLink/aarch32.h>
using namespace llvm;
using namespace llvm::jitlink;
@@ -18,7 +18,8 @@ using namespace llvm::support;
using namespace llvm::support::endian;
constexpr unsigned PointerSize = 4;
-auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"),
+auto SSP = std::make_shared<orc::SymbolStringPool>();
+auto G = std::make_unique<LinkGraph>("foo", SSP, Triple("armv7-linux-gnueabi"),
PointerSize, endianness::little,
aarch32::getEdgeKindName);
auto &Sec =
@@ -46,7 +47,8 @@ class AArch32Errors : public testing::Test {
static void SetUpTestCase() {}
void SetUp() override {
- G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"),
+ auto SSP = std::make_shared<orc::SymbolStringPool>();
+ G = std::make_unique<LinkGraph>("foo", SSP, Triple("armv7-linux-gnueabi"),
PointerSize, endianness::little,
aarch32::getEdgeKindName);
S = &G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
diff --git a/llvm/unittests/ExecutionEngine/JITLink/EHFrameSupportTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/EHFrameSupportTests.cpp
index e7e09b3fe40b13..eaf9733b228196 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/EHFrameSupportTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/EHFrameSupportTests.cpp
@@ -172,7 +172,8 @@ TEST(EHFrameCFIBlockInspector, BasicSuccessCase) {
// (3) Each FDE has an edge pointing to the CIE at the correct offset.
// (4) Each function has exactly one FDE pointing at it.
- auto G = cantFail(createLinkGraphFromMachOObject_arm64(TestObject));
+ auto G = cantFail(createLinkGraphFromMachOObject_arm64(
+ TestObject, std::make_shared<orc::SymbolStringPool>()));
cantFail(createEHFrameSplitterPass_MachO_arm64()(*G));
cantFail(createEHFrameEdgeFixerPass_MachO_arm64()(*G));
@@ -211,7 +212,7 @@ TEST(EHFrameCFIBlockInspector, BasicSuccessCase) {
ASSERT_TRUE(!!CFIBI.getPCBeginEdge());
auto &PCBeginTarget = CFIBI.getPCBeginEdge()->getTarget();
ASSERT_TRUE(PCBeginTarget.hasName());
- Targets.insert(PCBeginTarget.getName());
+ Targets.insert(*PCBeginTarget.getName());
// If the FDE points at CIEs[0] (the CIE without a personality) then it
// should not have an LSDA. If it points to CIEs[1] then it should have
@@ -232,11 +233,12 @@ TEST(EHFrameCFIBlockInspector, BasicSuccessCase) {
TEST(EHFrameCFIBlockInspector, ExternalPCBegin) {
// Check that we don't crash if we transform the target of an FDE into an
// external symbol before running edge-fixing.
- auto G = cantFail(createLinkGraphFromMachOObject_arm64(TestObject));
+ auto G = cantFail(createLinkGraphFromMachOObject_arm64(
+ TestObject, std::make_shared<orc::SymbolStringPool>()));
// Make '_a' external.
for (auto *Sym : G->defined_symbols())
- if (Sym->hasName() && Sym->getName() == "_a") {
+ if (Sym->hasName() && *Sym->getName() == "_a") {
G->makeExternal(*Sym);
break;
}
diff --git a/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestUtils.cpp b/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestUtils.cpp
index 9a7878edab5045..de3606db49bd03 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestUtils.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestUtils.cpp
@@ -92,9 +92,10 @@ void defaultCtxSetup(MockJITLinkContext &) {}
TEST(JITLinkMocks, SmokeTest) {
// Check that the testing infrastructure defaults can "link" a graph
// successfully.
- auto G = std::make_unique<LinkGraph>("foo", Triple("x86_64-apple-darwin"), 8,
- llvm::endianness::little,
- getGenericEdgeKindName);
+ auto SSP = std::make_shared<orc::SymbolStringPool>();
+ auto G = std::make_unique<LinkGraph>(
+ "foo", SSP, Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ getGenericEdgeKindName);
ArrayRef<char> Content = "hello, world!";
auto &Sec =
diff --git a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
index 32d917d75d5ca4..e6748a80114ca4 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
@@ -21,7 +21,8 @@ using namespace llvm::jitlink;
TEST(LinkGraphTest, Construction) {
// Check that LinkGraph construction works as expected.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
EXPECT_EQ(G.getName(), "foo");
EXPECT_EQ(G.getTargetTriple().str(), "x86_64-apple-darwin");
@@ -35,7 +36,8 @@ TEST(LinkGraphTest, Construction) {
TEST(LinkGraphTest, AddressAccess) {
// Check that we can get addresses for blocks, symbols, and edges.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec1 =
@@ -54,7 +56,8 @@ TEST(LinkGraphTest, AddressAccess) {
TEST(LinkGraphTest, SectionEmpty) {
// Check that Section::empty behaves as expected.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec1 =
G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
@@ -72,7 +75,8 @@ TEST(LinkGraphTest, SectionEmpty) {
TEST(LinkGraphTest, BlockAndSymbolIteration) {
// Check that we can iterate over blocks within Sections and across sections.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec1 =
G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
@@ -125,7 +129,8 @@ TEST(LinkGraphTest, BlockAndSymbolIteration) {
TEST(LinkGraphTest, ContentAccessAndUpdate) {
// Check that we can make a defined symbol external.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
@@ -214,7 +219,8 @@ TEST(LinkGraphTest, ContentAccessAndUpdate) {
TEST(LinkGraphTest, MakeExternal) {
// Check that we can make defined and absolute symbols external.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
@@ -284,7 +290,8 @@ TEST(LinkGraphTest, MakeExternal) {
TEST(LinkGraphTest, MakeAbsolute) {
// Check that we can make defined and external symbols absolute.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
@@ -353,7 +360,8 @@ TEST(LinkGraphTest, MakeAbsolute) {
TEST(LinkGraphTest, MakeDefined) {
// Check that we can make an external symbol defined.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
@@ -401,7 +409,8 @@ TEST(LinkGraphTest, MakeDefined) {
TEST(LinkGraphTest, TransferDefinedSymbol) {
// Check that we can transfer a defined symbol from one block to another.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
@@ -436,7 +445,8 @@ TEST(LinkGraphTest, TransferDefinedSymbol) {
TEST(LinkGraphTest, TransferDefinedSymbolAcrossSections) {
// Check that we can transfer a defined symbol from an existing block in one
// section to another.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec1 =
G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
@@ -470,7 +480,8 @@ TEST(LinkGraphTest, TransferDefinedSymbolAcrossSections) {
TEST(LinkGraphTest, TransferBlock) {
// Check that we can transfer a block (and all associated symbols) from one
// section to another.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec1 =
G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
@@ -518,7 +529,8 @@ TEST(LinkGraphTest, TransferBlock) {
TEST(LinkGraphTest, MergeSections) {
// Check that we can transfer a block (and all associated symbols) from one
// section to another.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec1 =
G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
@@ -604,7 +616,8 @@ TEST(LinkGraphTest, MergeSections) {
TEST(LinkGraphTest, SplitBlock) {
// Check that the LinkGraph::splitBlock test works as expected.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
@@ -707,7 +720,8 @@ TEST(LinkGraphTest, SplitBlock) {
}
TEST(LinkGraphTest, GraphAllocationMethods) {
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
// Test allocation of sized, uninitialized buffer.
@@ -728,7 +742,8 @@ TEST(LinkGraphTest, GraphAllocationMethods) {
TEST(LinkGraphTest, IsCStringBlockTest) {
// Check that the LinkGraph::splitBlock test works as expected.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
@@ -752,8 +767,8 @@ TEST(LinkGraphTest, IsCStringBlockTest) {
}
TEST(LinkGraphTest, BasicLayoutHonorsNoAlloc) {
- // Check that BasicLayout honors NoAlloc.
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
// Create a regular section and block.
diff --git a/llvm/unittests/ExecutionEngine/JITLink/MachOLinkGraphTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/MachOLinkGraphTests.cpp
index be922275be26f4..6a9cbcadc32499 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/MachOLinkGraphTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/MachOLinkGraphTests.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
#include "llvm/ExecutionEngine/JITLink/MachO.h"
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
@@ -20,8 +21,9 @@ using namespace llvm::jitlink;
TEST(MachOLinkGraphTest, GetStandardSections) {
// Check that LinkGraph construction works as expected.
- LinkGraph G("foo", Triple("arm64-apple-darwin"), 8, llvm::endianness::little,
- getGenericEdgeKindName);
+ auto SSP = std::make_shared<orc::SymbolStringPool>();
+ LinkGraph G("foo", SSP, Triple("arm64-apple-darwin"), 8,
+ llvm::endianness::little, getGenericEdgeKindName);
auto &Data = getMachODefaultRWDataSection(G);
EXPECT_TRUE(Data.empty());
diff --git a/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp
index 2b303f7a8c1a29..d1284ffb2ecf2a 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp
@@ -18,9 +18,10 @@ using namespace llvm::jitlink;
TEST(MemoryManagerErrorTest, ErrorOnFirstAllocate) {
// Check that we can get addresses for blocks, symbols, and edges.
- auto G = std::make_unique<LinkGraph>("foo", Triple("x86_64-apple-darwin"), 8,
- llvm::endianness::little,
- getGenericEdgeKindName);
+ auto G = std::make_unique<LinkGraph>(
+ "foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ getGenericEdgeKindName);
ArrayRef<char> Content = "hello, world!";
auto &Sec =
diff --git a/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp
index 6a8f89639a0743..8efbb54f59e848 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp
@@ -57,7 +57,8 @@ GenerateStub(LinkGraph &G, size_t PointerSize, Edge::Kind PointerEdgeKind) {
TEST(StubsTest, StubsGeneration_x86_64) {
const char PointerJumpStubContent[6] = {
static_cast<char>(0xFFu), 0x25, 0x00, 0x00, 0x00, 0x00};
- LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto [PointerSym, StubSym] = GenerateStub(G, 8U, x86_64::Pointer64);
@@ -77,7 +78,8 @@ TEST(StubsTest, StubsGeneration_aarch64) {
0x10, 0x02, 0x40, (char)0xf9u, // LDR x16, [x16, <imm>@pageoff12]
0x00, 0x02, 0x1f, (char)0xd6u // BR x16
};
- LinkGraph G("foo", Triple("aarch64-linux-gnu"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("aarch64-linux-gnu"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto [PointerSym, StubSym] = GenerateStub(G, 8U, aarch64::Pointer64);
@@ -97,8 +99,9 @@ TEST(StubsTest, StubsGeneration_aarch64) {
TEST(StubsTest, StubsGeneration_i386) {
const char PointerJumpStubContent[6] = {
static_cast<char>(0xFFu), 0x25, 0x00, 0x00, 0x00, 0x00};
- LinkGraph G("foo", Triple("i386-unknown-linux-gnu"), 4,
- llvm::endianness::little, getGenericEdgeKindName);
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("i386-unknown-linux-gnu"), 8, llvm::endianness::little,
+ getGenericEdgeKindName);
auto [PointerSym, StubSym] = GenerateStub(G, 4U, i386::Pointer32);
EXPECT_EQ(std::distance(StubSym.getBlock().edges().begin(),
@@ -126,7 +129,8 @@ TEST(StubsTest, StubsGeneration_loongarch32) {
0x00,
0x4c // jr $t8
};
- LinkGraph G("foo", Triple("loongarch32"), 4, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("loongarch32"), 4, llvm::endianness::little,
getGenericEdgeKindName);
auto [PointerSym, StubSym] = GenerateStub(G, 4U, loongarch::Pointer32);
@@ -158,7 +162,8 @@ TEST(StubsTest, StubsGeneration_loongarch64) {
0x00,
0x4c // jr $t8
};
- LinkGraph G("foo", Triple("loongarch64"), 8, llvm::endianness::little,
+ LinkGraph G("foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("loongarch64"), 8, llvm::endianness::little,
getGenericEdgeKindName);
auto [PointerSym, StubSym] = GenerateStub(G, 8U, loongarch::Pointer64);
diff --git a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp
index bc996711f7ec50..45913af1b89978 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp
@@ -15,6 +15,7 @@
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
#include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
+#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
@@ -44,9 +45,10 @@ class ObjectLinkingLayerTest : public testing::Test {
};
TEST_F(ObjectLinkingLayerTest, AddLinkGraph) {
- auto G = std::make_unique<LinkGraph>("foo", Triple("x86_64-apple-darwin"), 8,
- llvm::endianness::little,
- x86_64::getEdgeKindName);
+ auto SSP = std::make_shared<orc::SymbolStringPool>();
+ auto G = std::make_unique<LinkGraph>(
+ "foo", SSP, Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ x86_64::getEdgeKindName);
auto &Sec1 = G->createSection("__data", MemProt::Read | MemProt::Write);
auto &B1 = G->createContentBlock(Sec1, BlockContent,
@@ -70,10 +72,11 @@ TEST_F(ObjectLinkingLayerTest, ResourceTracker) {
// while increasing the number of trackers in the ObjectLinkingLayer, which
// may invalidate some iterators internally.
std::vector<ResourceTrackerSP> Trackers;
+ auto SSP = std::make_shared<orc::SymbolStringPool>();
for (unsigned I = 0; I < 64; I++) {
- auto G = std::make_unique<LinkGraph>("foo", Triple("x86_64-apple-darwin"),
- 8, llvm::endianness::little,
- x86_64::getEdgeKindName);
+ auto G = std::make_unique<LinkGraph>(
+ "foo", SSP, Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ x86_64::getEdgeKindName);
auto &Sec1 = G->createSection("__data", MemProt::Read | MemProt::Write);
auto &B1 = G->createContentBlock(Sec1, BlockContent,
@@ -139,9 +142,10 @@ TEST_F(ObjectLinkingLayerTest, ClaimLateDefinedWeakSymbols) {
ObjLinkingLayer.addPlugin(std::make_unique<TestPlugin>());
- auto G = std::make_unique<LinkGraph>("foo", Triple("x86_64-apple-darwin"), 8,
- llvm::endianness::little,
- x86_64::getEdgeKindName);
+ auto G = std::make_unique<LinkGraph>(
+ "foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ getGenericEdgeKindName);
auto &DataSec = G->createSection("__data", MemProt::Read | MemProt::Write);
auto &DataBlock = G->createContentBlock(DataSec, BlockContent,
@@ -193,9 +197,10 @@ TEST_F(ObjectLinkingLayerTest, HandleErrorDuringPostAllocationPass) {
ObjLinkingLayer.addPlugin(std::make_unique<TestPlugin>());
- auto G = std::make_unique<LinkGraph>("foo", Triple("x86_64-apple-darwin"), 8,
- llvm::endianness::little,
- x86_64::getEdgeKindName);
+ auto G = std::make_unique<LinkGraph>(
+ "foo", std::make_shared<orc::SymbolStringPool>(),
+ Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ getGenericEdgeKindName);
auto &DataSec = G->createSection("__data", MemProt::Read | MemProt::Write);
auto &DataBlock = G->createContentBlock(DataSec, BlockContent,
@@ -247,9 +252,10 @@ TEST_F(ObjectLinkingLayerTest, AddAndRemovePlugins) {
ObjLinkingLayer.addPlugin(P);
{
- auto G1 = std::make_unique<LinkGraph>("G1", Triple("x86_64-apple-darwin"),
- 8, llvm::endianness::little,
- x86_64::getEdgeKindName);
+ auto SSP = std::make_shared<orc::SymbolStringPool>();
+ auto G1 = std::make_unique<LinkGraph>(
+ "G1", SSP, Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ x86_64::getEdgeKindName);
auto &DataSec = G1->createSection("__data", MemProt::Read | MemProt::Write);
auto &DataBlock = G1->createContentBlock(DataSec, BlockContent,
@@ -265,9 +271,10 @@ TEST_F(ObjectLinkingLayerTest, AddAndRemovePlugins) {
ObjLinkingLayer.removePlugin(*P);
{
- auto G2 = std::make_unique<LinkGraph>("G2", Triple("x86_64-apple-darwin"),
- 8, llvm::endianness::little,
- x86_64::getEdgeKindName);
+ auto SSP = std::make_shared<orc::SymbolStringPool>();
+ auto G2 = std::make_unique<LinkGraph>(
+ "G2", SSP, Triple("x86_64-apple-darwin"), 8, llvm::endianness::little,
+ x86_64::getEdgeKindName);
auto &DataSec = G2->createSection("__data", MemProt::Read | MemProt::Write);
auto &DataBlock = G2->createContentBlock(DataSec, BlockContent,
@@ -325,8 +332,8 @@ TEST(ObjectLinkingLayerSearchGeneratorTest, AbsoluteSymbolsObjectLayer) {
auto G = EPCDynamicLibrarySearchGenerator::GetForTargetProcess(
ES, {}, [&](JITDylib &JD, SymbolMap Syms) {
- auto G =
- absoluteSymbolsLinkGraph(ES.getTargetTriple(), std::move(Syms));
+ auto G = absoluteSymbolsLinkGraph(
+ ES.getTargetTriple(), ES.getSymbolStringPool(), std::move(Syms));
return ObjLinkingLayer.add(JD, std::move(G));
});
ASSERT_THAT_EXPECTED(G, Succeeded());
@@ -347,10 +354,10 @@ TEST(ObjectLinkingLayerSearchGeneratorTest, AbsoluteSymbolsObjectLayer) {
ADD_FAILURE() << "unexpected unnamed symbol";
continue;
}
- if (Sym->getName() == "_testFunc")
+ if (*Sym->getName() == "_testFunc")
SawSymbolDef = true;
else
- ADD_FAILURE() << "unexpected symbol " << Sym->getName();
+ ADD_FAILURE() << "unexpected symbol " << *Sym->getName();
}
EXPECT_EQ(SymCount, 1u);
return Error::success();
More information about the llvm-commits
mailing list