AliasAnalysis.h revision b2143b6247901ae4eca2192ee134564c4f5f7853
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"
317107c3badfe78ec89dcab6c02cf1b1bcaccc42a8Reid Spencer#include "llvm/System/IncludeFile.h"
3236f78c8935da34074ccd06d5674e45b9cd45da8bChris Lattner#include <vector>
33d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
34d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm {
35d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
361c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass LoadInst;
371c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass StoreInst;
3814f1703ae33e13dbcadd701603fd4d7a6f7010b9Andrew Lenharthclass VAArgInst;
391c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass TargetData;
406df60a9effe4d20a48cfd9d105c0ab3c5dc3e690Reid Spencerclass Pass;
416df60a9effe4d20a48cfd9d105c0ab3c5dc3e690Reid Spencerclass AnalysisUsage;
421c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
431c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerclass AliasAnalysis {
441c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerprotected:
45ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  const TargetData *TD;
46cb74993bdc37681ddbb80fa361575107afae1350Dan Gohman
47cb74993bdc37681ddbb80fa361575107afae1350Dan Gohmanprivate:
48ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  AliasAnalysis *AA;       // Previous Alias Analysis to chain to.
49ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
50cb74993bdc37681ddbb80fa361575107afae1350Dan Gohmanprotected:
511c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// InitializeAliasAnalysis - Subclasses must call this method to initialize
521c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// the AliasAnalysis interface before any other methods are called.  This is
531c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// typically called by the run* methods of these subclasses.  This may be
541c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// called multiple times.
551c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  ///
561c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  void InitializeAliasAnalysis(Pass *P);
579769ab22265b313171d201b5928688524a01bd87Misha Brukman
5864d237cfae6bcb11157d525c79b5a5335e30370bDan Gohman  /// getAnalysisUsage - All alias analysis implementations should invoke this
59fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// directly (using AliasAnalysis::getAnalysisUsage(AU)).
601c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
611c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
621c56b730a6313886076d7b293a126ae5576f5288Chris Lattnerpublic:
631997473cf72957d0e70322e2fe6fe2ab141c58a6Devang Patel  static char ID; // Class identification, replacement for typeinfo
64ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  AliasAnalysis() : TD(0), AA(0) {}
651c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  virtual ~AliasAnalysis();  // We want to be subclassed
661c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
67ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman  /// UnknownSize - This is a special value which can be used with the
68ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman  /// size arguments in alias queries to indicate that the caller does not
69ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman  /// know the sizes of the potential memory references.
70ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman  static unsigned const UnknownSize = ~0u;
71ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman
72fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// getTargetData - Return a pointer to the current TargetData object, or
73fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// null if no TargetData object is available.
74dd298c8c6eb036baf35bf5a559c59d2afd2c7944Misha Brukman  ///
75fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  const TargetData *getTargetData() const { return TD; }
76fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman
77fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// getTypeStoreSize - Return the TargetData store size for the given type,
78fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  /// if known, or a conservative value otherwise.
79fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  ///
80fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0bDan Gohman  unsigned getTypeStoreSize(const Type *Ty);
814df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
821c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  //===--------------------------------------------------------------------===//
831c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// Alias Queries...
841c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  ///
854df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
86b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// Location - A description of a memory location.
87b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  struct Location {
88b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    /// Ptr - The address of the start of the location.
89b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    const Value *Ptr;
90b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    /// Size - The size of the location.
91b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    unsigned Size;
92b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    /// TBAATag - The metadata node which describes the TBAA type of
93b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    /// the location, or null if there is no (unique) tag.
94b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    const MDNode *TBAATag;
95b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
96b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    explicit Location(const Value *P = 0,
97b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                      unsigned S = UnknownSize,
98b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                      const MDNode *N = 0)
99b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman      : Ptr(P), Size(S), TBAATag(N) {}
100b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  };
101b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
102f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// Alias analysis result - Either we know for sure that it does not alias, we
103f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// know for sure it must alias, or we don't know anything: The two pointers
104f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// _might_ alias.  This enum is designed so you can do things like:
105f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  ///     if (AA.alias(P1, P2)) { ... }
106f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// to check to see if two pointers might alias.
107f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  ///
108e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman  /// See docs/AliasAnalysis.html for more information on the specific meanings
109e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman  /// of these values.
110e53e3772f3c8b4cba69b7d77c8b2148a080fe9aeDan Gohman  ///
1111c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  enum AliasResult { NoAlias = 0, MayAlias = 1, MustAlias = 2 };
1124df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
113f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// alias - The main low level interface to the alias analysis implementation.
114f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// Returns a Result indicating whether the two pointers are aliased to each
115f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// other.  This is the interface that must be implemented by specific alias
116f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// analysis implementations.
117b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  virtual AliasResult alias(const Location &LocA, const Location &LocB);
1184df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
119b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// alias - A convenience wrapper.
120b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  AliasResult alias(const Value *V1, unsigned V1Size,
121b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                    const Value *V2, unsigned V2Size) {
122b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return alias(Location(V1, V1Size), Location(V2, V2Size));
123b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
124b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
125b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// alias - A convenience wrapper.
126847a84efd23a2c7d90429b82f6e0f19d1f913d9aDan Gohman  AliasResult alias(const Value *V1, const Value *V2) {
127ef1cfac9e50def9097cd3e3ab3c5cad7f4c758ccDan Gohman    return alias(V1, UnknownSize, V2, UnknownSize);
128847a84efd23a2c7d90429b82f6e0f19d1f913d9aDan Gohman  }
129847a84efd23a2c7d90429b82f6e0f19d1f913d9aDan Gohman
130c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner  /// isNoAlias - A trivial helper function to check to see if the specified
131c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner  /// pointers are no-alias.
132b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool isNoAlias(const Location &LocA, const Location &LocB) {
133b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return alias(LocA, LocB) == NoAlias;
134b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
135b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
136b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// isNoAlias - A convenience wrapper.
137c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner  bool isNoAlias(const Value *V1, unsigned V1Size,
138c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner                 const Value *V2, unsigned V2Size) {
139b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return isNoAlias(Location(V1, V1Size), Location(V2, V2Size));
140c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner  }
141c46530b6a32a53edf0d6d32bcd09ea5d76940472Chris Lattner
142b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// pointsToConstantMemory - If the specified memory location is known to be
143b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// constant, return true.  This allows disambiguation of store
144762e8e846f0ad50ffea56216c5ea20db1c95b756Chris Lattner  /// instructions from constant pointers.
145762e8e846f0ad50ffea56216c5ea20db1c95b756Chris Lattner  ///
146b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  virtual bool pointsToConstantMemory(const Location &Loc);
147b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
148b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// pointsToConstantMemory - A convenient wrapper.
149b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool pointsToConstantMemory(const Value *P) {
150b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return pointsToConstantMemory(Location(P));
151b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
15262b5c167de0ca5883a7ad5eb0900eb0c15ad3707Chris Lattner
153248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  //===--------------------------------------------------------------------===//
154248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// Simple mod/ref information...
155248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  ///
156248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner
157248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// ModRefResult - Represent the result of a mod/ref query.  Mod and Ref are
158248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// bits which may be or'd together.
159248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  ///
160248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 };
1619769ab22265b313171d201b5928688524a01bd87Misha Brukman
1629769ab22265b313171d201b5928688524a01bd87Misha Brukman
163248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// ModRefBehavior - Summary of how a function affects memory in the program.
164248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// Loads from constant globals are not considered memory accesses for this
165248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// interface.  Also, functions may freely modify stack space local to their
166248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  /// invocation without having to report it through these interfaces.
167248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  enum ModRefBehavior {
168248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // DoesNotAccessMemory - This function does not perform any non-local loads
169248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // or stores to memory.
170248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    //
171248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // This property corresponds to the GCC 'const' attribute.
172248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    DoesNotAccessMemory,
1739769ab22265b313171d201b5928688524a01bd87Misha Brukman
174070fbe69d36b24616de4e484ecbea221a2c7e8c2Duncan Sands    // AccessesArguments - This function accesses function arguments in well
175070fbe69d36b24616de4e484ecbea221a2c7e8c2Duncan Sands    // known (possibly volatile) ways, but does not access any other memory.
176248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    AccessesArguments,
1779769ab22265b313171d201b5928688524a01bd87Misha Brukman
178248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // AccessesArgumentsAndGlobals - This function has accesses function
179070fbe69d36b24616de4e484ecbea221a2c7e8c2Duncan Sands    // arguments and global variables well known (possibly volatile) ways, but
180248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // does not access any other memory.
181248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    AccessesArgumentsAndGlobals,
1829769ab22265b313171d201b5928688524a01bd87Misha Brukman
183248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // OnlyReadsMemory - This function does not perform any non-local stores or
184248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // volatile loads, but may read from any memory location.
185248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    //
186248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // This property corresponds to the GCC 'pure' attribute.
187248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    OnlyReadsMemory,
1889769ab22265b313171d201b5928688524a01bd87Misha Brukman
189248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // UnknownModRefBehavior - This indicates that the function could not be
190248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    // classified into one of the behaviors above.
191248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner    UnknownModRefBehavior
192248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  };
1939769ab22265b313171d201b5928688524a01bd87Misha Brukman
194dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// getModRefBehavior - Return the behavior when calling the given call site.
195a41af344c2964573318a77e2b43eafd4d3804003Dan Gohman  virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
196dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
197dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// getModRefBehavior - Return the behavior when calling the given function.
198dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// For use when the call site is not known.
199a41af344c2964573318a77e2b43eafd4d3804003Dan Gohman  virtual ModRefBehavior getModRefBehavior(const Function *F);
200dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
20179fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  /// getIntrinsicModRefBehavior - Return the modref behavior of the intrinsic
20213214eb8ccaef26d9f5ad79a702f4b196d357537Dan Gohman  /// with the given id.  Most clients won't need this, because the regular
20313214eb8ccaef26d9f5ad79a702f4b196d357537Dan Gohman  /// getModRefBehavior incorporates this information.
20479fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  static ModRefBehavior getIntrinsicModRefBehavior(unsigned iid);
2057c422ac216fe39fc9c402a704cf296cca9dc5b22Duncan Sands
206dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// doesNotAccessMemory - If the specified call is known to never read or
207dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// write memory, return true.  If the call only reads from known-constant
208dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// memory, it is also legal to return true.  Calls that unwind the stack
209dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// are legal for this predicate.
2103e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
211dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// Many optimizations (such as CSE and LICM) can be performed on such calls
212dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// without worrying about aliasing properties, and many calls have this
213dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// property (e.g. calls to 'sin' and 'cos').
2143e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
2153e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// This property corresponds to the GCC 'const' attribute.
2163e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
21779fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool doesNotAccessMemory(ImmutableCallSite CS) {
218652f7ea955bb433d6b7a4d33685dca9485fd7b8bEvan Cheng    return getModRefBehavior(CS) == DoesNotAccessMemory;
219dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  }
220dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
221dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// doesNotAccessMemory - If the specified function is known to never read or
222dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// write memory, return true.  For use when the call site is not known.
223dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  ///
22479fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool doesNotAccessMemory(const Function *F) {
225dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands    return getModRefBehavior(F) == DoesNotAccessMemory;
226248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  }
2273e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner
228dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// onlyReadsMemory - If the specified call is known to only read from
229dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// non-volatile memory (or not access memory at all), return true.  Calls
230dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// that unwind the stack are legal for this predicate.
2313e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
2323e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// This property allows many common optimizations to be performed in the
2333e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// absence of interfering store instructions, such as CSE of strlen calls.
2343e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
2353e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  /// This property corresponds to the GCC 'pure' attribute.
2363e295b1b59e47916c8ae5d42eb27a23bd580cabeChris Lattner  ///
23779fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool onlyReadsMemory(ImmutableCallSite CS) {
238652f7ea955bb433d6b7a4d33685dca9485fd7b8bEvan Cheng    ModRefBehavior MRB = getModRefBehavior(CS);
239dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands    return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
240dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  }
241dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands
242dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// onlyReadsMemory - If the specified function is known to only read from
243dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// non-volatile memory (or not access memory at all), return true.  For use
244dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  /// when the call site is not known.
245dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands  ///
24679fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  bool onlyReadsMemory(const Function *F) {
247dff6710717b159f089c76a07eda074eb6347eb92Duncan Sands    ModRefBehavior MRB = getModRefBehavior(F);
2488eec644862251e14add0d2707d655fcce91e8f70Chris Lattner    return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
249248e8ebeff834db9b78917b1531eeee7035eb113Chris Lattner  }
2504df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
2511c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
2521c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// getModRefInfo - Return information about whether or not an instruction may
253b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// read or write the specified memory location.  An instruction
2541c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// that doesn't read or write memory may be trivially LICM'd for example.
255fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  ModRefResult getModRefInfo(const Instruction *I,
256b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                             const Location &Loc) {
257fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman    switch (I->getOpcode()) {
258b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::VAArg:  return getModRefInfo((const VAArgInst*)I, Loc);
259b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Load:   return getModRefInfo((const LoadInst*)I,  Loc);
260b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Store:  return getModRefInfo((const StoreInst*)I, Loc);
261b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Call:   return getModRefInfo((const CallInst*)I,  Loc);
262b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
263fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman    default:                  return NoModRef;
264fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman    }
265fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  }
2661c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
267b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo - A convenience wrapper.
268b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const Instruction *I,
269b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                             const Value *P, unsigned Size) {
270b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(I, Location(P, Size));
271b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
272b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
2731c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  /// getModRefInfo (for call sites) - Return whether information about whether
274b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular call site modifies or reads the specified memory location.
27579fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
276b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                                     const Location &Loc);
277b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
278b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for call sites) - A convenience wrapper.
279b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(ImmutableCallSite CS,
280b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                             const Value *P, unsigned Size) {
281b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(CS, Location(P, Size));
282b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
2831c56b730a6313886076d7b293a126ae5576f5288Chris Lattner
284fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for calls) - Return whether information about whether
285b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular call modifies or reads the specified memory location.
286b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const CallInst *C, const Location &Loc) {
287b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(ImmutableCallSite(C), Loc);
288b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
289b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
290b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for calls) - A convenience wrapper.
29179fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  ModRefResult getModRefInfo(const CallInst *C, const Value *P, unsigned Size) {
292b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(C, Location(P, Size));
2931c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  }
294fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
295fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for invokes) - Return whether information about whether
296b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular invoke modifies or reads the specified memory location.
297b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const InvokeInst *I,
298b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                             const Location &Loc) {
299b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(ImmutableCallSite(I), Loc);
300b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
301b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
302b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for invokes) - A convenience wrapper.
30379fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman  ModRefResult getModRefInfo(const InvokeInst *I,
30479fca6fea87be7221843031870bbf2c9ae1fc555Dan Gohman                             const Value *P, unsigned Size) {
305b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(I, Location(P, Size));
3061c56b730a6313886076d7b293a126ae5576f5288Chris Lattner  }
307fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
308fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for loads) - Return whether information about whether
309b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular load modifies or reads the specified memory location.
310b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const LoadInst *L, const Location &Loc);
311b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
312b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for loads) - A convenience wrapper.
313b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const LoadInst *L, const Value *P, unsigned Size) {
314b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(L, Location(P, Size));
315b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
316fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
317fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for stores) - Return whether information about whether
318b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular store modifies or reads the specified memory location.
319b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const StoreInst *S, const Location &Loc);
320b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
321b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for stores) - A convenience wrapper.
322b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const StoreInst *S, const Value *P, unsigned Size) {
323b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(S, Location(P, Size));
324b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
325fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
326fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo (for va_args) - Return whether information about whether
327b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// a particular va_arg modifies or reads the specified memory location.
328b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const VAArgInst* I, const Location &Loc);
329b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
330b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// getModRefInfo (for va_args) - A convenience wrapper.
331b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, unsigned Size) {
332b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return getModRefInfo(I, Location(P, Size));
333b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
334fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman
335fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// getModRefInfo - Return information about whether two call sites may refer
336fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// to the same set of memory locations.  See
337fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  ///   http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
338fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  /// for details.
339fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman  virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
340fa6cb8d8211579f1370e80b7bac54ebe3fbe35c8Dan Gohman                                     ImmutableCallSite CS2);
3414df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
342ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  //===--------------------------------------------------------------------===//
343ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// Higher level methods for querying mod/ref information.
344ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
345ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
346f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// canBasicBlockModify - Return true if it is possible for execution of the
347f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// specified basic block to modify the value pointed to by Ptr.
348b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool canBasicBlockModify(const BasicBlock &BB, const Location &Loc);
349b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
350b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// canBasicBlockModify - A convenience wrapper.
351b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool canBasicBlockModify(const BasicBlock &BB, const Value *P, unsigned Size){
352b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return canBasicBlockModify(BB, Location(P, Size));
353b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
3544df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
355f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// canInstructionRangeModify - Return true if it is possible for the
356f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// execution of the specified instructions to modify the value pointed to by
357f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// Ptr.  The instructions to consider are all of the instructions in the
358f12c2c28bd72091f2d7fff5718265c5ad52e7af8Chris Lattner  /// range of [I1,I2] INCLUSIVE.  I1 and I2 must be in the same basic block.
3594df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner  bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
360b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                                 const Location &Loc);
361b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman
362b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  /// canInstructionRangeModify - A convenience wrapper.
363b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
364b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman                                 const Value *Ptr, unsigned Size) {
365b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman    return canInstructionRangeModify(I1, I2, Location(Ptr, Size));
366b2143b6247901ae4eca2192ee134564c4f5f7853Dan Gohman  }
367ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
368ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  //===--------------------------------------------------------------------===//
369ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// Methods that clients should call when they transform the program to allow
370ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// alias analyses to update their internal data structures.  Note that these
371ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// methods may be called on any instruction, regardless of whether or not
372ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// they have pointer-analysis implications.
373ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
374ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
375ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// deleteValue - This method should be called whenever an LLVM Value is
376ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// deleted from the program, for example when an instruction is found to be
377ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// redundant and is eliminated.
378ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
379ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  virtual void deleteValue(Value *V);
380ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
381ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// copyValue - This method should be used whenever a preexisting value in the
382ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// program is copied or cloned, introducing a new value.  Note that analysis
383ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// implementations should tolerate clients that use this method to introduce
384ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// the same value multiple times: if the analysis already knows about a
385ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// value, it should ignore the request.
386ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
387ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  virtual void copyValue(Value *From, Value *To);
388ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner
389ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// replaceWithNewValue - This method is the obvious combination of the two
390ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  /// above, and it provided as a helper to simplify client code.
391ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  ///
392ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  void replaceWithNewValue(Value *Old, Value *New) {
393ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner    copyValue(Old, New);
394ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner    deleteValue(Old);
395ab8c565768ff7485f40cbb65e2914f9046e743d4Chris Lattner  }
3964df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner};
3974df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner
398a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman/// isNoAliasCall - Return true if this pointer is returned by a noalias
399a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman/// function.
400a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohmanbool isNoAliasCall(const Value *V);
401a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman
4023311a1f8f0d8a2c6d940802bbb95eba0b801a615Dan Gohman/// isIdentifiedObject - Return true if this pointer refers to a distinct and
403a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman/// identifiable object.  This returns true for:
4045753a4a0033da4add45f2e9930a4e1159d92a869Dan Gohman///    Global Variables and Functions (but not Global Aliases)
405a5f81bba4ab18d6129774d4d67495f14b6f64375Dan Gohman///    Allocas and Mallocs
4069e86f4364b912ae743490ba01d6989acfd12c046Dan Gohman///    ByVal and NoAlias Arguments
4079e86f4364b912ae743490ba01d6989acfd12c046Dan Gohman///    NoAlias returns
4083311a1f8f0d8a2c6d940802bbb95eba0b801a615Dan Gohman///
4099e86f4364b912ae743490ba01d6989acfd12c046Dan Gohmanbool isIdentifiedObject(const Value *V);
4103311a1f8f0d8a2c6d940802bbb95eba0b801a615Dan Gohman
4114f1bd9e9963239c119db70070db1d68286b3de7eReid Spencer} // End llvm namespace
4124f1bd9e9963239c119db70070db1d68286b3de7eReid Spencer
413fc188b95b81332c12043173c7f517341c6ad27a9Brian Gaeke// Because of the way .a files work, we must force the BasicAA implementation to
414fc188b95b81332c12043173c7f517341c6ad27a9Brian Gaeke// be pulled in if the AliasAnalysis header is included.  Otherwise we run
415fc188b95b81332c12043173c7f517341c6ad27a9Brian Gaeke// the risk of AliasAnalysis being used, but the default implementation not
416fc188b95b81332c12043173c7f517341c6ad27a9Brian Gaeke// being linked into the tool that uses it.
4174f1bd9e9963239c119db70070db1d68286b3de7eReid SpencerFORCE_DEFINING_FILE_TO_BE_LINKED(AliasAnalysis)
4184f1bd9e9963239c119db70070db1d68286b3de7eReid SpencerFORCE_DEFINING_FILE_TO_BE_LINKED(BasicAliasAnalysis)
419d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
4204df22c0100fe27f19e6f4874f24eedd0742b9cf4Chris Lattner#endif
421