Go to the documentation of this file.
23 #define DEBUG_TYPE "ctor_utils"
33 if (!CtorsToRemove.
test(
I))
66 static std::vector<std::pair<uint32_t, Function *>>
69 std::vector<std::pair<uint32_t, Function *>> Result;
73 Result.emplace_back(cast<ConstantInt>(CS->
getOperand(0))->getZExtValue(),
97 if (isa<ConstantAggregateZero>(V))
100 if (isa<ConstantPointerNull>(CS->
getOperand(1)))
105 if (!
F ||
F->arg_size() != 0)
119 std::vector<std::pair<uint32_t, Function *>> Ctors =
124 bool MadeChange =
false;
127 std::vector<size_t> CtorsByPriority(Ctors.size());
128 std::iota(CtorsByPriority.begin(), CtorsByPriority.end(), 0);
130 return Ctors[
LHS].first < Ctors[
RHS].first;
132 for (
unsigned CtorIndex : CtorsByPriority) {
133 const uint32_t Priority = Ctors[CtorIndex].first;
141 if (ShouldRemove(Priority,
F)) {
142 Ctors[CtorIndex].second =
nullptr;
143 CtorsToRemove.
set(CtorIndex);
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
This is an optimization pass for GlobalISel generic memory operations.
bool hasUniqueInitializer() const
hasUniqueInitializer - Whether the global variable has an initializer, and any changes made to the in...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
LinkageTypes getLinkage() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Class to represent array types.
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void removeGlobalCtors(GlobalVariable *GCL, const BitVector &CtorsToRemove)
Given a specified llvm.global_ctors list, remove the listed elements.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ThreadLocalMode getThreadLocalMode() const
ConstantArray - Constant Array Declarations.
An efficient, type-erasing, non-owning reference to a callable.
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
Module * getParent()
Get the module that this global value is contained inside of...
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
A Module instance is used to store all the information related to an LLVM module.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
self_iterator getIterator()
bool test(unsigned Idx) const
void stable_sort(R &&Range)
static GlobalVariable * findGlobalCtors(Module &M)
Find the llvm.global_ctors list.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
bool optimizeGlobalCtorsList(Module &M, function_ref< bool(uint32_t, Function *)> ShouldRemove)
Call "ShouldRemove" for every entry in M's global_ctor list and remove the entries for which it retur...
unsigned getNumOperands() const
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
PointerType * getType() const
Global values are always pointers.
void takeName(Value *V)
Transfer the name from V to this value.
Value * getOperand(unsigned i) const
static std::vector< std::pair< uint32_t, Function * > > parseGlobalCtors(GlobalVariable *GV)
Given a llvm.global_ctors list that we can understand, return a list of the functions and null termin...
Type * getElementType() const
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...