LLVM  8.0.0svn
Public Member Functions | List of all members
llvm::DeferredDominance Class Reference

Class to defer updates to a DominatorTree. More...

#include "llvm/IR/Dominators.h"

Public Member Functions

 DeferredDominance (DominatorTree &DT_)
 
void applyUpdates (ArrayRef< DominatorTree::UpdateType > Updates)
 Queues multiple updates and discards duplicates. More...
 
void insertEdge (BasicBlock *From, BasicBlock *To)
 Helper method for a single edge insertion. More...
 
void deleteEdge (BasicBlock *From, BasicBlock *To)
 Helper method for a single edge deletion. More...
 
void deleteBB (BasicBlock *DelBB)
 Delays the deletion of a basic block until a flush() event. More...
 
bool pendingDeletedBB (BasicBlock *DelBB)
 Returns true if DelBB is awaiting deletion at a flush() event. More...
 
bool pending ()
 Returns true if pending DT updates are queued for a flush() event. More...
 
DominatorTreeflush ()
 Flushes all pending updates and block deletions. More...
 
void recalculate (Function &F)
 Drops all internal state and forces a (slow) recalculation of the DominatorTree based on the current state of the LLVM IR in F. More...
 
LLVM_DUMP_METHOD void dump () const
 Debug method to help view the state of pending updates. More...
 

Detailed Description

Class to defer updates to a DominatorTree.

Definition: Applying updates to every edge insertion and deletion is expensive and not necessary. When one needs the DominatorTree for analysis they can request a flush() to perform a larger batch update. This has the advantage of the DominatorTree inspecting the set of updates to find duplicates or unnecessary subtree updates.

The scope of DeferredDominance operates at a Function level.

It is not necessary for the user to scrub the updates for duplicates or updates that point to the same block (Delete, BB_A, BB_A). Performance can be gained if the caller attempts to batch updates before submitting to applyUpdates(ArrayRef) in cases where duplicate edge requests will occur.

It is required for the state of the LLVM IR to be applied before submitting updates. The update routines must analyze the current state between a pair of (From, To) basic blocks to determine if the update needs to be queued. Example (good): TerminatorInstructionBB->removeFromParent(); DDT->deleteEdge(BB, Successor); Example (bad): DDT->deleteEdge(BB, Successor); TerminatorInstructionBB->removeFromParent();

Definition at line 307 of file Dominators.h.

Constructor & Destructor Documentation

◆ DeferredDominance()

llvm::DeferredDominance::DeferredDominance ( DominatorTree DT_)
inline

Definition at line 309 of file Dominators.h.

References llvm::dump(), F(), Kind, and LLVM_DUMP_METHOD.

Member Function Documentation

◆ applyUpdates()

void DeferredDominance::applyUpdates ( ArrayRef< DominatorTree::UpdateType Updates)

◆ deleteBB()

void DeferredDominance::deleteBB ( BasicBlock DelBB)

◆ deleteEdge()

void DeferredDominance::deleteEdge ( BasicBlock From,
BasicBlock To 
)

Helper method for a single edge deletion.

It's almost always better to batch updates and call applyUpdates to quickly remove duplicate edges. This is best used when there is only a single deletion needed to update Dominators.

Definition at line 409 of file Dominators.cpp.

References llvm::DominatorTreeBase< BasicBlock, false >::Delete.

◆ dump()

LLVM_DUMP_METHOD void DeferredDominance::dump ( ) const

◆ flush()

DominatorTree & DeferredDominance::flush ( )

Flushes all pending updates and block deletions.

Returns a correct DominatorTree reference to be used by the caller for analysis.

Definition at line 443 of file Dominators.cpp.

References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates().

◆ insertEdge()

void DeferredDominance::insertEdge ( BasicBlock From,
BasicBlock To 
)

Helper method for a single edge insertion.

It's almost always better to batch updates and call applyUpdates to quickly remove duplicate edges. This is best used when there is only a single insertion needed to update Dominators.

Definition at line 401 of file Dominators.cpp.

References llvm::DominatorTreeBase< BasicBlock, false >::Insert.

◆ pending()

bool DeferredDominance::pending ( )

Returns true if pending DT updates are queued for a flush() event.

Definition at line 439 of file Dominators.cpp.

◆ pendingDeletedBB()

bool DeferredDominance::pendingDeletedBB ( BasicBlock DelBB)

Returns true if DelBB is awaiting deletion at a flush() event.

Definition at line 432 of file Dominators.cpp.

◆ recalculate()

void DeferredDominance::recalculate ( Function F)

Drops all internal state and forces a (slow) recalculation of the DominatorTree based on the current state of the LLVM IR in F.

This should only be used in corner cases such as the Entry block of F being deleted.

Definition at line 457 of file Dominators.cpp.


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