LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
llvm::MemoryDependenceAnalysis Class Reference

#include <MemoryDependenceAnalysis.h>

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

Public Types

typedef std::vector
< NonLocalDepEntry
NonLocalDepInfo
 

Public Member Functions

 MemoryDependenceAnalysis ()
 
 ~MemoryDependenceAnalysis ()
 
bool runOnFunction (Function &)
 Pass Implementation stuff. This doesn't do any analysis eagerly. More...
 
void releaseMemory ()
 Clean up memory in between runs. More...
 
virtual void getAnalysisUsage (AnalysisUsage &AU) const
 
MemDepResult getDependency (Instruction *QueryInst)
 
const NonLocalDepInfogetNonLocalCallDependency (CallSite QueryCS)
 
void getNonLocalPointerDependency (const AliasAnalysis::Location &Loc, bool isLoad, BasicBlock *BB, SmallVectorImpl< NonLocalDepResult > &Result)
 
void removeInstruction (Instruction *InstToRemove)
 
void invalidateCachedPointerInfo (Value *Ptr)
 
void invalidateCachedPredecessors ()
 
MemDepResult getPointerDependencyFrom (const AliasAnalysis::Location &Loc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst=0)
 
- Public Member Functions inherited from llvm::FunctionPass
 FunctionPass (char &pid)
 
PasscreatePrinterPass (raw_ostream &O, const std::string &Banner) const
 createPrinterPass - Get a function printer pass. More...
 
virtual void assignPassManager (PMStack &PMS, PassManagerType T)
 
virtual PassManagerType getPotentialPassManagerType () const
 Return what kind of Pass Manager can manage this pass. More...
 
- Public Member Functions inherited from llvm::Pass
 Pass (PassKind K, char &pid)
 
virtual ~Pass ()
 
PassKind getPassKind () const
 
virtual const char * getPassName () const
 
AnalysisID getPassID () const
 getPassID - Return the PassID number that corresponds to this pass. More...
 
virtual bool doInitialization (Module &)
 
virtual bool doFinalization (Module &)
 
virtual void print (raw_ostream &O, const Module *M) const
 
void dump () const
 
virtual void preparePassManager (PMStack &)
 Check if available pass managers are suitable for this pass or not. More...
 
void setResolver (AnalysisResolver *AR)
 
AnalysisResolvergetResolver () const
 
virtual void * getAdjustedAnalysisPointer (AnalysisID ID)
 
virtual ImmutablePassgetAsImmutablePass ()
 
virtual PMDataManagergetAsPMDataManager ()
 
virtual void verifyAnalysis () const
 
virtual void dumpPassStructure (unsigned Offset=0)
 
template<typename AnalysisType >
AnalysisType * getAnalysisIfAvailable () const
 
bool mustPreserveAnalysisID (char &AID) const
 
template<typename AnalysisType >
AnalysisType & getAnalysis () const
 
template<typename AnalysisType >
AnalysisType & getAnalysis (Function &F)
 
template<typename AnalysisType >
AnalysisType & getAnalysisID (AnalysisID PI) const
 
template<typename AnalysisType >
AnalysisType & getAnalysisID (AnalysisID PI, Function &F)
 

Static Public Member Functions

static unsigned getLoadLoadClobberFullWidthSize (const Value *MemLocBase, int64_t MemLocOffs, unsigned MemLocSize, const LoadInst *LI, const DataLayout &TD)
 
- Static Public Member Functions inherited from llvm::Pass
static const PassInfolookupPassInfo (const void *TI)
 
static const PassInfolookupPassInfo (StringRef Arg)
 
static PasscreatePass (AnalysisID ID)
 

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 257 of file MemoryDependenceAnalysis.h.

Member Typedef Documentation

Definition at line 263 of file MemoryDependenceAnalysis.h.

Constructor & Destructor Documentation

Memory Dependence true MemoryDependenceAnalysis::MemoryDependenceAnalysis ( )
MemoryDependenceAnalysis::~MemoryDependenceAnalysis ( )

Definition at line 65 of file MemoryDependenceAnalysis.cpp.

Member Function Documentation

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 83 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 546 of file MemoryDependenceAnalysis.cpp.

References llvm::BasicBlock::begin(), llvm::Function::getEntryBlock(), llvm::MemDepResult::getInst(), GetLocation(), llvm::MemDepResult::getNonFuncLocal(), llvm::MemDepResult::getNonLocal(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), getPointerDependencyFrom(), llvm::MemDepResult::getUnknown(), I, llvm::Intrinsic::lifetime_start, llvm::AliasAnalysis::Mod, llvm::AliasAnalysis::onlyReadsMemory(), llvm::AliasAnalysis::Location::Ptr, and RemoveFromReverseMap().

Referenced by getNonLocalCallDependency().

unsigned MemoryDependenceAnalysis::getLoadLoadClobberFullWidthSize ( const Value MemLocBase,
int64_t  MemLocOffs,
unsigned  MemLocSize,
const LoadInst LI,
const DataLayout TD 
)
static

getLoadLoadClobberFullWidthSize - This is a little bit of analysis that looks at a memory location for a load (specified by MemLocBase, Offs, and Size) and compares it against a load. If the specified load could be safely widened to a larger integer load that is 1) still efficient, 2) safe for the target, and 3) would provide the specified memory location value, then this function returns the size in bytes of the load width to use. If not, this returns zero.

Definition at line 281 of file MemoryDependenceAnalysis.cpp.

References llvm::DataLayout::fitsInLegalInteger(), llvm::LoadInst::getAlignment(), llvm::Function::getAttributes(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GetPointerBaseWithConstantOffset(), llvm::LoadInst::getPointerOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::LoadInst::isSimple(), llvm::NextPowerOf2(), llvm::Attribute::SanitizeAddress, and llvm::Attribute::SanitizeThread.

Referenced by AnalyzeLoadFromClobberingLoad(), and isLoadLoadClobberIfExtendedToFullWidth().

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.

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 629 of file MemoryDependenceAnalysis.cpp.

References AssertSorted(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::BasicBlock::begin(), DEBUG, llvm::SmallVectorBase::empty(), llvm::BasicBlock::end(), getDependency(), llvm::Function::getEntryBlock(), llvm::MemDepResult::getInst(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::MemDepResult::getNonFuncLocal(), llvm::MemDepResult::getNonLocal(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::NonLocalDepEntry::getResult(), I, llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::MemDepResult::isNonLocal(), llvm::AliasAnalysis::onlyReadsMemory(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::prior(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), RemoveFromReverseMap(), llvm::NonLocalDepEntry::setResult(), and llvm::SmallPtrSetImpl::size().

void MemoryDependenceAnalysis::getNonLocalPointerDependency ( const AliasAnalysis::Location Loc,
bool  isLoad,
BasicBlock FromBB,
SmallVectorImpl< NonLocalDepResult > &  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 767 of file MemoryDependenceAnalysis.cpp.

References llvm::SmallVectorImpl< T >::clear(), llvm::Value::getType(), llvm::MemDepResult::getUnknown(), llvm::Type::isPointerTy(), llvm::AliasAnalysis::Location::Ptr, and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

MemDepResult MemoryDependenceAnalysis::getPointerDependencyFrom ( const AliasAnalysis::Location MemLoc,
bool  isLoad,
BasicBlock::iterator  ScanIt,
BasicBlock BB,
Instruction QueryInst = 0 
)

getPointerDependencyFrom - Return the instruction on which a memory location depends. If isLoad is true, this routine ignores may-aliases with read-only operations. If isLoad is false, this routine ignores may-aliases with reads from read-only locations. If possible, pass the query instruction as well; this function may take advantage of the metadata annotated to the query instruction to refine the result.

Note that this is an uncached query, and thus may be inefficient.

getPointerDependencyFrom - Return the instruction on which a memory location depends. If isLoad is true, this routine ignores may-aliases with read-only operations. If isLoad is false, this routine ignores may-aliases with reads from read-only locations. If possible, pass the query instruction as well; this function may take advantage of the metadata annotated to the query instruction to refine the result.

Definition at line 358 of file MemoryDependenceAnalysis.cpp.

References llvm::AliasAnalysis::alias(), llvm::BasicBlock::begin(), BlockScanLimit, llvm::AliasAnalysis::callCapturesBefore(), llvm::dyn_cast(), llvm::MemDepResult::getClobber(), llvm::MemDepResult::getDef(), llvm::Function::getEntryBlock(), llvm::AliasAnalysis::getLocation(), llvm::Instruction::getMetadata(), llvm::AliasAnalysis::getModRefInfo(), llvm::MemDepResult::getNonFuncLocal(), llvm::MemDepResult::getNonLocal(), llvm::BasicBlock::getParent(), llvm::AliasAnalysis::getTargetLibraryInfo(), llvm::GetUnderlyingObject(), llvm::MemDepResult::getUnknown(), llvm::isCallocLikeFn(), isLoadLoadClobberIfExtendedToFullWidth(), llvm::isMallocLikeFn(), llvm::AliasAnalysis::isMustAlias(), llvm::isNoAliasFn(), LI, llvm::Intrinsic::lifetime_start, llvm::LLVMContext::MD_invariant_load, llvm::AliasAnalysis::ModRef, llvm::AliasAnalysis::MustAlias, llvm::AliasAnalysis::NoAlias, llvm::AliasAnalysis::NoModRef, llvm::AliasAnalysis::PartialAlias, llvm::AliasAnalysis::pointsToConstantMemory(), llvm::AliasAnalysis::Location::Ptr, and llvm::AliasAnalysis::Ref.

Referenced by getDependency().

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.

Definition at line 1297 of file MemoryDependenceAnalysis.cpp.

References llvm::Value::getType(), and llvm::Type::isPointerTy().

void MemoryDependenceAnalysis::invalidateCachedPredecessors ( )

invalidateCachedPredecessors - Clear the PredIteratorCache info. This needs to be done when the CFG changes, e.g., due to splitting critical edges.

Definition at line 1309 of file MemoryDependenceAnalysis.cpp.

void MemoryDependenceAnalysis::releaseMemory ( )
virtual

Clean up memory in between runs.

Reimplemented from llvm::Pass.

Definition at line 69 of file MemoryDependenceAnalysis.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear().

void MemoryDependenceAnalysis::removeInstruction ( Instruction RemInst)
bool MemoryDependenceAnalysis::runOnFunction ( Function )
virtual

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

Implements llvm::FunctionPass.

Definition at line 88 of file MemoryDependenceAnalysis.cpp.

Member Data Documentation

char MemoryDependenceAnalysis::ID = 0
static

Definition at line 332 of file MemoryDependenceAnalysis.h.


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