32 Name(std::move(
Name)), Compile(std::move(Compile)) {}
50 CompileFunction Compile;
58 void IndirectStubsManager::anchor() {}
59 void TrampolinePool::anchor() {}
63 if (
auto TrampolineAddr = TP->getTrampoline()) {
67 std::lock_guard<std::mutex>
Lock(CCMgrMutex);
68 AddrToSymbol[*TrampolineAddr] = CallbackName;
70 std::make_unique<CompileCallbackMaterializationUnit>(
71 std::move(CallbackName), std::move(Compile),
72 ES.allocateVModule())));
73 return *TrampolineAddr;
75 return TrampolineAddr.takeError();
83 std::unique_lock<std::mutex>
Lock(CCMgrMutex);
84 auto I = AddrToSymbol.find(TrampolineAddr);
89 if (
I == AddrToSymbol.end()) {
94 ErrMsgStream <<
"No compile callback for trampoline at " 95 <<
format(
"0x%016" PRIx64, TrampolineAddr);
99 return ErrorHandlerAddress;
108 return Sym->getAddress();
113 ES.reportError(Sym.takeError());
114 return ErrorHandlerAddress;
123 return make_error<StringError>(
124 std::string(
"No callback manager available for ") + T.
str(),
129 return CCMgrT::Create(ES, ErrorHandlerAddress);
134 return CCMgrT::Create(ES, ErrorHandlerAddress);
139 return CCMgrT::Create(ES, ErrorHandlerAddress);
143 return CCMgrT::Create(ES, ErrorHandlerAddress);
149 return CCMgrT::Create(ES, ErrorHandlerAddress);
153 if ( T.
getOS() == Triple::OSType::Win32 ) {
155 return CCMgrT::Create(ES, ErrorHandlerAddress);
158 return CCMgrT::Create(ES, ErrorHandlerAddress);
165 std::function<std::unique_ptr<IndirectStubsManager>()>
170 return std::make_unique<
177 return std::make_unique<
183 return std::make_unique<
189 return std::make_unique<
195 return std::make_unique<
202 return std::make_unique<
207 if (T.
getOS() == Triple::OSType::Win32) {
209 return std::make_unique<
214 return std::make_unique<
234 Initializer, Name,
nullptr,
247 std::vector<Value*> CallArgs;
248 for (
auto &A : F.
args())
249 CallArgs.push_back(&A);
254 Builder.CreateRetVoid();
256 Builder.CreateRet(Call);
260 std::vector<GlobalValue *> PromotedGlobals;
263 bool Promoted =
true;
267 GV.setName(
"__orc_anon." +
Twine(NextId++));
268 else if (GV.getName().startswith(
"\01L"))
269 GV.setName(
"__" + GV.getName().substr(1) +
"." +
Twine(NextId++));
270 else if (GV.hasLocalLinkage())
271 GV.setName(
"__orc_lcl." + GV.getName() +
"." +
Twine(NextId++));
275 if (GV.hasLocalLinkage()) {
283 PromotedGlobals.push_back(&GV);
286 return PromotedGlobals;
301 (*VMap)[&*ArgI] = &*NewArgI;
312 NewF = cast<Function>(VMap[&OrigF]);
314 assert(VMap[&OrigF] == NewF &&
"Incorrect function mapping in VMap.");
315 assert(NewF &&
"Function mapping missing from VMap.");
317 "moveFunctionBody should only be used to move bodies between " 322 "",
nullptr,
nullptr, Materializer);
334 (*VMap)[&GV] = NewGV;
344 NewGV = cast<GlobalVariable>(VMap[&OrigGV]);
346 assert(VMap[&OrigGV] == NewGV &&
347 "Incorrect global variable mapping in VMap.");
349 "moveGlobalVariableInitializer should only be used to move " 350 "initializers between modules");
353 nullptr, Materializer));
372 for (
auto *MF : MFs->operands())
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
ThreadLocalMode getThreadLocalMode() const
IndirectStubsManager implementation for the host architecture, e.g.
Error notifyEmitted()
Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by t...
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This class represents lattice values for constants.
std::function< std::unique_ptr< IndirectStubsManager >)> createLocalIndirectStubsManagerBuilder(const Triple &T)
Create a local indriect stubs manager builder.
GlobalAlias * cloneGlobalAliasDecl(Module &Dst, const GlobalAlias &OrigA, ValueToValueMapTy &VMap)
Clone a global alias declaration into a new module.
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
void cloneModuleFlagsMetadata(Module &Dst, const Module &Src, ValueToValueMapTy &VMap)
Clone module flags metadata into the destination module.
This class represents a function call, abstracting a target machine's calling convention.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
Externally visible function.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
static IntegerType * getInt64Ty(LLVMContext &C)
Manage compile callbacks for in-process JITs.
Metadata * MapMetadata(const Metadata *MD, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Lookup or compute a mapping for a piece of metadata.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueToValueMapTy &VMap, bool ModuleLevelChanges, SmallVectorImpl< ReturnInst *> &Returns, const char *NameSuffix="", ClonedCodeInfo *CodeInfo=nullptr, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Clone OldFunc into NewFunc, transforming the old arguments into references to VMap values...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
GlobalVariable * createImplPointer(PointerType &PT, Module &M, const Twine &Name, Constant *Initializer)
Create a function pointer with the given type, name, and initializer in the given Module...
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
static StringRef getName(Value *V)
void moveGlobalVariableInitializer(GlobalVariable &OrigGV, ValueToValueMapTy &VMap, ValueMaterializer *Materializer=nullptr, GlobalVariable *NewGV=nullptr)
Move global variable GV from its parent module to cloned global declaration in a different module...
Tagged union holding either a T or a Error.
void makeStub(Function &F, Value &ImplPointer)
Turn a function declaration into a stub function that makes an indirect call using the given function...
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Class to represent function types.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
AttributeList getAttributes() const
Return the attribute list for this Function.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
LinkageTypes getLinkage() const
const std::string & str() const
GlobalVariable * cloneGlobalVariableDecl(Module &Dst, const GlobalVariable &GV, ValueToValueMapTy *VMap=nullptr)
Clone a global variable declaration into a new module.
Class to represent pointers.
Pointer to a pooled string representing a symbol name.
bool isVoidTy() const
Return true if this is 'void'.
This is a class that can be implemented by clients to materialize Values on demand.
Type * getReturnType() const
Returns the type of the ret val.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
LLVM Basic Block Representation.
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external...
This is an important base class in LLVM.
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib *> JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
void setTailCall(bool isTC=true)
Error notifyResolved(const SymbolMap &Symbols)
Notifies the target JITDylib that the given symbols have been resolved.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Value * MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Look up or compute a value in the value map.
Triple - Helper class for working with autoconf configuration names.
Constant * createIRTypedAddress(FunctionType &FT, JITTargetAddress Addr)
Build a function pointer of FunctionType with the given constant address.
std::function< JITTargetAddress()> CompileFunction
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group...
Function * cloneFunctionDecl(Module &Dst, const Function &F, ValueToValueMapTy *VMap=nullptr)
Clone a function declaration into a new module.
Expected< std::unique_ptr< JITCompileCallbackManager > > createLocalCompileCallbackManager(const Triple &T, ExecutionSession &ES, JITTargetAddress ErrorHandlerAddress)
Create a local compile callback manager.
void copyAttributesFrom(const GlobalValue *Src)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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.
Expected< JITTargetAddress > getCompileCallback(CompileFunction Compile)
Reserve a compile callback.
An ExecutionSession represents a running JIT program.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Represents a symbol that has been evaluated to an address already.
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
uint8_t uint64_t VModuleKey
VModuleKey provides a unique identifier (allocated and managed by ExecutionSessions) for a module add...
JITTargetAddress executeCompileCallback(JITTargetAddress TrampolineAddr)
Execute the callback for the given trampoline id.
StringRef getName() const
Return a constant reference to the value's name.
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
Type * getValueType() const
const std::string to_string(const T &Value)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
bool hasInitializer() const
Definitions have initializers, declarations don't.
StringRef - Represent a constant reference to a string, i.e.
void moveFunctionBody(Function &OrigF, ValueToValueMapTy &VMap, ValueMaterializer *Materializer=nullptr, Function *NewF=nullptr)
Move the body of function 'F' to a cloned function declaration in a different module (See related clo...
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
PointerType * getType() const
Global values are always pointers.
iterator_range< arg_iterator > args()
A symbol table that supports asynchoronous symbol queries.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
iterator_range< global_value_iterator > global_values()
const Constant * getAliasee() const