LLVM  4.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 <MemorySSA.h>

Classes

class  CachingWalker
 A MemorySSAWalker that does AA walks and caching of lookups 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 }
 
using AccessList = iplist< MemoryAccess >
 

Public Member Functions

 MemorySSA (Function &, AliasAnalysis *, DominatorTree *)
 
 ~MemorySSA ()
 
MemorySSAWalkergetWalker ()
 
MemoryUseOrDefgetMemoryAccess (const Instruction *) 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...
 
MemoryPhicreateMemoryPhi (BasicBlock *BB)
 Create an empty MemoryPhi in MemorySSA for a given basic block. More...
 
MemoryAccesscreateMemoryAccessInBB (Instruction *I, MemoryAccess *Definition, const BasicBlock *BB, InsertionPlace Point)
 Create a MemoryAccess in MemorySSA at a specified point in a block, with a specified clobbering definition. More...
 
MemoryUseOrDefcreateMemoryAccessBefore (Instruction *I, MemoryAccess *Definition, MemoryUseOrDef *InsertPt)
 Create a MemoryAccess in MemorySSA before or after an existing MemoryAccess. More...
 
MemoryUseOrDefcreateMemoryAccessAfter (Instruction *I, MemoryAccess *Definition, MemoryAccess *InsertPt)
 
void spliceMemoryAccessAbove (MemoryDef *Where, MemoryUseOrDef *What)
 
void removeMemoryAccess (MemoryAccess *)
 Remove a MemoryAccess from MemorySSA, including updating all definitions and uses. 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...
 
AccessListgetWritableBlockAccesses (const BasicBlock *BB) const
 

Friends

class MemorySSAAnnotatedWriter
 
class MemorySSAPrinterLegacyPass
 

Detailed Description

Encapsulates MemorySSA, including all data associated with memory accesses.

Definition at line 500 of file MemorySSA.h.

Member Typedef Documentation

Definition at line 532 of file MemorySSA.h.

Member Enumeration Documentation

Enumerator
Beginning 
End 

Definition at line 546 of file MemorySSA.h.

Constructor & Destructor Documentation

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

Definition at line 1230 of file MemorySSA.cpp.

llvm::MemorySSA::~MemorySSA ( )

Definition at line 1236 of file MemorySSA.cpp.

References llvm::User::dropAllReferences().

Member Function Documentation

MemoryUseOrDef * llvm::MemorySSA::createMemoryAccessAfter ( Instruction I,
MemoryAccess Definition,
MemoryAccess InsertPt 
)
MemoryUseOrDef * llvm::MemorySSA::createMemoryAccessBefore ( Instruction I,
MemoryAccess Definition,
MemoryUseOrDef InsertPt 
)

Create a MemoryAccess in MemorySSA before or after an existing MemoryAccess.

Returns the new MemoryAccess. This should be called when a memory instruction is created that is being used to replace an existing memory instruction. It will not create PHI nodes, or verify the clobbering definition. The clobbering definition must be non-null. Note: If a MemoryAccess already exists for I, this function will make it inaccessible and it must have removeMemoryAccess called on it.

Definition at line 1602 of file MemorySSA.cpp.

References assert(), llvm::MemoryAccess::getBlock(), llvm::Instruction::getParent(), and llvm::iplist_impl< IntrusiveListT, TraitsT >::insert().

MemoryAccess * llvm::MemorySSA::createMemoryAccessInBB ( Instruction I,
MemoryAccess Definition,
const BasicBlock BB,
InsertionPlace  Point 
)

Create a MemoryAccess in MemorySSA at a specified point in a block, with a specified clobbering definition.

Returns the new MemoryAccess. This should be called when a memory instruction is created that is being used to replace an existing memory instruction. It will not create PHI nodes, or verify the clobbering definition. The insertion place is used solely to determine where in the memoryssa access lists the instruction will be placed. The caller is expected to keep ordering the same as instructions. It will return the new MemoryAccess. Note: If a MemoryAccess already exists for I, this function will make it inaccessible and it must have removeMemoryAccess called on it.

Definition at line 1583 of file MemorySSA.cpp.

References Beginning, and llvm::find_if().

MemoryPhi * llvm::MemorySSA::createMemoryPhi ( BasicBlock BB)

Create an empty MemoryPhi in MemorySSA for a given basic block.

Only one MemoryPhi for a block exists at a time, so this function will assert if you try to create one where it already exists.

Definition at line 1561 of file MemorySSA.cpp.

References assert(), llvm::BasicBlock::getContext(), getMemoryAccess(), and llvm::iplist_impl< IntrusiveListT, TraitsT >::push_front().

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

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

Referenced by dominates(), spliceMemoryAccessAbove(), 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 2003 of file MemorySSA.cpp.

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

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

Definition at line 1822 of file MemorySSA.cpp.

References llvm::dbgs().

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

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

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

Definition at line 1935 of file MemorySSA.cpp.

MemorySSAWalker * llvm::MemorySSA::getWalker ( )

Definition at line 1551 of file MemorySSA.cpp.

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

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

Definition at line 623 of file MemorySSA.h.

Referenced by spliceMemoryAccessAbove().

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

Referenced by dominates(), llvm::MemorySSA::CachingWalker::getClobberingMemoryAccess(), locallyDominates(), and 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 1958 of file MemorySSA.cpp.

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

Referenced by dominates().

void llvm::MemorySSA::print ( raw_ostream OS) const
void llvm::MemorySSA::removeMemoryAccess ( MemoryAccess MA)

Remove a MemoryAccess from MemorySSA, including updating all definitions and uses.

This should be called when a memory instruction that has a MemoryAccess associated with it is erased from the program. For example, if a store or load is simply erased (not replaced), removeMemoryAccess should be called on the MemoryAccess for that store/load.

Definition at line 1771 of file MemorySSA.cpp.

References assert(), llvm::Use::getUser(), llvm::Value::hasValueHandle(), isLiveOnEntryDef(), llvm::onlySingleValue(), llvm::Use::set(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::ValueHandleBase::ValueIsRAUWd().

void llvm::MemorySSA::spliceMemoryAccessAbove ( MemoryDef Where,
MemoryUseOrDef What 
)
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 1912 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 1874 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 1827 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 616 of file MemorySSA.h.

friend class MemorySSAPrinterLegacyPass
friend

Definition at line 617 of file MemorySSA.h.


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