Go to the documentation of this file.
46 Worklist.push_back(
C);
47 while (!Worklist.empty()) {
51 if (isa<GlobalValue>(
C) || isa<ConstantData>(
C))
55 if (
const Constant *
CU = dyn_cast<Constant>(U))
56 Worklist.push_back(
CU);
67 if (GV->isExternallyInitialized())
70 for (
const Use &U : V->
uses()) {
71 const User *UR = U.getUser();
72 if (
const Constant *
C = dyn_cast<Constant>(UR)) {
74 if (CE && isa<PointerType>(CE->getType())) {
84 }
else if (
const Instruction *
I = dyn_cast<Instruction>(UR)) {
85 if (!
GS.HasMultipleAccessingFunctions) {
86 const Function *
F =
I->getParent()->getParent();
87 if (!
GS.AccessingFunction)
88 GS.AccessingFunction =
F;
89 else if (
GS.AccessingFunction !=
F)
90 GS.HasMultipleAccessingFunctions =
true;
92 if (
const LoadInst *LI = dyn_cast<LoadInst>(
I)) {
98 }
else if (
const StoreInst *
SI = dyn_cast<StoreInst>(
I)) {
100 if (
SI->getOperand(0) == V)
104 if (
SI->isVolatile())
115 const Value *Ptr =
SI->getPointerOperand()->stripPointerCasts();
117 Value *StoredVal =
SI->getOperand(0);
119 if (
Constant *
C = dyn_cast<Constant>(StoredVal)) {
120 if (
C->isThreadDependent()) {
126 if (GV->hasInitializer() && StoredVal == GV->getInitializer()) {
129 }
else if (isa<LoadInst>(StoredVal) &&
130 cast<LoadInst>(StoredVal)->getOperand(0) == GV) {
135 GS.StoredOnceStore =
SI;
137 GS.getStoredOnceValue() == StoredVal) {
146 }
else if (isa<BitCastInst>(
I) || isa<GetElementPtrInst>(
I) ||
147 isa<AddrSpaceCastInst>(
I)) {
152 }
else if (isa<SelectInst>(
I) || isa<PHINode>(
I)) {
157 if (VisitedUsers.
insert(
I).second)
160 }
else if (isa<CmpInst>(
I)) {
161 GS.IsCompared =
true;
163 if (MTI->isVolatile())
165 if (MTI->getArgOperand(0) == V)
167 if (MTI->getArgOperand(1) == V)
169 }
else if (
const MemSetInst *MSI = dyn_cast<MemSetInst>(
I)) {
170 assert(MSI->getArgOperand(0) == V &&
"Memset only takes one pointer!");
171 if (MSI->isVolatile())
174 }
else if (
const auto *CB = dyn_cast<CallBase>(
I)) {
175 if (!CB->isCallee(&U))
This is an optimization pass for GlobalISel generic memory operations.
This class wraps the llvm.memcpy/memmove intrinsics.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static bool analyzeGlobal(const Value *V, GlobalStatus &GS)
Look at all uses of the global and fill in the GlobalStatus structure.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
LLVM_NODISCARD T pop_back_val()
As we analyze each global, keep track of some information about it.
(vector float) vec_cmpeq(*A, *B) C
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
static AtomicOrdering strongerOrdering(AtomicOrdering X, AtomicOrdering Y)
Return the stronger of the two ordering.
iterator_range< use_iterator > uses()
bool isSafeToDestroyConstant(const Constant *C)
It is safe to destroy a constant iff it is only used by constants itself.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
AtomicOrdering
Atomic ordering for LLVM's memory model.
An instruction for storing to memory.
This is an important base class in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StandardInstrumentations SI(Debug, VerifyEach)
@ Stored
This global is stored to by multiple values or something else that we cannot track.
@ InitializerStored
This global is stored to, but the only thing stored is the constant it was initialized with.
An instruction for reading from memory.
static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS, SmallPtrSetImpl< const Value * > &VisitedUsers)
A constant value that is initialized with an expression using other constant values.
@ StoredOnce
This global is stored to, but only its initializer and one other value is ever stored to it.
LLVM Value Representation.
iterator_range< user_iterator > users()
A Use represents the edge between a Value definition and its users.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.