22 void JITCompileCallbackManager::anchor() {}
23 void IndirectStubsManager::anchor() {}
25 std::unique_ptr<JITCompileCallbackManager>
29 default:
return nullptr;
33 return llvm::make_unique<CCMgrT>(ErrorHandlerAddress);
37 if ( T.
getOS() == Triple::OSType::Win32 ) {
39 return llvm::make_unique<CCMgrT>(ErrorHandlerAddress);
42 return llvm::make_unique<CCMgrT>(ErrorHandlerAddress);
48 std::function<std::unique_ptr<IndirectStubsManager>()>
51 default:
return nullptr;
60 if (T.
getOS() == Triple::OSType::Win32) {
86 Initializer, Name,
nullptr,
98 LoadInst *ImplAddr = Builder.CreateLoad(&ImplPointer);
99 std::vector<Value*> CallArgs;
100 for (
auto &
A : F.
args())
101 CallArgs.push_back(&
A);
102 CallInst *
Call = Builder.CreateCall(ImplAddr, CallArgs);
106 Builder.CreateRetVoid();
108 Builder.CreateRet(Call);
122 auto I = Names.find(&Orig);
123 if (
I != Names.end())
130 unsigned ID = Names.size();
131 std::ostringstream NameStream;
132 NameStream <<
"__orc_anon" << ID++;
133 auto I = Names.insert(std::make_pair(&Orig, NameStream.str()));
134 return I.first->second;
157 for (
auto &GV : M.globals())
160 for (
auto &
A : M.aliases())
166 assert(F.
getParent() != &Dst &&
"Can't copy decl over existing function.");
174 auto NewArgI = NewF->arg_begin();
177 (*VMap)[&*ArgI] = &*NewArgI;
188 NewF = cast<Function>(VMap[&OrigF]);
190 assert(VMap[&OrigF] == NewF &&
"Incorrect function mapping in VMap.");
191 assert(NewF &&
"Function mapping missing from VMap.");
193 "moveFunctionBody should only be used to move bodies between "
198 "",
nullptr,
nullptr, Materializer);
204 assert(GV.
getParent() != &Dst &&
"Can't copy decl over existing global var.");
211 (*VMap)[&GV] = NewGV;
221 NewGV = cast<GlobalVariable>(VMap[&OrigGV]);
223 assert(VMap[&OrigGV] == NewGV &&
224 "Incorrect global variable mapping in VMap.");
226 "moveGlobalVariable should only be used to move initializers between "
230 nullptr, Materializer));
249 for (
auto *MF : MFs->operands())
void setVisibility(VisibilityTypes V)
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
LinkageTypes getLinkage() const
IndirectStubsManager implementation for the host architecture, e.g.
virtual void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
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. ...
void cloneModuleFlagsMetadata(Module &Dst, const Module &Src, ValueToValueMapTy &VMap)
Clone module flags metadata into the destination module.
Type * getValueType() const
This class represents a function call, abstracting a target machine's calling convention.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
static bool needsRenaming(const Value &New)
Externally visible function.
Type * getReturnType() const
Returns the type of the ret val.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
An instruction for reading from memory.
static IntegerType * getInt64Ty(LLVMContext &C)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
const Constant * getAliasee() const
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.
StringRef getName() const
Return a constant reference to the value's name.
const std::string & getRename(const Value &Orig)
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...
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...
std::unique_ptr< JITCompileCallbackManager > createLocalCompileCallbackManager(const Triple &T, JITTargetAddress ErrorHandlerAddress)
Create a local compile callback manager.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static void raiseVisibilityOnValue(GlobalValue &V, GlobalRenamer &R)
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...
void setName(const Twine &Name)
Change the name of the value.
void makeStub(Function &F, Value &ImplPointer)
Turn a function declaration into a stub function that makes an indirect call using the given function...
Class to represent function types.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
GlobalVariable * cloneGlobalVariableDecl(Module &Dst, const GlobalVariable &GV, ValueToValueMapTy *VMap=nullptr)
Clone a global variable declaration into a new module.
Class to represent pointers.
void setAttributes(AttributeSet Attrs)
Set the parameter attributes for this call.
This is a class that can be implemented by clients to materialize Values on demand.
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
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 getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
void setTailCall(bool isTC=true)
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.
Function * cloneFunctionDecl(Module &Dst, const Function &F, ValueToValueMapTy *VMap=nullptr)
Clone a function declaration into a new module.
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.
void setLinkage(LinkageTypes LT)
AttributeSet getAttributes() const
Return the attribute list for this Function.
bool hasInitializer() const
Definitions have initializers, declarations don't.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
void makeAllSymbolsExternallyAccessible(Module &M)
Raise linkage types and rename as necessary to ensure that all symbols are accessible for other modul...
ThreadLocalMode getThreadLocalMode() const
PointerType * getType() const
Global values are always pointers.
void setUnnamedAddr(UnnamedAddr Val)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool hasLocalLinkage() const
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
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...
iterator_range< arg_iterator > args()
bool isVoidTy() const
Return true if this is 'void'.