LLVM  8.0.1
Public Member Functions | Friends | List of all members
llvm::SSAUpdater Class Reference

Helper class for SSA formation on a set of values defined in multiple blocks. More...

#include "llvm/Transforms/Utils/SSAUpdater.h"

Public Member Functions

 SSAUpdater (SmallVectorImpl< PHINode *> *InsertedPHIs=nullptr)
 If InsertedPHIs is specified, it will be filled in with all PHI Nodes created by rewriting. More...
 
 SSAUpdater (const SSAUpdater &)=delete
 
SSAUpdateroperator= (const SSAUpdater &)=delete
 
 ~SSAUpdater ()
 
void Initialize (Type *Ty, StringRef Name)
 Reset this object to get ready for a new set of SSA updates with type 'Ty'. More...
 
void AddAvailableValue (BasicBlock *BB, Value *V)
 Indicate that a rewritten value is available in the specified block with the specified value. More...
 
bool HasValueForBlock (BasicBlock *BB) const
 Return true if the SSAUpdater already has a value for the specified block. More...
 
ValueFindValueForBlock (BasicBlock *BB) const
 Return the value for the specified block if the SSAUpdater has one, otherwise return nullptr. More...
 
ValueGetValueAtEndOfBlock (BasicBlock *BB)
 Construct SSA form, materializing a value that is live at the end of the specified block. More...
 
ValueGetValueInMiddleOfBlock (BasicBlock *BB)
 Construct SSA form, materializing a value that is live in the middle of the specified block. More...
 
void RewriteUse (Use &U)
 Rewrite a use of the symbolic value. More...
 
void RewriteUseAfterInsertions (Use &U)
 Rewrite a use like RewriteUse but handling in-block definitions. More...
 

Friends

class SSAUpdaterTraits< SSAUpdater >
 

Detailed Description

Helper class for SSA formation on a set of values defined in multiple blocks.

This is used when code duplication or another unstructured transformation wants to rewrite a set of uses of one value with uses of a set of values.

Definition at line 39 of file SSAUpdater.h.

Constructor & Destructor Documentation

◆ SSAUpdater() [1/2]

SSAUpdater::SSAUpdater ( SmallVectorImpl< PHINode *> *  InsertedPHIs = nullptr)
explicit

If InsertedPHIs is specified, it will be filled in with all PHI Nodes created by rewriting.

Definition at line 47 of file SSAUpdater.cpp.

◆ SSAUpdater() [2/2]

llvm::SSAUpdater::SSAUpdater ( const SSAUpdater )
delete

◆ ~SSAUpdater()

SSAUpdater::~SSAUpdater ( )

Definition at line 50 of file SSAUpdater.cpp.

Member Function Documentation

◆ AddAvailableValue()

void SSAUpdater::AddAvailableValue ( BasicBlock BB,
Value V 
)

◆ FindValueForBlock()

Value * SSAUpdater::FindValueForBlock ( BasicBlock BB) const

Return the value for the specified block if the SSAUpdater has one, otherwise return nullptr.

Definition at line 67 of file SSAUpdater.cpp.

References llvm::sys::path::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), and getAvailableVals().

Referenced by llvm::formLCSSAForInstructions().

◆ GetValueAtEndOfBlock()

Value * SSAUpdater::GetValueAtEndOfBlock ( BasicBlock BB)

Construct SSA form, materializing a value that is live at the end of the specified block.

Definition at line 95 of file SSAUpdater.cpp.

Referenced by GetValueInMiddleOfBlock(), RewriteUse(), and RewriteUseAfterInsertions().

◆ GetValueInMiddleOfBlock()

Value * SSAUpdater::GetValueInMiddleOfBlock ( BasicBlock BB)

Construct SSA form, materializing a value that is live in the middle of the specified block.

GetValueInMiddleOfBlock is the same as GetValueAtEndOfBlock except in one important case: if there is a definition of the rewritten value after the 'use' in BB. Consider code like this:

X1 = ...
SomeBB:
use(X)
X2 = ...
br Cond, SomeBB, OutBB

In this case, there are two values (X1 and X2) added to the AvailableVals set by the client of the rewriter, and those values are both live out of their respective blocks. However, the use of X happens in the middle of a block. Because of this, we need to insert a new PHI node in SomeBB to merge the appropriate values, and this value isn't live out of the block.

Definition at line 100 of file SSAUpdater.cpp.

References llvm::PHINode::addIncoming(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::BasicBlock::begin(), llvm::PHINode::Create(), llvm::dbgs(), E, llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::front(), llvm::UndefValue::get(), llvm::Module::getDataLayout(), llvm::BasicBlock::getFirstNonPHI(), llvm::BasicBlock::getModule(), GetValueAtEndOfBlock(), HasValueForBlock(), I, IsEquivalentPHI(), LLVM_DEBUG, llvm::BasicBlock::phis(), llvm::pred_begin(), llvm::pred_end(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Instruction::setDebugLoc(), llvm::SimplifyInstruction(), and llvm::SmallVectorBase::size().

Referenced by ConstructSSAForLoadSet(), RewriteUse(), RewriteUsesOfClonedInstructions(), and llvm::LoadAndStorePromoter::run().

◆ HasValueForBlock()

bool SSAUpdater::HasValueForBlock ( BasicBlock BB) const

◆ Initialize()

void SSAUpdater::Initialize ( Type Ty,
StringRef  Name 
)

◆ operator=()

SSAUpdater& llvm::SSAUpdater::operator= ( const SSAUpdater )
delete

◆ RewriteUse()

void SSAUpdater::RewriteUse ( Use U)

Rewrite a use of the symbolic value.

This handles PHI nodes, which use their value in the corresponding predecessor. Note that this will not work if the use is supposed to be rewritten to a value defined in the same block as the use, but above it. Any 'AddAvailableValue's added for the use's block will be considered to be below it.

Definition at line 190 of file SSAUpdater.cpp.

References llvm::Use::get(), llvm::Instruction::getParent(), llvm::Use::getUser(), GetValueAtEndOfBlock(), GetValueInMiddleOfBlock(), llvm::Use::set(), and llvm::ValueHandleBase::ValueIsRAUWd().

Referenced by llvm::formLCSSAForInstructions(), getSignature(), RewriteUsesOfClonedInstructions(), and llvm::JumpThreadingPass::ThreadEdge().

◆ RewriteUseAfterInsertions()

void SSAUpdater::RewriteUseAfterInsertions ( Use U)

Rewrite a use like RewriteUse but handling in-block definitions.

This version of the method can rewrite uses in the same block as a definition, because it assumes that all uses of a value are below any inserted values.

Definition at line 207 of file SSAUpdater.cpp.

References llvm::Instruction::getParent(), llvm::Use::getUser(), GetValueAtEndOfBlock(), and llvm::Use::set().

Referenced by getSignature().

Friends And Related Function Documentation

◆ SSAUpdaterTraits< SSAUpdater >

friend class SSAUpdaterTraits< SSAUpdater >
friend

Definition at line 40 of file SSAUpdater.h.


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