Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 1 | //===- AliasAnalysis.cpp - Generic Alias Analysis Interface Implementation -==// |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 2 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 2b37d7c | 2005-04-21 21:13:18 +0000 | [diff] [blame] | 7 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 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 | |
Chris Lattner | d501c13 | 2003-02-26 19:41:54 +0000 | [diff] [blame] | 27 | #include "llvm/Analysis/AliasAnalysis.h" |
Reid Spencer | 6df60a9 | 2006-06-07 20:00:19 +0000 | [diff] [blame] | 28 | #include "llvm/Pass.h" |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 29 | #include "llvm/BasicBlock.h" |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 30 | #include "llvm/Function.h" |
Owen Anderson | cd89525 | 2009-02-03 06:27:22 +0000 | [diff] [blame] | 31 | #include "llvm/IntrinsicInst.h" |
Misha Brukman | 47b14a4 | 2004-07-29 17:30:56 +0000 | [diff] [blame] | 32 | #include "llvm/Instructions.h" |
Chris Lattner | 5b3a455 | 2005-03-17 15:38:16 +0000 | [diff] [blame] | 33 | #include "llvm/Type.h" |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 34 | #include "llvm/Target/TargetData.h" |
Chris Lattner | 992860c | 2004-03-15 04:07:29 +0000 | [diff] [blame] | 35 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 36 | |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 37 | // Register the AliasAnalysis interface, providing a nice name to refer to. |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 38 | static RegisterAnalysisGroup<AliasAnalysis> Z("Alias Analysis"); |
Devang Patel | 1997473 | 2007-05-03 01:11:54 +0000 | [diff] [blame] | 39 | char AliasAnalysis::ID = 0; |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 40 | |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 41 | //===----------------------------------------------------------------------===// |
| 42 | // Default chaining methods |
| 43 | //===----------------------------------------------------------------------===// |
| 44 | |
| 45 | AliasAnalysis::AliasResult |
| 46 | AliasAnalysis::alias(const Value *V1, unsigned V1Size, |
| 47 | const Value *V2, unsigned V2Size) { |
| 48 | assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); |
| 49 | return AA->alias(V1, V1Size, V2, V2Size); |
| 50 | } |
| 51 | |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 52 | bool AliasAnalysis::pointsToConstantMemory(const Value *P) { |
| 53 | assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); |
| 54 | return AA->pointsToConstantMemory(P); |
| 55 | } |
| 56 | |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 57 | void AliasAnalysis::deleteValue(Value *V) { |
| 58 | assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); |
| 59 | AA->deleteValue(V); |
| 60 | } |
| 61 | |
| 62 | void AliasAnalysis::copyValue(Value *From, Value *To) { |
| 63 | assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); |
| 64 | AA->copyValue(From, To); |
| 65 | } |
| 66 | |
| 67 | AliasAnalysis::ModRefResult |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 68 | AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) { |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 69 | // FIXME: we can do better. |
| 70 | assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!"); |
| 71 | return AA->getModRefInfo(CS1, CS2); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | //===----------------------------------------------------------------------===// |
| 76 | // AliasAnalysis non-virtual helper method implementation |
| 77 | //===----------------------------------------------------------------------===// |
| 78 | |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 79 | AliasAnalysis::ModRefResult |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 80 | AliasAnalysis::getModRefInfo(const LoadInst *L, const Value *P, unsigned Size) { |
Dan Gohman | 14a498a | 2010-08-03 17:27:43 +0000 | [diff] [blame] | 81 | // If the load address doesn't alias the given address, it doesn't read |
| 82 | // or write the specified memory. |
| 83 | if (!alias(L->getOperand(0), getTypeStoreSize(L->getType()), P, Size)) |
| 84 | return NoModRef; |
| 85 | |
| 86 | // Be conservative in the face of volatile. |
| 87 | if (L->isVolatile()) |
| 88 | return ModRef; |
| 89 | |
| 90 | // Otherwise, a load just reads. |
| 91 | return Ref; |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 94 | AliasAnalysis::ModRefResult |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 95 | AliasAnalysis::getModRefInfo(const StoreInst *S, const Value *P, unsigned Size) { |
Chris Lattner | f4d904d | 2004-01-30 22:16:42 +0000 | [diff] [blame] | 96 | // If the stored address cannot alias the pointer in question, then the |
| 97 | // pointer cannot be modified by the store. |
Duncan Sands | 514ab34 | 2007-11-01 20:53:16 +0000 | [diff] [blame] | 98 | if (!alias(S->getOperand(1), |
Dan Gohman | fc2a3ed | 2009-07-25 00:48:42 +0000 | [diff] [blame] | 99 | getTypeStoreSize(S->getOperand(0)->getType()), P, Size)) |
Chris Lattner | f4d904d | 2004-01-30 22:16:42 +0000 | [diff] [blame] | 100 | return NoModRef; |
| 101 | |
Dan Gohman | 14a498a | 2010-08-03 17:27:43 +0000 | [diff] [blame] | 102 | // Be conservative in the face of volatile. |
| 103 | if (S->isVolatile()) |
| 104 | return ModRef; |
| 105 | |
Chris Lattner | f4d904d | 2004-01-30 22:16:42 +0000 | [diff] [blame] | 106 | // If the pointer is a pointer to constant memory, then it could not have been |
| 107 | // modified by this store. |
Dan Gohman | 14a498a | 2010-08-03 17:27:43 +0000 | [diff] [blame] | 108 | if (pointsToConstantMemory(P)) |
| 109 | return NoModRef; |
| 110 | |
| 111 | // Otherwise, a store just writes. |
| 112 | return Mod; |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 115 | AliasAnalysis::ModRefBehavior |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 116 | AliasAnalysis::getModRefBehavior(ImmutableCallSite CS, |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 117 | std::vector<PointerAccessInfo> *Info) { |
Duncan Sands | 7915cbe | 2007-12-12 16:01:40 +0000 | [diff] [blame] | 118 | if (CS.doesNotAccessMemory()) |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 119 | // Can't do better than this. |
| 120 | return DoesNotAccessMemory; |
Owen Anderson | e794220 | 2009-02-05 23:36:27 +0000 | [diff] [blame] | 121 | ModRefBehavior MRB = getModRefBehavior(CS.getCalledFunction(), Info); |
Duncan Sands | 7915cbe | 2007-12-12 16:01:40 +0000 | [diff] [blame] | 122 | if (MRB != DoesNotAccessMemory && CS.onlyReadsMemory()) |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 123 | return OnlyReadsMemory; |
| 124 | return MRB; |
| 125 | } |
| 126 | |
| 127 | AliasAnalysis::ModRefBehavior |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 128 | AliasAnalysis::getModRefBehavior(const Function *F, |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 129 | std::vector<PointerAccessInfo> *Info) { |
Duncan Sands | ddd8c45 | 2009-02-13 17:32:26 +0000 | [diff] [blame] | 130 | if (F) { |
| 131 | if (F->doesNotAccessMemory()) |
| 132 | // Can't do better than this. |
| 133 | return DoesNotAccessMemory; |
Duncan Sands | d869b38 | 2009-02-14 10:56:35 +0000 | [diff] [blame] | 134 | if (F->onlyReadsMemory()) |
Duncan Sands | ddd8c45 | 2009-02-13 17:32:26 +0000 | [diff] [blame] | 135 | return OnlyReadsMemory; |
Duncan Sands | 7c422ac | 2010-01-06 08:45:52 +0000 | [diff] [blame] | 136 | if (unsigned id = F->getIntrinsicID()) |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 137 | return getIntrinsicModRefBehavior(id); |
Duncan Sands | 7c422ac | 2010-01-06 08:45:52 +0000 | [diff] [blame] | 138 | } |
| 139 | return UnknownModRefBehavior; |
| 140 | } |
| 141 | |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 142 | AliasAnalysis::ModRefBehavior |
| 143 | AliasAnalysis::getIntrinsicModRefBehavior(unsigned iid) { |
Duncan Sands | d869b38 | 2009-02-14 10:56:35 +0000 | [diff] [blame] | 144 | #define GET_INTRINSIC_MODREF_BEHAVIOR |
| 145 | #include "llvm/Intrinsics.gen" |
| 146 | #undef GET_INTRINSIC_MODREF_BEHAVIOR |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Chris Lattner | 992860c | 2004-03-15 04:07:29 +0000 | [diff] [blame] | 149 | AliasAnalysis::ModRefResult |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 150 | AliasAnalysis::getModRefInfo(ImmutableCallSite CS, |
| 151 | const Value *P, unsigned Size) { |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 152 | ModRefBehavior MRB = getModRefBehavior(CS); |
Duncan Sands | ddd8c45 | 2009-02-13 17:32:26 +0000 | [diff] [blame] | 153 | if (MRB == DoesNotAccessMemory) |
Duncan Sands | dff6710 | 2007-12-01 07:51:45 +0000 | [diff] [blame] | 154 | return NoModRef; |
Chris Lattner | 403ac2e | 2009-11-23 16:46:41 +0000 | [diff] [blame] | 155 | |
| 156 | ModRefResult Mask = ModRef; |
| 157 | if (MRB == OnlyReadsMemory) |
Duncan Sands | ddd8c45 | 2009-02-13 17:32:26 +0000 | [diff] [blame] | 158 | Mask = Ref; |
Owen Anderson | e794220 | 2009-02-05 23:36:27 +0000 | [diff] [blame] | 159 | else if (MRB == AliasAnalysis::AccessesArguments) { |
| 160 | bool doesAlias = false; |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 161 | for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); |
Owen Anderson | e794220 | 2009-02-05 23:36:27 +0000 | [diff] [blame] | 162 | AI != AE; ++AI) |
Chris Lattner | 403ac2e | 2009-11-23 16:46:41 +0000 | [diff] [blame] | 163 | if (!isNoAlias(*AI, ~0U, P, Size)) { |
Owen Anderson | e794220 | 2009-02-05 23:36:27 +0000 | [diff] [blame] | 164 | doesAlias = true; |
| 165 | break; |
| 166 | } |
Duncan Sands | ddd8c45 | 2009-02-13 17:32:26 +0000 | [diff] [blame] | 167 | |
Owen Anderson | e794220 | 2009-02-05 23:36:27 +0000 | [diff] [blame] | 168 | if (!doesAlias) |
| 169 | return NoModRef; |
| 170 | } |
Chris Lattner | 992860c | 2004-03-15 04:07:29 +0000 | [diff] [blame] | 171 | |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 172 | if (!AA) return Mask; |
| 173 | |
Chris Lattner | 992860c | 2004-03-15 04:07:29 +0000 | [diff] [blame] | 174 | // If P points to a constant memory location, the call definitely could not |
| 175 | // modify the memory location. |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 176 | if ((Mask & Mod) && AA->pointsToConstantMemory(P)) |
Chris Lattner | d433bde | 2005-03-23 22:06:41 +0000 | [diff] [blame] | 177 | Mask = ModRefResult(Mask & ~Mod); |
Chris Lattner | 992860c | 2004-03-15 04:07:29 +0000 | [diff] [blame] | 178 | |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 179 | return ModRefResult(Mask & AA->getModRefInfo(CS, P, Size)); |
Chris Lattner | 992860c | 2004-03-15 04:07:29 +0000 | [diff] [blame] | 180 | } |
| 181 | |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 182 | // AliasAnalysis destructor: DO NOT move this to the header file for |
| 183 | // AliasAnalysis or else clients of the AliasAnalysis class may not depend on |
| 184 | // the AliasAnalysis.o file in the current .a file, causing alias analysis |
| 185 | // support to not be included in the tool correctly! |
| 186 | // |
| 187 | AliasAnalysis::~AliasAnalysis() {} |
| 188 | |
Dan Gohman | 5a56bf6 | 2008-05-30 00:02:02 +0000 | [diff] [blame] | 189 | /// InitializeAliasAnalysis - Subclasses must call this method to initialize the |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 190 | /// AliasAnalysis interface before any other methods are called. |
| 191 | /// |
| 192 | void AliasAnalysis::InitializeAliasAnalysis(Pass *P) { |
Dan Gohman | fc2a3ed | 2009-07-25 00:48:42 +0000 | [diff] [blame] | 193 | TD = P->getAnalysisIfAvailable<TargetData>(); |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 194 | AA = &P->getAnalysis<AliasAnalysis>(); |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | // getAnalysisUsage - All alias analysis implementations should invoke this |
Dan Gohman | fc2a3ed | 2009-07-25 00:48:42 +0000 | [diff] [blame] | 198 | // directly (using AliasAnalysis::getAnalysisUsage(AU)). |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 199 | void AliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { |
Chris Lattner | 5a24d70 | 2004-05-23 21:15:48 +0000 | [diff] [blame] | 200 | AU.addRequired<AliasAnalysis>(); // All AA's chain |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Dan Gohman | fc2a3ed | 2009-07-25 00:48:42 +0000 | [diff] [blame] | 203 | /// getTypeStoreSize - Return the TargetData store size for the given type, |
| 204 | /// if known, or a conservative value otherwise. |
| 205 | /// |
| 206 | unsigned AliasAnalysis::getTypeStoreSize(const Type *Ty) { |
| 207 | return TD ? TD->getTypeStoreSize(Ty) : ~0u; |
| 208 | } |
| 209 | |
Chris Lattner | f9355f6 | 2002-08-22 22:46:39 +0000 | [diff] [blame] | 210 | /// canBasicBlockModify - Return true if it is possible for execution of the |
| 211 | /// specified basic block to modify the value pointed to by Ptr. |
| 212 | /// |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 213 | bool AliasAnalysis::canBasicBlockModify(const BasicBlock &BB, |
| 214 | const Value *Ptr, unsigned Size) { |
| 215 | return canInstructionRangeModify(BB.front(), BB.back(), Ptr, Size); |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 216 | } |
| 217 | |
Chris Lattner | f9355f6 | 2002-08-22 22:46:39 +0000 | [diff] [blame] | 218 | /// canInstructionRangeModify - Return true if it is possible for the execution |
| 219 | /// of the specified instructions to modify the value pointed to by Ptr. The |
| 220 | /// instructions to consider are all of the instructions in the range of [I1,I2] |
| 221 | /// INCLUSIVE. I1 and I2 must be in the same basic block. |
| 222 | /// |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 223 | bool AliasAnalysis::canInstructionRangeModify(const Instruction &I1, |
| 224 | const Instruction &I2, |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 225 | const Value *Ptr, unsigned Size) { |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 226 | assert(I1.getParent() == I2.getParent() && |
| 227 | "Instructions not in same basic block!"); |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 228 | BasicBlock::const_iterator I = &I1; |
| 229 | BasicBlock::const_iterator E = &I2; |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 230 | ++E; // Convert from inclusive to exclusive range. |
| 231 | |
Chris Lattner | 14ac877 | 2003-02-26 19:26:51 +0000 | [diff] [blame] | 232 | for (; I != E; ++I) // Check every instruction in range |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 233 | if (getModRefInfo(I, Ptr, Size) & Mod) |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 234 | return true; |
Chris Lattner | 53ad0ed | 2002-08-22 18:25:32 +0000 | [diff] [blame] | 235 | return false; |
| 236 | } |
| 237 | |
Dan Gohman | a5f81bb | 2009-02-03 01:28:32 +0000 | [diff] [blame] | 238 | /// isNoAliasCall - Return true if this pointer is returned by a noalias |
| 239 | /// function. |
| 240 | bool llvm::isNoAliasCall(const Value *V) { |
| 241 | if (isa<CallInst>(V) || isa<InvokeInst>(V)) |
Dan Gohman | 79fca6f | 2010-08-03 21:48:53 +0000 | [diff] [blame^] | 242 | return ImmutableCallSite(cast<Instruction>(V)) |
Dan Gohman | a5f81bb | 2009-02-03 01:28:32 +0000 | [diff] [blame] | 243 | .paramHasAttr(0, Attribute::NoAlias); |
| 244 | return false; |
| 245 | } |
| 246 | |
| 247 | /// isIdentifiedObject - Return true if this pointer refers to a distinct and |
| 248 | /// identifiable object. This returns true for: |
Dan Gohman | 5753a4a | 2009-08-27 17:52:56 +0000 | [diff] [blame] | 249 | /// Global Variables and Functions (but not Global Aliases) |
Dan Gohman | a5f81bb | 2009-02-03 01:28:32 +0000 | [diff] [blame] | 250 | /// Allocas and Mallocs |
Dan Gohman | 9e86f43 | 2010-07-07 14:27:09 +0000 | [diff] [blame] | 251 | /// ByVal and NoAlias Arguments |
| 252 | /// NoAlias returns |
Dan Gohman | a5f81bb | 2009-02-03 01:28:32 +0000 | [diff] [blame] | 253 | /// |
Dan Gohman | 9e86f43 | 2010-07-07 14:27:09 +0000 | [diff] [blame] | 254 | bool llvm::isIdentifiedObject(const Value *V) { |
Dan Gohman | 6be2bd5 | 2010-06-29 00:50:39 +0000 | [diff] [blame] | 255 | if (isa<AllocaInst>(V)) |
Dan Gohman | 5753a4a | 2009-08-27 17:52:56 +0000 | [diff] [blame] | 256 | return true; |
| 257 | if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V)) |
Dan Gohman | a5f81bb | 2009-02-03 01:28:32 +0000 | [diff] [blame] | 258 | return true; |
Dan Gohman | 9e86f43 | 2010-07-07 14:27:09 +0000 | [diff] [blame] | 259 | if (isNoAliasCall(V)) |
| 260 | return true; |
| 261 | if (const Argument *A = dyn_cast<Argument>(V)) |
| 262 | return A->hasNoAliasAttr() || A->hasByValAttr(); |
Dan Gohman | a5f81bb | 2009-02-03 01:28:32 +0000 | [diff] [blame] | 263 | return false; |
| 264 | } |
| 265 | |
Chris Lattner | d501c13 | 2003-02-26 19:41:54 +0000 | [diff] [blame] | 266 | // Because of the way .a files work, we must force the BasicAA implementation to |
| 267 | // be pulled in if the AliasAnalysis classes are pulled in. Otherwise we run |
| 268 | // the risk of AliasAnalysis being used, but the default implementation not |
| 269 | // being linked into the tool that uses it. |
Reid Spencer | 4f1bd9e | 2006-06-07 22:00:26 +0000 | [diff] [blame] | 270 | DEFINING_FILE_FOR(AliasAnalysis) |