aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2024-12-03 15:30:24 +1100
committerLang Hames <lhames@gmail.com>2024-12-03 15:36:03 +1100
commitaba6bb0820b247d4caf4b5e00810909214a58053 (patch)
tree406f3968dd0e7f4605c74036921e7ea4f244d42b /llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
parent6ef4990daa1da215b25b1802f5d03cf1044f72bf (diff)
downloadllvm-aba6bb0820b247d4caf4b5e00810909214a58053.zip
llvm-aba6bb0820b247d4caf4b5e00810909214a58053.tar.gz
llvm-aba6bb0820b247d4caf4b5e00810909214a58053.tar.bz2
[ORC][JITLink] Add jitlink::Scope::SideEffectsOnly, use it in ORC Platforms.
SideEffectsOnly is a new jitlink::Scope value that corresponds to the JITSymbolFlags::MaterializationSideEffectsOnly flag: Symbols with this scope can be looked up (and form part of the initial interface of a LinkGraph) but never actually resolve to an address (so can only be looked up with a WeaklyReferencedSymbol lookup). Previously ObjectLinkingLayer implicitly treated JITLink symbols as having this scope, regardless of a Symbol's actual scope, if the MaterializationSideEffectsOnly flag was set on the corresponding symbol in the MaterializationResponsibility object. Using an explicit scope in JITLink for this (1) allows JITLink plugins to identify and correctly handle side-effects-only symbols, and (2) allows raw LinkGraphs to define side-effects-only symbols without clients having to manually modify their `MaterializationUnit::Interface`.
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
index c1c5540..c5342c4 100644
--- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
@@ -65,6 +65,8 @@ JITSymbolFlags getJITSymbolFlagsForSymbol(Symbol &Sym) {
if (Sym.getScope() == Scope::Default)
Flags |= JITSymbolFlags::Exported;
+ else if (Sym.getScope() == Scope::SideEffectsOnly)
+ Flags |= JITSymbolFlags::MaterializationSideEffectsOnly;
if (Sym.isCallable())
Flags |= JITSymbolFlags::Callable;
@@ -236,7 +238,7 @@ public:
SymbolMap InternedResult;
for (auto *Sym : G.defined_symbols())
- if (Sym->getScope() != Scope::Local) {
+ if (Sym->getScope() < Scope::SideEffectsOnly) {
auto InternedName = ES.intern(Sym->getName());
auto Ptr = getJITSymbolPtrForSymbol(*Sym, G.getTargetTriple());
auto Flags = getJITSymbolFlagsForSymbol(*Sym);
@@ -249,7 +251,7 @@ public:
}
for (auto *Sym : G.absolute_symbols())
- if (Sym->getScope() != Scope::Local) {
+ if (Sym->getScope() < Scope::SideEffectsOnly) {
auto InternedName = ES.intern(Sym->getName());
auto Ptr = getJITSymbolPtrForSymbol(*Sym, G.getTargetTriple());
auto Flags = getJITSymbolFlagsForSymbol(*Sym);
@@ -281,11 +283,9 @@ public:
// If this is a materialization-side-effects only symbol then bump
// the counter and remove in from the result, otherwise make sure that
// it's defined.
- if (Flags.hasMaterializationSideEffectsOnly()) {
+ if (Flags.hasMaterializationSideEffectsOnly())
++NumMaterializationSideEffectsOnlySymbols;
- InternedResult.erase(Sym);
- continue;
- } else if (I == InternedResult.end())
+ else if (I == InternedResult.end())
MissingSymbols.push_back(Sym);
else if (Layer.OverrideObjectFlags)
I->second.setFlags(Flags);