MemoryDependenceAnalysis.h revision d777d405cdda8d418ba8e8818e5c1272dfd999a0
178e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//===- llvm/Analysis/MemoryDependenceAnalysis.h - Memory Deps  --*- C++ -*-===//
278e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//
378e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//                     The LLVM Compiler Infrastructure
478e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
778e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//
878e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//===----------------------------------------------------------------------===//
978e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//
10e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner// This file defines the MemoryDependenceAnalysis analysis pass.
1178e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//
1278e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson//===----------------------------------------------------------------------===//
1378e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
1478e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson#ifndef LLVM_ANALYSIS_MEMORY_DEPENDENCE_H
1578e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson#define LLVM_ANALYSIS_MEMORY_DEPENDENCE_H
1678e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
175391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner#include "llvm/BasicBlock.h"
1878e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson#include "llvm/Pass.h"
1978e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson#include "llvm/ADT/DenseMap.h"
204beedbd0063a8ba6f97db02c3c94707d8ab45b50Owen Anderson#include "llvm/ADT/SmallPtrSet.h"
2139f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner#include "llvm/ADT/PointerIntPair.h"
2278e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
2378e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Andersonnamespace llvm {
24e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  class Function;
25e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  class FunctionPass;
26e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  class Instruction;
27b390b1728e6c36f1f28d75d6f8f27cb91f8a8c56Chris Lattner  class CallSite;
28d777d405cdda8d418ba8e8818e5c1272dfd999a0Chris Lattner  class AliasAnalysis;
29d777d405cdda8d418ba8e8818e5c1272dfd999a0Chris Lattner  class TargetData;
304c724006256032e827177afeae04ea62436796e7Chris Lattner
314c724006256032e827177afeae04ea62436796e7Chris Lattner  /// MemDepResult - A memory dependence query can return one of three different
324c724006256032e827177afeae04ea62436796e7Chris Lattner  /// answers:
334c724006256032e827177afeae04ea62436796e7Chris Lattner  ///   Normal  : The query is dependent on a specific instruction.
344c724006256032e827177afeae04ea62436796e7Chris Lattner  ///   NonLocal: The query does not depend on anything inside this block, but
354c724006256032e827177afeae04ea62436796e7Chris Lattner  ///             we haven't scanned beyond the block to find out what.
364c724006256032e827177afeae04ea62436796e7Chris Lattner  ///   None    : The query does not depend on anything: we found the entry
374c724006256032e827177afeae04ea62436796e7Chris Lattner  ///             block or the allocation site of the memory.
384c724006256032e827177afeae04ea62436796e7Chris Lattner  class MemDepResult {
394c724006256032e827177afeae04ea62436796e7Chris Lattner    enum DepType {
404c724006256032e827177afeae04ea62436796e7Chris Lattner      Invalid = 0, Normal, NonLocal, None
414c724006256032e827177afeae04ea62436796e7Chris Lattner    };
424c724006256032e827177afeae04ea62436796e7Chris Lattner    typedef PointerIntPair<Instruction*, 2, DepType> PairTy;
434c724006256032e827177afeae04ea62436796e7Chris Lattner    PairTy Value;
444c724006256032e827177afeae04ea62436796e7Chris Lattner    explicit MemDepResult(PairTy V) : Value(V) {}
454c724006256032e827177afeae04ea62436796e7Chris Lattner  public:
464c724006256032e827177afeae04ea62436796e7Chris Lattner    MemDepResult() : Value(0, Invalid) {}
474c724006256032e827177afeae04ea62436796e7Chris Lattner
484c724006256032e827177afeae04ea62436796e7Chris Lattner    /// get methods: These are static ctor methods for creating various
494c724006256032e827177afeae04ea62436796e7Chris Lattner    /// MemDepResult kinds.
504c724006256032e827177afeae04ea62436796e7Chris Lattner    static MemDepResult get(Instruction *Inst) {
514c724006256032e827177afeae04ea62436796e7Chris Lattner      return MemDepResult(PairTy(Inst, Normal));
524c724006256032e827177afeae04ea62436796e7Chris Lattner    }
534c724006256032e827177afeae04ea62436796e7Chris Lattner    static MemDepResult getNonLocal() {
544c724006256032e827177afeae04ea62436796e7Chris Lattner      return MemDepResult(PairTy(0, NonLocal));
554c724006256032e827177afeae04ea62436796e7Chris Lattner    }
564c724006256032e827177afeae04ea62436796e7Chris Lattner    static MemDepResult getNone() {
574c724006256032e827177afeae04ea62436796e7Chris Lattner      return MemDepResult(PairTy(0, None));
584c724006256032e827177afeae04ea62436796e7Chris Lattner    }
594c724006256032e827177afeae04ea62436796e7Chris Lattner
604c724006256032e827177afeae04ea62436796e7Chris Lattner    /// isNormal - Return true if this MemDepResult represents a query that is
614c724006256032e827177afeae04ea62436796e7Chris Lattner    /// a normal instruction dependency.
6286b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    bool isNormal() const { return Value.getInt() == Normal; }
634c724006256032e827177afeae04ea62436796e7Chris Lattner
644c724006256032e827177afeae04ea62436796e7Chris Lattner    /// isNonLocal - Return true if this MemDepResult represents an query that
654c724006256032e827177afeae04ea62436796e7Chris Lattner    /// is transparent to the start of the block, but where a non-local hasn't
664c724006256032e827177afeae04ea62436796e7Chris Lattner    /// been done.
6786b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    bool isNonLocal() const { return Value.getInt() == NonLocal; }
684c724006256032e827177afeae04ea62436796e7Chris Lattner
694c724006256032e827177afeae04ea62436796e7Chris Lattner    /// isNone - Return true if this MemDepResult represents a query that
704c724006256032e827177afeae04ea62436796e7Chris Lattner    /// doesn't depend on any instruction.
7186b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    bool isNone() const { return Value.getInt() == None; }
724c724006256032e827177afeae04ea62436796e7Chris Lattner
734c724006256032e827177afeae04ea62436796e7Chris Lattner    /// getInst() - If this is a normal dependency, return the instruction that
744c724006256032e827177afeae04ea62436796e7Chris Lattner    /// is depended on.  Otherwise, return null.
754c724006256032e827177afeae04ea62436796e7Chris Lattner    Instruction *getInst() const { return isNormal() ? Value.getPointer() : 0; }
764c724006256032e827177afeae04ea62436796e7Chris Lattner
774c724006256032e827177afeae04ea62436796e7Chris Lattner    bool operator==(const MemDepResult &M) { return M.Value == Value; }
784c724006256032e827177afeae04ea62436796e7Chris Lattner    bool operator!=(const MemDepResult &M) { return M.Value != Value; }
794c724006256032e827177afeae04ea62436796e7Chris Lattner  };
8078e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
81e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  /// MemoryDependenceAnalysis - This is an analysis that determines, for a
82e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  /// given memory operation, what preceding memory operations it depends on.
83e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  /// It builds on alias analysis information, and tries to provide a lazy,
84e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  /// caching interface to a common kind of alias information query.
850e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  ///
860e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// The dependency information returned is somewhat unusual, but is pragmatic.
870e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// If queried about a store or call that might modify memory, the analysis
880e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// will return the instruction[s] that may either load from that memory or
890e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// store to it.  If queried with a load or call that can never modify memory,
900e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// the analysis will return calls and stores that might modify the pointer,
910e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// but generally does not return loads unless a) they are volatile, or
920e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// b) they load from *must-aliased* pointers.  Returning a dependence on
930e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// must-alias'd pointers instead of all pointers interacts well with the
940e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  /// internal caching mechanism.
950e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner  ///
96e85866313a551fa3d4e2f118c3bf34e96af36763Chris Lattner  class MemoryDependenceAnalysis : public FunctionPass {
9739f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    /// DepType - This enum is used to indicate what flavor of dependence this
9839f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    /// is.  If the type is Normal, there is an associated instruction pointer.
9939f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    enum DepType {
1000ec48ddef20deaa061152d86645972122beef605Chris Lattner      /// Dirty - Entries with this marker occur in a LocalDeps map or
1010ec48ddef20deaa061152d86645972122beef605Chris Lattner      /// NonLocalDeps map when the instruction they previously referenced was
1020ec48ddef20deaa061152d86645972122beef605Chris Lattner      /// removed from MemDep.  In either case, the entry may include an
1030ec48ddef20deaa061152d86645972122beef605Chris Lattner      /// instruction pointer.  If so, the pointer is an instruction in the
1040ec48ddef20deaa061152d86645972122beef605Chris Lattner      /// block where scanning can start from, saving some work.
1057f52422a3c821c1deb7171808ffcf83386970791Chris Lattner      ///
1067f52422a3c821c1deb7171808ffcf83386970791Chris Lattner      /// In a default-constructed DepResultTy object, the type will be Dirty
1077f52422a3c821c1deb7171808ffcf83386970791Chris Lattner      /// and the instruction pointer will be null.
1087f52422a3c821c1deb7171808ffcf83386970791Chris Lattner      ///
1097f52422a3c821c1deb7171808ffcf83386970791Chris Lattner      Dirty = 0,
1107f52422a3c821c1deb7171808ffcf83386970791Chris Lattner
11139f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      /// Normal - This is a normal instruction dependence.  The pointer member
11239f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      /// of the DepResultTy pair holds the instruction.
1137f52422a3c821c1deb7171808ffcf83386970791Chris Lattner      Normal,
11439f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner
11539f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      /// None - This dependence type indicates that the query does not depend
116f68f310386c8e1772a3e6eba01f09590678a8f96Chris Lattner      /// on any instructions, either because it is not a memory instruction or
117f68f310386c8e1772a3e6eba01f09590678a8f96Chris Lattner      /// because it scanned to the definition of the memory (alloca/malloc)
118f68f310386c8e1772a3e6eba01f09590678a8f96Chris Lattner      /// being accessed.
11939f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      None,
12039f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner
12139f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      /// NonLocal - This marker indicates that the query has no dependency in
12239f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      /// the specified block.  To find out more, the client should query other
12339f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      /// predecessor blocks.
1247f52422a3c821c1deb7171808ffcf83386970791Chris Lattner      NonLocal
12539f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    };
12639f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    typedef PointerIntPair<Instruction*, 2, DepType> DepResultTy;
1274c724006256032e827177afeae04ea62436796e7Chris Lattner
1287f52422a3c821c1deb7171808ffcf83386970791Chris Lattner    // A map from instructions to their dependency.
1297f52422a3c821c1deb7171808ffcf83386970791Chris Lattner    typedef DenseMap<Instruction*, DepResultTy> LocalDepMapType;
13039f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    LocalDepMapType LocalDeps;
131df464195fe049d5ea921e2e37f4f833c2ea4e3ecDavid Greene
13225f4b2b7a3f1f2bbaf954257e7834ba29a6ede7cChris Lattner    typedef DenseMap<BasicBlock*, DepResultTy> NonLocalDepInfo;
13325f4b2b7a3f1f2bbaf954257e7834ba29a6ede7cChris Lattner
1344a69bade2385022ca776edc22150f3b750cdf23cChris Lattner    /// PerInstNLInfo - This is the instruction we keep for each cached access
1354a69bade2385022ca776edc22150f3b750cdf23cChris Lattner    /// that we have for an instruction.  The pointer is an owning pointer and
1364a69bade2385022ca776edc22150f3b750cdf23cChris Lattner    /// the bool indicates whether we have any dirty bits in the set.
1374a69bade2385022ca776edc22150f3b750cdf23cChris Lattner    typedef PointerIntPair<NonLocalDepInfo*, 1, bool> PerInstNLInfo;
13825f4b2b7a3f1f2bbaf954257e7834ba29a6ede7cChris Lattner
1394d13de4e3bfc5121207efd01e1b31caa6bb4e40bOwen Anderson    // A map from instructions to their non-local dependencies.
1404a69bade2385022ca776edc22150f3b750cdf23cChris Lattner    typedef DenseMap<Instruction*, PerInstNLInfo> NonLocalDepMapType;
1414a69bade2385022ca776edc22150f3b750cdf23cChris Lattner
1428c4652790e04515f34cf920b0783d6ec4161a313Chris Lattner    NonLocalDepMapType NonLocalDeps;
1434d13de4e3bfc5121207efd01e1b31caa6bb4e40bOwen Anderson
144956033a4f5de491fcc07bc3ef0700ad22fd836a0Chris Lattner    // A reverse mapping from dependencies to the dependees.  This is
145179463c0d4c20bfb2c6b1e697eed6f16305a201eOwen Anderson    // used when removing instructions to keep the cache coherent.
1467f52422a3c821c1deb7171808ffcf83386970791Chris Lattner    typedef DenseMap<Instruction*,
1478c4652790e04515f34cf920b0783d6ec4161a313Chris Lattner                     SmallPtrSet<Instruction*, 4> > ReverseDepMapType;
1488c4652790e04515f34cf920b0783d6ec4161a313Chris Lattner    ReverseDepMapType ReverseLocalDeps;
14978e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
1504d13de4e3bfc5121207efd01e1b31caa6bb4e40bOwen Anderson    // A reverse mapping form dependencies to the non-local dependees.
1518c4652790e04515f34cf920b0783d6ec4161a313Chris Lattner    ReverseDepMapType ReverseNonLocalDeps;
1524d13de4e3bfc5121207efd01e1b31caa6bb4e40bOwen Anderson
153d777d405cdda8d418ba8e8818e5c1272dfd999a0Chris Lattner    /// Current AA implementation, just a cache.
154d777d405cdda8d418ba8e8818e5c1272dfd999a0Chris Lattner    AliasAnalysis *AA;
155d777d405cdda8d418ba8e8818e5c1272dfd999a0Chris Lattner    TargetData *TD;
156179463c0d4c20bfb2c6b1e697eed6f16305a201eOwen Anderson  public:
157ae73dc1448d25b02cabc7c64c86c64371453dda8Dan Gohman    MemoryDependenceAnalysis() : FunctionPass(&ID) {}
15839f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    static char ID;
1591cee94f04111cfd7114979d6dfddce2669c9380dDevang Patel
160d777d405cdda8d418ba8e8818e5c1272dfd999a0Chris Lattner    /// Pass Implementation stuff.  This doesn't do any analysis eagerly.
161d777d405cdda8d418ba8e8818e5c1272dfd999a0Chris Lattner    bool runOnFunction(Function &);
1626b278fc7860c1e0e5cf72340e43f78a87159be4cOwen Anderson
1636b278fc7860c1e0e5cf72340e43f78a87159be4cOwen Anderson    /// Clean up memory in between runs
1646b278fc7860c1e0e5cf72340e43f78a87159be4cOwen Anderson    void releaseMemory() {
16539f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner      LocalDeps.clear();
166f68f310386c8e1772a3e6eba01f09590678a8f96Chris Lattner      for (NonLocalDepMapType::iterator I = NonLocalDeps.begin(),
167f68f310386c8e1772a3e6eba01f09590678a8f96Chris Lattner           E = NonLocalDeps.end(); I != E; ++I)
1684a69bade2385022ca776edc22150f3b750cdf23cChris Lattner        delete I->second.getPointer();
1698c4652790e04515f34cf920b0783d6ec4161a313Chris Lattner      NonLocalDeps.clear();
1708c4652790e04515f34cf920b0783d6ec4161a313Chris Lattner      ReverseLocalDeps.clear();
1718c4652790e04515f34cf920b0783d6ec4161a313Chris Lattner      ReverseNonLocalDeps.clear();
17278e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    }
17378e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
17478e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    /// getAnalysisUsage - Does not modify anything.  It uses Value Numbering
17578e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    /// and Alias Analysis.
17678e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    ///
17778e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    virtual void getAnalysisUsage(AnalysisUsage &AU) const;
17878e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
17978e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    /// getDependency - Return the instruction on which a memory operation
1800e0a5b690ca772a9002d8e8d21edac5f011bc7e8Chris Lattner    /// depends.  See the class comment for more details.
1815391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner    MemDepResult getDependency(Instruction *QueryInst);
1825391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner
1835391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner    /// getDependencyFrom - Return the instruction on which the memory operation
1845391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner    /// 'QueryInst' depends.  This starts scanning from the instruction before
1855391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner    /// the position indicated by ScanIt.
18673ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    ///
18773ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    /// Note that this method does no caching at all.  You should use
18873ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    /// getDependency where possible.
1895391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner    MemDepResult getDependencyFrom(Instruction *QueryInst,
19073ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner                                   BasicBlock::iterator ScanIt, BasicBlock *BB){
19173ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner      return ConvToResult(getDependencyFromInternal(QueryInst, ScanIt, BB));
19273ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    }
1935391a1d8046396fb4dd005b1910973789f5427f4Chris Lattner
1944beedbd0063a8ba6f97db02c3c94707d8ab45b50Owen Anderson
19586b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    /// getNonLocalDependency - Perform a full dependency query for the
19686b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    /// specified instruction, returning the set of blocks that the value is
19786b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    /// potentially live across.  The returned set of results will include a
19886b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    /// "NonLocal" result for all blocks where the value is live across.
19986b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    ///
20086b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    /// This method assumes the instruction returns a "nonlocal" dependency
20186b29ef64a36c8779ef7855b3c4b95744eb2f08bChris Lattner    /// within its own block.
202233336ebc588e77dde51ebbc3ce88c2d4304f168Chris Lattner    void getNonLocalDependency(Instruction *QueryInst,
203396a4a55e535728e2023aa331401c1a2b782cb9aChris Lattner                               SmallVectorImpl<std::pair<BasicBlock*,
204396a4a55e535728e2023aa331401c1a2b782cb9aChris Lattner                                                       MemDepResult> > &Result);
20578e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
20678e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    /// removeInstruction - Remove an instruction from the dependence analysis,
20778e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson    /// updating the dependence of instructions that previously depended on it.
20839f372e23e49cecb8db2eb7120eb331173e50c74Chris Lattner    void removeInstruction(Instruction *InstToRemove);
209179463c0d4c20bfb2c6b1e697eed6f16305a201eOwen Anderson
210179463c0d4c20bfb2c6b1e697eed6f16305a201eOwen Anderson  private:
2114c724006256032e827177afeae04ea62436796e7Chris Lattner    MemDepResult ConvToResult(DepResultTy R) {
2124c724006256032e827177afeae04ea62436796e7Chris Lattner      if (R.getInt() == Normal)
2134c724006256032e827177afeae04ea62436796e7Chris Lattner        return MemDepResult::get(R.getPointer());
2144c724006256032e827177afeae04ea62436796e7Chris Lattner      if (R.getInt() == NonLocal)
2154c724006256032e827177afeae04ea62436796e7Chris Lattner        return MemDepResult::getNonLocal();
2164c724006256032e827177afeae04ea62436796e7Chris Lattner      assert(R.getInt() == None && "Unknown MemDepResult!");
2174c724006256032e827177afeae04ea62436796e7Chris Lattner      return MemDepResult::getNone();
2184c724006256032e827177afeae04ea62436796e7Chris Lattner    }
2194c724006256032e827177afeae04ea62436796e7Chris Lattner
2208b589fa135d873e683b29ed0918638a79272f5d2Chris Lattner    /// verifyRemoved - Verify that the specified instruction does not occur
2218b589fa135d873e683b29ed0918638a79272f5d2Chris Lattner    /// in our internal data structures.
2228b589fa135d873e683b29ed0918638a79272f5d2Chris Lattner    void verifyRemoved(Instruction *Inst) const;
2238b589fa135d873e683b29ed0918638a79272f5d2Chris Lattner
22473ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    /// getDependencyFromInternal - Return the instruction on which the memory
22573ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    /// operation 'QueryInst' depends.  This starts scanning from the
22673ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    /// instruction before the position indicated by ScanIt.
22773ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    DepResultTy getDependencyFromInternal(Instruction *QueryInst,
22873ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner                                   BasicBlock::iterator ScanIt, BasicBlock *BB);
22973ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner    DepResultTy getCallSiteDependency(CallSite C, BasicBlock::iterator ScanIt,
23073ec3cdd7140aee6d2b9ac32bc2298254ff48c97Chris Lattner                                      BasicBlock *BB);
23178e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson  };
23278e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
23378e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson} // End llvm namespace
23478e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson
23578e02f78ce68274163e1e63be59abd17aaaf6cbfOwen Anderson#endif
236