LLVM 23.0.0git
llvm::PHITransAddr Class Reference

PHITransAddr - An address value which tracks and handles phi translation. More...

#include "llvm/Analysis/PHITransAddr.h"

Public Member Functions

 PHITransAddr (Value *Addr, const DataLayout &DL, AssumptionCache *AC)
ValuegetAddr () const
LLVM_ABI ValuegetSelectCondition () const
 If the address expression depends on a select instruction (possibly through casts or GEPs), return that select's condition.
bool needsPHITranslationFromBlock (BasicBlock *BB) const
 needsPHITranslationFromBlock - Return true if moving from the specified BasicBlock to its predecessors requires PHI translation.
LLVM_ABI bool isPotentiallyPHITranslatable () const
 isPotentiallyPHITranslatable - If this needs PHI translation, return true if we have some hope of doing it.
LLVM_ABI ValuetranslateValue (BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree *DT, bool MustDominate)
 translateValue - PHI translate the current address up the CFG from CurBB to Pred, updating our state to reflect any needed changes.
LLVM_ABI SelectAddr::SelectAddrs translateValue (BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree *DT, Value *Cond)
 PHI translate the current address from CurBB to PredBB, and if the resulting address depends on a select instruction with condition Cond, translate both the "true" and the "false" side.
LLVM_ABI ValuetranslateWithInsertion (BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree &DT, SmallVectorImpl< Instruction * > &NewInsts)
 translateWithInsertion - PHI translate this value into the specified predecessor block, inserting a computation of the value if it is unavailable.
LLVM_ABI void dump () const
LLVM_ABI bool verify () const
 verify - Check internal consistency of this data structure.

Detailed Description

PHITransAddr - An address value which tracks and handles phi translation.

As we walk "up" the CFG through predecessors, we need to ensure that the address we're tracking is kept up to date. For example, if we're analyzing an address of "&A[i]" and walk through the definition of 'i' which is a PHI node, we must phi translate i to get "&A[j]" or else we will analyze an incorrect pointer in the predecessor block.

This is designed to be a relatively small object that lives on the stack and is copyable.

Definition at line 68 of file PHITransAddr.h.

Constructor & Destructor Documentation

◆ PHITransAddr()

llvm::PHITransAddr::PHITransAddr ( Value * Addr,
const DataLayout & DL,
AssumptionCache * AC )
inline

Definition at line 85 of file PHITransAddr.h.

Referenced by translateValue().

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void PHITransAddr::dump ( ) const

Definition at line 41 of file PHITransAddr.cpp.

References llvm::dbgs(), and LLVM_DUMP_METHOD.

◆ getAddr()

Value * llvm::PHITransAddr::getAddr ( ) const
inline

Definition at line 91 of file PHITransAddr.h.

Referenced by memoryIsNotModifiedBetween().

◆ getSelectCondition()

Value * PHITransAddr::getSelectCondition ( ) const

If the address expression depends on a select instruction (possibly through casts or GEPs), return that select's condition.

Otherwise return nullptr. This is used to drive translation of both sides of a select-dependent address (see the Cond overload of translateValue).

Definition at line 356 of file PHITransAddr.cpp.

References llvm::dyn_cast(), and I.

◆ isPotentiallyPHITranslatable()

bool PHITransAddr::isPotentiallyPHITranslatable ( ) const

isPotentiallyPHITranslatable - If this needs PHI translation, return true if we have some hope of doing it.

This should be used as a filter to avoid calling PHITranslateValue in hopeless situations.

Definition at line 104 of file PHITransAddr.cpp.

References canPHITrans(), and llvm::dyn_cast().

Referenced by memoryIsNotModifiedBetween().

◆ needsPHITranslationFromBlock()

bool llvm::PHITransAddr::needsPHITranslationFromBlock ( BasicBlock * BB) const
inline

needsPHITranslationFromBlock - Return true if moving from the specified BasicBlock to its predecessors requires PHI translation.

Definition at line 101 of file PHITransAddr.h.

References llvm::any_of().

Referenced by memoryIsNotModifiedBetween().

◆ translateValue() [1/2]

Value * PHITransAddr::translateValue ( BasicBlock * CurBB,
BasicBlock * PredBB,
const DominatorTree * DT,
bool MustDominate )

translateValue - PHI translate the current address up the CFG from CurBB to Pred, updating our state to reflect any needed changes.

PHITranslateValue - PHI translate the current address up the CFG from CurBB to Pred, updating our state to reflect any needed changes.

If 'MustDominate' is true, the translated value must dominate PredBB.

Definition at line 316 of file PHITransAddr.cpp.

References assert(), llvm::DominatorTree::dominates(), llvm::dyn_cast_or_null(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::DominatorTree::isReachableFromEntry(), and verify().

Referenced by memoryIsNotModifiedBetween().

◆ translateValue() [2/2]

SelectAddr::SelectAddrs PHITransAddr::translateValue ( BasicBlock * CurBB,
BasicBlock * PredBB,
const DominatorTree * DT,
Value * Cond )

PHI translate the current address from CurBB to PredBB, and if the resulting address depends on a select instruction with condition Cond, translate both the "true" and the "false" side.

Returns a pair of addresses (true, false); either may be null on failure.

Definition at line 336 of file PHITransAddr.cpp.

References assert(), Cond, llvm::DominatorTree::isReachableFromEntry(), PHITransAddr(), and verify().

◆ translateWithInsertion()

Value * PHITransAddr::translateWithInsertion ( BasicBlock * CurBB,
BasicBlock * PredBB,
const DominatorTree & DT,
SmallVectorImpl< Instruction * > & NewInsts )

translateWithInsertion - PHI translate this value into the specified predecessor block, inserting a computation of the value if it is unavailable.

PHITranslateWithInsertion - PHI translate this value into the specified predecessor block, inserting a computation of the value if it is unavailable.

All newly created instructions are added to the NewInsts list. This returns null on failure.

Definition at line 371 of file PHITransAddr.cpp.

References llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

◆ verify()

bool PHITransAddr::verify ( ) const

verify - Check internal consistency of this data structure.

If the structure is valid, it returns true. If invalid, it prints errors and returns false.

Definition at line 82 of file PHITransAddr.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::errs(), llvm_unreachable, and verifySubExpr().

Referenced by translateValue(), and translateValue().


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