1 //===- llvm/Analysis/MemoryDependenceAnalysis.h - Memory Deps --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
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.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_ANALYSIS_MEMORY_DEPENDENCE_H
18 #define LLVM_ANALYSIS_MEMORY_DEPENDENCE_H
20 #include "llvm/Pass.h"
21 #include "llvm/Support/CallSite.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/Support/Compiler.h"
32 class MemoryDependenceAnalysis : public FunctionPass {
35 DenseMap<Instruction*, std::pair<Instruction*, bool> > depGraphLocal;
36 std::multimap<Instruction*, Instruction*> reverseDep;
38 Instruction* getCallSiteDependency(CallSite C, bool local = true);
41 static Instruction* NonLocal;
42 static Instruction* None;
44 static char ID; // Class identification, replacement for typeinfo
45 MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {}
47 /// Pass Implementation stuff. This doesn't do any analysis.
49 bool runOnFunction(Function &) {return false; }
51 /// Clean up memory in between runs
52 void releaseMemory() {
53 depGraphLocal.clear();
57 /// getAnalysisUsage - Does not modify anything. It uses Value Numbering
58 /// and Alias Analysis.
60 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
62 /// getDependency - Return the instruction on which a memory operation
64 Instruction* getDependency(Instruction* query, bool local = true);
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);
71 } // End llvm namespace