LLVM  4.0.0
MemoryDependenceAnalysis.h
Go to the documentation of this file.
1 //===- llvm/Analysis/MemoryDependenceAnalysis.h - Memory Deps --*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the MemoryDependenceAnalysis analysis pass.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
15 #define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
16 
17 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/IR/BasicBlock.h"
23 #include "llvm/IR/PassManager.h"
25 #include "llvm/IR/ValueHandle.h"
26 #include "llvm/Pass.h"
27 
28 namespace llvm {
29 class Function;
30 class FunctionPass;
31 class Instruction;
32 class CallSite;
33 class AssumptionCache;
34 class MemoryDependenceResults;
35 class PredIteratorCache;
36 class DominatorTree;
37 class PHITransAddr;
38 
39 /// A memory dependence query can return one of three different answers.
40 class MemDepResult {
41  enum DepType {
42  /// Clients of MemDep never see this.
43  ///
44  /// Entries with this marker occur in a LocalDeps map or NonLocalDeps map
45  /// when the instruction they previously referenced was removed from
46  /// MemDep. In either case, the entry may include an instruction pointer.
47  /// If so, the pointer is an instruction in the block where scanning can
48  /// start from, saving some work.
49  ///
50  /// In a default-constructed MemDepResult object, the type will be Invalid
51  /// and the instruction pointer will be null.
52  Invalid = 0,
53 
54  /// This is a dependence on the specified instruction which clobbers the
55  /// desired value. The pointer member of the MemDepResult pair holds the
56  /// instruction that clobbers the memory. For example, this occurs when we
57  /// see a may-aliased store to the memory location we care about.
58  ///
59  /// There are several cases that may be interesting here:
60  /// 1. Loads are clobbered by may-alias stores.
61  /// 2. Loads are considered clobbered by partially-aliased loads. The
62  /// client may choose to analyze deeper into these cases.
63  Clobber,
64 
65  /// This is a dependence on the specified instruction which defines or
66  /// produces the desired memory location. The pointer member of the
67  /// MemDepResult pair holds the instruction that defines the memory.
68  ///
69  /// Cases of interest:
70  /// 1. This could be a load or store for dependence queries on
71  /// load/store. The value loaded or stored is the produced value.
72  /// Note that the pointer operand may be different than that of the
73  /// queried pointer due to must aliases and phi translation. Note
74  /// that the def may not be the same type as the query, the pointers
75  /// may just be must aliases.
76  /// 2. For loads and stores, this could be an allocation instruction. In
77  /// this case, the load is loading an undef value or a store is the
78  /// first store to (that part of) the allocation.
79  /// 3. Dependence queries on calls return Def only when they are readonly
80  /// calls or memory use intrinsics with identical callees and no
81  /// intervening clobbers. No validation is done that the operands to
82  /// the calls are the same.
83  Def,
84 
85  /// This marker indicates that the query has no known dependency in the
86  /// specified block.
87  ///
88  /// More detailed state info is encoded in the upper part of the pair (i.e.
89  /// the Instruction*)
90  Other
91  };
92 
93  /// If DepType is "Other", the upper part of the sum type is an encoding of
94  /// the following more detailed type information.
95  enum OtherType {
96  /// This marker indicates that the query has no dependency in the specified
97  /// block.
98  ///
99  /// To find out more, the client should query other predecessor blocks.
100  NonLocal = 1,
101  /// This marker indicates that the query has no dependency in the specified
102  /// function.
103  NonFuncLocal,
104  /// This marker indicates that the query dependency is unknown.
105  Unknown
106  };
107 
108  typedef PointerSumType<
113  ValueTy;
114  ValueTy Value;
115  explicit MemDepResult(ValueTy V) : Value(V) {}
116 
117 public:
119 
120  /// get methods: These are static ctor methods for creating various
121  /// MemDepResult kinds.
123  assert(Inst && "Def requires inst");
124  return MemDepResult(ValueTy::create<Def>(Inst));
125  }
127  assert(Inst && "Clobber requires inst");
128  return MemDepResult(ValueTy::create<Clobber>(Inst));
129  }
131  return MemDepResult(ValueTy::create<Other>(NonLocal));
132  }
134  return MemDepResult(ValueTy::create<Other>(NonFuncLocal));
135  }
137  return MemDepResult(ValueTy::create<Other>(Unknown));
138  }
139 
140  /// Tests if this MemDepResult represents a query that is an instruction
141  /// clobber dependency.
142  bool isClobber() const { return Value.is<Clobber>(); }
143 
144  /// Tests if this MemDepResult represents a query that is an instruction
145  /// definition dependency.
146  bool isDef() const { return Value.is<Def>(); }
147 
148  /// Tests if this MemDepResult represents a query that is transparent to the
149  /// start of the block, but where a non-local hasn't been done.
150  bool isNonLocal() const {
151  return Value.is<Other>() && Value.cast<Other>() == NonLocal;
152  }
153 
154  /// Tests if this MemDepResult represents a query that is transparent to the
155  /// start of the function.
156  bool isNonFuncLocal() const {
157  return Value.is<Other>() && Value.cast<Other>() == NonFuncLocal;
158  }
159 
160  /// Tests if this MemDepResult represents a query which cannot and/or will
161  /// not be computed.
162  bool isUnknown() const {
163  return Value.is<Other>() && Value.cast<Other>() == Unknown;
164  }
165 
166  /// If this is a normal dependency, returns the instruction that is depended
167  /// on. Otherwise, returns null.
168  Instruction *getInst() const {
169  switch (Value.getTag()) {
170  case Invalid:
171  return Value.cast<Invalid>();
172  case Clobber:
173  return Value.cast<Clobber>();
174  case Def:
175  return Value.cast<Def>();
176  case Other:
177  return nullptr;
178  }
179  llvm_unreachable("Unknown discriminant!");
180  }
181 
182  bool operator==(const MemDepResult &M) const { return Value == M.Value; }
183  bool operator!=(const MemDepResult &M) const { return Value != M.Value; }
184  bool operator<(const MemDepResult &M) const { return Value < M.Value; }
185  bool operator>(const MemDepResult &M) const { return Value > M.Value; }
186 
187 private:
189 
190  /// Tests if this is a MemDepResult in its dirty/invalid. state.
191  bool isDirty() const { return Value.is<Invalid>(); }
192 
193  static MemDepResult getDirty(Instruction *Inst) {
194  return MemDepResult(ValueTy::create<Invalid>(Inst));
195  }
196 };
197 
198 /// This is an entry in the NonLocalDepInfo cache.
199 ///
200 /// For each BasicBlock (the BB entry) it keeps a MemDepResult.
202  BasicBlock *BB;
203  MemDepResult Result;
204 
205 public:
207  : BB(bb), Result(result) {}
208 
209  // This is used for searches.
210  NonLocalDepEntry(BasicBlock *bb) : BB(bb) {}
211 
212  // BB is the sort key, it can't be changed.
213  BasicBlock *getBB() const { return BB; }
214 
215  void setResult(const MemDepResult &R) { Result = R; }
216 
217  const MemDepResult &getResult() const { return Result; }
218 
219  bool operator<(const NonLocalDepEntry &RHS) const { return BB < RHS.BB; }
220 };
221 
222 /// This is a result from a NonLocal dependence query.
223 ///
224 /// For each BasicBlock (the BB entry) it keeps a MemDepResult and the
225 /// (potentially phi translated) address that was live in the block.
227  NonLocalDepEntry Entry;
228  Value *Address;
229 
230 public:
232  : Entry(bb, result), Address(address) {}
233 
234  // BB is the sort key, it can't be changed.
235  BasicBlock *getBB() const { return Entry.getBB(); }
236 
237  void setResult(const MemDepResult &R, Value *Addr) {
238  Entry.setResult(R);
239  Address = Addr;
240  }
241 
242  const MemDepResult &getResult() const { return Entry.getResult(); }
243 
244  /// Returns the address of this pointer in this block.
245  ///
246  /// This can be different than the address queried for the non-local result
247  /// because of phi translation. This returns null if the address was not
248  /// available in a block (i.e. because phi translation failed) or if this is
249  /// a cached result and that address was deleted.
250  ///
251  /// The address is always null for a non-local 'call' dependence.
252  Value *getAddress() const { return Address; }
253 };
254 
255 /// Provides a lazy, caching interface for making common memory aliasing
256 /// information queries, backed by LLVM's alias analysis passes.
257 ///
258 /// The dependency information returned is somewhat unusual, but is pragmatic.
259 /// If queried about a store or call that might modify memory, the analysis
260 /// will return the instruction[s] that may either load from that memory or
261 /// store to it. If queried with a load or call that can never modify memory,
262 /// the analysis will return calls and stores that might modify the pointer,
263 /// but generally does not return loads unless a) they are volatile, or
264 /// b) they load from *must-aliased* pointers. Returning a dependence on
265 /// must-alias'd pointers instead of all pointers interacts well with the
266 /// internal caching mechanism.
268  // A map from instructions to their dependency.
270  LocalDepMapType LocalDeps;
271 
272 public:
273  typedef std::vector<NonLocalDepEntry> NonLocalDepInfo;
274 
275 private:
276  /// A pair<Value*, bool> where the bool is true if the dependence is a read
277  /// only dependence, false if read/write.
279 
280  /// This pair is used when caching information for a block.
281  ///
282  /// If the pointer is null, the cache value is not a full query that starts
283  /// at the specified block. If non-null, the bool indicates whether or not
284  /// the contents of the block was skipped.
286 
287  /// This record is the information kept for each (value, is load) pair.
288  struct NonLocalPointerInfo {
289  /// The pair of the block and the skip-first-block flag.
291  /// The results of the query for each relevant block.
292  NonLocalDepInfo NonLocalDeps;
293  /// The maximum size of the dereferences of the pointer.
294  ///
295  /// May be UnknownSize if the sizes are unknown.
296  uint64_t Size;
297  /// The AA tags associated with dereferences of the pointer.
298  ///
299  /// The members may be null if there are no tags or conflicting tags.
300  AAMDNodes AATags;
301 
302  NonLocalPointerInfo() : Size(MemoryLocation::UnknownSize) {}
303  };
304 
305  /// Cache storing single nonlocal def for the instruction.
306  /// It is set when nonlocal def would be found in function returning only
307  /// local dependencies.
309  /// This map stores the cached results of doing a pointer lookup at the
310  /// bottom of a block.
311  ///
312  /// The key of this map is the pointer+isload bit, the value is a list of
313  /// <bb->result> mappings.
315  CachedNonLocalPointerInfo;
316  CachedNonLocalPointerInfo NonLocalPointerDeps;
317 
318  // A map from instructions to their non-local pointer dependencies.
320  ReverseNonLocalPtrDepTy;
321  ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
322 
323  /// This is the instruction we keep for each cached access that we have for
324  /// an instruction.
325  ///
326  /// The pointer is an owning pointer and the bool indicates whether we have
327  /// any dirty bits in the set.
328  typedef std::pair<NonLocalDepInfo, bool> PerInstNLInfo;
329 
330  // A map from instructions to their non-local dependencies.
331  typedef DenseMap<Instruction *, PerInstNLInfo> NonLocalDepMapType;
332 
333  NonLocalDepMapType NonLocalDeps;
334 
335  // A reverse mapping from dependencies to the dependees. This is
336  // used when removing instructions to keep the cache coherent.
338  ReverseDepMapType;
339  ReverseDepMapType ReverseLocalDeps;
340 
341  // A reverse mapping from dependencies to the non-local dependees.
342  ReverseDepMapType ReverseNonLocalDeps;
343 
344  /// Current AA implementation, just a cache.
345  AliasAnalysis &AA;
346  AssumptionCache &AC;
347  const TargetLibraryInfo &TLI;
348  DominatorTree &DT;
349  PredIteratorCache PredCache;
350 
351 public:
353  const TargetLibraryInfo &TLI,
354  DominatorTree &DT)
355  : AA(AA), AC(AC), TLI(TLI), DT(DT) {}
356 
357  /// Handle invalidation in the new PM.
358  bool invalidate(Function &F, const PreservedAnalyses &PA,
360 
361  /// Some methods limit the number of instructions they will examine.
362  /// The return value of this method is the default limit that will be
363  /// used if no limit is explicitly passed in.
364  unsigned getDefaultBlockScanLimit() const;
365 
366  /// Returns the instruction on which a memory operation depends.
367  ///
368  /// See the class comment for more details. It is illegal to call this on
369  /// non-memory instructions.
371 
372  /// Perform a full dependency query for the specified call, returning the set
373  /// of blocks that the value is potentially live across.
374  ///
375  /// The returned set of results will include a "NonLocal" result for all
376  /// blocks where the value is live across.
377  ///
378  /// This method assumes the instruction returns a "NonLocal" dependency
379  /// within its own block.
380  ///
381  /// This returns a reference to an internal data structure that may be
382  /// invalidated on the next non-local query or when an instruction is
383  /// removed. Clients must copy this data if they want it around longer than
384  /// that.
386 
387  /// Perform a full dependency query for an access to the QueryInst's
388  /// specified memory location, returning the set of instructions that either
389  /// define or clobber the value.
390  ///
391  /// Warning: For a volatile query instruction, the dependencies will be
392  /// accurate, and thus usable for reordering, but it is never legal to
393  /// remove the query instruction.
394  ///
395  /// This method assumes the pointer has a "NonLocal" dependency within
396  /// QueryInst's parent basic block.
399 
400  /// Removes an instruction from the dependence analysis, updating the
401  /// dependence of instructions that previously depended on it.
402  void removeInstruction(Instruction *InstToRemove);
403 
404  /// Invalidates cached information about the specified pointer, because it
405  /// may be too conservative in memdep.
406  ///
407  /// This is an optional call that can be used when the client detects an
408  /// equivalence between the pointer and some other value and replaces the
409  /// other value with ptr. This can make Ptr available in more places that
410  /// cached info does not necessarily keep.
412 
413  /// Clears the PredIteratorCache info.
414  ///
415  /// This needs to be done when the CFG changes, e.g., due to splitting
416  /// critical edges.
418 
419  /// Returns the instruction on which a memory location depends.
420  ///
421  /// If isLoad is true, this routine ignores may-aliases with read-only
422  /// operations. If isLoad is false, this routine ignores may-aliases
423  /// with reads from read-only locations. If possible, pass the query
424  /// instruction as well; this function may take advantage of the metadata
425  /// annotated to the query instruction to refine the result. \p Limit
426  /// can be used to set the maximum number of instructions that will be
427  /// examined to find the pointer dependency. On return, it will be set to
428  /// the number of instructions left to examine. If a null pointer is passed
429  /// in, the limit will default to the value of -memdep-block-scan-limit.
430  ///
431  /// Note that this is an uncached query, and thus may be inefficient.
432  MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad,
433  BasicBlock::iterator ScanIt,
434  BasicBlock *BB,
435  Instruction *QueryInst = nullptr,
436  unsigned *Limit = nullptr);
437 
439  bool isLoad,
440  BasicBlock::iterator ScanIt,
441  BasicBlock *BB,
442  Instruction *QueryInst,
443  unsigned *Limit = nullptr);
444 
445  /// This analysis looks for other loads and stores with invariant.group
446  /// metadata and the same pointer operand. Returns Unknown if it does not
447  /// find anything, and Def if it can be assumed that 2 instructions load or
448  /// store the same value and NonLocal which indicate that non-local Def was
449  /// found, which can be retrieved by calling getNonLocalPointerDependency
450  /// with the same queried instruction.
452 
453  /// Looks at a memory location for a load (specified by MemLocBase, Offs, and
454  /// Size) and compares it against a load.
455  ///
456  /// If the specified load could be safely widened to a larger integer load
457  /// that is 1) still efficient, 2) safe for the target, and 3) would provide
458  /// the specified memory location value, then this function returns the size
459  /// in bytes of the load width to use. If not, this returns zero.
460  static unsigned getLoadLoadClobberFullWidthSize(const Value *MemLocBase,
461  int64_t MemLocOffs,
462  unsigned MemLocSize,
463  const LoadInst *LI);
464 
465  /// Release memory in caches.
466  void releaseMemory();
467 
468 private:
469  MemDepResult getCallSiteDependencyFrom(CallSite C, bool isReadOnlyCall,
470  BasicBlock::iterator ScanIt,
471  BasicBlock *BB);
472  bool getNonLocalPointerDepFromBB(Instruction *QueryInst,
473  const PHITransAddr &Pointer,
474  const MemoryLocation &Loc, bool isLoad,
475  BasicBlock *BB,
478  bool SkipFirstBlock = false);
479  MemDepResult GetNonLocalInfoForBlock(Instruction *QueryInst,
480  const MemoryLocation &Loc, bool isLoad,
481  BasicBlock *BB, NonLocalDepInfo *Cache,
482  unsigned NumSortedEntries);
483 
484  void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P);
485 
486  void verifyRemoved(Instruction *Inst) const;
487 };
488 
489 /// An analysis that produces \c MemoryDependenceResults for a function.
490 ///
491 /// This is essentially a no-op because the results are computed entirely
492 /// lazily.
494  : public AnalysisInfoMixin<MemoryDependenceAnalysis> {
496  static AnalysisKey Key;
497 
498 public:
500 
502 };
503 
504 /// A wrapper analysis pass for the legacy pass manager that exposes a \c
505 /// MemoryDepnedenceResults instance.
508 public:
510  ~MemoryDependenceWrapperPass() override;
511  static char ID;
512 
513  /// Pass Implementation stuff. This doesn't do any analysis eagerly.
514  bool runOnFunction(Function &) override;
515 
516  /// Clean up memory in between runs
517  void releaseMemory() override;
518 
519  /// Does not modify anything. It uses Value Numbering and Alias Analysis.
520  void getAnalysisUsage(AnalysisUsage &AU) const override;
521 
522  MemoryDependenceResults &getMemDep() { return *MemDep; }
523 };
524 
525 } // End llvm namespace
526 
527 #endif
void invalidateCachedPointerInfo(Value *Ptr)
Invalidates cached information about the specified pointer, because it may be too conservative in mem...
void invalidateCachedPredecessors()
Clears the PredIteratorCache info.
MemoryDependenceResults(AliasAnalysis &AA, AssumptionCache &AC, const TargetLibraryInfo &TLI, DominatorTree &DT)
Provides a lazy, caching interface for making common memory aliasing information queries, backed by LLVM's alias analysis passes.
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
A compile time pair of an integer tag and the pointer-like type which it indexes within a sum type...
MemDepResult getInvariantGroupPointerDependency(LoadInst *LI, BasicBlock *BB)
This analysis looks for other loads and stores with invariant.group metadata and the same pointer ope...
bool operator<(const MemDepResult &M) const
A cache of .assume calls within a function.
void releaseMemory()
Release memory in caches.
An instruction for reading from memory.
Definition: Instructions.h:164
void setResult(const MemDepResult &R, Value *Addr)
bool isUnknown() const
Tests if this MemDepResult represents a query which cannot and/or will not be computed.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
static unsigned getLoadLoadClobberFullWidthSize(const Value *MemLocBase, int64_t MemLocOffs, unsigned MemLocSize, const LoadInst *LI)
Looks at a memory location for a load (specified by MemLocBase, Offs, and Size) and compares it again...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:32
void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result)
Perform a full dependency query for an access to the QueryInst's specified memory location...
static MemDepResult getDef(Instruction *Inst)
get methods: These are static ctor methods for creating various MemDepResult kinds.
An analysis that produces MemoryDependenceResults for a function.
std::vector< NonLocalDepEntry > NonLocalDepInfo
Value * getAddress() const
Returns the address of this pointer in this block.
#define F(x, y, z)
Definition: MD5.cpp:51
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries...
bool operator==(const MemDepResult &M) const
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:96
static MemDepResult getUnknown()
#define P(N)
const NonLocalDepInfo & getNonLocalCallDependency(CallSite QueryCS)
Perform a full dependency query for the specified call, returning the set of blocks that the value is...
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:107
LLVM Basic Block Representation.
Definition: BasicBlock.h:51
PointerIntPair - This class implements a pair of a pointer and small integer.
PHITransAddr - An address value which tracks and handles phi translation.
Definition: PHITransAddr.h:36
bool operator>(const MemDepResult &M) const
This is a result from a NonLocal dependence query.
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:328
NonLocalDepResult(BasicBlock *bb, MemDepResult result, Value *address)
MemDepResult getSimplePointerDependencyFrom(const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst, unsigned *Limit=nullptr)
Represent the analysis usage information of a pass.
static MemDepResult getNonFuncLocal()
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
const MemDepResult & getResult() const
void setResult(const MemDepResult &R)
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
A memory dependence query can return one of three different answers.
unsigned getDefaultBlockScanLimit() const
Some methods limit the number of instructions they will examine.
Representation for a specific memory location.
MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst=nullptr, unsigned *Limit=nullptr)
Returns the instruction on which a memory location depends.
NonLocalDepEntry(BasicBlock *bb, MemDepResult result)
Iterator for intrusive lists based on ilist_node.
Provides information about what library functions are available for the current target.
static MemDepResult getClobber(Instruction *Inst)
MemoryDependenceResults run(Function &F, FunctionAnalysisManager &AM)
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:625
bool isNonLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the block...
void getAnalysisUsage(AnalysisUsage &AU) const override
Does not modify anything. It uses Value Numbering and Alias Analysis.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void releaseMemory() override
Clean up memory in between runs.
bool operator<(const NonLocalDepEntry &RHS) const
bool runOnFunction(Function &) override
Pass Implementation stuff. This doesn't do any analysis eagerly.
A sum type over pointer-like types.
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation in the new PM.
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:525
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Definition: Value.h:71
void removeInstruction(Instruction *InstToRemove)
Removes an instruction from the dependence analysis, updating the dependence of instructions that pre...
const MemDepResult & getResult() const
This is an entry in the NonLocalDepInfo cache.
A container for analyses that lazily runs them and caches their results.
int * Ptr
This header defines various interfaces for pass management in LLVM.
static MemDepResult getNonLocal()
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:64
bool isNonFuncLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the function...
bool operator!=(const MemDepResult &M) const
MemDepResult getDependency(Instruction *QueryInst)
Returns the instruction on which a memory operation depends.