LLVM: lib/Transforms/Utils/GlobalStatus.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
25#include
26#include
27
28using namespace llvm;
29
30
31
32
39
40
41
42
47 while (!Worklist.empty()) {
49 if (!Visited.insert(C).second)
50 continue;
52 return false;
53
54 for (const User *U : C->users()) {
57 else
58 return false;
59 }
60 }
61 return true;
62}
63
67 if (GV->isExternallyInitialized())
69
70 for (const Use &U : V->uses()) {
71 const User *UR = U.getUser();
75
76
78 return true;
79 } else {
80
82 return true;
83 }
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;
91 }
93 GS.IsLoaded = true;
94
95 if (LI->isVolatile())
96 return true;
97 GS.Ordering = strongerOrdering(GS.Ordering, LI->getOrdering());
99
100 if (SI->getOperand(0) == V)
101 return true;
102
103
104 if (SI->isVolatile())
105 return true;
106
107 ++GS.NumStores;
108
110
111
112
113
115 const Value *Ptr = SI->getPointerOperand()->stripPointerCasts();
117 Value *StoredVal = SI->getOperand(0);
118
120 if (C->isThreadDependent()) {
121
122 return true;
123 }
124 }
125
126 if (GV->hasInitializer() && StoredVal == GV->getInitializer()) {
135 GS.StoredOnceStore = SI;
137 GS.getStoredOnceValue() == StoredVal) {
138
139 } else {
141 }
142 } else {
144 }
145 }
147
148
150 return true;
152
153
154
155
156 if (VisitedUsers.insert(I).second)
158 return true;
160 GS.IsCompared = true;
162 if (MTI->isVolatile())
163 return true;
164 if (MTI->getArgOperand(0) == V)
166 if (MTI->getArgOperand(1) == V)
167 GS.IsLoaded = true;
169 assert(MSI->getArgOperand(0) == V && "Memset only takes one pointer!");
170 if (MSI->isVolatile())
171 return true;
174 if (CB->getIntrinsicID() == Intrinsic::threadlocal_address) {
176 return true;
177 } else {
178 if (!CB->isCallee(&U))
179 return true;
180 GS.IsLoaded = true;
181 }
182 } else {
183 return true;
184 }
185 } else {
186
187 return true;
188 }
189 }
190
191 return false;
192}
193
195
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Atomic ordering constants.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS, SmallPtrSetImpl< const Value * > &VisitedUsers)
Definition GlobalStatus.cpp:64
static AtomicOrdering strongerOrdering(AtomicOrdering X, AtomicOrdering Y)
Return the stronger of the two ordering.
Definition GlobalStatus.cpp:33
This defines the Use class.
This file defines the SmallPtrSet class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
A constant value that is initialized with an expression using other constant values.
This is an important base class in LLVM.
An instruction for reading from memory.
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
This class wraps the llvm.memcpy/memmove intrinsics.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
iterator_range< use_iterator > uses()
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
bool isSafeToDestroyConstant(const Constant *C)
It is safe to destroy a constant iff it is only used by constants itself.
Definition GlobalStatus.cpp:43
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
AtomicOrdering
Atomic ordering for LLVM's memory model.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
As we analyze each global or thread-local variable, keep track of some information about it.
@ 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.
@ StoredOnce
This global is stored to, but only its initializer and one other value is ever stored to it.
static bool analyzeGlobal(const Value *V, GlobalStatus &GS)
Look at all uses of the global and fill in the GlobalStatus structure.
Definition GlobalStatus.cpp:196