LLVM API Documentation

llvm::MemoryDependenceAnalysis Class Reference

#include <MemoryDependenceAnalysis.h>

Inheritance diagram for llvm::MemoryDependenceAnalysis:
[legend]
Collaboration diagram for llvm::MemoryDependenceAnalysis:
[legend]

List of all members.

Public Types

typedef std::pair< BasicBlock
*, MemDepResult > 
NonLocalDepEntry
typedef std::vector
< NonLocalDepEntry > 
NonLocalDepInfo

Public Member Functions

 MemoryDependenceAnalysis ()
 ~MemoryDependenceAnalysis ()
bool runOnFunction (Function &)
 Pass Implementation stuff. This doesn't do any analysis eagerly.
void releaseMemory ()
 Clean up memory in between runs.
virtual void getAnalysisUsage (AnalysisUsage &AU) const
MemDepResult getDependency (Instruction *QueryInst)
const NonLocalDepInfo & getNonLocalCallDependency (CallSite QueryCS)
void getNonLocalPointerDependency (Value *Pointer, bool isLoad, BasicBlock *BB, SmallVectorImpl< NonLocalDepEntry > &Result)
void removeInstruction (Instruction *InstToRemove)
void invalidateCachedPointerInfo (Value *Ptr)

Static Public Attributes

static char ID = 0


Detailed Description

MemoryDependenceAnalysis - This is an analysis that determines, for a given memory operation, what preceding memory operations it depends on. It builds on alias analysis information, and tries to provide a lazy, caching interface to a common kind of alias information query.

The dependency information returned is somewhat unusual, but is pragmatic. If queried about a store or call that might modify memory, the analysis will return the instruction[s] that may either load from that memory or store to it. If queried with a load or call that can never modify memory, the analysis will return calls and stores that might modify the pointer, but generally does not return loads unless a) they are volatile, or b) they load from *must-aliased* pointers. Returning a dependence on must-alias'd pointers instead of all pointers interacts well with the internal caching mechanism.

Definition at line 147 of file MemoryDependenceAnalysis.h.


Member Typedef Documentation

Definition at line 153 of file MemoryDependenceAnalysis.h.

Definition at line 154 of file MemoryDependenceAnalysis.h.


Constructor & Destructor Documentation

MemoryDependenceAnalysis::MemoryDependenceAnalysis (  ) 

Definition at line 49 of file MemoryDependenceAnalysis.cpp.

MemoryDependenceAnalysis::~MemoryDependenceAnalysis (  ) 

Definition at line 52 of file MemoryDependenceAnalysis.cpp.


Member Function Documentation

bool MemoryDependenceAnalysis::runOnFunction ( Function &   )  [virtual]

Pass Implementation stuff. This doesn't do any analysis eagerly.

Implements llvm::FunctionPass.

Definition at line 76 of file MemoryDependenceAnalysis.cpp.

void MemoryDependenceAnalysis::releaseMemory (  )  [virtual]

Clean up memory in between runs.

Reimplemented from llvm::Pass.

Definition at line 56 of file MemoryDependenceAnalysis.cpp.

void MemoryDependenceAnalysis::getAnalysisUsage ( AnalysisUsage &  AU  )  const [virtual]

getAnalysisUsage - Does not modify anything. It uses Value Numbering and Alias Analysis.

getAnalysisUsage - Does not modify anything. It uses Alias Analysis.

Reimplemented from llvm::Pass.

Definition at line 70 of file MemoryDependenceAnalysis.cpp.

References llvm::AnalysisUsage::addRequiredTransitive(), and llvm::AnalysisUsage::setPreservesAll().

MemDepResult MemoryDependenceAnalysis::getDependency ( Instruction *  QueryInst  ) 

getDependency - Return the instruction on which a memory operation depends. See the class comment for more details. It is illegal to call this on non-memory instructions.

getDependency - Return the instruction on which a memory operation depends.

Definition at line 252 of file MemoryDependenceAnalysis.cpp.

References llvm::BasicBlock::begin(), FI, llvm::CallSite::get(), llvm::MemDepResult::getClobber(), llvm::Function::getEntryBlock(), llvm::MemDepResult::getInst(), llvm::MemDepResult::getNonLocal(), llvm::BasicBlock::getParent(), llvm::Instruction::getParent(), llvm::TargetData::getTypeStoreSize(), llvm::MemDepResult::isDirty(), llvm::SectionKind::isReadOnly(), LI, llvm::AliasAnalysis::onlyReadsMemory(), and RemoveFromReverseMap().

Referenced by getNonLocalCallDependency().

const MemoryDependenceAnalysis::NonLocalDepInfo & MemoryDependenceAnalysis::getNonLocalCallDependency ( CallSite  QueryCS  ) 

getNonLocalCallDependency - Perform a full dependency query for the specified call, returning the set of blocks that the value is potentially live across. The returned set of results will include a "NonLocal" result for all blocks where the value is live across.

This method assumes the instruction returns a "NonLocal" dependency within its own block.

This returns a reference to an internal data structure that may be invalidated on the next non-local query or when an instruction is removed. Clients must copy this data if they want it around longer than that.

getNonLocalCallDependency - Perform a full dependency query for the specified call, returning the set of blocks that the value is potentially live across. The returned set of results will include a "NonLocal" result for all blocks where the value is live across.

This method assumes the instruction returns a "NonLocal" dependency within its own block.

This returns a reference to an internal data structure that may be invalidated on the next non-local query or when an instruction is removed. Clients must copy this data if they want it around longer than that.

DirtyBlocks - This is the set of blocks that need to be recomputed. In the cached case, this can happen due to instructions being deleted etc. In the uncached case, this starts out as the set of predecessors we care about.

Definition at line 355 of file MemoryDependenceAnalysis.cpp.

References AssertSorted(), llvm::SmallVectorImpl< T >::back(), llvm::BasicBlock::begin(), Cache, DEBUG, E, llvm::SmallVectorImpl< T >::empty(), llvm::BasicBlock::end(), Entry, llvm::MemDepResult::getClobber(), getDependency(), llvm::Function::getEntryBlock(), llvm::MemDepResult::getInst(), llvm::CallSite::getInstruction(), llvm::MemDepResult::getNonLocal(), llvm::BasicBlock::getParent(), llvm::Instruction::getParent(), llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::MemDepResult::isNonLocal(), llvm::AliasAnalysis::onlyReadsMemory(), PI, llvm::SmallVectorImpl< T >::pop_back(), llvm::prior(), llvm::SmallVectorImpl< T >::push_back(), RemoveFromReverseMap(), and Visited.

void MemoryDependenceAnalysis::getNonLocalPointerDependency ( Value *  Pointer,
bool  isLoad,
BasicBlock *  FromBB,
SmallVectorImpl< NonLocalDepEntry > &  Result 
)

getNonLocalPointerDependency - Perform a full dependency query for an access to the specified (non-volatile) memory location, returning the set of instructions that either define or clobber the value.

This method assumes the pointer has a "NonLocal" dependency within BB.

getNonLocalPointerDependency - Perform a full dependency query for an access to the specified (non-volatile) memory location, returning the set of instructions that either define or clobber the value.

This method assumes the pointer has a "NonLocal" dependency within its own block.

Definition at line 493 of file MemoryDependenceAnalysis.cpp.

References llvm::BasicBlock::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::MemDepResult::getClobber(), llvm::Value::getType(), llvm::TargetData::getTypeStoreSize(), llvm::SmallVectorImpl< T >::push_back(), and Visited.

void MemoryDependenceAnalysis::removeInstruction ( Instruction *  RemInst  ) 

removeInstruction - Remove an instruction from the dependence analysis, updating the dependence of instructions that previously depended on it.

removeInstruction - Remove an instruction from the dependence analysis, updating the dependence of instructions that previously depended on it. This method attempts to keep the cache coherent using the reverse map.

Definition at line 906 of file MemoryDependenceAnalysis.cpp.

References llvm::SmallVectorImpl< T >::back(), llvm::SmallPtrSet< PtrType, SmallSize >::begin(), DE, DEBUG, llvm::AliasAnalysis::deleteValue(), E, llvm::SmallVectorImpl< T >::empty(), llvm::SmallPtrSetImpl::empty(), llvm::SmallPtrSet< PtrType, SmallSize >::end(), llvm::MemDepResult::getInst(), llvm::PointerIntPair< PointerTy, IntBits, IntType >::getPointer(), llvm::Value::getType(), llvm::Instruction::isTerminator(), llvm::SmallVectorImpl< T >::pop_back(), llvm::SmallVectorImpl< T >::push_back(), RemoveFromReverseMap(), and llvm::PointerIntPair< PointerTy, IntBits, IntType >::setFromOpaqueValue().

void MemoryDependenceAnalysis::invalidateCachedPointerInfo ( Value *  Ptr  ) 

invalidateCachedPointerInfo - This method is used to invalidate cached information about the specified pointer, because it may be too conservative in memdep. This is an optional call that can be used when the client detects an equivalence between the pointer and some other value and replaces the other value with ptr. This can make Ptr available in more places that cached info does not necessarily keep.

invalidateCachedPointerInfo - This method is used to invalidate cached information about the specified pointer, because it may be too conservative in memdep. This is an optional call that can be used when the client detects an equivalence between the pointer and some other value and replaces the other value with ptr. This can make Ptr available in more places that cached info does not necessarily keep.

Definition at line 894 of file MemoryDependenceAnalysis.cpp.

References llvm::Value::getType().


Member Data Documentation

char MemoryDependenceAnalysis::ID = 0 [static]

Definition at line 206 of file MemoryDependenceAnalysis.h.


The documentation for this class was generated from the following files: