From aba6bb0820b247d4caf4b5e00810909214a58053 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 3 Dec 2024 15:30:24 +1100 Subject: [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`. --- llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp') 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); -- cgit v1.1