blob: be02ddbaa53492d78add3906d8754735391351e2 [file] [log] [blame]
Chris Lattner7d58f8d2002-08-22 18:25:32 +00001//===- AliasAnalysis.cpp - Generic Alias Analysis Interface Implementation -==//
Misha Brukman01808ca2005-04-21 21:13:18 +00002//
John Criswell482202a2003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman01808ca2005-04-21 21:13:18 +00007//
John Criswell482202a2003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattner7d58f8d2002-08-22 18:25:32 +00009//
10// This file implements the generic AliasAnalysis interface which is used as the
11// common interface used by all clients and implementations of alias analysis.
12//
13// This file also implements the default version of the AliasAnalysis interface
14// that is to be used when no other implementation is specified. This does some
15// simple tests that detect obvious cases: two different global pointers cannot
16// alias, a global cannot alias a malloc, two different mallocs cannot alias,
17// etc.
18//
19// This alias analysis implementation really isn't very good for anything, but
20// it is very fast, and makes a nice clean default implementation. Because it
21// handles lots of little corner cases, other, more complex, alias analysis
22// implementations may choose to rely on this pass to resolve these simple and
23// easy cases.
24//
25//===----------------------------------------------------------------------===//
26
Chris Lattnerd6a2a992003-02-26 19:41:54 +000027#include "llvm/Analysis/AliasAnalysis.h"
Reid Spencer54cb2d82006-06-07 20:00:19 +000028#include "llvm/Pass.h"
Chris Lattner7d58f8d2002-08-22 18:25:32 +000029#include "llvm/BasicBlock.h"
Duncan Sands68b6f502007-12-01 07:51:45 +000030#include "llvm/Function.h"
Owen Andersonf755c2b2009-02-03 06:27:22 +000031#include "llvm/IntrinsicInst.h"
Misha Brukman63b38bd2004-07-29 17:30:56 +000032#include "llvm/Instructions.h"
Dan Gohman41f14cf2010-09-14 21:25:10 +000033#include "llvm/LLVMContext.h"
Chris Lattner7b9020a2005-03-17 15:38:16 +000034#include "llvm/Type.h"
Chris Lattner3a311832003-02-26 19:26:51 +000035#include "llvm/Target/TargetData.h"
Chris Lattnera67dbd02004-03-15 04:07:29 +000036using namespace llvm;
Brian Gaeke960707c2003-11-11 22:41:34 +000037
Chris Lattner7d58f8d2002-08-22 18:25:32 +000038// Register the AliasAnalysis interface, providing a nice name to refer to.
Owen Anderson6c18d1a2010-10-19 17:21:58 +000039INITIALIZE_ANALYSIS_GROUP(AliasAnalysis, "Alias Analysis", NoAA)
Devang Patel8c78a0b2007-05-03 01:11:54 +000040char AliasAnalysis::ID = 0;
Chris Lattner7d58f8d2002-08-22 18:25:32 +000041
Chris Lattner62c37002004-05-23 21:15:48 +000042//===----------------------------------------------------------------------===//
43// Default chaining methods
44//===----------------------------------------------------------------------===//
45
46AliasAnalysis::AliasResult
Dan Gohman41f14cf2010-09-14 21:25:10 +000047AliasAnalysis::alias(const Location &LocA, const Location &LocB) {
Chris Lattner62c37002004-05-23 21:15:48 +000048 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
Dan Gohman41f14cf2010-09-14 21:25:10 +000049 return AA->alias(LocA, LocB);
Chris Lattner62c37002004-05-23 21:15:48 +000050}
51
Dan Gohman9130bad2010-11-08 16:45:26 +000052bool AliasAnalysis::pointsToConstantMemory(const Location &Loc,
53 bool OrLocal) {
Chris Lattner62c37002004-05-23 21:15:48 +000054 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
Dan Gohman9130bad2010-11-08 16:45:26 +000055 return AA->pointsToConstantMemory(Loc, OrLocal);
Chris Lattner62c37002004-05-23 21:15:48 +000056}
57
Chris Lattner62c37002004-05-23 21:15:48 +000058void AliasAnalysis::deleteValue(Value *V) {
59 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
60 AA->deleteValue(V);
61}
62
63void AliasAnalysis::copyValue(Value *From, Value *To) {
64 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
65 AA->copyValue(From, To);
66}
67
Owen Andersonb6e4ff02011-01-03 21:38:41 +000068void AliasAnalysis::addEscapingUse(Use &U) {
69 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
70 AA->addEscapingUse(U);
71}
72
73
Chris Lattner62c37002004-05-23 21:15:48 +000074AliasAnalysis::ModRefResult
Dan Gohman5f1702e2010-08-06 01:25:49 +000075AliasAnalysis::getModRefInfo(ImmutableCallSite CS,
Dan Gohman41f14cf2010-09-14 21:25:10 +000076 const Location &Loc) {
Dan Gohman1033ce62010-10-25 16:28:57 +000077 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
Dan Gohman5f1702e2010-08-06 01:25:49 +000078
79 ModRefBehavior MRB = getModRefBehavior(CS);
80 if (MRB == DoesNotAccessMemory)
81 return NoModRef;
82
83 ModRefResult Mask = ModRef;
Dan Gohman5d06f892010-11-09 20:06:55 +000084 if (onlyReadsMemory(MRB))
Dan Gohman5f1702e2010-08-06 01:25:49 +000085 Mask = Ref;
Dan Gohman5d06f892010-11-09 20:06:55 +000086
Dan Gohman066c1bb2010-11-10 18:17:28 +000087 if (onlyAccessesArgPointees(MRB)) {
Dan Gohman5f1702e2010-08-06 01:25:49 +000088 bool doesAlias = false;
Dan Gohman066c1bb2010-11-10 18:17:28 +000089 if (doesAccessArgPointees(MRB))
90 for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
91 AI != AE; ++AI)
92 if (!isNoAlias(Location(*AI), Loc)) {
93 doesAlias = true;
94 break;
95 }
Dan Gohman5f1702e2010-08-06 01:25:49 +000096
97 if (!doesAlias)
98 return NoModRef;
99 }
100
Dan Gohman41f14cf2010-09-14 21:25:10 +0000101 // If Loc is a constant memory location, the call definitely could not
Dan Gohman5f1702e2010-08-06 01:25:49 +0000102 // modify the memory location.
Dan Gohman41f14cf2010-09-14 21:25:10 +0000103 if ((Mask & Mod) && pointsToConstantMemory(Loc))
Dan Gohman5f1702e2010-08-06 01:25:49 +0000104 Mask = ModRefResult(Mask & ~Mod);
105
Dan Gohmanabaf2d82010-10-25 16:29:52 +0000106 // If this is the end of the chain, don't forward.
Dan Gohman5f1702e2010-08-06 01:25:49 +0000107 if (!AA) return Mask;
108
109 // Otherwise, fall back to the next AA in the chain. But we can merge
110 // in any mask we've managed to compute.
Dan Gohman41f14cf2010-09-14 21:25:10 +0000111 return ModRefResult(AA->getModRefInfo(CS, Loc) & Mask);
Dan Gohman5f1702e2010-08-06 01:25:49 +0000112}
113
114AliasAnalysis::ModRefResult
Dan Gohman5442c712010-08-03 21:48:53 +0000115AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
Dan Gohman1033ce62010-10-25 16:28:57 +0000116 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
Dan Gohman5f1702e2010-08-06 01:25:49 +0000117
118 // If CS1 or CS2 are readnone, they don't interact.
119 ModRefBehavior CS1B = getModRefBehavior(CS1);
120 if (CS1B == DoesNotAccessMemory) return NoModRef;
121
122 ModRefBehavior CS2B = getModRefBehavior(CS2);
123 if (CS2B == DoesNotAccessMemory) return NoModRef;
124
125 // If they both only read from memory, there is no dependence.
Dan Gohman5d06f892010-11-09 20:06:55 +0000126 if (onlyReadsMemory(CS1B) && onlyReadsMemory(CS2B))
Dan Gohman5f1702e2010-08-06 01:25:49 +0000127 return NoModRef;
128
129 AliasAnalysis::ModRefResult Mask = ModRef;
130
131 // If CS1 only reads memory, the only dependence on CS2 can be
132 // from CS1 reading memory written by CS2.
Dan Gohman5d06f892010-11-09 20:06:55 +0000133 if (onlyReadsMemory(CS1B))
Dan Gohman5f1702e2010-08-06 01:25:49 +0000134 Mask = ModRefResult(Mask & Ref);
135
136 // If CS2 only access memory through arguments, accumulate the mod/ref
137 // information from CS1's references to the memory referenced by
138 // CS2's arguments.
Dan Gohman066c1bb2010-11-10 18:17:28 +0000139 if (onlyAccessesArgPointees(CS2B)) {
Dan Gohman5f1702e2010-08-06 01:25:49 +0000140 AliasAnalysis::ModRefResult R = NoModRef;
Dan Gohman066c1bb2010-11-10 18:17:28 +0000141 if (doesAccessArgPointees(CS2B))
142 for (ImmutableCallSite::arg_iterator
143 I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
144 R = ModRefResult((R | getModRefInfo(CS1, *I, UnknownSize)) & Mask);
145 if (R == Mask)
146 break;
147 }
Dan Gohman5f1702e2010-08-06 01:25:49 +0000148 return R;
149 }
150
151 // If CS1 only accesses memory through arguments, check if CS2 references
152 // any of the memory referenced by CS1's arguments. If not, return NoModRef.
Dan Gohman066c1bb2010-11-10 18:17:28 +0000153 if (onlyAccessesArgPointees(CS1B)) {
Dan Gohman5f1702e2010-08-06 01:25:49 +0000154 AliasAnalysis::ModRefResult R = NoModRef;
Dan Gohman066c1bb2010-11-10 18:17:28 +0000155 if (doesAccessArgPointees(CS1B))
156 for (ImmutableCallSite::arg_iterator
157 I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I)
158 if (getModRefInfo(CS2, *I, UnknownSize) != NoModRef) {
159 R = Mask;
160 break;
161 }
Dan Gohman5f1702e2010-08-06 01:25:49 +0000162 if (R == NoModRef)
163 return R;
164 }
165
Dan Gohmanabaf2d82010-10-25 16:29:52 +0000166 // If this is the end of the chain, don't forward.
Dan Gohman5f1702e2010-08-06 01:25:49 +0000167 if (!AA) return Mask;
168
169 // Otherwise, fall back to the next AA in the chain. But we can merge
170 // in any mask we've managed to compute.
171 return ModRefResult(AA->getModRefInfo(CS1, CS2) & Mask);
172}
173
174AliasAnalysis::ModRefBehavior
175AliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
Dan Gohman1033ce62010-10-25 16:28:57 +0000176 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
Dan Gohman5f1702e2010-08-06 01:25:49 +0000177
178 ModRefBehavior Min = UnknownModRefBehavior;
179
180 // Call back into the alias analysis with the other form of getModRefBehavior
181 // to see if it can give a better response.
182 if (const Function *F = CS.getCalledFunction())
183 Min = getModRefBehavior(F);
184
Dan Gohmanabaf2d82010-10-25 16:29:52 +0000185 // If this is the end of the chain, don't forward.
Dan Gohman5f1702e2010-08-06 01:25:49 +0000186 if (!AA) return Min;
187
188 // Otherwise, fall back to the next AA in the chain. But we can merge
189 // in any result we've managed to compute.
Dan Gohman2694e142010-11-10 01:02:18 +0000190 return ModRefBehavior(AA->getModRefBehavior(CS) & Min);
Dan Gohman5f1702e2010-08-06 01:25:49 +0000191}
192
193AliasAnalysis::ModRefBehavior
194AliasAnalysis::getModRefBehavior(const Function *F) {
Chris Lattner62c37002004-05-23 21:15:48 +0000195 assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
Dan Gohman5f1702e2010-08-06 01:25:49 +0000196 return AA->getModRefBehavior(F);
Chris Lattner62c37002004-05-23 21:15:48 +0000197}
198
Chris Lattner62c37002004-05-23 21:15:48 +0000199//===----------------------------------------------------------------------===//
200// AliasAnalysis non-virtual helper method implementation
201//===----------------------------------------------------------------------===//
202
Dan Gohman65316d62010-11-11 21:50:19 +0000203AliasAnalysis::Location AliasAnalysis::getLocation(const LoadInst *LI) {
204 return Location(LI->getPointerOperand(),
205 getTypeStoreSize(LI->getType()),
206 LI->getMetadata(LLVMContext::MD_tbaa));
207}
208
209AliasAnalysis::Location AliasAnalysis::getLocation(const StoreInst *SI) {
210 return Location(SI->getPointerOperand(),
211 getTypeStoreSize(SI->getValueOperand()->getType()),
212 SI->getMetadata(LLVMContext::MD_tbaa));
213}
214
215AliasAnalysis::Location AliasAnalysis::getLocation(const VAArgInst *VI) {
216 return Location(VI->getPointerOperand(),
217 UnknownSize,
218 VI->getMetadata(LLVMContext::MD_tbaa));
219}
220
Chris Lattner663ba912010-11-21 07:51:27 +0000221
222AliasAnalysis::Location
223AliasAnalysis::getLocationForSource(const MemTransferInst *MTI) {
224 uint64_t Size = UnknownSize;
225 if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
226 Size = C->getValue().getZExtValue();
227
Dan Gohmane1a17a32010-12-16 02:51:19 +0000228 // memcpy/memmove can have TBAA tags. For memcpy, they apply
229 // to both the source and the destination.
230 MDNode *TBAATag = MTI->getMetadata(LLVMContext::MD_tbaa);
231
232 return Location(MTI->getRawSource(), Size, TBAATag);
Chris Lattner663ba912010-11-21 07:51:27 +0000233}
234
235AliasAnalysis::Location
Chris Lattnerafbc0c22010-11-30 01:48:20 +0000236AliasAnalysis::getLocationForDest(const MemIntrinsic *MTI) {
Chris Lattner663ba912010-11-21 07:51:27 +0000237 uint64_t Size = UnknownSize;
238 if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
239 Size = C->getValue().getZExtValue();
Dan Gohmane1a17a32010-12-16 02:51:19 +0000240
241 // memcpy/memmove can have TBAA tags. For memcpy, they apply
242 // to both the source and the destination.
243 MDNode *TBAATag = MTI->getMetadata(LLVMContext::MD_tbaa);
Chris Lattner663ba912010-11-21 07:51:27 +0000244
Dan Gohmane1a17a32010-12-16 02:51:19 +0000245 return Location(MTI->getRawDest(), Size, TBAATag);
Chris Lattner663ba912010-11-21 07:51:27 +0000246}
247
248
249
Chris Lattner3a311832003-02-26 19:26:51 +0000250AliasAnalysis::ModRefResult
Dan Gohman41f14cf2010-09-14 21:25:10 +0000251AliasAnalysis::getModRefInfo(const LoadInst *L, const Location &Loc) {
Dan Gohman6b4671b2010-08-06 18:11:28 +0000252 // Be conservative in the face of volatile.
253 if (L->isVolatile())
254 return ModRef;
255
Dan Gohman52f9d7d2010-08-03 17:27:43 +0000256 // If the load address doesn't alias the given address, it doesn't read
257 // or write the specified memory.
Dan Gohman65316d62010-11-11 21:50:19 +0000258 if (!alias(getLocation(L), Loc))
Dan Gohman52f9d7d2010-08-03 17:27:43 +0000259 return NoModRef;
260
Dan Gohman52f9d7d2010-08-03 17:27:43 +0000261 // Otherwise, a load just reads.
262 return Ref;
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000263}
264
Chris Lattner3a311832003-02-26 19:26:51 +0000265AliasAnalysis::ModRefResult
Dan Gohman41f14cf2010-09-14 21:25:10 +0000266AliasAnalysis::getModRefInfo(const StoreInst *S, const Location &Loc) {
Dan Gohman6b4671b2010-08-06 18:11:28 +0000267 // Be conservative in the face of volatile.
268 if (S->isVolatile())
269 return ModRef;
270
Dan Gohman23976df2010-08-06 18:10:45 +0000271 // If the store address cannot alias the pointer in question, then the
272 // specified memory cannot be modified by the store.
Dan Gohman65316d62010-11-11 21:50:19 +0000273 if (!alias(getLocation(S), Loc))
Chris Lattner96055762004-01-30 22:16:42 +0000274 return NoModRef;
275
276 // If the pointer is a pointer to constant memory, then it could not have been
277 // modified by this store.
Dan Gohman41f14cf2010-09-14 21:25:10 +0000278 if (pointsToConstantMemory(Loc))
Dan Gohman52f9d7d2010-08-03 17:27:43 +0000279 return NoModRef;
280
281 // Otherwise, a store just writes.
282 return Mod;
Chris Lattner3a311832003-02-26 19:26:51 +0000283}
284
Dan Gohmane68958f2010-08-06 18:24:38 +0000285AliasAnalysis::ModRefResult
Dan Gohman41f14cf2010-09-14 21:25:10 +0000286AliasAnalysis::getModRefInfo(const VAArgInst *V, const Location &Loc) {
Dan Gohmane68958f2010-08-06 18:24:38 +0000287 // If the va_arg address cannot alias the pointer in question, then the
288 // specified memory cannot be accessed by the va_arg.
Dan Gohman65316d62010-11-11 21:50:19 +0000289 if (!alias(getLocation(V), Loc))
Dan Gohmane68958f2010-08-06 18:24:38 +0000290 return NoModRef;
291
292 // If the pointer is a pointer to constant memory, then it could not have been
293 // modified by this va_arg.
Dan Gohman41f14cf2010-09-14 21:25:10 +0000294 if (pointsToConstantMemory(Loc))
Dan Gohmane68958f2010-08-06 18:24:38 +0000295 return NoModRef;
296
297 // Otherwise, a va_arg reads and writes.
298 return ModRef;
299}
300
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000301// AliasAnalysis destructor: DO NOT move this to the header file for
302// AliasAnalysis or else clients of the AliasAnalysis class may not depend on
303// the AliasAnalysis.o file in the current .a file, causing alias analysis
304// support to not be included in the tool correctly!
305//
306AliasAnalysis::~AliasAnalysis() {}
307
Dan Gohman7a68b662008-05-30 00:02:02 +0000308/// InitializeAliasAnalysis - Subclasses must call this method to initialize the
Chris Lattner3a311832003-02-26 19:26:51 +0000309/// AliasAnalysis interface before any other methods are called.
310///
311void AliasAnalysis::InitializeAliasAnalysis(Pass *P) {
Dan Gohman43d19d62009-07-25 00:48:42 +0000312 TD = P->getAnalysisIfAvailable<TargetData>();
Chris Lattner62c37002004-05-23 21:15:48 +0000313 AA = &P->getAnalysis<AliasAnalysis>();
Chris Lattner3a311832003-02-26 19:26:51 +0000314}
315
316// getAnalysisUsage - All alias analysis implementations should invoke this
Dan Gohman43d19d62009-07-25 00:48:42 +0000317// directly (using AliasAnalysis::getAnalysisUsage(AU)).
Chris Lattner3a311832003-02-26 19:26:51 +0000318void AliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
Chris Lattner62c37002004-05-23 21:15:48 +0000319 AU.addRequired<AliasAnalysis>(); // All AA's chain
Chris Lattner3a311832003-02-26 19:26:51 +0000320}
321
Dan Gohman43d19d62009-07-25 00:48:42 +0000322/// getTypeStoreSize - Return the TargetData store size for the given type,
323/// if known, or a conservative value otherwise.
324///
Dan Gohmanf372cf82010-10-19 22:54:46 +0000325uint64_t AliasAnalysis::getTypeStoreSize(const Type *Ty) {
Dan Gohman14fe8cf22010-10-19 17:06:23 +0000326 return TD ? TD->getTypeStoreSize(Ty) : UnknownSize;
Dan Gohman43d19d62009-07-25 00:48:42 +0000327}
328
Chris Lattnerd922a842002-08-22 22:46:39 +0000329/// canBasicBlockModify - Return true if it is possible for execution of the
330/// specified basic block to modify the value pointed to by Ptr.
331///
Chris Lattner3a311832003-02-26 19:26:51 +0000332bool AliasAnalysis::canBasicBlockModify(const BasicBlock &BB,
Dan Gohman41f14cf2010-09-14 21:25:10 +0000333 const Location &Loc) {
334 return canInstructionRangeModify(BB.front(), BB.back(), Loc);
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000335}
336
Chris Lattnerd922a842002-08-22 22:46:39 +0000337/// canInstructionRangeModify - Return true if it is possible for the execution
338/// of the specified instructions to modify the value pointed to by Ptr. The
339/// instructions to consider are all of the instructions in the range of [I1,I2]
340/// INCLUSIVE. I1 and I2 must be in the same basic block.
341///
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000342bool AliasAnalysis::canInstructionRangeModify(const Instruction &I1,
343 const Instruction &I2,
Dan Gohman41f14cf2010-09-14 21:25:10 +0000344 const Location &Loc) {
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000345 assert(I1.getParent() == I2.getParent() &&
346 "Instructions not in same basic block!");
Dan Gohman5442c712010-08-03 21:48:53 +0000347 BasicBlock::const_iterator I = &I1;
348 BasicBlock::const_iterator E = &I2;
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000349 ++E; // Convert from inclusive to exclusive range.
350
Chris Lattner3a311832003-02-26 19:26:51 +0000351 for (; I != E; ++I) // Check every instruction in range
Dan Gohman41f14cf2010-09-14 21:25:10 +0000352 if (getModRefInfo(I, Loc) & Mod)
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000353 return true;
Chris Lattner7d58f8d2002-08-22 18:25:32 +0000354 return false;
355}
356
Dan Gohmanfb306c02009-02-03 01:28:32 +0000357/// isNoAliasCall - Return true if this pointer is returned by a noalias
358/// function.
359bool llvm::isNoAliasCall(const Value *V) {
360 if (isa<CallInst>(V) || isa<InvokeInst>(V))
Dan Gohman5442c712010-08-03 21:48:53 +0000361 return ImmutableCallSite(cast<Instruction>(V))
Dan Gohmanfb306c02009-02-03 01:28:32 +0000362 .paramHasAttr(0, Attribute::NoAlias);
363 return false;
364}
365
366/// isIdentifiedObject - Return true if this pointer refers to a distinct and
367/// identifiable object. This returns true for:
Dan Gohman1f59f012009-08-27 17:52:56 +0000368/// Global Variables and Functions (but not Global Aliases)
Dan Gohmanfb306c02009-02-03 01:28:32 +0000369/// Allocas and Mallocs
Dan Gohman00ef9322010-07-07 14:27:09 +0000370/// ByVal and NoAlias Arguments
371/// NoAlias returns
Dan Gohmanfb306c02009-02-03 01:28:32 +0000372///
Dan Gohman00ef9322010-07-07 14:27:09 +0000373bool llvm::isIdentifiedObject(const Value *V) {
Dan Gohman0824aff2010-06-29 00:50:39 +0000374 if (isa<AllocaInst>(V))
Dan Gohman1f59f012009-08-27 17:52:56 +0000375 return true;
376 if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
Dan Gohmanfb306c02009-02-03 01:28:32 +0000377 return true;
Dan Gohman00ef9322010-07-07 14:27:09 +0000378 if (isNoAliasCall(V))
379 return true;
380 if (const Argument *A = dyn_cast<Argument>(V))
381 return A->hasNoAliasAttr() || A->hasByValAttr();
Dan Gohmanfb306c02009-02-03 01:28:32 +0000382 return false;
383}