AliasAnalysis.h revision 467a0adfc8b6bd4b114e024c200c159497a4cd86
14df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner//===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
29769ab22265b313171d201b5928688524a01bd87Misha Brukman//
36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//                     The LLVM Compiler Infrastructure
46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
79769ab22265b313171d201b5928688524a01bd87Misha Brukman//
86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===//
94df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner//
104df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner// This file defines the generic AliasAnalysis interface, which is used as the
114df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner// common interface used by all clients of alias analysis information, and
121c56b730a6313886076d7b293a126ae5576f5288Chris Lattner// implemented by all alias analysis implementations.  Mod/Ref information is
131c56b730a6313886076d7b293a126ae5576f5288Chris Lattner// also captured by this interface.
144df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner//
154df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner// Implementations of this interface must implement the various virtual methods,
164df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner// which automatically provides functionality for the entire suite of client
174df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner// APIs.
184df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner//
191c56b730a6313886076d7b293a126ae5576f5288Chris Lattner// This API represents memory as a (Pointer, Size) pair.  The Pointer component
201c56b730a6313886076d7b293a126ae5576f5288Chris Lattner// specifies the base memory address of the region, the Size specifies how large
21e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman// of an area is being queried, or UnknownSize if the size is not known.
22e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman// Pointers that point to two completely different objects in memory never
23e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman// alias, regardless of the value of the Size component.
241c56b730a6313886076d7b293a126ae5576f5288Chris Lattner//
254df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner//===----------------------------------------------------------------------===//
264df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
274df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner#ifndef LLVM_ANALYSIS_ALIAS_ANALYSIS_H
284df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner#define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
294df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
301c56b730a6313886076d7b293a126ae5576f5288Chris Lattner#include "llvm/Support/CallSite.h"
3136f78c8935da34074ccd06d5674e45b9cd45da8bChris Lattner#include <vector>
32d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
33d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm {
34d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
351c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass LoadInst;
361c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass StoreInst;
3714f1703ae33e13dbcadd701603fd4d7a6f7010b9Andrew Lenharthclass VAArgInst;
381c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass TargetData;
396df60a9effe4d20a48cfd9d105c0ab3c5dc3e690Reid Spencerclass Pass;
406df60a9effe4d20a48cfd9d105c0ab3c5dc3e690Reid Spencerclass AnalysisUsage;
411c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
421c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass AliasAnalysis {
431c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerprotected:
44ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  const TargetData *TD;
45cb74993bdc37681ddbb80fa361575107afae1350Dan Gohman
46cb74993bdc37681ddbb80fa361575107afae1350Dan Gohmanprivate:
47ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  AliasAnalysis *AA;       // Previous Alias Analysis to chain to.
48ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
49cb74993bdc37681ddbb80fa361575107afae1350Dan Gohmanprotected:
501c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// InitializeAliasAnalysis - Subclasses must call this method to initialize
511c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// the AliasAnalysis interface before any other methods are called.  This is
521c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// typically called by the run* methods of these subclasses.  This may be
531c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// called multiple times.
541c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  ///
551c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  void InitializeAliasAnalysis(Pass *P);
569769ab22265b313171d201b5928688524a01bd87Misha Brukman
5764d237cfae6bcb11157d525c79b5a5335e30370bDan Gohman  /// getAnalysisUsage - All alias analysis implementations should invoke this
58fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// directly (using AliasAnalysis::getAnalysisUsage(AU)).
591c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
601c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
611c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerpublic:
621997473cf72957d0e70322e2fe6fe2ab141c58a6Devang Patel  static char ID; // Class identification, replacement for typeinfo
63ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  AliasAnalysis() : TD(0), AA(0) {}
641c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  virtual ~AliasAnalysis();  // We want to be subclassed
651c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
66ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman  /// UnknownSize - This is a special value which can be used with the
67ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman  /// size arguments in alias queries to indicate that the caller does not
68ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman  /// know the sizes of the potential memory references.
693da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  static uint64_t const UnknownSize = ~UINT64_C(0);
70ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman
71fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// getTargetData - Return a pointer to the current TargetData object, or
72fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// null if no TargetData object is available.
73dd298c8c6eb036baf35bf5a559c59d2afd2c7944Misha Brukman  ///
74fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  const TargetData *getTargetData() const { return TD; }
75fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman
76fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// getTypeStoreSize - Return the TargetData store size for the given type,
77fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// if known, or a conservative value otherwise.
78fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  ///
793da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  uint64_t getTypeStoreSize(const Type *Ty);
804df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
811c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  //===--------------------------------------------------------------------===//
821c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// Alias Queries...
831c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  ///
844df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
85b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// Location - A description of a memory location.
86b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  struct Location {
87b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    /// Ptr - The address of the start of the location.
88b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    const Value *Ptr;
896c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman    /// Size - The maximum size of the location, or UnknownSize if the size is
906c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman    /// not known.  Note that an unknown size does not mean the pointer aliases
916c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman    /// the entire virtual address space, because there are restrictions on
926c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman    /// stepping out of one object and into another.
936c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman    /// See http://llvm.org/docs/LangRef.html#pointeraliasing
943da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman    uint64_t Size;
95b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    /// TBAATag - The metadata node which describes the TBAA type of
966c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman    /// the location, or null if there is no known unique tag.
97b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    const MDNode *TBAATag;
98b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
99b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    explicit Location(const Value *P = 0,
1003da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman                      uint64_t S = UnknownSize,
101b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                      const MDNode *N = 0)
102b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman      : Ptr(P), Size(S), TBAATag(N) {}
1039f27074f42f03af640977006dc7c05005fb77991Dan Gohman
1049f27074f42f03af640977006dc7c05005fb77991Dan Gohman    Location getWithNewPtr(const Value *NewPtr) const {
1059f27074f42f03af640977006dc7c05005fb77991Dan Gohman      Location Copy(*this);
1069f27074f42f03af640977006dc7c05005fb77991Dan Gohman      Copy.Ptr = NewPtr;
1079f27074f42f03af640977006dc7c05005fb77991Dan Gohman      return Copy;
1089f27074f42f03af640977006dc7c05005fb77991Dan Gohman    }
1099f27074f42f03af640977006dc7c05005fb77991Dan Gohman
1109f27074f42f03af640977006dc7c05005fb77991Dan Gohman    Location getWithoutTBAATag() const {
1119f27074f42f03af640977006dc7c05005fb77991Dan Gohman      Location Copy(*this);
1129f27074f42f03af640977006dc7c05005fb77991Dan Gohman      Copy.TBAATag = 0;
1139f27074f42f03af640977006dc7c05005fb77991Dan Gohman      return Copy;
1149f27074f42f03af640977006dc7c05005fb77991Dan Gohman    }
115b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  };
116b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
117f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// Alias analysis result - Either we know for sure that it does not alias, we
118f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// know for sure it must alias, or we don't know anything: The two pointers
119f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// _might_ alias.  This enum is designed so you can do things like:
120f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  ///     if (AA.alias(P1, P2)) { ... }
121f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// to check to see if two pointers might alias.
122f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  ///
123e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman  /// See docs/AliasAnalysis.html for more information on the specific meanings
124e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman  /// of these values.
125e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman  ///
1261c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  enum AliasResult { NoAlias = 0, MayAlias = 1, MustAlias = 2 };
1274df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
128f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// alias - The main low level interface to the alias analysis implementation.
1296c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman  /// Returns an AliasResult indicating whether the two pointers are aliased to
1306c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman  /// each other.  This is the interface that must be implemented by specific
1316c25c920e66aa2d8f6b48454bc9770087ff7939aDan Gohman  /// alias analysis implementations.
132b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  virtual AliasResult alias(const Location &LocA, const Location &LocB);
1334df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
134b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// alias - A convenience wrapper.
1353da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  AliasResult alias(const Value *V1, uint64_t V1Size,
1363da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman                    const Value *V2, uint64_t V2Size) {
137b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return alias(Location(V1, V1Size), Location(V2, V2Size));
138b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
139b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
140b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// alias - A convenience wrapper.
141847a84efd23a2c7d90429b82f6e0f19d1f913d9aDan Gohman  AliasResult alias(const Value *V1, const Value *V2) {
142ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman    return alias(V1, UnknownSize, V2, UnknownSize);
143847a84efd23a2c7d90429b82f6e0f19d1f913d9aDan Gohman  }
144847a84efd23a2c7d90429b82f6e0f19d1f913d9aDan Gohman
145c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner  /// isNoAlias - A trivial helper function to check to see if the specified
146c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner  /// pointers are no-alias.
147b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool isNoAlias(const Location &LocA, const Location &LocB) {
148b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return alias(LocA, LocB) == NoAlias;
149b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
150b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
151b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// isNoAlias - A convenience wrapper.
1523da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  bool isNoAlias(const Value *V1, uint64_t V1Size,
1533da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman                 const Value *V2, uint64_t V2Size) {
154b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return isNoAlias(Location(V1, V1Size), Location(V2, V2Size));
155c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner  }
156c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner
157a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman  /// pointsToConstantMemory - If the specified memory location is
158a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman  /// known to be constant, return true. If OrLocal is true and the
159a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman  /// specified memory location is known to be "local" (derived from
160a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman  /// an alloca), return true. Otherwise return false.
161a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman  virtual bool pointsToConstantMemory(const Location &Loc,
162a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman                                      bool OrLocal = false);
163b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
164b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// pointsToConstantMemory - A convenient wrapper.
165a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman  bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
166a25e5dbcc2371352386a01e3c1b8e76dd890272bDan Gohman    return pointsToConstantMemory(Location(P), OrLocal);
167b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
16862b5c167de0ca5883a7ad5eb0900eb0c15ad3707Chris Lattner
169248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  //===--------------------------------------------------------------------===//
170248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// Simple mod/ref information...
171248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  ///
172248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner
173248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// ModRefResult - Represent the result of a mod/ref query.  Mod and Ref are
174248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// bits which may be or'd together.
175248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  ///
176248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 };
1779769ab22265b313171d201b5928688524a01bd87Misha Brukman
1789769ab22265b313171d201b5928688524a01bd87Misha Brukman
179248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// ModRefBehavior - Summary of how a function affects memory in the program.
180248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// Loads from constant globals are not considered memory accesses for this
181248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// interface.  Also, functions may freely modify stack space local to their
182248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// invocation without having to report it through these interfaces.
183248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  enum ModRefBehavior {
184248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // DoesNotAccessMemory - This function does not perform any non-local loads
185248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // or stores to memory.
186248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    //
187248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // This property corresponds to the GCC 'const' attribute.
188902da265f684b00b76c669c2a7cbc0f209cda187Dan Gohman    // This property corresponds to the LLVM IR 'readnone' attribute.
189902da265f684b00b76c669c2a7cbc0f209cda187Dan Gohman    // This property corresponds to the IntrNoMem LLVM intrinsic flag.
190248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    DoesNotAccessMemory,
1919769ab22265b313171d201b5928688524a01bd87Misha Brukman
192070fbe69d36b24616de4e484ecbea221a2c7e8c2Duncan Sands    // AccessesArguments - This function accesses function arguments in well
193070fbe69d36b24616de4e484ecbea221a2c7e8c2Duncan Sands    // known (possibly volatile) ways, but does not access any other memory.
194902da265f684b00b76c669c2a7cbc0f209cda187Dan Gohman    //
195902da265f684b00b76c669c2a7cbc0f209cda187Dan Gohman    // This property corresponds to the IntrReadWriteArgMem LLVM intrinsic flag.
196248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    AccessesArguments,
1979769ab22265b313171d201b5928688524a01bd87Misha Brukman
198248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // OnlyReadsMemory - This function does not perform any non-local stores or
199248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // volatile loads, but may read from any memory location.
200248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    //
201248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // This property corresponds to the GCC 'pure' attribute.
202902da265f684b00b76c669c2a7cbc0f209cda187Dan Gohman    // This property corresponds to the LLVM IR 'readonly' attribute.
203902da265f684b00b76c669c2a7cbc0f209cda187Dan Gohman    // This property corresponds to the IntrReadMem LLVM intrinsic flag.
204248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    OnlyReadsMemory,
2059769ab22265b313171d201b5928688524a01bd87Misha Brukman
206248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // UnknownModRefBehavior - This indicates that the function could not be
207248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // classified into one of the behaviors above.
208248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    UnknownModRefBehavior
209248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  };
2109769ab22265b313171d201b5928688524a01bd87Misha Brukman
211dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// getModRefBehavior - Return the behavior when calling the given call site.
212a41af344c2964573318a77e2b43eafd4d3804003Dan Gohman  virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
213dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
214dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// getModRefBehavior - Return the behavior when calling the given function.
215dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// For use when the call site is not known.
216a41af344c2964573318a77e2b43eafd4d3804003Dan Gohman  virtual ModRefBehavior getModRefBehavior(const Function *F);
217dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
218dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// doesNotAccessMemory - If the specified call is known to never read or
219dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// write memory, return true.  If the call only reads from known-constant
220dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// memory, it is also legal to return true.  Calls that unwind the stack
221dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// are legal for this predicate.
2223e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
223dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// Many optimizations (such as CSE and LICM) can be performed on such calls
224dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// without worrying about aliasing properties, and many calls have this
225dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// property (e.g. calls to 'sin' and 'cos').
2263e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
2273e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// This property corresponds to the GCC 'const' attribute.
2283e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
22979fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool doesNotAccessMemory(ImmutableCallSite CS) {
230652f7ea955bb433d6b7a4d33685dca9485fd7b8bEvan Cheng    return getModRefBehavior(CS) == DoesNotAccessMemory;
231dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  }
232dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
233dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// doesNotAccessMemory - If the specified function is known to never read or
234dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// write memory, return true.  For use when the call site is not known.
235dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  ///
23679fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool doesNotAccessMemory(const Function *F) {
237dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands    return getModRefBehavior(F) == DoesNotAccessMemory;
238248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  }
2393e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner
240dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// onlyReadsMemory - If the specified call is known to only read from
241dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// non-volatile memory (or not access memory at all), return true.  Calls
242dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// that unwind the stack are legal for this predicate.
2433e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
2443e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// This property allows many common optimizations to be performed in the
2453e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// absence of interfering store instructions, such as CSE of strlen calls.
2463e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
2473e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// This property corresponds to the GCC 'pure' attribute.
2483e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
24979fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool onlyReadsMemory(ImmutableCallSite CS) {
250467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman    return onlyReadsMemory(getModRefBehavior(CS));
251dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  }
252dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
253dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// onlyReadsMemory - If the specified function is known to only read from
254dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// non-volatile memory (or not access memory at all), return true.  For use
255dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// when the call site is not known.
256dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  ///
25779fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool onlyReadsMemory(const Function *F) {
258467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman    return onlyReadsMemory(getModRefBehavior(F));
259467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman  }
260467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman
261467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman  /// onlyReadsMemory - If the functions with the specified behavior are known
262467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman  /// to only read from non-volatile memory (or not access memory at all), return
263467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman  /// true.  For use when the call site is not known.
264467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman  ///
265467a0adfc8b6bd4b114e024c200c159497a4cd86Dan Gohman  static bool onlyReadsMemory(ModRefBehavior MRB) {
2668eec644862251e14add0d2707d655fcce91e8f70Chris Lattner    return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
267248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  }
2684df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
2691c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
2701c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// getModRefInfo - Return information about whether or not an instruction may
271b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// read or write the specified memory location.  An instruction
2721c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// that doesn't read or write memory may be trivially LICM'd for example.
273fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  ModRefResult getModRefInfo(const Instruction *I,
274b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                             const Location &Loc) {
275fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman    switch (I->getOpcode()) {
276b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::VAArg:  return getModRefInfo((const VAArgInst*)I, Loc);
277b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Load:   return getModRefInfo((const LoadInst*)I,  Loc);
278b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Store:  return getModRefInfo((const StoreInst*)I, Loc);
279b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Call:   return getModRefInfo((const CallInst*)I,  Loc);
280b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
281fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman    default:                  return NoModRef;
282fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman    }
283fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  }
2841c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
285b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo - A convenience wrapper.
286b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const Instruction *I,
2873da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman                             const Value *P, uint64_t Size) {
288b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(I, Location(P, Size));
289b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
290b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
2911c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// getModRefInfo (for call sites) - Return whether information about whether
292b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular call site modifies or reads the specified memory location.
29379fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
294b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                                     const Location &Loc);
295b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
296b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for call sites) - A convenience wrapper.
297b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(ImmutableCallSite CS,
2983da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman                             const Value *P, uint64_t Size) {
299b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(CS, Location(P, Size));
300b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
3011c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
302fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for calls) - Return whether information about whether
303b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular call modifies or reads the specified memory location.
304b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const CallInst *C, const Location &Loc) {
305b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(ImmutableCallSite(C), Loc);
306b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
307b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
308b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for calls) - A convenience wrapper.
3093da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  ModRefResult getModRefInfo(const CallInst *C, const Value *P, uint64_t Size) {
310b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(C, Location(P, Size));
3111c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  }
312fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
313fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for invokes) - Return whether information about whether
314b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular invoke modifies or reads the specified memory location.
315b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const InvokeInst *I,
316b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                             const Location &Loc) {
317b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(ImmutableCallSite(I), Loc);
318b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
319b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
320b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for invokes) - A convenience wrapper.
32179fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  ModRefResult getModRefInfo(const InvokeInst *I,
3223da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman                             const Value *P, uint64_t Size) {
323b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(I, Location(P, Size));
3241c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  }
325fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
326fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for loads) - Return whether information about whether
327b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular load modifies or reads the specified memory location.
328b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const LoadInst *L, const Location &Loc);
329b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
330b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for loads) - A convenience wrapper.
3313da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  ModRefResult getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size) {
332b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(L, Location(P, Size));
333b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
334fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
335fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for stores) - Return whether information about whether
336b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular store modifies or reads the specified memory location.
337b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const StoreInst *S, const Location &Loc);
338b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
339b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for stores) - A convenience wrapper.
3403da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  ModRefResult getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size) {
341b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(S, Location(P, Size));
342b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
343fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
344fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for va_args) - Return whether information about whether
345b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular va_arg modifies or reads the specified memory location.
346b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const VAArgInst* I, const Location &Loc);
347b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
348b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for va_args) - A convenience wrapper.
3493da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size) {
350b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(I, Location(P, Size));
351b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
352fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
353fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo - Return information about whether two call sites may refer
354fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// to the same set of memory locations.  See
355fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  ///   http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
356fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// for details.
357fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
358fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman                                     ImmutableCallSite CS2);
3594df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
360ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  //===--------------------------------------------------------------------===//
361ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// Higher level methods for querying mod/ref information.
362ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
363ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
364f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// canBasicBlockModify - Return true if it is possible for execution of the
365f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// specified basic block to modify the value pointed to by Ptr.
366b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool canBasicBlockModify(const BasicBlock &BB, const Location &Loc);
367b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
368b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// canBasicBlockModify - A convenience wrapper.
3693da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman  bool canBasicBlockModify(const BasicBlock &BB, const Value *P, uint64_t Size){
370b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return canBasicBlockModify(BB, Location(P, Size));
371b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
3724df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
373f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// canInstructionRangeModify - Return true if it is possible for the
374f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// execution of the specified instructions to modify the value pointed to by
375f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// Ptr.  The instructions to consider are all of the instructions in the
376f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// range of [I1,I2] INCLUSIVE.  I1 and I2 must be in the same basic block.
3774df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner  bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
378b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                                 const Location &Loc);
379b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
380b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// canInstructionRangeModify - A convenience wrapper.
381b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
3823da848bbda62b25c12335998aaa44ab361f0bf15Dan Gohman                                 const Value *Ptr, uint64_t Size) {
383b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return canInstructionRangeModify(I1, I2, Location(Ptr, Size));
384b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
385ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
386ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  //===--------------------------------------------------------------------===//
387ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// Methods that clients should call when they transform the program to allow
388ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// alias analyses to update their internal data structures.  Note that these
389ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// methods may be called on any instruction, regardless of whether or not
390ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// they have pointer-analysis implications.
391ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
392ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
393ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// deleteValue - This method should be called whenever an LLVM Value is
394ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// deleted from the program, for example when an instruction is found to be
395ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// redundant and is eliminated.
396ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
397ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  virtual void deleteValue(Value *V);
398ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
399ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// copyValue - This method should be used whenever a preexisting value in the
400ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// program is copied or cloned, introducing a new value.  Note that analysis
401ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// implementations should tolerate clients that use this method to introduce
402ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// the same value multiple times: if the analysis already knows about a
403ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// value, it should ignore the request.
404ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
405ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  virtual void copyValue(Value *From, Value *To);
406ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
407ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// replaceWithNewValue - This method is the obvious combination of the two
408ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// above, and it provided as a helper to simplify client code.
409ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
410ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  void replaceWithNewValue(Value *Old, Value *New) {
411ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner    copyValue(Old, New);
412ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner    deleteValue(Old);
413ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  }
4144df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner};
4154df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
416a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman/// isNoAliasCall - Return true if this pointer is returned by a noalias
417a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman/// function.
418a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohmanbool isNoAliasCall(const Value *V);
419a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman
4203311a1f8f0d8a2c6d940802bbb95eba0b801a615Dan Gohman/// isIdentifiedObject - Return true if this pointer refers to a distinct and
421a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman/// identifiable object.  This returns true for:
4225753a4a0033da4add45f2e9930a4e1159d92a869Dan Gohman///    Global Variables and Functions (but not Global Aliases)
423a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman///    Allocas and Mallocs
4249e86f4364b912ae743490ba01d6989acfd12c046Dan Gohman///    ByVal and NoAlias Arguments
4259e86f4364b912ae743490ba01d6989acfd12c046Dan Gohman///    NoAlias returns
4263311a1f8f0d8a2c6d940802bbb95eba0b801a615Dan Gohman///
4279e86f4364b912ae743490ba01d6989acfd12c046Dan Gohmanbool isIdentifiedObject(const Value *V);
4283311a1f8f0d8a2c6d940802bbb95eba0b801a615Dan Gohman
4294f1bd9e9963239c119db70070db1d68286b3de7eReid Spencer} // End llvm namespace
4304f1bd9e9963239c119db70070db1d68286b3de7eReid Spencer
4314df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner#endif
432