LLVM API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes
llvm::MemoryDependenceAnalysis Class Reference

#include <MemoryDependenceAnalysis.h>

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

List of all members.

Classes

struct  NonLocalPointerInfo

Public Types

typedef std::vector
< NonLocalDepEntry
NonLocalDepInfo

Public Member Functions

 MemoryDependenceAnalysis ()
 ~MemoryDependenceAnalysis ()
bool runOnFunction (Function &) override
 Pass Implementation stuff. This doesn't do any analysis eagerly.
void releaseMemory () override
 Clean up memory in between runs.
void getAnalysisUsage (AnalysisUsage &AU) const override
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=nullptr)

Static Public Member Functions

static unsigned getLoadLoadClobberFullWidthSize (const Value *MemLocBase, int64_t MemLocOffs, unsigned MemLocSize, const LoadInst *LI, const DataLayout &DL)

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

Definition at line 68 of file MemoryDependenceAnalysis.cpp.


Member Function Documentation

void MemoryDependenceAnalysis::getAnalysisUsage ( AnalysisUsage AU) const [override, 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 86 of file MemoryDependenceAnalysis.cpp.

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

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 638 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::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 DL 
) [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 292 of file MemoryDependenceAnalysis.cpp.

References llvm::DataLayout::fitsInLegalInteger(), llvm::AttributeSet::FunctionIndex, 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().

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 721 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::SmallPtrSetImpl< PtrType >::insert(), llvm::MemDepResult::isNonLocal(), llvm::AliasAnalysis::onlyReadsMemory(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), RemoveFromReverseMap(), llvm::NonLocalDepEntry::setResult(), and llvm::SmallPtrSetImplBase::size().

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 859 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().

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

References llvm::AliasAnalysis::alias(), llvm::BasicBlock::begin(), BlockScanLimit, llvm::AliasAnalysis::callCapturesBefore(), llvm::dyn_cast(), llvm::MemDepResult::getClobber(), llvm::MemDepResult::getDef(), 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::isAtLeastAcquire(), llvm::isAtLeastRelease(), llvm::isCallocLikeFn(), isLoadLoadClobberIfExtendedToFullWidth(), llvm::isMallocLikeFn(), llvm::AliasAnalysis::isMustAlias(), llvm::isNoAliasFn(), LI, llvm::Instruction::mayReadOrWriteMemory(), 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().

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

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

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

Definition at line 1401 of file MemoryDependenceAnalysis.cpp.

void MemoryDependenceAnalysis::releaseMemory ( ) [override, virtual]

Clean up memory in between runs.

Reimplemented from llvm::Pass.

Definition at line 72 of file MemoryDependenceAnalysis.cpp.

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

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

Implements llvm::FunctionPass.

Definition at line 92 of file MemoryDependenceAnalysis.cpp.

References llvm::DominatorTreeWrapperPass::getDomTree().


Member Data Documentation

char MemoryDependenceAnalysis::ID = 0 [static]

Definition at line 335 of file MemoryDependenceAnalysis.h.


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