LLVM  7.0.0
Public Member Functions | List of all members
llvm::MemorySSAUpdater Class Reference

#include "llvm/Analysis/MemorySSAUpdater.h"

Public Member Functions

 MemorySSAUpdater (MemorySSA *MSSA)
 
void insertDef (MemoryDef *Def, bool RenameUses=false)
 Insert a definition into the MemorySSA IR. More...
 
void insertUse (MemoryUse *Use)
 
void moveBefore (MemoryUseOrDef *What, MemoryUseOrDef *Where)
 
void moveAfter (MemoryUseOrDef *What, MemoryUseOrDef *Where)
 
void moveToPlace (MemoryUseOrDef *What, BasicBlock *BB, MemorySSA::InsertionPlace Where)
 
void moveAllAfterSpliceBlocks (BasicBlock *From, BasicBlock *To, Instruction *Start)
 From block was spliced into From and To. More...
 
void moveAllAfterMergeBlocks (BasicBlock *From, BasicBlock *To, Instruction *Start)
 From block was merged into To. More...
 
void wireOldPredecessorsToNewImmediatePredecessor (BasicBlock *Old, BasicBlock *New, ArrayRef< BasicBlock *> Preds)
 BasicBlock Old had New, an empty BasicBlock, added directly before it, and the predecessors in Preds that used to point to Old, now point to New. More...
 
MemoryAccess * createMemoryAccessInBB (Instruction *I, MemoryAccess *Definition, const BasicBlock *BB, MemorySSA::InsertionPlace Point)
 Create a MemoryAccess in MemorySSA at a specified point in a block, with a specified clobbering definition. More...
 
MemoryUseOrDef * createMemoryAccessBefore (Instruction *I, MemoryAccess *Definition, MemoryUseOrDef *InsertPt)
 Create a MemoryAccess in MemorySSA before or after an existing MemoryAccess. More...
 
MemoryUseOrDef * createMemoryAccessAfter (Instruction *I, MemoryAccess *Definition, MemoryAccess *InsertPt)
 
void removeMemoryAccess (MemoryAccess *)
 Remove a MemoryAccess from MemorySSA, including updating all definitions and uses. More...
 
void removeMemoryAccess (const Instruction *I)
 Remove MemoryAccess for a given instruction, if a MemoryAccess exists. More...
 
void removeBlocks (const SmallPtrSetImpl< BasicBlock *> &DeadBlocks)
 Remove all MemoryAcceses in a set of BasicBlocks about to be deleted. More...
 
MemorySSA * getMemorySSA () const
 Get handle on MemorySSA. More...
 

Detailed Description

Definition at line 60 of file MemorySSAUpdater.h.

Constructor & Destructor Documentation

◆ MemorySSAUpdater()

llvm::MemorySSAUpdater::MemorySSAUpdater ( MemorySSA *  MSSA)
inline

Member Function Documentation

◆ createMemoryAccessAfter()

MemoryUseOrDef * MemorySSAUpdater::createMemoryAccessAfter ( Instruction *  I,
MemoryAccess *  Definition,
MemoryAccess *  InsertPt 
)

◆ createMemoryAccessBefore()

MemoryUseOrDef * MemorySSAUpdater::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.

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 618 of file MemorySSAUpdater.cpp.

References assert(), llvm::MemorySSA::createDefinedAccess(), llvm::MemoryAccess::getBlock(), llvm::MemoryAccess::getIterator(), llvm::Instruction::getParent(), and llvm::MemorySSA::insertIntoListsBefore().

◆ createMemoryAccessInBB()

MemoryAccess * MemorySSAUpdater::createMemoryAccessInBB ( Instruction *  I,
MemoryAccess *  Definition,
const BasicBlock *  BB,
MemorySSA::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 610 of file MemorySSAUpdater.cpp.

References llvm::MemorySSA::createDefinedAccess(), and llvm::MemorySSA::insertIntoListsForBlock().

◆ getMemorySSA()

MemorySSA* llvm::MemorySSAUpdater::getMemorySSA ( ) const
inline

Get handle on MemorySSA.

Definition at line 202 of file MemorySSAUpdater.h.

◆ insertDef()

void MemorySSAUpdater::insertDef ( MemoryDef *  Def,
bool  RenameUses = false 
)

Insert a definition into the MemorySSA IR.

RenameUses will rename any use below the new def block (and any inserted phis). RenameUses should be set to true if the definition may cause new aliases for loads below it. This is not the case for hoisting or sinking or other forms of code movement. It is the case for straight code insertion. For example: store a if (foo) { } load a

Moving the store into the if block, and calling insertDef, does not require RenameUses. However, changing it to: store a if (foo) { store b } load a Where a mayalias b, does require RenameUses be set to true.

Definition at line 252 of file MemorySSAUpdater.cpp.

References assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::simple_ilist< T, Options >::begin(), llvm::MemorySSA::dominates(), llvm::SmallVectorBase::empty(), llvm::MemoryAccess::getBlock(), llvm::MemoryUseOrDef::getDefiningAccess(), llvm::MemoryAccess::getDefsIterator(), llvm::MemorySSA::getMemoryAccess(), llvm::Use::getUser(), llvm::MemorySSA::getWritableBlockDefs(), llvm::SmallPtrSetImpl< PtrType >::insert(), insertUse(), llvm::MemorySSA::moveTo(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::MemorySSA::renamePass(), llvm::Value::replaceAllUsesWith(), llvm::Use::set(), llvm::MemoryUseOrDef::setDefiningAccess(), setMemoryPhiValueForBlock(), llvm::successors(), llvm::Value::use_begin(), llvm::Value::use_end(), and llvm::Value::users().

Referenced by MemorySSAUpdater().

◆ insertUse()

void MemorySSAUpdater::insertUse ( MemoryUse *  Use)

Definition at line 215 of file MemorySSAUpdater.cpp.

References llvm::MemoryUseOrDef::setDefiningAccess().

Referenced by insertDef(), and MemorySSAUpdater().

◆ moveAfter()

void MemorySSAUpdater::moveAfter ( MemoryUseOrDef *  What,
MemoryUseOrDef *  Where 
)

◆ moveAllAfterMergeBlocks()

void MemorySSAUpdater::moveAllAfterMergeBlocks ( BasicBlock *  From,
BasicBlock *  To,
Instruction *  Start 
)

From block was merged into To.

All instructions were moved and From is an empty block with successor edges; From is about to be deleted. Move all accesses from From to To starting at instruction Start. To may have multiple successors, From has a single predecessor. From may have successors with MPhi nodes, replace their incoming block with To. |---—| |---—|

To To
=>

\/ | | |---—| | | <- Start | From | | | |---—| |---—|

Definition at line 476 of file MemorySSAUpdater.cpp.

References assert(), llvm::MemorySSA::getMemoryAccess(), llvm::BasicBlock::getSinglePredecessor(), and llvm::successors().

◆ moveAllAfterSpliceBlocks()

void MemorySSAUpdater::moveAllAfterSpliceBlocks ( BasicBlock *  From,
BasicBlock *  To,
Instruction *  Start 
)

From block was spliced into From and To.

Move all accesses from From to To starting at instruction Start. To is newly created BB, so empty of MemorySSA::MemoryAccesses. Edges are already updated, so successors of To with MPhi nodes need to update incoming block. |---—| |---—|

From From

| | => \/ | | |---—| <- Start | | | To | |---—| |---—|

Definition at line 465 of file MemorySSAUpdater.cpp.

References assert(), llvm::MemorySSA::getBlockAccesses(), llvm::MemorySSA::getMemoryAccess(), and llvm::successors().

Referenced by MemorySSAUpdater().

◆ moveBefore()

void MemorySSAUpdater::moveBefore ( MemoryUseOrDef *  What,
MemoryUseOrDef *  Where 
)

◆ moveToPlace()

void MemorySSAUpdater::moveToPlace ( MemoryUseOrDef *  What,
BasicBlock *  BB,
MemorySSA::InsertionPlace  Where 
)

Definition at line 431 of file MemorySSAUpdater.cpp.

Referenced by MemorySSAUpdater().

◆ removeBlocks()

void MemorySSAUpdater::removeBlocks ( const SmallPtrSetImpl< BasicBlock *> &  DeadBlocks)

Remove all MemoryAcceses in a set of BasicBlocks about to be deleted.

Assumption we make here: all uses of deleted defs and phi must either occur in blocks about to be deleted (thus will be deleted as well), or they occur in phis that will simply lose an incoming value. Deleted blocks still have successor info, but their predecessor edges and Phi nodes may already be updated. Instructions in DeadBlocks should be deleted after this call.

Definition at line 577 of file MemorySSAUpdater.cpp.

References assert(), llvm::User::dropAllReferences(), llvm::MemorySSA::getMemoryAccess(), llvm::BasicBlock::getTerminator(), llvm::MemorySSA::getWritableBlockAccesses(), llvm::MemorySSA::removeFromLists(), llvm::MemorySSA::removeFromLookups(), removeMemoryAccess(), and llvm::TerminatorInst::successors().

Referenced by removeMemoryAccess().

◆ removeMemoryAccess() [1/2]

void MemorySSAUpdater::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 529 of file MemorySSAUpdater.cpp.

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

Referenced by removeBlocks(), removeMemoryAccess(), and wireOldPredecessorsToNewImmediatePredecessor().

◆ removeMemoryAccess() [2/2]

void llvm::MemorySSAUpdater::removeMemoryAccess ( const Instruction *  I)
inline

Remove MemoryAccess for a given instruction, if a MemoryAccess exists.

This should be called when an instruction (load/store) is deleted from the program.

Definition at line 187 of file MemorySSAUpdater.h.

References llvm::MemorySSA::getMemoryAccess(), removeBlocks(), and removeMemoryAccess().

◆ wireOldPredecessorsToNewImmediatePredecessor()

void MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor ( BasicBlock *  Old,
BasicBlock *  New,
ArrayRef< BasicBlock *>  Preds 
)

BasicBlock Old had New, an empty BasicBlock, added directly before it, and the predecessors in Preds that used to point to Old, now point to New.

If New is the only predecessor, move Old's Phi, if present, to New. Otherwise, add a new Phi in New with appropriate incoming values, and update the incoming values in Old's Phi node too, if present.

Definition at line 500 of file MemorySSAUpdater.cpp.

References assert(), B, llvm::ArrayRef< T >::begin(), llvm::MemorySSA::Beginning, llvm::ArrayRef< T >::empty(), llvm::ArrayRef< T >::end(), llvm::MemorySSA::getMemoryAccess(), llvm::MemorySSA::getWritableBlockAccesses(), llvm::MemorySSA::moveTo(), onlySingleValue(), llvm::pred_size(), removeMemoryAccess(), and llvm::ArrayRef< T >::size().


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