29 assert(SrcJD &&
"Tracking on Null Source .impl dylib");
30 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
31 for (
auto &
I : ImplMaps) {
32 auto It = Maps.
insert({
I.first, {
I.second.Aliasee, SrcJD}});
34 assert(It.second &&
"ImplSymbols are already tracked for this Symbol?");
40 void Speculator::speculateForEntryPoint(
Speculator *Ptr, uint64_t StubId) {
41 assert(Ptr &&
" Null Address Received in orc_speculate_for ");
53 {Mangle(
"__orc_speculator"), ThisPtr},
54 {Mangle(
"__orc_speculate_for"), SpeculateForEntryPtr}
64 assert(TSM &&
"Speculation Layer received Null Module ?");
66 "Module with null LLVMContext?");
77 "__orc_speculate_for", &M);
79 M, SpeculatorVTy,
false, GlobalValue::LinkageTypes::ExternalLinkage,
80 nullptr,
"__orc_speculator");
87 if (!Fn.isDeclaration()) {
89 auto IRNames = QueryAnalysis(Fn);
91 if (IRNames.hasValue()) {
96 M, LoadValueTy,
false, GlobalValue::LinkageTypes::InternalLinkage,
98 "__orc_speculate.guard.for." + Fn.
getName());
102 BasicBlock &ProgramEntry = Fn.getEntryBlock();
105 MContext,
"__orc_speculate.block", &Fn, &ProgramEntry);
107 MContext,
"__orc_speculate.decision.block", &Fn, SpeculateBlock);
109 assert(SpeculateDecisionBlock == &Fn.getEntryBlock() &&
110 "SpeculateDecisionBlock not updated?");
114 Mutator.
CreateLoad(LoadValueTy, SpeculatorGuard,
"guard.value");
118 "compare.to.speculate");
119 Mutator.
CreateCondBr(CanSpeculate, SpeculateBlock, &ProgramEntry);
122 auto ImplAddrToUint =
124 Mutator.
CreateCall(RuntimeCallTy, RuntimeCall,
125 {SpeclAddr, ImplAddrToUint});
131 "IR builder association mismatch?");
132 S.registerSymbols(internToJITSymbols(IRNames.getValue()),
140 "Speculation Instrumentation breaks IR?");
142 NextLayer.emit(std::move(R), std::move(TSM));
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
This class represents lattice values for constants.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
A Module instance is used to store all the information related to an LLVM module. ...
auto withModuleDo(Func &&F) -> decltype(F(std::declval< Module &>()))
Locks the associated ThreadSafeContext and calls the given function on the contained Module...
Error addSpeculationRuntime(JITDylib &JD, MangleAndInterner &Mangle)
Define symbols for this Speculator object (__orc_speculator) and the speculation runtime entry point ...
static IntegerType * getInt64Ty(LLVMContext &C)
void emit(MaterializationResponsibility R, ThreadSafeModule TSM)
Emit should materialize the given IR.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols, VModuleKey K=VModuleKey())
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
LLVMContext & getContext() const
Get the global data context.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
Error define(std::unique_ptr< MaterializationUnitType > &&MU)
Define all symbols provided by the materialization unit to be part of this JITDylib.
Mangles symbol names then uniques them in the context of an ExecutionSession.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
BasicBlock * GetInsertBlock() const
void speculateFor(TargetFAddr StubAddr)
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
void trackImpls(SymbolAliasMap ImplMaps, JITDylib *SrcJD)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
LLVM Basic Block Representation.
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
LLVMContext * getContext()
Returns a pointer to the LLVMContext that was used to construct this instance, or null if the instanc...
JITTargetAddress pointerToJITTargetAddress(T *Ptr)
Convert a pointer to a JITTargetAddress.
ThreadSafeContext getContext() const
Returns the context for this ThreadSafeModule.
static Type * getVoidTy(LLVMContext &C)
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
An LLVM Module together with a shared ThreadSafeContext.
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
Module.h This file contains the declarations for the Module class.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Represents a symbol that has been evaluated to an address already.
void setAlignment(MaybeAlign Align)
StringRef getName() const
Return a constant reference to the value's name.
const Function * getParent() const
Return the enclosing method, or null if none.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Lightweight error class with error context and mandatory checking.
static IntegerType * getInt8Ty(LLVMContext &C)
A symbol table that supports asynchoronous symbol queries.