LLVM  5.0.0
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  CachingWalker
 A MemorySSAWalker that does AA walks to disambiguate accesses. More...
 
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 ()
 
MemorySSAWalker * getWalker ()
 
MemoryUseOrDef * getMemoryAccess (const Instruction *) 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...
 

Protected Member Functions

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...
 
AccessList * getWritableBlockAccesses (const BasicBlock *BB) const
 
DefsList * getWritableBlockDefs (const BasicBlock *BB) const
 
void moveTo (MemoryUseOrDef *What, BasicBlock *BB, AccessList::iterator Where)
 
void moveTo (MemoryUseOrDef *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)
 
MemoryUseOrDef * createDefinedAccess (Instruction *, MemoryAccess *)
 

Friends

class MemorySSAAnnotatedWriter
 
class MemorySSAPrinterLegacyPass
 
class MemorySSAUpdater
 

Detailed Description

Encapsulates MemorySSA, including all data associated with memory accesses.

Definition at line 606 of file MemorySSA.h.

Member Typedef Documentation

Definition at line 643 of file MemorySSA.h.

Definition at line 645 of file MemorySSA.h.

Member Enumeration Documentation

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 680 of file MemorySSA.h.

Constructor & Destructor Documentation

llvm::MemorySSA::MemorySSA ( Function &  Func,
AliasAnalysis *  AA,
DominatorTree *  DT 
)

Definition at line 1018 of file MemorySSA.cpp.

llvm::MemorySSA::~MemorySSA ( )

Definition at line 1024 of file MemorySSA.cpp.

References llvm::User::dropAllReferences().

Member Function Documentation

MemoryUseOrDef * llvm::MemorySSA::createDefinedAccess ( Instruction *  I,
MemoryAccess *  Definition 
)
protected
bool llvm::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 1772 of file MemorySSA.cpp.

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

Referenced by dominates(), and verifyDomination().

bool llvm::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 1785 of file MemorySSA.cpp.

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

LLVM_DUMP_METHOD void llvm::MemorySSA::dump ( ) const

Definition at line 1581 of file MemorySSA.cpp.

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

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 650 of file MemorySSA.h.

Referenced by verifyOrdering().

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 658 of file MemorySSA.h.

Referenced by verifyOrdering().

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

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

Referenced by llvm::MemorySSAAnnotatedWriter::emitBasicBlockStartAnnot(), llvm::MemorySSAAnnotatedWriter::emitInstructionAnnot(), llvm::MemorySSAWalker::getClobberingMemoryAccess(), verifyDefUses(), verifyDomination(), and verifyOrdering().

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

Definition at line 1717 of file MemorySSA.cpp.

MemorySSAWalker * llvm::MemorySSA::getWalker ( )

Definition at line 1340 of file MemorySSA.cpp.

Referenced by llvm::MemorySSA::OptimizeUses::OptimizeUses().

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

Definition at line 693 of file MemorySSA.h.

Referenced by insertIntoListsBefore().

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

Definition at line 699 of file MemorySSA.h.

References llvm::simple_ilist< T, Options >::end().

Referenced by llvm::MemorySSAUpdater::insertDef().

void llvm::MemorySSA::insertIntoListsBefore ( MemoryAccess *  What,
const BasicBlock *  BB,
AccessList::iterator  InsertPt 
)
protected
void llvm::MemorySSA::insertIntoListsForBlock ( MemoryAccess *  NewAccess,
const BasicBlock *  BB,
InsertionPlace  Point 
)
protected

Definition at line 1353 of file MemorySSA.cpp.

References Beginning, and llvm::find_if_not().

Referenced by llvm::MemorySSAUpdater::createMemoryAccessInBB(), and moveTo().

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 630 of file MemorySSA.h.

Referenced by dominates(), llvm::MemorySSA::CachingWalker::getClobberingMemoryAccess(), locallyDominates(), and llvm::MemorySSAUpdater::removeMemoryAccess().

bool llvm::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 1740 of file MemorySSA.cpp.

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

Referenced by dominates().

void llvm::MemorySSA::moveTo ( MemoryUseOrDef *  What,
BasicBlock *  BB,
AccessList::iterator  Where 
)
protected
void llvm::MemorySSA::moveTo ( MemoryUseOrDef *  What,
BasicBlock *  BB,
InsertionPlace  Point 
)
protected
void llvm::MemorySSA::print ( raw_ostream &  OS) const
void llvm::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 1551 of file MemorySSA.cpp.

References llvm::MemoryAccess::getBlock().

Referenced by moveTo(), and llvm::MemorySSAUpdater::removeMemoryAccess().

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

Definition at line 711 of file MemorySSA.h.

Referenced by llvm::MemorySSAUpdater::insertDef().

void llvm::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 1694 of file MemorySSA.cpp.

References assert(), E, llvm::MemoryPhi::getIncomingValue(), getMemoryAccess(), llvm::MemoryPhi::getNumIncomingValues(), llvm::User::getNumOperands(), I, llvm::pred_begin(), and llvm::pred_end().

Referenced by verifyMemorySSA().

void llvm::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 1656 of file MemorySSA.cpp.

References assert(), dominates(), getMemoryAccess(), and llvm::Value::uses().

Referenced by verifyMemorySSA().

void llvm::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 1584 of file MemorySSA.cpp.

References verifyDefUses(), verifyDomination(), and verifyOrdering().

Referenced by llvm::MemorySSAPrinterLegacyPass::runOnFunction(), and llvm::MemorySSAWrapperPass::verifyAnalysis().

void llvm::MemorySSA::verifyOrdering ( Function &  F) const
protected

Friends And Related Function Documentation

friend class MemorySSAAnnotatedWriter
friend

Definition at line 684 of file MemorySSA.h.

friend class MemorySSAPrinterLegacyPass
friend

Definition at line 685 of file MemorySSA.h.

friend class MemorySSAUpdater
friend

Definition at line 686 of file MemorySSA.h.


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