LLVM 20.0.0git
|
Encapsulates MemorySSA, including all data associated with memory accesses. More...
#include "llvm/Analysis/MemorySSA.h"
Classes | |
class | CachingWalker |
A MemorySSAWalker that does AA walks to disambiguate accesses. More... | |
class | ClobberWalkerBase |
class | OptimizeUses |
This class is a batch walker of all MemoryUse's in the program, and points their defining access at the thing that actually clobbers them. More... | |
class | SkipSelfWalker |
Public Types | |
enum class | VerificationLevel { Fast , Full } |
enum | InsertionPlace { Beginning , End , BeforeTerminator } |
Used in various insertion functions to specify whether we are talking about the beginning or end of a block. More... | |
using | AccessList = iplist< MemoryAccess, ilist_tag< MSSAHelpers::AllAccessTag > > |
using | DefsList = simple_ilist< MemoryAccess, ilist_tag< MSSAHelpers::DefsOnlyTag > > |
Protected Member Functions | |
template<typename IterT > | |
void | verifyOrderingDominationAndDefUses (IterT Blocks, VerificationLevel=VerificationLevel::Fast) const |
Verify ordering: the order and existence of MemoryAccesses matches the order and existence of memory affecting instructions. | |
template<typename IterT > | |
void | verifyDominationNumbers (IterT Blocks) const |
Verify that all of the blocks we believe to have valid domination numbers actually have valid domination numbers. | |
template<typename IterT > | |
void | verifyPrevDefInPhis (IterT Blocks) const |
AccessList * | getWritableBlockAccesses (const BasicBlock *BB) const |
DefsList * | getWritableBlockDefs (const BasicBlock *BB) const |
void | moveTo (MemoryUseOrDef *What, BasicBlock *BB, AccessList::iterator Where) |
void | moveTo (MemoryAccess *What, BasicBlock *BB, InsertionPlace Point) |
void | renamePass (BasicBlock *BB, MemoryAccess *IncomingVal, SmallPtrSetImpl< BasicBlock * > &Visited) |
void | removeFromLookups (MemoryAccess *) |
Properly remove MA from all of MemorySSA's lookup tables. | |
void | removeFromLists (MemoryAccess *, bool ShouldDelete=true) |
Properly remove MA from all of MemorySSA's lists. | |
void | insertIntoListsForBlock (MemoryAccess *, const BasicBlock *, InsertionPlace) |
void | insertIntoListsBefore (MemoryAccess *, const BasicBlock *, AccessList::iterator) |
MemoryUseOrDef * | createDefinedAccess (Instruction *, MemoryAccess *, const MemoryUseOrDef *Template=nullptr, bool CreationMustSucceed=true) |
Friends | |
class | MemorySSAUpdater |
Encapsulates MemorySSA, including all data associated with memory accesses.
Definition at line 701 of file MemorySSA.h.
Definition at line 752 of file MemorySSA.h.
Definition at line 753 of file MemorySSA.h.
Used in various insertion functions to specify whether we are talking about the beginning or end of a block.
Enumerator | |
---|---|
Beginning | |
End | |
BeforeTerminator |
Definition at line 790 of file MemorySSA.h.
|
strong |
Enumerator | |
---|---|
Fast | |
Full |
Definition at line 783 of file MemorySSA.h.
MemorySSA::MemorySSA | ( | Function & | Func, |
AliasAnalysis * | AA, | ||
DominatorTree * | DT | ||
) |
Definition at line 1233 of file MemorySSA.cpp.
References assert(), llvm::Function::begin(), llvm::Function::end(), and getWalker().
MemorySSA::MemorySSA | ( | Loop & | L, |
AliasAnalysis * | AA, | ||
DominatorTree * | DT | ||
) |
Definition at line 1251 of file MemorySSA.cpp.
References assert(), getWalker(), and llvm::map_range().
|
delete |
MemorySSA::~MemorySSA | ( | ) |
Definition at line 1272 of file MemorySSA.cpp.
References llvm::User::dropAllReferences().
|
protected |
Definition at line 1725 of file MemorySSA.cpp.
References assert(), I, llvm::MemoryUseOrDef::setDefiningAccess(), and Template.
Referenced by llvm::MemorySSAUpdater::createMemoryAccessAfter(), llvm::MemorySSAUpdater::createMemoryAccessBefore(), and llvm::MemorySSAUpdater::createMemoryAccessInBB().
bool MemorySSA::dominates | ( | const MemoryAccess * | A, |
const MemoryAccess * | B | ||
) | const |
Given two memory accesses in potentially different blocks, determine whether MemoryAccess A
dominates MemoryAccess B
.
Definition at line 2173 of file MemorySSA.cpp.
References llvm::DominatorTree::dominates(), llvm::MemoryAccess::getBlock(), isLiveOnEntryDef(), and locallyDominates().
Referenced by llvm::canSinkOrHoistInst(), checkClobberSanity(), dominates(), getMatchingValue(), verifyOrderingDominationAndDefUses(), and writtenBetween().
bool MemorySSA::dominates | ( | const MemoryAccess * | A, |
const Use & | B | ||
) | const |
Given a MemoryAccess and a Use, determine whether MemoryAccess A
dominates Use B
.
Definition at line 2186 of file MemorySSA.cpp.
References llvm::DominatorTree::dominates(), dominates(), llvm::MemoryAccess::getBlock(), llvm::Use::getUser(), and locallyDominates().
LLVM_DUMP_METHOD void MemorySSA::dump | ( | ) | const |
Definition at line 1902 of file MemorySSA.cpp.
References llvm::dbgs(), and print().
void MemorySSA::ensureOptimizedUses | ( | ) |
By default, uses are not optimized during MemorySSA construction.
Calling this method will attempt to optimize all MemoryUses, if this has not happened yet for this MemorySSA instance. This should be done if you plan to query the clobbering access for most uses, or if you walk the def-use chain of uses.
Definition at line 2200 of file MemorySSA.cpp.
References llvm::MemorySSA::OptimizeUses::optimizeUses().
Referenced by llvm::GVNHoist::GVNHoist(), and llvm::MemorySSAPrinterPass::run().
|
inline |
Definition at line 799 of file MemorySSA.h.
Referenced by llvm::MemorySSAWalker::getClobberingMemoryAccess(), pointerInvalidatedByLoop(), and usersDominator().
|
inline |
Return the list of MemoryAccess's for a given basic block.
This list is not modifiable by the user.
Definition at line 759 of file MemorySSA.h.
Referenced by llvm::canSinkOrHoistInst(), foreachMemoryAccess(), llvm::MemorySSAUpdater::moveAllAfterSpliceBlocks(), llvm::SinkAndHoistLICMFlags::SinkAndHoistLICMFlags(), verifyDominationNumbers(), and verifyOrderingDominationAndDefUses().
|
inline |
Return the list of MemoryDef's and MemoryPhi's for a given basic block.
This list is not modifiable by the user.
Definition at line 767 of file MemorySSA.h.
Referenced by llvm::MemorySSAUpdater::insertUse(), pointerInvalidatedByBlock(), unswitchAllTrivialConditions(), verifyOrderingDominationAndDefUses(), and verifyPrevDefInPhis().
|
inline |
Definition at line 727 of file MemorySSA.h.
Referenced by checkClobberSanity(), and llvm::MemorySSA::ClobberWalkerBase::getClobberingMemoryAccessBase().
|
inline |
Definition at line 743 of file MemorySSA.h.
Referenced by llvm::MemorySSA::ClobberWalkerBase::getClobberingMemoryAccessBase(), llvm::MemorySSAUpdater::insertDef(), and llvm::MemorySSA::OptimizeUses::optimizeUses().
|
inline |
Definition at line 723 of file MemorySSA.h.
|
inline |
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
If passed a basic block gets the memory phi node that exists for that block, if there is one. Otherwise, this will get a MemoryUseOrDef.
Definition at line 719 of file MemorySSA.h.
References I.
Referenced by buildPartialInvariantUnswitchConditionalBranch(), llvm::canSinkOrHoistInst(), llvm::MemorySSAUpdater::changeToUnreachable(), cloneInstructionInExitBlock(), llvm::MemorySSAWalker::getClobberingMemoryAccess(), llvm::MemorySSA::ClobberWalkerBase::getClobberingMemoryAccessBase(), getMatchingValue(), getNewDefiningAccessForClone(), llvm::hasPartialIVCondition(), llvm::MemorySSAUpdater::insertDef(), llvm::Loop::makeLoopInvariant(), llvm::MergeBlockIntoPredecessor(), llvm::MemorySSAUpdater::moveAllAfterMergeBlocks(), llvm::MemorySSAUpdater::moveAllAfterSpliceBlocks(), moveInstructionBefore(), llvm::MemorySSAUpdater::moveToPlace(), llvm::MemorySSAUpdater::removeBlocks(), llvm::MemorySSAUpdater::removeDuplicatePhiEdgesBetween(), llvm::MemorySSAUpdater::removeEdge(), llvm::MemorySSAUpdater::removeMemoryAccess(), runMoveAutoInit(), simplifyLoopInst(), sinkInstruction(), turnGuardIntoBranch(), llvm::MemorySSAUpdater::updateForClonedBlockIntoPred(), llvm::MemorySSAUpdater::updateForClonedLoop(), llvm::MemorySSAUpdater::updatePhisWhenInsertingUniqueBackedgeBlock(), usersDominator(), verifyOrderingDominationAndDefUses(), verifyPrevDefInPhis(), and llvm::MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor().
MemorySSAWalker * MemorySSA::getSkipSelfWalker | ( | ) |
Definition at line 1603 of file MemorySSA.cpp.
Referenced by getClobberingMemoryAccess().
MemorySSAWalker * MemorySSA::getWalker | ( | ) |
Definition at line 1590 of file MemorySSA.cpp.
Referenced by getMatchingValue(), llvm::AMDGPU::isClobberedInFunction(), MemorySSA(), removeFromLookups(), and writtenBetween().
|
inlineprotected |
Definition at line 812 of file MemorySSA.h.
Referenced by insertIntoListsBefore(), llvm::MemorySSAUpdater::removeBlocks(), llvm::MemorySSAUpdater::updateForClonedLoop(), and llvm::MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor().
|
inlineprotected |
Definition at line 818 of file MemorySSA.h.
References llvm::simple_ilist< T, Options >::end().
Referenced by llvm::MemorySSAUpdater::insertDef(), and llvm::MemorySSAUpdater::insertUse().
|
protected |
Definition at line 1650 of file MemorySSA.cpp.
References getWritableBlockAccesses().
Referenced by llvm::MemorySSAUpdater::createMemoryAccessAfter(), llvm::MemorySSAUpdater::createMemoryAccessBefore(), and moveTo().
|
protected |
Definition at line 1618 of file MemorySSA.cpp.
References Beginning, and llvm::find_if_not().
Referenced by llvm::MemorySSAUpdater::createMemoryAccessInBB(), and moveTo().
|
inline |
Return true if MA
represents the live on entry value.
Loads and stores from pointer arguments and other global values may be defined by memory operations that do not occur in the current function, so they may be live on entry to the function. MemorySSA represents such memory state by the live on entry definition, which is guaranteed to occur before any other memory access in the function.
Definition at line 739 of file MemorySSA.h.
Referenced by llvm::canSinkOrHoistInst(), checkClobberSanity(), dominates(), llvm::MemorySSA::ClobberWalkerBase::getClobberingMemoryAccessBase(), getNewDefiningAccessForClone(), hasUndefContents(), llvm::AMDGPU::isClobberedInFunction(), locallyDominates(), pointerInvalidatedByLoop(), and llvm::MemorySSAUpdater::removeMemoryAccess().
bool MemorySSA::locallyDominates | ( | const MemoryAccess * | Dominator, |
const MemoryAccess * | Dominatee | ||
) | const |
Given two memory accesses in the same basic block, determine whether MemoryAccess A
dominates MemoryAccess B
.
Determine, for two memory accesses in the same block, whether Dominator
dominates Dominatee
.
Dominator
dominates Dominatee
. Definition at line 2142 of file MemorySSA.cpp.
References assert(), llvm::MemoryAccess::getBlock(), and isLiveOnEntryDef().
Referenced by dominates(), and pointerInvalidatedByBlock().
|
protected |
Definition at line 1700 of file MemorySSA.cpp.
References assert(), Beginning, llvm::MemoryAccess::getBlock(), and insertIntoListsForBlock().
|
protected |
Definition at line 1694 of file MemorySSA.cpp.
References insertIntoListsBefore().
Referenced by llvm::MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor().
void MemorySSA::print | ( | raw_ostream & | OS | ) | const |
Definition at line 1893 of file MemorySSA.cpp.
References F, llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::BasicBlock::getParent(), and OS.
Referenced by llvm::MemoryAccess::dump(), dump(), llvm::MemoryAccess::print(), llvm::MemorySSAWrapperPass::print(), and llvm::MemorySSAPrinterPass::run().
|
protected |
Properly remove MA
from all of MemorySSA's lists.
Because of the way the intrusive list and use lists work, it is important to do removal in the right order. ShouldDelete defaults to true, and will cause the memory access to also be deleted, not just removed.
Definition at line 1866 of file MemorySSA.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), and llvm::MemoryAccess::getBlock().
Referenced by llvm::MemorySSAUpdater::removeBlocks(), and llvm::MemorySSAUpdater::removeMemoryAccess().
|
protected |
Properly remove MA
from all of MemorySSA's lookup tables.
Definition at line 1839 of file MemorySSA.cpp.
References assert(), llvm::MemoryAccess::getBlock(), llvm::MemoryUseOrDef::getMemoryInst(), getWalker(), llvm::MemorySSAWalker::invalidateInfo(), llvm::MemoryUseOrDef::setDefiningAccess(), and llvm::Value::use_empty().
Referenced by llvm::MemorySSAUpdater::removeBlocks(), and llvm::MemorySSAUpdater::removeMemoryAccess().
|
inlineprotected |
Definition at line 831 of file MemorySSA.h.
Referenced by llvm::MemorySSAUpdater::insertDef(), and llvm::MemorySSAUpdater::insertUse().
|
protected |
Verify that all of the blocks we believe to have valid domination numbers actually have valid domination numbers.
Definition at line 1979 of file MemorySSA.cpp.
References assert(), Blocks, llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallPtrSetImplBase::empty(), llvm::SmallPtrSetImpl< PtrType >::erase(), and getBlockAccesses().
Referenced by verifyMemorySSA().
void MemorySSA::verifyMemorySSA | ( | VerificationLevel | VL = VerificationLevel::Fast | ) | const |
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right places).
This is used by unit tests.
Definition at line 1905 of file MemorySSA.cpp.
References assert(), llvm::Function::begin(), llvm::LoopBase< BlockT, LoopT >::blocks(), Blocks, llvm::Function::end(), Full, llvm::map_range(), verifyDominationNumbers(), verifyOrderingDominationAndDefUses(), and verifyPrevDefInPhis().
Referenced by llvm::deleteDeadLoop(), llvm::hoistRegion(), injectPendingInvariantConditions(), mergeBlocksIntoPredecessors(), llvm::promoteLoopAccessesToScalars(), llvm::FunctionToLoopPassAdaptor::run(), llvm::LoopInstSimplifyPass::run(), llvm::LoopRotatePass::run(), llvm::SimpleLoopUnswitchPass::run(), llvm::LoopFlattenPass::run(), llvm::MemCpyOptPass::runImpl(), runMoveAutoInit(), simplifyLoopInst(), simplifyOneLoop(), llvm::sinkRegion(), llvm::splitBlockBefore(), turnGuardIntoBranch(), turnSelectIntoBranch(), unswitchNontrivialInvariants(), unswitchTrivialBranch(), unswitchTrivialSwitch(), and llvm::MemorySSAWrapperPass::verifyAnalysis().
|
protected |
Verify ordering: the order and existence of MemoryAccesses matches the order and existence of memory affecting instructions.
Verify domination: each definition dominates all of its uses. Verify def-uses: the immediate use information - walk all the memory accesses and verifying that, for each use, it appears in the appropriate def's use list
Definition at line 2021 of file MemorySSA.cpp.
References assert(), B, llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::MachineBasicBlock::begin(), Blocks, llvm::SmallVectorImpl< T >::clear(), DL, dominates(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::MachineBasicBlock::end(), Full, getBlockAccesses(), getBlockDefs(), llvm::MemoryUseOrDef::getDefiningAccess(), getMemoryAccess(), I, llvm::is_contained(), llvm::pred_size(), llvm::predecessors(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), llvm::MachineBasicBlock::size(), and llvm::Value::uses().
Referenced by verifyMemorySSA().
|
protected |
Definition at line 1942 of file MemorySSA.cpp.
References assert(), Blocks, getBlockDefs(), getMemoryAccess(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), and I.
Referenced by verifyMemorySSA().
|
friend |
Definition at line 803 of file MemorySSA.h.