28 assert(SrcJD &&
"Tracking on Null Source .impl dylib");
29 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
30 for (
auto &
I : ImplMaps) {
31 auto It = Maps.
insert({
I.first, {
I.second.Aliasee, SrcJD}});
33 assert(It.second &&
"ImplSymbols are already tracked for this Symbol?");
40 assert(
Ptr &&
" Null Address Received in orc_speculate_for ");
51 {Mangle(
"__orc_speculator"), ThisPtr},
52 {Mangle(
"__orc_speculate_for"), SpeculateForEntryPtr}
62 assert(TSM &&
"Speculation Layer received Null Module ?");
64 "Module with null LLVMContext?");
68 auto &MContext = M.getContext();
75 "__orc_speculate_for", &M);
78 nullptr,
"__orc_speculator");
84 for (
auto &Fn : M.getFunctionList()) {
85 if (!Fn.isDeclaration()) {
87 auto IRNames = QueryAnalysis(Fn);
95 ConstantInt::get(LoadValueTy, 0),
96 "__orc_speculate.guard.for." + Fn.getName());
97 SpeculatorGuard->setAlignment(
Align(1));
100 BasicBlock &ProgramEntry = Fn.getEntryBlock();
103 MContext,
"__orc_speculate.block", &Fn, &ProgramEntry);
105 MContext,
"__orc_speculate.decision.block", &Fn, SpeculateBlock);
107 assert(SpeculateDecisionBlock == &Fn.getEntryBlock() &&
108 "SpeculateDecisionBlock not updated?");
112 Mutator.
CreateLoad(LoadValueTy, SpeculatorGuard,
"guard.value");
115 Mutator.
CreateICmpEQ(LoadGuard, ConstantInt::get(LoadValueTy, 0),
116 "compare.to.speculate");
117 Mutator.
CreateCondBr(CanSpeculate, SpeculateBlock, &ProgramEntry);
120 auto ImplAddrToUint =
122 Mutator.
CreateCall(RuntimeCallTy, RuntimeCall,
123 {SpeclAddr, ImplAddrToUint});
124 Mutator.
CreateStore(ConstantInt::get(LoadValueTy, 1),
129 "IR builder association mismatch?");
131 &R->getTargetJITDylib());
138 "Speculation Instrumentation breaks IR?");
140 NextLayer.
emit(std::move(R), std::move(TSM));
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Basic Block Representation.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
const Function * getParent() const
Return the enclosing method, or null if none.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Lightweight error class with error context and mandatory checking.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
@ InternalLinkage
Rename collisions when linking (static functions).
@ ExternalLinkage
Externally visible function.
BasicBlock * GetInsertBlock() const
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
A Module instance is used to store all the information related to an LLVM module.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
static Type * getVoidTy(LLVMContext &C)
static IntegerType * getInt8Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
Represents an address in the executor process.
static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap=UnwrapFn())
Create an ExecutorAddr from the given pointer.
Represents a defining location for a JIT symbol.
virtual void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM)=0
Emit should materialize the given IR.
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emit should materialize the given IR.
void trackImpls(SymbolAliasMap ImplMaps, JITDylib *SrcJD)
Represents a JIT'd dynamic library.
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
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.
Error addSpeculationRuntime(JITDylib &JD, MangleAndInterner &Mangle)
Define symbols for this Speculator object (__orc_speculator) and the speculation runtime entry point ...
void registerSymbols(FunctionCandidatesMap Candidates, JITDylib *JD)
LLVMContext * getContext()
Returns a pointer to the LLVMContext that was used to construct this instance, or null if the instanc...
An LLVM Module together with a shared ThreadSafeContext.
ThreadSafeContext getContext() const
Returns the context for this ThreadSafeModule.
decltype(auto) withModuleDo(Func &&F)
Locks the associated ThreadSafeContext and calls the given function on the contained Module.
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.