Move isIdentifiedFunctionLocal from BasicAA to AA
[oota-llvm.git] / lib / Analysis / AliasAnalysis.cpp
1 //===- AliasAnalysis.cpp - Generic Alias Analysis Interface Implementation -==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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
27 #include "llvm/Analysis/AliasAnalysis.h"
28 #include "llvm/Analysis/CFG.h"
29 #include "llvm/Analysis/CaptureTracking.h"
30 #include "llvm/Analysis/ValueTracking.h"
31 #include "llvm/IR/BasicBlock.h"
32 #include "llvm/IR/DataLayout.h"
33 #include "llvm/IR/Dominators.h"
34 #include "llvm/IR/Function.h"
35 #include "llvm/IR/Instructions.h"
36 #include "llvm/IR/IntrinsicInst.h"
37 #include "llvm/IR/LLVMContext.h"
38 #include "llvm/IR/Type.h"
39 #include "llvm/Pass.h"
40 #include "llvm/Target/TargetLibraryInfo.h"
41 using namespace llvm;
42
43 // Register the AliasAnalysis interface, providing a nice name to refer to.
44 INITIALIZE_ANALYSIS_GROUP(AliasAnalysis, "Alias Analysis", NoAA)
45 char AliasAnalysis::ID = 0;
46
47 //===----------------------------------------------------------------------===//
48 // Default chaining methods
49 //===----------------------------------------------------------------------===//
50
51 AliasAnalysis::AliasResult
52 AliasAnalysis::alias(const Location &LocA, const Location &LocB) {
53   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
54   return AA->alias(LocA, LocB);
55 }
56
57 bool AliasAnalysis::pointsToConstantMemory(const Location &Loc,
58                                            bool OrLocal) {
59   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
60   return AA->pointsToConstantMemory(Loc, OrLocal);
61 }
62
63 AliasAnalysis::Location
64 AliasAnalysis::getArgLocation(ImmutableCallSite CS, unsigned ArgIdx,
65                               AliasAnalysis::ModRefResult &Mask) {
66   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
67   return AA->getArgLocation(CS, ArgIdx, Mask);
68 }
69
70 void AliasAnalysis::deleteValue(Value *V) {
71   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
72   AA->deleteValue(V);
73 }
74
75 void AliasAnalysis::copyValue(Value *From, Value *To) {
76   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
77   AA->copyValue(From, To);
78 }
79
80 void AliasAnalysis::addEscapingUse(Use &U) {
81   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
82   AA->addEscapingUse(U);
83 }
84
85
86 AliasAnalysis::ModRefResult
87 AliasAnalysis::getModRefInfo(ImmutableCallSite CS,
88                              const Location &Loc) {
89   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
90
91   ModRefBehavior MRB = getModRefBehavior(CS);
92   if (MRB == DoesNotAccessMemory)
93     return NoModRef;
94
95   ModRefResult Mask = ModRef;
96   if (onlyReadsMemory(MRB))
97     Mask = Ref;
98
99   if (onlyAccessesArgPointees(MRB)) {
100     bool doesAlias = false;
101     ModRefResult AllArgsMask = NoModRef;
102     if (doesAccessArgPointees(MRB)) {
103       for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
104            AI != AE; ++AI) {
105         const Value *Arg = *AI;
106         if (!Arg->getType()->isPointerTy())
107           continue;
108         ModRefResult ArgMask;
109         Location CSLoc =
110           getArgLocation(CS, (unsigned) std::distance(CS.arg_begin(), AI),
111                          ArgMask);
112         if (!isNoAlias(CSLoc, Loc)) {
113           doesAlias = true;
114           AllArgsMask = ModRefResult(AllArgsMask | ArgMask);
115         }
116       }
117     }
118     if (!doesAlias)
119       return NoModRef;
120     Mask = ModRefResult(Mask & AllArgsMask);
121   }
122
123   // If Loc is a constant memory location, the call definitely could not
124   // modify the memory location.
125   if ((Mask & Mod) && pointsToConstantMemory(Loc))
126     Mask = ModRefResult(Mask & ~Mod);
127
128   // If this is the end of the chain, don't forward.
129   if (!AA) return Mask;
130
131   // Otherwise, fall back to the next AA in the chain. But we can merge
132   // in any mask we've managed to compute.
133   return ModRefResult(AA->getModRefInfo(CS, Loc) & Mask);
134 }
135
136 AliasAnalysis::ModRefResult
137 AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
138   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
139
140   // If CS1 or CS2 are readnone, they don't interact.
141   ModRefBehavior CS1B = getModRefBehavior(CS1);
142   if (CS1B == DoesNotAccessMemory) return NoModRef;
143
144   ModRefBehavior CS2B = getModRefBehavior(CS2);
145   if (CS2B == DoesNotAccessMemory) return NoModRef;
146
147   // If they both only read from memory, there is no dependence.
148   if (onlyReadsMemory(CS1B) && onlyReadsMemory(CS2B))
149     return NoModRef;
150
151   AliasAnalysis::ModRefResult Mask = ModRef;
152
153   // If CS1 only reads memory, the only dependence on CS2 can be
154   // from CS1 reading memory written by CS2.
155   if (onlyReadsMemory(CS1B))
156     Mask = ModRefResult(Mask & Ref);
157
158   // If CS2 only access memory through arguments, accumulate the mod/ref
159   // information from CS1's references to the memory referenced by
160   // CS2's arguments.
161   if (onlyAccessesArgPointees(CS2B)) {
162     AliasAnalysis::ModRefResult R = NoModRef;
163     if (doesAccessArgPointees(CS2B)) {
164       for (ImmutableCallSite::arg_iterator
165            I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
166         const Value *Arg = *I;
167         if (!Arg->getType()->isPointerTy())
168           continue;
169         ModRefResult ArgMask;
170         Location CS2Loc =
171           getArgLocation(CS2, (unsigned) std::distance(CS2.arg_begin(), I),
172                          ArgMask);
173         // ArgMask indicates what CS2 might do to CS2Loc, and the dependence of
174         // CS1 on that location is the inverse.
175         if (ArgMask == Mod)
176           ArgMask = ModRef;
177         else if (ArgMask == Ref)
178           ArgMask = Mod;
179
180         R = ModRefResult((R | (getModRefInfo(CS1, CS2Loc) & ArgMask)) & Mask);
181         if (R == Mask)
182           break;
183       }
184     }
185     return R;
186   }
187
188   // If CS1 only accesses memory through arguments, check if CS2 references
189   // any of the memory referenced by CS1's arguments. If not, return NoModRef.
190   if (onlyAccessesArgPointees(CS1B)) {
191     AliasAnalysis::ModRefResult R = NoModRef;
192     if (doesAccessArgPointees(CS1B)) {
193       for (ImmutableCallSite::arg_iterator
194            I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I) {
195         const Value *Arg = *I;
196         if (!Arg->getType()->isPointerTy())
197           continue;
198         ModRefResult ArgMask;
199         Location CS1Loc =
200           getArgLocation(CS1, (unsigned) std::distance(CS1.arg_begin(), I),
201                          ArgMask);
202         // ArgMask indicates what CS1 might do to CS1Loc; if CS1 might Mod
203         // CS1Loc, then we care about either a Mod or a Ref by CS2. If CS1
204         // might Ref, then we care only about a Mod by CS2.
205         ModRefResult ArgR = getModRefInfo(CS2, CS1Loc);
206         if (((ArgMask & Mod) != NoModRef && (ArgR & ModRef) != NoModRef) ||
207             ((ArgMask & Ref) != NoModRef && (ArgR & Mod)    != NoModRef))
208           R = ModRefResult((R | ArgMask) & Mask);
209
210         if (R == Mask)
211           break;
212       }
213     }
214     return R;
215   }
216
217   // If this is the end of the chain, don't forward.
218   if (!AA) return Mask;
219
220   // Otherwise, fall back to the next AA in the chain. But we can merge
221   // in any mask we've managed to compute.
222   return ModRefResult(AA->getModRefInfo(CS1, CS2) & Mask);
223 }
224
225 AliasAnalysis::ModRefBehavior
226 AliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
227   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
228
229   ModRefBehavior Min = UnknownModRefBehavior;
230
231   // Call back into the alias analysis with the other form of getModRefBehavior
232   // to see if it can give a better response.
233   if (const Function *F = CS.getCalledFunction())
234     Min = getModRefBehavior(F);
235
236   // If this is the end of the chain, don't forward.
237   if (!AA) return Min;
238
239   // Otherwise, fall back to the next AA in the chain. But we can merge
240   // in any result we've managed to compute.
241   return ModRefBehavior(AA->getModRefBehavior(CS) & Min);
242 }
243
244 AliasAnalysis::ModRefBehavior
245 AliasAnalysis::getModRefBehavior(const Function *F) {
246   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
247   return AA->getModRefBehavior(F);
248 }
249
250 //===----------------------------------------------------------------------===//
251 // AliasAnalysis non-virtual helper method implementation
252 //===----------------------------------------------------------------------===//
253
254 AliasAnalysis::Location AliasAnalysis::getLocation(const LoadInst *LI) {
255   return Location(LI->getPointerOperand(),
256                   getTypeStoreSize(LI->getType()),
257                   LI->getMetadata(LLVMContext::MD_tbaa));
258 }
259
260 AliasAnalysis::Location AliasAnalysis::getLocation(const StoreInst *SI) {
261   return Location(SI->getPointerOperand(),
262                   getTypeStoreSize(SI->getValueOperand()->getType()),
263                   SI->getMetadata(LLVMContext::MD_tbaa));
264 }
265
266 AliasAnalysis::Location AliasAnalysis::getLocation(const VAArgInst *VI) {
267   return Location(VI->getPointerOperand(),
268                   UnknownSize,
269                   VI->getMetadata(LLVMContext::MD_tbaa));
270 }
271
272 AliasAnalysis::Location
273 AliasAnalysis::getLocation(const AtomicCmpXchgInst *CXI) {
274   return Location(CXI->getPointerOperand(),
275                   getTypeStoreSize(CXI->getCompareOperand()->getType()),
276                   CXI->getMetadata(LLVMContext::MD_tbaa));
277 }
278
279 AliasAnalysis::Location
280 AliasAnalysis::getLocation(const AtomicRMWInst *RMWI) {
281   return Location(RMWI->getPointerOperand(),
282                   getTypeStoreSize(RMWI->getValOperand()->getType()),
283                   RMWI->getMetadata(LLVMContext::MD_tbaa));
284 }
285
286 AliasAnalysis::Location 
287 AliasAnalysis::getLocationForSource(const MemTransferInst *MTI) {
288   uint64_t Size = UnknownSize;
289   if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
290     Size = C->getValue().getZExtValue();
291
292   // memcpy/memmove can have TBAA tags. For memcpy, they apply
293   // to both the source and the destination.
294   MDNode *TBAATag = MTI->getMetadata(LLVMContext::MD_tbaa);
295
296   return Location(MTI->getRawSource(), Size, TBAATag);
297 }
298
299 AliasAnalysis::Location 
300 AliasAnalysis::getLocationForDest(const MemIntrinsic *MTI) {
301   uint64_t Size = UnknownSize;
302   if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
303     Size = C->getValue().getZExtValue();
304
305   // memcpy/memmove can have TBAA tags. For memcpy, they apply
306   // to both the source and the destination.
307   MDNode *TBAATag = MTI->getMetadata(LLVMContext::MD_tbaa);
308   
309   return Location(MTI->getRawDest(), Size, TBAATag);
310 }
311
312
313
314 AliasAnalysis::ModRefResult
315 AliasAnalysis::getModRefInfo(const LoadInst *L, const Location &Loc) {
316   // Be conservative in the face of volatile/atomic.
317   if (!L->isUnordered())
318     return ModRef;
319
320   // If the load address doesn't alias the given address, it doesn't read
321   // or write the specified memory.
322   if (!alias(getLocation(L), Loc))
323     return NoModRef;
324
325   // Otherwise, a load just reads.
326   return Ref;
327 }
328
329 AliasAnalysis::ModRefResult
330 AliasAnalysis::getModRefInfo(const StoreInst *S, const Location &Loc) {
331   // Be conservative in the face of volatile/atomic.
332   if (!S->isUnordered())
333     return ModRef;
334
335   // If the store address cannot alias the pointer in question, then the
336   // specified memory cannot be modified by the store.
337   if (!alias(getLocation(S), Loc))
338     return NoModRef;
339
340   // If the pointer is a pointer to constant memory, then it could not have been
341   // modified by this store.
342   if (pointsToConstantMemory(Loc))
343     return NoModRef;
344
345   // Otherwise, a store just writes.
346   return Mod;
347 }
348
349 AliasAnalysis::ModRefResult
350 AliasAnalysis::getModRefInfo(const VAArgInst *V, const Location &Loc) {
351   // If the va_arg address cannot alias the pointer in question, then the
352   // specified memory cannot be accessed by the va_arg.
353   if (!alias(getLocation(V), Loc))
354     return NoModRef;
355
356   // If the pointer is a pointer to constant memory, then it could not have been
357   // modified by this va_arg.
358   if (pointsToConstantMemory(Loc))
359     return NoModRef;
360
361   // Otherwise, a va_arg reads and writes.
362   return ModRef;
363 }
364
365 AliasAnalysis::ModRefResult
366 AliasAnalysis::getModRefInfo(const AtomicCmpXchgInst *CX, const Location &Loc) {
367   // Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
368   if (CX->getSuccessOrdering() > Monotonic)
369     return ModRef;
370
371   // If the cmpxchg address does not alias the location, it does not access it.
372   if (!alias(getLocation(CX), Loc))
373     return NoModRef;
374
375   return ModRef;
376 }
377
378 AliasAnalysis::ModRefResult
379 AliasAnalysis::getModRefInfo(const AtomicRMWInst *RMW, const Location &Loc) {
380   // Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
381   if (RMW->getOrdering() > Monotonic)
382     return ModRef;
383
384   // If the atomicrmw address does not alias the location, it does not access it.
385   if (!alias(getLocation(RMW), Loc))
386     return NoModRef;
387
388   return ModRef;
389 }
390
391 namespace {
392   /// Only find pointer captures which happen before the given instruction. Uses
393   /// the dominator tree to determine whether one instruction is before another.
394   /// Only support the case where the Value is defined in the same basic block
395   /// as the given instruction and the use.
396   struct CapturesBefore : public CaptureTracker {
397     CapturesBefore(const Instruction *I, DominatorTree *DT)
398       : BeforeHere(I), DT(DT), Captured(false) {}
399
400     void tooManyUses() override { Captured = true; }
401
402     bool shouldExplore(const Use *U) override {
403       Instruction *I = cast<Instruction>(U->getUser());
404       BasicBlock *BB = I->getParent();
405       // We explore this usage only if the usage can reach "BeforeHere".
406       // If use is not reachable from entry, there is no need to explore.
407       if (BeforeHere != I && !DT->isReachableFromEntry(BB))
408         return false;
409       // If the value is defined in the same basic block as use and BeforeHere,
410       // there is no need to explore the use if BeforeHere dominates use.
411       // Check whether there is a path from I to BeforeHere.
412       if (BeforeHere != I && DT->dominates(BeforeHere, I) &&
413           !isPotentiallyReachable(I, BeforeHere, DT))
414         return false;
415       return true;
416     }
417
418     bool captured(const Use *U) override {
419       Instruction *I = cast<Instruction>(U->getUser());
420       BasicBlock *BB = I->getParent();
421       // Same logic as in shouldExplore.
422       if (BeforeHere != I && !DT->isReachableFromEntry(BB))
423         return false;
424       if (BeforeHere != I && DT->dominates(BeforeHere, I) &&
425           !isPotentiallyReachable(I, BeforeHere, DT))
426         return false;
427       Captured = true;
428       return true;
429     }
430
431     const Instruction *BeforeHere;
432     DominatorTree *DT;
433
434     bool Captured;
435   };
436 }
437
438 // FIXME: this is really just shoring-up a deficiency in alias analysis.
439 // BasicAA isn't willing to spend linear time determining whether an alloca
440 // was captured before or after this particular call, while we are. However,
441 // with a smarter AA in place, this test is just wasting compile time.
442 AliasAnalysis::ModRefResult
443 AliasAnalysis::callCapturesBefore(const Instruction *I,
444                                   const AliasAnalysis::Location &MemLoc,
445                                   DominatorTree *DT) {
446   if (!DT || !DL) return AliasAnalysis::ModRef;
447
448   const Value *Object = GetUnderlyingObject(MemLoc.Ptr, DL);
449   if (!isIdentifiedObject(Object) || isa<GlobalValue>(Object) ||
450       isa<Constant>(Object))
451     return AliasAnalysis::ModRef;
452
453   ImmutableCallSite CS(I);
454   if (!CS.getInstruction() || CS.getInstruction() == Object)
455     return AliasAnalysis::ModRef;
456
457   CapturesBefore CB(I, DT);
458   llvm::PointerMayBeCaptured(Object, &CB);
459   if (CB.Captured)
460     return AliasAnalysis::ModRef;
461
462   unsigned ArgNo = 0;
463   AliasAnalysis::ModRefResult R = AliasAnalysis::NoModRef;
464   for (ImmutableCallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
465        CI != CE; ++CI, ++ArgNo) {
466     // Only look at the no-capture or byval pointer arguments.  If this
467     // pointer were passed to arguments that were neither of these, then it
468     // couldn't be no-capture.
469     if (!(*CI)->getType()->isPointerTy() ||
470         (!CS.doesNotCapture(ArgNo) && !CS.isByValArgument(ArgNo)))
471       continue;
472
473     // If this is a no-capture pointer argument, see if we can tell that it
474     // is impossible to alias the pointer we're checking.  If not, we have to
475     // assume that the call could touch the pointer, even though it doesn't
476     // escape.
477     if (isNoAlias(AliasAnalysis::Location(*CI),
478                   AliasAnalysis::Location(Object)))
479       continue;
480     if (CS.doesNotAccessMemory(ArgNo))
481       continue;
482     if (CS.onlyReadsMemory(ArgNo)) {
483       R = AliasAnalysis::Ref;
484       continue;
485     }
486     return AliasAnalysis::ModRef;
487   }
488   return R;
489 }
490
491 // AliasAnalysis destructor: DO NOT move this to the header file for
492 // AliasAnalysis or else clients of the AliasAnalysis class may not depend on
493 // the AliasAnalysis.o file in the current .a file, causing alias analysis
494 // support to not be included in the tool correctly!
495 //
496 AliasAnalysis::~AliasAnalysis() {}
497
498 /// InitializeAliasAnalysis - Subclasses must call this method to initialize the
499 /// AliasAnalysis interface before any other methods are called.
500 ///
501 void AliasAnalysis::InitializeAliasAnalysis(Pass *P) {
502   DataLayoutPass *DLP = P->getAnalysisIfAvailable<DataLayoutPass>();
503   DL = DLP ? &DLP->getDataLayout() : nullptr;
504   TLI = P->getAnalysisIfAvailable<TargetLibraryInfo>();
505   AA = &P->getAnalysis<AliasAnalysis>();
506 }
507
508 // getAnalysisUsage - All alias analysis implementations should invoke this
509 // directly (using AliasAnalysis::getAnalysisUsage(AU)).
510 void AliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
511   AU.addRequired<AliasAnalysis>();         // All AA's chain
512 }
513
514 /// getTypeStoreSize - Return the DataLayout store size for the given type,
515 /// if known, or a conservative value otherwise.
516 ///
517 uint64_t AliasAnalysis::getTypeStoreSize(Type *Ty) {
518   return DL ? DL->getTypeStoreSize(Ty) : UnknownSize;
519 }
520
521 /// canBasicBlockModify - Return true if it is possible for execution of the
522 /// specified basic block to modify the value pointed to by Ptr.
523 ///
524 bool AliasAnalysis::canBasicBlockModify(const BasicBlock &BB,
525                                         const Location &Loc) {
526   return canInstructionRangeModify(BB.front(), BB.back(), Loc);
527 }
528
529 /// canInstructionRangeModify - Return true if it is possible for the execution
530 /// of the specified instructions to modify the value pointed to by Ptr.  The
531 /// instructions to consider are all of the instructions in the range of [I1,I2]
532 /// INCLUSIVE.  I1 and I2 must be in the same basic block.
533 ///
534 bool AliasAnalysis::canInstructionRangeModify(const Instruction &I1,
535                                               const Instruction &I2,
536                                               const Location &Loc) {
537   assert(I1.getParent() == I2.getParent() &&
538          "Instructions not in same basic block!");
539   BasicBlock::const_iterator I = &I1;
540   BasicBlock::const_iterator E = &I2;
541   ++E;  // Convert from inclusive to exclusive range.
542
543   for (; I != E; ++I) // Check every instruction in range
544     if (getModRefInfo(I, Loc) & Mod)
545       return true;
546   return false;
547 }
548
549 /// isNoAliasCall - Return true if this pointer is returned by a noalias
550 /// function.
551 bool llvm::isNoAliasCall(const Value *V) {
552   if (isa<CallInst>(V) || isa<InvokeInst>(V))
553     return ImmutableCallSite(cast<Instruction>(V))
554       .paramHasAttr(0, Attribute::NoAlias);
555   return false;
556 }
557
558 /// isNoAliasArgument - Return true if this is an argument with the noalias
559 /// attribute.
560 bool llvm::isNoAliasArgument(const Value *V)
561 {
562   if (const Argument *A = dyn_cast<Argument>(V))
563     return A->hasNoAliasAttr();
564   return false;
565 }
566
567 /// isIdentifiedObject - Return true if this pointer refers to a distinct and
568 /// identifiable object.  This returns true for:
569 ///    Global Variables and Functions (but not Global Aliases)
570 ///    Allocas and Mallocs
571 ///    ByVal and NoAlias Arguments
572 ///    NoAlias returns
573 ///
574 bool llvm::isIdentifiedObject(const Value *V) {
575   if (isa<AllocaInst>(V))
576     return true;
577   if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
578     return true;
579   if (isNoAliasCall(V))
580     return true;
581   if (const Argument *A = dyn_cast<Argument>(V))
582     return A->hasNoAliasAttr() || A->hasByValAttr();
583   return false;
584 }
585
586 /// isIdentifiedFunctionLocal - Return true if V is umabigously identified
587 /// at the function-level. Different IdentifiedFunctionLocals can't alias.
588 /// Further, an IdentifiedFunctionLocal can not alias with any function
589 /// arguments other than itself, which is not necessarily true for
590 /// IdentifiedObjects.
591 bool llvm::isIdentifiedFunctionLocal(const Value *V)
592 {
593   return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasArgument(V);
594 }
595