20constexpr StringRef FnBodySuffix =
"$orc_fnbody";
27 :
public ObjectLinkingLayer::Plugin {
35 Config.PrePrunePasses.insert(
36 Config.PrePrunePasses.begin(),
37 [&MR](
LinkGraph &
G) { return renameFunctionBodies(G, MR); });
56 if ((*Name).ends_with(FnBodySuffix))
57 SymsToRename[(*Name).drop_back(FnBodySuffix.size())] =
60 for (
auto *
Sym :
G.defined_symbols()) {
64 if (
I == SymsToRename.
end())
75 :
ObjectLayer(BaseLayer.getExecutionSession()), BaseLayer(BaseLayer),
77 BaseLayer.
addPlugin(std::make_unique<RenamerPlugin>());
81 std::unique_ptr<MemoryBuffer> O,
86 return BaseLayer.
add(std::move(RT), std::move(O), std::move(
I));
90 for (
auto &[
Name, Flags] :
I.SymbolFlags)
91 if (Flags.isCallable())
92 LazySymbols[
Name] = {ES.intern((*
Name + FnBodySuffix).str()), Flags};
94 for (
auto &[
Name, AI] : LazySymbols) {
95 I.SymbolFlags.erase(
Name);
96 I.SymbolFlags[AI.Aliasee] = AI.AliasFlags;
99 if (
auto Err = BaseLayer.
add(RT, std::move(O), std::move(
I)))
102 auto &JD = RT->getJITDylib();
103 return JD.define(
lazyReexports(LRMgr, std::move(LazySymbols)), std::move(RT));
107 std::unique_ptr<MaterializationResponsibility> MR,
108 std::unique_ptr<MemoryBuffer> Obj) {
109 return BaseLayer.
emit(std::move(MR), std::move(Obj));
iterator find(const_arg_type_t< KeyT > Val)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringRef - Represent a constant reference to a string, i.e.
void setName(const orc::SymbolStringPtr Name)
Rename this symbol.
const orc::SymbolStringPtr & getName() const
Returns the name of this symbol (empty if the symbol is anonymous).
bool hasName() const
Returns true if this symbol has a name.
Represents a JIT'd dynamic library.
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &LG, jitlink::PassConfiguration &Config) override
Error notifyFailed(MaterializationResponsibility &MR) override
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override
void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, ResourceKey SrcKey) override
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Emit should materialize the given IR.
LazyObjectLinkingLayer(ObjectLinkingLayer &BaseLayer, LazyReexportsManager &LRMgr)
llvm::Error add(llvm::orc::ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > O, MaterializationUnit::Interface I) override
Add an object file to the JITDylib targeted by the given tracker.
LinkGraphLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
const SymbolFlagsMap & getSymbols() const
Returns the symbol flags map for this responsibility instance.
Non-owning SymbolStringPool entry pointer.
Interface for Layers that accept object files.
ExecutionSession & getExecutionSession()
Returns the execution session for this layer.
An ObjectLayer implementation built on JITLink.
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Emit an object file.
virtual Error add(ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > O, MaterializationUnit::Interface I)
Adds a MaterializationUnit for the object file in the given memory buffer to the JITDylib for the giv...
std::unique_ptr< LazyReexportsMaterializationUnit > lazyReexports(LazyCallThroughManager &LCTManager, RedirectableSymbolManager &RSManager, JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc=nullptr)
Define lazy-reexports based on the given SymbolAliasMap.
This is an optimization pass for GlobalISel generic memory operations.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...