LLVM  10.0.0svn
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
llvm::MemorySSA Class Reference

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 }
 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 ()
 
MemorySSAWalkergetWalker ()
 
MemorySSAWalkergetSkipSelfWalker ()
 
MemoryUseOrDefgetMemoryAccess (const Instruction *I) const
 Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it. More...
 
MemoryPhigetMemoryAccess (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...
 
MemoryAccessgetLiveOnEntryDef () const
 
const AccessListgetBlockAccesses (const BasicBlock *BB) const
 Return the list of MemoryAccess's for a given basic block. More...
 
const DefsListgetBlockDefs (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...
 

Protected Member Functions

void verifyPrevDefInPhis (Function &F) const
 
void verifyDefUses (Function &F) const
 Verify the immediate use information, by walking all the memory accesses and verifying that, for each use, it appears in the appropriate def's use list. More...
 
void verifyDomination (Function &F) const
 Verify the domination properties of MemorySSA by checking that each definition dominates all of its uses. More...
 
void verifyOrdering (Function &F) const
 Verify that the order and existence of MemoryAccesses matches the order and existence of memory affecting instructions. More...
 
void verifyDominationNumbers (const Function &F) const
 Verify that all of the blocks we believe to have valid domination numbers actually have valid domination numbers. More...
 
AccessListgetWritableBlockAccesses (const BasicBlock *BB) const
 
DefsListgetWritableBlockDefs (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. More...
 
void removeFromLists (MemoryAccess *, bool ShouldDelete=true)
 Properly remove MA from all of MemorySSA's lists. More...
 
void insertIntoListsForBlock (MemoryAccess *, const BasicBlock *, InsertionPlace)
 
void insertIntoListsBefore (MemoryAccess *, const BasicBlock *, AccessList::iterator)
 
MemoryUseOrDefcreateDefinedAccess (Instruction *, MemoryAccess *, const MemoryUseOrDef *Template=nullptr, bool CreationMustSucceed=true)
 

Friends

class MemorySSAAnnotatedWriter
 
class MemorySSAPrinterLegacyPass
 
class MemorySSAUpdater
 

Detailed Description

Encapsulates MemorySSA, including all data associated with memory accesses.

Definition at line 703 of file MemorySSA.h.

Member Typedef Documentation

◆ AccessList

Definition at line 751 of file MemorySSA.h.

◆ DefsList

Definition at line 753 of file MemorySSA.h.

Member Enumeration Documentation

◆ InsertionPlace

Used in various insertion functions to specify whether we are talking about the beginning or end of a block.

Enumerator
Beginning 
End 

Definition at line 788 of file MemorySSA.h.

Constructor & Destructor Documentation

◆ MemorySSA() [1/2]

MemorySSA::MemorySSA ( Function Func,
AliasAnalysis AA,
DominatorTree DT 
)

Definition at line 1224 of file MemorySSA.cpp.

References getWalker().

◆ MemorySSA() [2/2]

llvm::MemorySSA::MemorySSA ( MemorySSA &&  )
delete

◆ ~MemorySSA()

MemorySSA::~MemorySSA ( )

Member Function Documentation

◆ createDefinedAccess()

MemoryUseOrDef * MemorySSA::createDefinedAccess ( Instruction I,
MemoryAccess Definition,
const MemoryUseOrDef Template = nullptr,
bool  CreationMustSucceed = true 
)
protected

Definition at line 1700 of file MemorySSA.cpp.

References assert(), and llvm::MemoryUseOrDef::setDefiningAccess().

Referenced by getNewDefiningAccessForClone().

◆ dominates() [1/2]

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 2139 of file MemorySSA.cpp.

References llvm::MemoryAccess::getBlock(), isLiveOnEntryDef(), and locallyDominates().

Referenced by llvm::canSinkOrHoistInst(), dominates(), llvm::MemorySSAUpdater::insertDef(), and verifyDomination().

◆ dominates() [2/2]

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 2152 of file MemorySSA.cpp.

References dominates(), llvm::MemoryAccess::getBlock(), llvm::Use::getUser(), and locallyDominates().

◆ dump()

LLVM_DUMP_METHOD void MemorySSA::dump ( ) const

Definition at line 1867 of file MemorySSA.cpp.

References llvm::dbgs(), and print().

◆ getBlockAccesses()

const AccessList* llvm::MemorySSA::getBlockAccesses ( const BasicBlock BB) const
inline

Return the list of MemoryAccess's for a given basic block.

This list is not modifiable by the user.

Definition at line 758 of file MemorySSA.h.

Referenced by llvm::canSinkOrHoistInst(), llvm::createLICMPass(), getNewDefiningAccessForClone(), isLoadInvariantInLoop(), llvm::GVNHoist::rank(), verifyDefUses(), verifyDominationNumbers(), and verifyOrdering().

◆ getBlockDefs()

const DefsList* llvm::MemorySSA::getBlockDefs ( const BasicBlock BB) const
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 766 of file MemorySSA.h.

References B.

Referenced by getNewDefiningAccessForClone(), llvm::MemorySSAUpdater::insertDef(), llvm::MemorySSAUpdater::insertUse(), isLoadInvariantInLoop(), pointerInvalidatedByLoopWithMSSA(), unswitchAllTrivialConditions(), verifyOrdering(), and verifyPrevDefInPhis().

◆ getLiveOnEntryDef()

MemoryAccess* llvm::MemorySSA::getLiveOnEntryDef ( ) const
inline

◆ getMemoryAccess() [1/2]

MemoryUseOrDef* llvm::MemorySSA::getMemoryAccess ( const Instruction I) const
inline

◆ getMemoryAccess() [2/2]

MemoryPhi* llvm::MemorySSA::getMemoryAccess ( const BasicBlock BB) const
inline

Definition at line 724 of file MemorySSA.h.

References llvm::dump(), and print().

◆ getSkipSelfWalker()

MemorySSAWalker * MemorySSA::getSkipSelfWalker ( )

Definition at line 1576 of file MemorySSA.cpp.

Referenced by llvm::canSinkOrHoistInst(), and pointerInvalidatedByLoopWithMSSA().

◆ getWalker()

MemorySSAWalker * MemorySSA::getWalker ( )

Definition at line 1561 of file MemorySSA.cpp.

Referenced by MemorySSA(), and removeFromLookups().

◆ getWritableBlockAccesses()

AccessList* llvm::MemorySSA::getWritableBlockAccesses ( const BasicBlock BB) const
inlineprotected

◆ getWritableBlockDefs()

DefsList* llvm::MemorySSA::getWritableBlockDefs ( const BasicBlock BB) const
inlineprotected

◆ insertIntoListsBefore()

void MemorySSA::insertIntoListsBefore ( MemoryAccess What,
const BasicBlock BB,
AccessList::iterator  InsertPt 
)
protected

Definition at line 1625 of file MemorySSA.cpp.

References getWritableBlockAccesses(), removeFromLists(), and llvm::MemoryAccess::setBlock().

Referenced by moveTo().

◆ insertIntoListsForBlock()

void MemorySSA::insertIntoListsForBlock ( MemoryAccess NewAccess,
const BasicBlock BB,
InsertionPlace  Point 
)
protected

Definition at line 1593 of file MemorySSA.cpp.

References Beginning, and llvm::find_if_not().

Referenced by getNewDefiningAccessForClone(), and moveTo().

◆ isLiveOnEntryDef()

bool llvm::MemorySSA::isLiveOnEntryDef ( const MemoryAccess MA) const
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 738 of file MemorySSA.h.

Referenced by llvm::canSinkOrHoistInst(), dominates(), getNewDefiningAccessForClone(), locallyDominates(), llvm::MemorySSAWalker::MemorySSAWalker(), pointerInvalidatedByLoopWithMSSA(), llvm::GVNHoist::rank(), llvm::MemorySSAUpdater::updateForClonedLoop(), and verifyDomination().

◆ locallyDominates()

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.

Returns
True if Dominator dominates Dominatee.

Definition at line 2108 of file MemorySSA.cpp.

References assert(), llvm::MemoryAccess::getBlock(), and isLiveOnEntryDef().

Referenced by dominates(), pointerInvalidatedByLoopWithMSSA(), and llvm::GVNHoist::rank().

◆ moveTo() [1/2]

void MemorySSA::moveTo ( MemoryUseOrDef What,
BasicBlock BB,
AccessList::iterator  Where 
)
protected

Definition at line 1669 of file MemorySSA.cpp.

References insertIntoListsBefore().

◆ moveTo() [2/2]

void MemorySSA::moveTo ( MemoryAccess What,
BasicBlock BB,
InsertionPlace  Point 
)
protected

◆ print()

void MemorySSA::print ( raw_ostream OS) const

Definition at line 1861 of file MemorySSA.cpp.

References F.

Referenced by llvm::MemoryAccess::dump(), dump(), and llvm::MemoryAccess::print().

◆ removeFromLists()

void MemorySSA::removeFromLists ( MemoryAccess MA,
bool  ShouldDelete = true 
)
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 1834 of file MemorySSA.cpp.

References llvm::MemoryAccess::getBlock().

Referenced by insertIntoListsBefore().

◆ removeFromLookups()

void MemorySSA::removeFromLookups ( MemoryAccess MA)
protected

Properly remove MA from all of MemorySSA's lookup tables.

Definition at line 1807 of file MemorySSA.cpp.

References assert(), llvm::MemoryAccess::getBlock(), getWalker(), llvm::MemorySSAWalker::invalidateInfo(), and llvm::Value::use_empty().

◆ renamePass()

void llvm::MemorySSA::renamePass ( BasicBlock BB,
MemoryAccess IncomingVal,
SmallPtrSetImpl< BasicBlock *> &  Visited 
)
inlineprotected

◆ verifyDefUses()

void MemorySSA::verifyDefUses ( Function F) const
protected

Verify the immediate use information, by walking all the memory accesses and verifying that, for each use, it appears in the appropriate def's use list.

Definition at line 2064 of file MemorySSA.cpp.

References llvm::AArch64CC::AL, assert(), B, E, llvm::find(), getBlockAccesses(), getMemoryAccess(), I, llvm::pred_begin(), llvm::pred_end(), and llvm::predecessors().

Referenced by verifyMemorySSA().

◆ verifyDomination()

void MemorySSA::verifyDomination ( Function F) const
protected

Verify the domination properties of MemorySSA by checking that each definition dominates all of its uses.

Definition at line 2027 of file MemorySSA.cpp.

References assert(), B, llvm::tgtok::Def, dominates(), getMemoryAccess(), llvm::is_contained(), isLiveOnEntryDef(), llvm::Value::users(), and llvm::Value::uses().

Referenced by verifyMemorySSA().

◆ verifyDominationNumbers()

void MemorySSA::verifyDominationNumbers ( const Function F) const
protected

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

◆ verifyMemorySSA()

void MemorySSA::verifyMemorySSA ( ) const

◆ verifyOrdering()

void MemorySSA::verifyOrdering ( Function F) const
protected

◆ verifyPrevDefInPhis()

void MemorySSA::verifyPrevDefInPhis ( Function F) const
protected

Definition at line 1888 of file MemorySSA.cpp.

References assert(), E, getBlockDefs(), getMemoryAccess(), and I.

Referenced by verifyMemorySSA().

Friends And Related Function Documentation

◆ MemorySSAAnnotatedWriter

friend class MemorySSAAnnotatedWriter
friend

Definition at line 792 of file MemorySSA.h.

◆ MemorySSAPrinterLegacyPass

friend class MemorySSAPrinterLegacyPass
friend

Definition at line 793 of file MemorySSA.h.

◆ MemorySSAUpdater

friend class MemorySSAUpdater
friend

Definition at line 794 of file MemorySSA.h.


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