|
LLVM
10.0.0
|
Encapsulates MemorySSA, including all data associated with memory accesses. More...
#include "llvm/Analysis/MemorySSA.h"
Classes | |
| 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... | |
Public Types | |
| 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 > > |
Public Member Functions | |
| MemorySSA (Function &, AliasAnalysis *, DominatorTree *) | |
| MemorySSA (MemorySSA &&)=delete | |
| ~MemorySSA () | |
| MemorySSAWalker * | getWalker () |
| MemorySSAWalker * | getSkipSelfWalker () |
| MemoryUseOrDef * | getMemoryAccess (const Instruction *I) const |
| Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it. More... | |
| MemoryPhi * | getMemoryAccess (const BasicBlock *BB) const |
| void | dump () const |
| void | print (raw_ostream &) const |
| bool | isLiveOnEntryDef (const MemoryAccess *MA) const |
Return true if MA represents the live on entry value. More... | |
| MemoryAccess * | getLiveOnEntryDef () const |
| const AccessList * | getBlockAccesses (const BasicBlock *BB) const |
| Return the list of MemoryAccess's for a given basic block. More... | |
| const DefsList * | getBlockDefs (const BasicBlock *BB) const |
| Return the list of MemoryDef's and MemoryPhi's for a given basic block. More... | |
| bool | locallyDominates (const MemoryAccess *A, const MemoryAccess *B) const |
Given two memory accesses in the same basic block, determine whether MemoryAccess A dominates MemoryAccess B. More... | |
| bool | dominates (const MemoryAccess *A, const MemoryAccess *B) const |
Given two memory accesses in potentially different blocks, determine whether MemoryAccess A dominates MemoryAccess B. More... | |
| bool | dominates (const MemoryAccess *A, const Use &B) const |
Given a MemoryAccess and a Use, determine whether MemoryAccess A dominates Use B. More... | |
| void | verifyMemorySSA () const |
| Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right places). More... | |
Friends | |
| class | MemorySSAAnnotatedWriter |
| class | MemorySSAPrinterLegacyPass |
| class | MemorySSAUpdater |
Encapsulates MemorySSA, including all data associated with memory accesses.
Definition at line 704 of file MemorySSA.h.
Definition at line 752 of file MemorySSA.h.
Definition at line 754 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 789 of file MemorySSA.h.
| MemorySSA::MemorySSA | ( | Function & | Func, |
| AliasAnalysis * | AA, | ||
| DominatorTree * | DT | ||
| ) |
Definition at line 1225 of file MemorySSA.cpp.
References assert(), and getWalker().
|
delete |
| MemorySSA::~MemorySSA | ( | ) |
Definition at line 1243 of file MemorySSA.cpp.
References llvm::User::dropAllReferences(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert().
|
protected |
Definition at line 1702 of file MemorySSA.cpp.
References assert(), and llvm::MemoryUseOrDef::setDefiningAccess().
Referenced by getNewDefiningAccessForClone().
| 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 2120 of file MemorySSA.cpp.
References llvm::MemoryAccess::getBlock(), isLiveOnEntryDef(), and locallyDominates().
Referenced by llvm::canSinkOrHoistInst(), dominates(), llvm::MemorySSAUpdater::insertDef(), and verifyOrderingDominationAndDefUses().
| 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 2133 of file MemorySSA.cpp.
References dominates(), llvm::MemoryAccess::getBlock(), llvm::Use::getUser(), and locallyDominates().
| LLVM_DUMP_METHOD void MemorySSA::dump | ( | ) | const |
Definition at line 1869 of file MemorySSA.cpp.
References llvm::dbgs(), and print().
|
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(), llvm::createLICMPass(), getNewDefiningAccessForClone(), isLoadInvariantInLoop(), llvm::GVNHoist::rank(), 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.
References B.
Referenced by getNewDefiningAccessForClone(), llvm::MemorySSAUpdater::insertDef(), llvm::MemorySSAUpdater::insertUse(), isLoadInvariantInLoop(), pointerInvalidatedByLoopWithMSSA(), unswitchAllTrivialConditions(), verifyOrderingDominationAndDefUses(), and verifyPrevDefInPhis().
|
inline |
Definition at line 743 of file MemorySSA.h.
Referenced by llvm::MemorySSAUpdater::applyInsertUpdates(), and llvm::MemorySSAWalker::MemorySSAWalker().
|
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 721 of file MemorySSA.h.
Referenced by llvm::canSinkOrHoistInst(), CloneInstructionInExitBlock(), llvm::MemorySSAAnnotatedWriter::emitBasicBlockStartAnnot(), llvm::MemorySSAAnnotatedWriter::emitInstructionAnnot(), getNewDefiningAccessForClone(), llvm::MemorySSAUpdater::insertDef(), llvm::Loop::makeLoopInvariant(), moveInstructionBefore(), moveTo(), llvm::GVNHoist::rank(), llvm::MemorySSAUpdater::removeDuplicatePhiEdgesBetween(), llvm::MemorySSAUpdater::removeEdge(), llvm::MemorySSAUpdater::removeMemoryAccess(), simplifyLoopInst(), turnGuardIntoBranch(), llvm::MemorySSAUpdater::updateForClonedBlockIntoPred(), llvm::MemorySSAUpdater::updateForClonedLoop(), llvm::MemorySSAUpdater::updatePhisWhenInsertingUniqueBackedgeBlock(), verifyOrderingDominationAndDefUses(), and verifyPrevDefInPhis().
|
inline |
Definition at line 725 of file MemorySSA.h.
References llvm::dump(), and print().
| MemorySSAWalker * MemorySSA::getSkipSelfWalker | ( | ) |
Definition at line 1578 of file MemorySSA.cpp.
Referenced by llvm::canSinkOrHoistInst(), and pointerInvalidatedByLoopWithMSSA().
| MemorySSAWalker * MemorySSA::getWalker | ( | ) |
Definition at line 1563 of file MemorySSA.cpp.
Referenced by MemorySSA(), and removeFromLookups().
|
inlineprotected |
Definition at line 802 of file MemorySSA.h.
Referenced by insertIntoListsBefore(), and llvm::MemorySSAUpdater::updateForClonedLoop().
|
inlineprotected |
Definition at line 808 of file MemorySSA.h.
References llvm::simple_ilist< T, Options >::end().
Referenced by llvm::MemorySSAUpdater::applyInsertUpdates(), llvm::MemorySSAUpdater::insertDef(), and llvm::MemorySSAUpdater::insertUse().
|
protected |
Definition at line 1627 of file MemorySSA.cpp.
References getWritableBlockAccesses(), removeFromLists(), and llvm::MemoryAccess::setBlock().
Referenced by moveTo().
|
protected |
Definition at line 1595 of file MemorySSA.cpp.
References Beginning, and llvm::find_if_not().
Referenced by getNewDefiningAccessForClone(), 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(), dominates(), getNewDefiningAccessForClone(), locallyDominates(), llvm::MemorySSAWalker::MemorySSAWalker(), pointerInvalidatedByLoopWithMSSA(), llvm::GVNHoist::rank(), llvm::MemorySSAUpdater::updateForClonedLoop(), and verifyOrderingDominationAndDefUses().
| 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 2089 of file MemorySSA.cpp.
References assert(), llvm::MemoryAccess::getBlock(), and isLiveOnEntryDef().
Referenced by dominates(), pointerInvalidatedByLoopWithMSSA(), and llvm::GVNHoist::rank().
|
protected |
Definition at line 1671 of file MemorySSA.cpp.
References insertIntoListsBefore().
|
protected |
Definition at line 1677 of file MemorySSA.cpp.
References assert(), Beginning, llvm::MemoryAccess::getBlock(), llvm::BasicBlock::getContext(), getMemoryAccess(), insertIntoListsForBlock(), and second.
| void MemorySSA::print | ( | raw_ostream & | OS | ) | const |
Definition at line 1863 of file MemorySSA.cpp.
References F.
Referenced by llvm::MemoryAccess::dump(), dump(), and llvm::MemoryAccess::print().
|
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 1836 of file MemorySSA.cpp.
References llvm::MemoryAccess::getBlock().
Referenced by insertIntoListsBefore().
|
protected |
Properly remove MA from all of MemorySSA's lookup tables.
Definition at line 1809 of file MemorySSA.cpp.
References assert(), llvm::MemoryAccess::getBlock(), getWalker(), llvm::MemorySSAWalker::invalidateInfo(), and llvm::Value::use_empty().
|
inlineprotected |
Definition at line 821 of file MemorySSA.h.
Referenced by llvm::MemorySSAUpdater::insertDef(), llvm::MemorySSAUpdater::insertUse(), and llvm::MemorySSA::OptimizeUses::optimizeUses().
Verify that all of the blocks we believe to have valid domination numbers actually have valid domination numbers.
Definition at line 1924 of file MemorySSA.cpp.
References assert(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallPtrSetImplBase::empty(), llvm::SmallPtrSetImpl< PtrType >::erase(), and getBlockAccesses().
Referenced by verifyMemorySSA().
| void MemorySSA::verifyMemorySSA | ( | ) | 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 1872 of file MemorySSA.cpp.
References F, verifyDominationNumbers(), verifyOrderingDominationAndDefUses(), and verifyPrevDefInPhis().
Referenced by getInnermostLoopFor(), llvm::hoistRegion(), llvm::LoopRotation(), mergeBlocksIntoPredecessors(), llvm::promoteLoopAccessesToScalars(), llvm::LoopRotatePass::run(), llvm::LoopInstSimplifyPass::run(), llvm::LoopSimplifyCFGPass::run(), llvm::SimpleLoopUnswitchPass::run(), simplifyLoopInst(), simplifyOneLoop(), llvm::sinkRegion(), turnGuardIntoBranch(), unswitchNontrivialInvariants(), unswitchTrivialBranch(), and unswitchTrivialSwitch().
|
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 1966 of file MemorySSA.cpp.
References llvm::AArch64CC::AL, assert(), B, llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::tgtok::Def, dominates(), E, llvm::SmallVectorTemplateCommon< T >::end(), llvm::find(), getBlockAccesses(), getBlockDefs(), llvm::MemoryUseOrDef::getDefiningAccess(), llvm::MemoryPhi::getIncomingBlock(), llvm::MemoryPhi::getIncomingValue(), getMemoryAccess(), llvm::MemoryPhi::getNumIncomingValues(), llvm::User::getNumOperands(), I, llvm::is_contained(), isLiveOnEntryDef(), llvm::pred_begin(), llvm::pred_end(), llvm::predecessors(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorBase::size(), llvm::Value::users(), and llvm::Value::uses().
Referenced by verifyMemorySSA().
|
protected |
Definition at line 1888 of file MemorySSA.cpp.
References assert(), E, getBlockDefs(), getMemoryAccess(), and I.
Referenced by verifyMemorySSA().
|
friend |
Definition at line 793 of file MemorySSA.h.
|
friend |
Definition at line 794 of file MemorySSA.h.
|
friend |
Definition at line 795 of file MemorySSA.h.
1.8.13