13#ifndef LIB_EXECUTIONENGINE_JITLINK_JITLINKGENERIC_H
14#define LIB_EXECUTIONENGINE_JITLINK_JITLINKGENERIC_H
18#define DEBUG_TYPE "jitlink"
34 assert(this->Ctx &&
"Ctx can not be null");
35 assert(this->G &&
"G can not be null");
52 return Ctx->shouldAddDefaultTargetPasses(TT);
66 void linkPhase1(std::unique_ptr<JITLinkerBase> Self);
80 void linkPhase3(std::unique_ptr<JITLinkerBase> Self,
98 void abandonAllocAndBailOut(std::unique_ptr<JITLinkerBase> Self,
Error Err);
100 std::unique_ptr<JITLinkContext> Ctx;
101 std::unique_ptr<LinkGraph> G;
103 std::unique_ptr<InFlightAlloc> Alloc;
113 template <
typename... ArgTs>
static void link(ArgTs &&... Args) {
114 auto L = std::make_unique<LinkerImpl>(std::forward<ArgTs>(Args)...);
124 LTmp.linkPhase1(std::move(L));
128 const LinkerImpl &impl()
const {
129 return static_cast<const LinkerImpl &
>(*this);
132 Error fixUpBlocks(LinkGraph &G)
const override {
135 for (
auto &Sec :
G.sections()) {
138 for (
auto *
B : Sec.blocks()) {
145 return E.getKind() ==
148 "Non-KeepAlive edges in zero-fill block?");
154 (void)
B->getMutableContent(G);
156 for (
auto &
E :
B->edges()) {
159 if (!
E.isRelocation())
164 assert((NoAllocSection || !
E.getTarget().isDefined() ||
165 E.getTarget().getBlock().getSection().getMemLifetime() !=
167 "Block in allocated section has edge pointing to no-alloc "
171 if (
auto Err = impl().applyFixup(G, *
B,
E))
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Triple - Helper class for working with autoconf configuration names.
Represents an allocation which has not been finalized yet.
Base class for a JIT linker.
void linkPhase4(std::unique_ptr< JITLinkerBase > Self, FinalizeResult FR)
void linkPhase3(std::unique_ptr< JITLinkerBase > Self, Expected< AsyncLookupResult > LookupResult)
PassConfiguration & getPassConfig()
void linkPhase1(std::unique_ptr< JITLinkerBase > Self)
Expected< JITLinkMemoryManager::FinalizedAlloc > FinalizeResult
void linkPhase2(std::unique_ptr< JITLinkerBase > Self, AllocResult AR)
Expected< std::unique_ptr< InFlightAlloc > > AllocResult
JITLinkerBase(std::unique_ptr< JITLinkContext > Ctx, std::unique_ptr< LinkGraph > G, PassConfiguration Passes)
bool shouldAddDefaultTargetPasses(const Triple &TT)
static void link(ArgTs &&... Args)
Link constructs a LinkerImpl instance and calls linkPhase1.
void prune(LinkGraph &G)
Removes dead symbols/blocks/addressables.
std::vector< LinkGraphPassFunction > LinkGraphPassList
A list of LinkGraph passes.
@ NoAlloc
NoAlloc memory should not be allocated by the JITLinkMemoryManager at all.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...