Add support for finding the dependencies of call and invoke instructions.
[oota-llvm.git] / include / llvm / Analysis / MemoryDependenceAnalysis.h
1 //===- llvm/Analysis/MemoryDependenceAnalysis.h - Memory Deps  --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the Owen Anderson and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines an analysis that determines, for a given memory operation,
11 // what preceding memory operations it depends on.  It builds on alias analysis
12 // information, and tries to provide a lazy, caching interface to a common kind
13 // of alias information query.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_ANALYSIS_MEMORY_DEPENDENCE_H
18 #define LLVM_ANALYSIS_MEMORY_DEPENDENCE_H
19
20 #include "llvm/Pass.h"
21 #include "llvm/Support/CallSite.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/Support/Compiler.h"
24 #include <map>
25
26 namespace llvm {
27
28 class Function;
29 class FunctionPass;
30 class Instruction;
31
32 class MemoryDependenceAnalysis : public FunctionPass {
33   private:
34     
35     DenseMap<Instruction*, std::pair<Instruction*, bool> > depGraphLocal;
36     std::multimap<Instruction*, Instruction*> reverseDep;
37   
38     Instruction* getCallSiteDependency(CallSite C, bool local = true);
39   public:
40     
41     static Instruction* NonLocal;
42     static Instruction* None;
43     
44     static char ID; // Class identification, replacement for typeinfo
45     MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {}
46
47     /// Pass Implementation stuff.  This doesn't do any analysis.
48     ///
49     bool runOnFunction(Function &) {return false; }
50     
51     /// Clean up memory in between runs
52     void releaseMemory() {
53       depGraphLocal.clear();
54       reverseDep.clear();
55     }
56
57     /// getAnalysisUsage - Does not modify anything.  It uses Value Numbering
58     /// and Alias Analysis.
59     ///
60     virtual void getAnalysisUsage(AnalysisUsage &AU) const;
61     
62     /// getDependency - Return the instruction on which a memory operation
63     /// depends.
64     Instruction* getDependency(Instruction* query, bool local = true);
65     
66     /// removeInstruction - Remove an instruction from the dependence analysis,
67     /// updating the dependence of instructions that previously depended on it.
68     void removeInstruction(Instruction* rem);
69   };
70
71 } // End llvm namespace
72
73 #endif