21 return V.
define(llvm::make_unique<BasicIRLayerMaterializationUnit>(
22 *
this, std::move(K), std::move(M)));
26 std::unique_ptr<Module> M)
30 for (
auto &
G : this->M->global_values()) {
31 if (
G.hasName() && !
G.isDeclaration() && !
G.hasLocalLinkage() &&
32 !
G.hasAvailableExternallyLinkage() && !
G.hasAppendingLinkage()) {
33 auto MangledName =
Mangle(
G.getName());
44 SymbolToDefinition(
std::move(SymbolToDefinition)) {}
49 "Symbol not provided by this MU, or previously discarded");
50 assert(!
I->second->isDeclaration() &&
51 "Discard should only apply to definitions");
59 L(L), K(
std::move(K)) {}
61 void BasicIRLayerMaterializationUnit::materialize(
63 L.
emit(std::move(R), std::move(K), std::move(
M));
71 return V.
define(llvm::make_unique<BasicObjectLayerMaterializationUnit>(
72 *
this, std::move(K), std::move(O)));
84 for (
auto &Sym : Obj->symbols()) {
88 ES.getSymbolStringPool().intern(
cantFail(Sym.getName()));
94 void BasicObjectLayerMaterializationUnit::materialize(
96 L.
emit(std::move(R), std::move(K), std::move(O));
99 void BasicObjectLayerMaterializationUnit::discard(
const VSO &V,
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
IRLayer(ExecutionSession &ES)
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
virtual Error add(VSO &V, VModuleKey K, std::unique_ptr< Module > M)
Adds a MaterializationUnit representing the given IR to the given VSO.
std::enable_if< std::is_convertible< typename std::decay< UniquePtrToMaterializationUnit >::type, std::unique_ptr< MaterializationUnit > >::value, Error >::type define(UniquePtrToMaterializationUnit &&MU)
Define all symbols provided by the materialization unit to be part of the given VSO.
static JITSymbolFlags fromGlobalValue(const GlobalValue &GV)
Construct a JITSymbolFlags value based on the flags of the given global value.
Compute iterated dominance frontiers using a linear time algorithm.
BasicIRLayerMaterializationUnit(IRLayer &L, VModuleKey K, std::unique_ptr< Module > M)
A symbol table that supports asynchoronous symbol queries.
SymbolNameToDefinitionMap SymbolToDefinition
Available for inspection, not emission.
std::unique_ptr< Module > M
uint64_t VModuleKey
VModuleKey provides a unique identifier (allocated and managed by ExecutionSessions) for a module add...
std::map< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
SymbolFlagsMap SymbolFlags
Mangles symbol names then uniques them in the context of an ExecutionSession.
std::map< SymbolStringPtr, GlobalValue * > SymbolNameToDefinitionMap
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
virtual void emit(MaterializationResponsibility R, VModuleKey K, std::unique_ptr< Module > M)=0
Emit should materialize the given IR.
IRMaterializationUnit is a convenient base class for MaterializationUnits wrapping LLVM IR...
ExecutionSession & getExecutionSession()
Returns the execution session for this layer.
IRMaterializationUnit(ExecutionSession &ES, std::unique_ptr< Module > M)
Create an IRMaterializationLayer.
Pointer to a pooled string representing a symbol name.
ObjectLayer(ExecutionSession &ES)
static JITSymbolFlags fromObjectSymbol(const object::BasicSymbolRef &Symbol)
Construct a JITSymbolFlags value based on the flags of the given libobject symbol.
virtual Error add(VSO &V, VModuleKey K, std::unique_ptr< MemoryBuffer > O)
Adds a MaterializationUnit representing the given IR to the given VSO.
Interface for layers that accept LLVM IR.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group...
virtual void emit(MaterializationResponsibility R, VModuleKey K, std::unique_ptr< MemoryBuffer > O)=0
Emit should materialize the given IR.
An ExecutionSession represents a running JIT program.
BasicObjectLayerMaterializationUnit(ObjectLayer &L, VModuleKey K, std::unique_ptr< MemoryBuffer > O)
The MemoryBuffer should represent a valid object file.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Interface for Layers that accept object files.