35 if (isa<GlobalValue>(C))
38 if (isa<ConstantInt>(C) || isa<ConstantFP>(C))
42 if (
const Constant *CU = dyn_cast<Constant>(U)) {
52 for (
const Use &U : V->
uses()) {
53 const User *UR = U.getUser();
54 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(UR)) {
59 if (!isa<PointerType>(CE->getType()))
64 }
else if (
const Instruction *
I = dyn_cast<Instruction>(UR)) {
66 const Function *
F =
I->getParent()->getParent();
72 if (
const LoadInst *LI = dyn_cast<LoadInst>(
I)) {
78 }
else if (
const StoreInst *
SI = dyn_cast<StoreInst>(
I)) {
80 if (
SI->getOperand(0) == V)
94 dyn_cast<GlobalVariable>(
SI->getOperand(1))) {
95 Value *StoredVal =
SI->getOperand(0);
97 if (
Constant *C = dyn_cast<Constant>(StoredVal)) {
98 if (C->isThreadDependent()) {
104 if (StoredVal == GV->getInitializer()) {
107 }
else if (isa<LoadInst>(StoredVal) &&
108 cast<LoadInst>(StoredVal)->getOperand(0) == GV) {
124 }
else if (isa<BitCastInst>(
I)) {
127 }
else if (isa<GetElementPtrInst>(
I)) {
130 }
else if (isa<SelectInst>(
I)) {
133 }
else if (
const PHINode *PN = dyn_cast<PHINode>(
I)) {
136 if (PhiUsers.
insert(PN).second)
139 }
else if (isa<CmpInst>(
I)) {
142 if (MTI->isVolatile())
144 if (MTI->getArgOperand(0) == V)
146 if (MTI->getArgOperand(1) == V)
148 }
else if (
const MemSetInst *MSI = dyn_cast<MemSetInst>(
I)) {
149 assert(MSI->getArgOperand(0) == V &&
"Memset only takes one pointer!");
150 if (MSI->isVolatile())
160 }
else if (
const Constant *C = dyn_cast<Constant>(UR)) {
182 StoredOnceValue(nullptr), AccessingFunction(nullptr),
183 HasMultipleAccessingFunctions(
false), HasNonInstructionUser(
false),
bool IsLoaded
True if the global is ever loaded.
iterator_range< use_iterator > uses()
Value * StoredOnceValue
If only one value (besides the initializer constant) is ever stored to this global, keep track of what value it is.
const Function * AccessingFunction
These start out null/false.
bool HasMultipleAccessingFunctions
MemSetInst - This class wraps the llvm.memset intrinsic.
LoadInst - an instruction for reading from memory.
This global is stored to, but the only thing stored is the constant it was initialized with...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
A Use represents the edge between a Value definition and its users.
StoredType
Keep track of what stores to the global look like.
bool HasNonInstructionUser
Set to true if this global has a user that is not an instruction (e.g.
ConstantExpr - a constant value that is initialized with an expression using other constant values...
StoreInst - an instruction for storing to memory.
This global is stored to, but only its initializer and one other value is ever stored to it...
static AtomicOrdering strongerOrdering(AtomicOrdering X, AtomicOrdering Y)
Return the stronger of the two ordering.
As we analyze each global, keep track of some information about it.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
This is an important base class in LLVM.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
static bool analyzeGlobal(const Value *V, GlobalStatus &GS)
Look at all uses of the global and fill in the GlobalStatus structure.
bool isSafeToDestroyConstant(const Constant *C)
It is safe to destroy a constant iff it is only used by constants itself.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This global is stored to by multiple values or something else that we cannot track.
iterator_range< user_iterator > users()
MemTransferInst - This class wraps the llvm.memcpy/memmove intrinsics.
bool IsCompared
True if the global's address is used in a comparison.
AtomicOrdering Ordering
Set to the strongest atomic ordering requirement.
ImmutableCallSite - establish a view to a call site for examination.
LLVM Value Representation.
static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS, SmallPtrSetImpl< const PHINode * > &PhiUsers)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")