36 ArrayType *ATy = cast<ArrayType>(GVCtor->getType()->getElementType());
39 unsigned n =
Init->getNumOperands();
40 CurrentCtors.reserve(n + 1);
41 for (
unsigned i = 0; i != n; ++i)
42 CurrentCtors.push_back(cast<Constant>(
Init->getOperand(i)));
44 GVCtor->eraseFromParent();
53 CSVals[0] = IRB.getInt32(Priority);
61 CurrentCtors.push_back(RuntimeCtorInit);
84 const char *
Name = CompilerUsed ?
"llvm.compiler.used" :
"llvm.used";
99 if (isa<Function>(FuncOrBitcast))
100 return cast<Function>(FuncOrBitcast);
101 FuncOrBitcast->
dump();
104 Stream <<
"Sanitizer interface function redefined: " << *FuncOrBitcast;
111 assert(!InitName.
empty() &&
"Expected init function name");
112 assert(InitArgTypes.
size() == InitArgTypes.
size() &&
113 "Sanitizer's init function expects different number of arguments");
124 IRB.CreateCall(InitFunction, InitArgs);
125 return std::make_pair(Ctor, InitFunction);
Special purpose, only applies to global arrays.
Function * checkSanitizerInterfaceFunction(Constant *FuncOrBitcast)
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumOperands() const
void appendToGlobalCtors(Module &M, Function *F, int Priority)
Append F to the list of global ctors of module M with the given Priority.
Externally visible function.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
static Constant * getNullValue(Type *Ty)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
StructType - Class to represent struct types.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
FunctionType - Class to represent function types.
ArrayType - Class to represent array types.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
FunctionType::get - This static method is the primary way of constructing a FunctionType.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Type * getElementType() const
size_t size() const
size - Get the array size.
Value * stripPointerCastsNoFollowAliases()
Strip off pointer casts and all-zero GEPs.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
Look up the specified function in the module symbol table.
LLVM Basic Block Representation.
This is an important base class in LLVM.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static Type * getVoidTy(LLVMContext &C)
Value * getOperand(unsigned i) const
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
static void appendToGlobalArray(const char *Array, Module &M, Function *F, int Priority)
void appendToGlobalDtors(Module &M, Function *F, int Priority)
Same as appendToGlobalCtors(), but for global dtors.
void dump() const
Support for debugging, callable in GDB: V->dump()
static PointerType * getUnqual(Type *ElementType)
PointerType::getUnqual - This constructs a pointer to an object of the specified type in the generic ...
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
StructType::get - This static method is the primary way to create a literal StructType.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
GlobalVariable * getNamedGlobal(StringRef Name)
Return the global variable in the module with the specified name, of arbitrary type.
void setLinkage(LinkageTypes LT)
ConstantArray - Constant Array Declarations.
bool hasInitializer() const
Definitions have initializers, declarations don't.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
ArrayType::get - This static method is the primary way to construct an ArrayType. ...
std::pair< Function *, Function * > createSanitizerCtorAndInitFunctions(Module &M, StringRef CtorName, StringRef InitName, ArrayRef< Type * > InitArgTypes, ArrayRef< Value * > InitArgs)
Creates sanitizer constructor function, and calls sanitizer's init function from it.
Rename collisions when linking (static functions).
A raw_ostream that writes to an std::string.
LLVM Value Representation.
GlobalVariable * collectUsedGlobalVariables(Module &M, SmallPtrSetImpl< GlobalValue * > &Set, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
StringRef - Represent a constant reference to a string, i.e.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
unsigned getNumElements() const
Random access to the elements.
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
LLVMContext & getContext() const
Get the global data context.
bool empty() const
empty - Check if the string is empty.