LLVM API Documentation
#include <MemoryDependenceAnalysis.h>
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 NonLocalDepInfo & | getNonLocalCallDependency (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) |
![]() | |
FunctionPass (char &pid) | |
Pass * | createPrinterPass (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... | |
![]() | |
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) |
AnalysisResolver * | getResolver () const |
virtual void * | getAdjustedAnalysisPointer (AnalysisID ID) |
virtual ImmutablePass * | getAsImmutablePass () |
virtual PMDataManager * | getAsPMDataManager () |
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 const PassInfo * | lookupPassInfo (const void *TI) |
static const PassInfo * | lookupPassInfo (StringRef Arg) |
static Pass * | createPass (AnalysisID ID) |
Static Public Attributes | |
static char | ID = 0 |
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.
typedef std::vector<NonLocalDepEntry> llvm::MemoryDependenceAnalysis::NonLocalDepInfo |
Definition at line 263 of file MemoryDependenceAnalysis.h.
Memory Dependence true MemoryDependenceAnalysis::MemoryDependenceAnalysis | ( | ) |
Definition at line 61 of file MemoryDependenceAnalysis.cpp.
References llvm::PassRegistry::getPassRegistry(), and llvm::initializeMemoryDependenceAnalysisPass().
MemoryDependenceAnalysis::~MemoryDependenceAnalysis | ( | ) |
Definition at line 65 of file MemoryDependenceAnalysis.cpp.
|
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().
|
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.
|
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 | ) |
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 1316 of file MemoryDependenceAnalysis.cpp.
References llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallPtrSet< PtrType, SmallSize >::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::count(), llvm::X86II::DE, DEBUG, llvm::AliasAnalysis::deleteValue(), llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImpl::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::SmallPtrSet< PtrType, SmallSize >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), llvm::MemDepResult::getInst(), llvm::PointerIntPair< PointerTy, IntBits, IntType, PtrTraits >::getPointer(), llvm::Value::getType(), I, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::insert(), llvm::Type::isPointerTy(), llvm::Instruction::isTerminator(), P, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and RemoveFromReverseMap().
Referenced by DeleteDeadInstruction(), and llvm::FoldSingleEntryPHINodes().
Pass Implementation stuff. This doesn't do any analysis eagerly.
Implements llvm::FunctionPass.
Definition at line 88 of file MemoryDependenceAnalysis.cpp.
|
static |
Definition at line 332 of file MemoryDependenceAnalysis.h.