26 assert(SrcJD &&
"Tracking on Null Source .impl dylib");
27 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
28 for (
auto &
I : ImplMaps) {
29 auto It = Maps.
insert({
I.first, {
I.second.Aliasee, SrcJD}});
31 assert(It.second &&
"ImplSymbols are already tracked for this Symbol?");
38 assert(
Ptr &&
" Null Address Received in orc_speculate_for ");
49 {Mangle(
"__orc_speculator"), ThisPtr},
50 {Mangle(
"__orc_speculate_for"), SpeculateForEntryPtr}
60 assert(TSM &&
"Speculation Layer received Null Module ?");
62 "Module with null LLVMContext?");
66 auto &MContext = M.getContext();
73 "__orc_speculate_for", &M);
76 nullptr,
"__orc_speculator");
82 for (
auto &Fn : M.getFunctionList()) {
83 if (!Fn.isDeclaration()) {
85 auto IRNames = QueryAnalysis(Fn);
93 ConstantInt::get(LoadValueTy, 0),
94 "__orc_speculate.guard.for." + Fn.getName());
95 SpeculatorGuard->setAlignment(
Align(1));
101 MContext,
"__orc_speculate.block", &Fn, &ProgramEntry);
103 MContext,
"__orc_speculate.decision.block", &Fn, SpeculateBlock);
105 assert(SpeculateDecisionBlock == &Fn.getEntryBlock() &&
106 "SpeculateDecisionBlock not updated?");
110 Mutator.
CreateLoad(LoadValueTy, SpeculatorGuard,
"guard.value");
113 Mutator.
CreateICmpEQ(LoadGuard, ConstantInt::get(LoadValueTy, 0),
114 "compare.to.speculate");
115 Mutator.
CreateCondBr(CanSpeculate, SpeculateBlock, &ProgramEntry);
118 auto ImplAddrToUint =
120 Mutator.
CreateCall(RuntimeCallTy, RuntimeCall,
121 {SpeclAddr, ImplAddrToUint});
122 Mutator.
CreateStore(ConstantInt::get(LoadValueTy, 1),
127 "IR builder association mismatch?");
129 &R->getTargetJITDylib());
136 "Speculation Instrumentation breaks IR?");
138 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="")
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.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args=std::nullopt, const Twine &Name="", MDNode *FPMathTag=nullptr)
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.