|
LLVM
3.7.0
|
MemoryDependenceAnalysis - This is an analysis that determines, for a given memory operation, what preceding memory operations it depends on. More...
#include <MemoryDependenceAnalysis.h>
Public Types | |
| typedef std::vector < NonLocalDepEntry > | NonLocalDepInfo |
Public Member Functions | |
| MemoryDependenceAnalysis () | |
| ~MemoryDependenceAnalysis () override | |
| bool | runOnFunction (Function &) override |
| Pass Implementation stuff. This doesn't do any analysis eagerly. More... | |
| void | releaseMemory () override |
| Clean up memory in between runs. More... | |
| void | getAnalysisUsage (AnalysisUsage &AU) const override |
| getAnalysisUsage - Does not modify anything. More... | |
| MemDepResult | getDependency (Instruction *QueryInst) |
| getDependency - Return the instruction on which a memory operation depends. More... | |
| const NonLocalDepInfo & | 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. More... | |
| void | getNonLocalPointerDependency (Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result) |
| getNonLocalPointerDependency - Perform a full dependency query for an access to the QueryInst's specified memory location, returning the set of instructions that either define or clobber the value. More... | |
| void | removeInstruction (Instruction *InstToRemove) |
| removeInstruction - Remove an instruction from the dependence analysis, updating the dependence of instructions that previously depended on it. More... | |
| void | invalidateCachedPointerInfo (Value *Ptr) |
| invalidateCachedPointerInfo - This method is used to invalidate cached information about the specified pointer, because it may be too conservative in memdep. More... | |
| void | invalidateCachedPredecessors () |
| invalidateCachedPredecessors - Clear the PredIteratorCache info. More... | |
| MemDepResult | getPointerDependencyFrom (const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst=nullptr) |
| getPointerDependencyFrom - Return the instruction on which a memory location depends. More... | |
Public Member Functions inherited from llvm::FunctionPass | |
| FunctionPass (char &pid) | |
| Pass * | createPrinterPass (raw_ostream &O, const std::string &Banner) const override |
| createPrinterPass - Get a function printer pass. More... | |
| void | assignPassManager (PMStack &PMS, PassManagerType T) override |
| Find appropriate Function Pass Manager or Call Graph Pass Manager in the PM Stack and add self into that manager. More... | |
| PassManagerType | getPotentialPassManagerType () const override |
| 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 |
| getPassName - Return a nice clean name for a pass. More... | |
| AnalysisID | getPassID () const |
| getPassID - Return the PassID number that corresponds to this pass. More... | |
| virtual bool | doInitialization (Module &) |
| doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run. More... | |
| virtual bool | doFinalization (Module &) |
| doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes have run. More... | |
| virtual void | print (raw_ostream &O, const Module *M) const |
| print - Print out the internal state of the pass. More... | |
| 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) |
| getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance. More... | |
| virtual ImmutablePass * | getAsImmutablePass () |
| virtual PMDataManager * | getAsPMDataManager () |
| virtual void | verifyAnalysis () const |
| verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis information. More... | |
| virtual void | dumpPassStructure (unsigned Offset=0) |
| template<typename AnalysisType > | |
| AnalysisType * | getAnalysisIfAvailable () const |
| getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information that might be around, for example to update it. More... | |
| bool | mustPreserveAnalysisID (char &AID) const |
| mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID. More... | |
| template<typename AnalysisType > | |
| AnalysisType & | getAnalysis () const |
| getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. More... | |
| template<typename AnalysisType > | |
| AnalysisType & | getAnalysis (Function &F) |
| getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function. More... | |
| 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) |
| 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. More... | |
Static Public Member Functions inherited from llvm::Pass | |
| 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 |
Additional Inherited Members | |
Protected Member Functions inherited from llvm::FunctionPass | |
| bool | skipOptnoneFunction (const Function &F) const |
| skipOptnoneFunction - This function has Attribute::OptimizeNone and most transformation passes should skip it. More... | |
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 67 of file MemoryDependenceAnalysis.cpp.
References llvm::PassRegistry::getPassRegistry(), and llvm::initializeMemoryDependenceAnalysisPass().
|
override |
Definition at line 71 of file MemoryDependenceAnalysis.cpp.
|
overridevirtual |
getAnalysisUsage - Does not modify anything.
It uses Value Numbering and Alias Analysis.
It uses Alias Analysis.
Reimplemented from llvm::Pass.
Definition at line 87 of file MemoryDependenceAnalysis.cpp.
References llvm::AnalysisUsage::addRequired(), 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.
Definition at line 649 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::Mod, llvm::AliasAnalysis::onlyReadsMemory(), llvm::MemoryLocation::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 282 of file MemoryDependenceAnalysis.cpp.
References llvm::DL, llvm::DataLayout::fitsInLegalInteger(), llvm::LoadInst::getAlignment(), llvm::Module::getDataLayout(), llvm::Instruction::getModule(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GetPointerBaseWithConstantOffset(), llvm::LoadInst::getPointerOperand(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Function::hasFnAttribute(), 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 732 of file MemoryDependenceAnalysis.cpp.
References AssertSorted(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::BasicBlock::begin(), DEBUG, llvm::SmallVectorBase::empty(), llvm::BasicBlock::end(), llvm::PredIteratorCache::get(), getDependency(), llvm::Function::getEntryBlock(), llvm::MemDepResult::getInst(), llvm::CallSiteBase< FunTy, BBTy, 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().
| void MemoryDependenceAnalysis::getNonLocalPointerDependency | ( | Instruction * | QueryInst, |
| SmallVectorImpl< NonLocalDepResult > & | Result | ||
| ) |
getNonLocalPointerDependency - Perform a full dependency query for an access to the QueryInst's specified memory location, returning the set of instructions that either define or clobber the value.
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.
Warning: For a volatile query instruction, the dependencies will be accurate, and thus usable for reordering, but it is never legal to remove the query instruction.
This method assumes the pointer has a "NonLocal" dependency within QueryInst's parent basic block.
This method assumes the pointer has a "NonLocal" dependency within its own block.
Definition at line 870 of file MemoryDependenceAnalysis.cpp.
References llvm::dwarf::syntax::Address, llvm::SmallVectorImpl< T >::clear(), llvm::DL, llvm::MemoryLocation::get(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::MemDepResult::getUnknown(), llvm::Type::isPointerTy(), isVolatile(), llvm::MemoryLocation::Ptr, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::SI.
| MemDepResult MemoryDependenceAnalysis::getPointerDependencyFrom | ( | const MemoryLocation & | MemLoc, |
| bool | isLoad, | ||
| BasicBlock::iterator | ScanIt, | ||
| BasicBlock * | BB, | ||
| Instruction * | QueryInst = nullptr |
||
| ) |
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.
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 370 of file MemoryDependenceAnalysis.cpp.
References llvm::AliasAnalysis::alias(), llvm::BasicBlock::begin(), BlockScanLimit, llvm::AliasAnalysis::callCapturesBefore(), llvm::DL, llvm::dyn_cast(), llvm::MemoryLocation::get(), llvm::MemDepResult::getClobber(), llvm::Module::getDataLayout(), llvm::MemDepResult::getDef(), llvm::Function::getEntryBlock(), llvm::Instruction::getMetadata(), llvm::AliasAnalysis::getModRefInfo(), llvm::BasicBlock::getModule(), 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(), isVolatile(), llvm::Instruction::mayReadOrWriteMemory(), llvm::LLVMContext::MD_invariant_load, llvm::AliasAnalysis::ModRef, llvm::Monotonic, llvm::MustAlias, llvm::NoAlias, llvm::AliasAnalysis::NoModRef, llvm::PartialAlias, llvm::AliasAnalysis::pointsToConstantMemory(), llvm::MemoryLocation::Ptr, llvm::AliasAnalysis::Ref, llvm::SI, and llvm::Unordered.
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 1443 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 1455 of file MemoryDependenceAnalysis.cpp.
References llvm::PredIteratorCache::clear().
Referenced by llvm::MergeBlockIntoPredecessor().
|
overridevirtual |
Clean up memory in between runs.
Reimplemented from llvm::Pass.
Definition at line 75 of file MemoryDependenceAnalysis.cpp.
References llvm::PredIteratorCache::clear(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear().
| void MemoryDependenceAnalysis::removeInstruction | ( | Instruction * | RemInst | ) |
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 1462 of file MemoryDependenceAnalysis.cpp.
References llvm::SmallVectorTemplateCommon< T >::back(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), DEBUG, llvm::AliasAnalysis::deleteValue(), llvm::DI, llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MemDepResult::getInst(), llvm::PointerIntPair< PointerTy, IntBits, IntType, PtrTraits >::getPointer(), llvm::Value::getType(), I, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::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 93 of file MemoryDependenceAnalysis.cpp.
References llvm::DominatorTreeWrapperPass::getDomTree().
|
static |
Definition at line 334 of file MemoryDependenceAnalysis.h.
1.8.6