34 Initializer, Name,
nullptr,
41 assert(F.
isDeclaration() &&
"Can't turn a definition into a stub.");
42 assert(F.
getParent() &&
"Function isn't in a module.");
46 LoadInst *ImplAddr = Builder.CreateLoad(&ImplPointer);
47 std::vector<Value*> CallArgs;
48 for (
auto &
A : F.
args())
49 CallArgs.push_back(&
A);
54 Builder.CreateRetVoid();
56 Builder.CreateRet(Call);
72 auto I = Names.find(&Orig);
80 unsigned ID = Names.size();
81 std::ostringstream NameStream;
82 NameStream <<
"__orc_anon" << ID++;
83 auto I = Names.insert(std::make_pair(&Orig, NameStream.str()));
84 return I.first->second;
107 for (
auto &GV : M.globals())
113 assert(F.
getParent() != &Dst &&
"Can't copy decl over existing function.");
121 auto NewArgI = NewF->arg_begin();
124 (*VMap)[ArgI] = NewArgI;
135 NewF = cast<Function>(VMap[&OrigF]);
137 assert(VMap[&OrigF] == NewF &&
"Incorrect function mapping in VMap.");
138 assert(NewF &&
"Function mapping missing from VMap.");
140 "moveFunctionBody should only be used to move bodies between "
145 "",
nullptr,
nullptr, Materializer);
151 assert(GV.
getParent() != &Dst &&
"Can't copy decl over existing global var.");
158 (*VMap)[&GV] = NewGV;
168 NewGV = cast<GlobalVariable>(VMap[&OrigGV]);
170 assert(VMap[&OrigGV] == NewGV &&
171 "Incorrect global variable mapping in VMap.");
173 "moveGlobalVariable should only be used to move initializers between "
177 nullptr, Materializer));
void setVisibility(VisibilityTypes V)
LinkageTypes getLinkage() const
A Module instance is used to store all the information related to an LLVM module. ...
CallInst - This class represents a function call, abstracting a target machine's calling convention...
static PointerType * get(Type *ElementType, unsigned AddressSpace)
PointerType::get - This constructs a pointer to an object of the specified type in a numbered address...
static bool needsRenaming(const Value &New)
Externally visible function.
Type * getReturnType() const
unsigned getAddressSpace() const
Return the address space of the Pointer type.
LoadInst - an instruction for reading from memory.
static IntegerType * getInt64Ty(LLVMContext &C)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
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...
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static void raiseVisibilityOnValue(GlobalValue &V, GlobalRenamer &R)
Constant * createIRTypedAddress(FunctionType &FT, TargetAddress Addr)
Build a function pointer of FunctionType with the given constant address.
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.
FunctionType - Class to represent function types.
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
Type * getElementType() const
GlobalVariable * cloneGlobalVariableDecl(Module &Dst, const GlobalVariable &GV, ValueToValueMapTy *VMap=nullptr)
Clone a global variable declaration into a new module.
PointerType - Class to represent pointers.
ValueMaterializer - This is a class that can be implemented by clients to materialize Values on deman...
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.
Value * MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
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.
void setTailCall(bool isTC=true)
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
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...
void setUnnamedAddr(bool Val)
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.
uint64_t TargetAddress
Represents an address in the target process's address space.
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.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
void makeStub(Function &F, GlobalVariable &ImplPointer)
Turn a function declaration into a stub function that makes an indirect call using the given function...
bool hasLocalLinkage() const
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
void setAttributes(const AttributeSet &Attrs)
setAttributes - Set the parameter attributes for this call.
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)
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...
iterator_range< arg_iterator > args()
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.