23 #define DEBUG_TYPE "ctor_utils" 33 if (!CtorsToRemove.
test(
I))
42 if (CA->getType() == OldCA->
getType()) {
68 return std::vector<Function *>();
70 std::vector<Function *> Result;
74 Result.push_back(dyn_cast<Function>(CS->
getOperand(1)));
96 if (isa<ConstantAggregateZero>(V))
99 if (isa<ConstantPointerNull>(CS->
getOperand(1)))
127 bool MadeChange =
false;
130 unsigned NumCtors = Ctors.size();
132 for (
unsigned i = 0; i != Ctors.size() && NumCtors > 0; ++i) {
139 LLVM_DEBUG(
dbgs() <<
"Optimizing Global Constructor: " << *F <<
"\n");
146 if (ShouldRemove(F)) {
148 CtorsToRemove.
set(i);
ThreadLocalMode getThreadLocalMode() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
void push_back(const T &Elt)
bool test(unsigned Idx) const
An efficient, type-erasing, non-owning reference to a callable.
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
static void removeGlobalCtors(GlobalVariable *GCL, const BitVector &CtorsToRemove)
Given a specified llvm.global_ctors list, remove the listed elements.
static Constant * get(ArrayType *T, ArrayRef< Constant *> V)
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
static std::vector< Function * > parseGlobalCtors(GlobalVariable *GV)
Given a llvm.global_ctors list that we can understand, return a list of the functions and null termin...
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
Type * getType() const
All values are typed, get the type of this value.
Class to represent array types.
LinkageTypes getLinkage() const
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void takeName(Value *V)
Transfer the name from V to this value.
Value * getOperand(unsigned i) const
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool hasUniqueInitializer() const
hasUniqueInitializer - Whether the global variable has an initializer, and any changes made to the in...
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
self_iterator getIterator()
unsigned getNumOperands() const
This is the shared class of boolean and integer constants.
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ConstantArray - Constant Array Declarations.
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
iterator insert(iterator where, pointer New)
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Module * getParent()
Get the module that this global value is contained inside of...
Type * getElementType() const
static GlobalVariable * findGlobalCtors(Module &M)
Find the llvm.global_ctors list, verifying that all initializers have an init priority of 65535...
bool optimizeGlobalCtorsList(Module &M, function_ref< bool(Function *)> ShouldRemove)
Call "ShouldRemove" for every entry in M's global_ctor list and remove the entries for which it retur...
PointerType * getType() const
Global values are always pointers.