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/ADT/SmallPtrSet.h"
24 #include "llvm/Support/Compiler.h"
32 class MemoryDependenceAnalysis : public FunctionPass {
35 typedef DenseMap<Instruction*, std::pair<const Instruction*, bool> >
38 depMapType depGraphLocal;
40 typedef DenseMap<const Instruction*,
41 SmallPtrSet<Instruction*, 4> > reverseDepMapType;
42 reverseDepMapType reverseDep;
44 const Instruction* getCallSiteDependency(CallSite C, Instruction* start,
46 void nonLocalHelper(Instruction* query, BasicBlock* block,
47 DenseMap<BasicBlock*, Value*>& resp);
50 static const Instruction* NonLocal;
51 static const Instruction* None;
53 static char ID; // Class identification, replacement for typeinfo
54 MemoryDependenceAnalysis() : FunctionPass((intptr_t)&ID) {}
56 /// Pass Implementation stuff. This doesn't do any analysis.
58 bool runOnFunction(Function &) {return false; }
60 /// Clean up memory in between runs
61 void releaseMemory() {
62 depGraphLocal.clear();
66 /// getAnalysisUsage - Does not modify anything. It uses Value Numbering
67 /// and Alias Analysis.
69 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
71 /// getDependency - Return the instruction on which a memory operation
72 /// depends, starting with start.
73 const Instruction* getDependency(Instruction* query, Instruction* start = 0,
74 BasicBlock* block = 0);
76 void getNonLocalDependency(Instruction* query,
77 DenseMap<BasicBlock*, Value*>& resp);
79 /// removeInstruction - Remove an instruction from the dependence analysis,
80 /// updating the dependence of instructions that previously depended on it.
81 void removeInstruction(Instruction* rem);
84 } // End llvm namespace