LLVM 20.0.0git
Classes | Namespaces | Functions
BasicBlockUtils.h File Reference
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Dominators.h"
#include <cassert>

Go to the source code of this file.

Classes

struct  llvm::CriticalEdgeSplittingOptions
 Option class for critical edge splitting. More...
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Functions

void llvm::detachDeadBlocks (ArrayRef< BasicBlock * > BBs, SmallVectorImpl< DominatorTree::UpdateType > *Updates, bool KeepOneInputPHIs=false)
 Replace contents of every block in BBs with single unreachable instruction.
 
void llvm::DeleteDeadBlock (BasicBlock *BB, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
 Delete the specified block, which must have no predecessors.
 
void llvm::DeleteDeadBlocks (ArrayRef< BasicBlock * > BBs, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
 Delete the specified blocks from BB.
 
bool llvm::EliminateUnreachableBlocks (Function &F, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
 Delete all basic blocks from F that are not reachable from its entry node.
 
bool llvm::FoldSingleEntryPHINodes (BasicBlock *BB, MemoryDependenceResults *MemDep=nullptr)
 We know that BB has one predecessor.
 
bool llvm::DeleteDeadPHIs (BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr)
 Examine each PHI in the given block and delete it if it is dead.
 
bool llvm::MergeBlockIntoPredecessor (BasicBlock *BB, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, MemoryDependenceResults *MemDep=nullptr, bool PredecessorWithTwoSuccessors=false, DominatorTree *DT=nullptr)
 Attempts to merge a block into its predecessor, if possible.
 
bool llvm::MergeBlockSuccessorsIntoGivenBlocks (SmallPtrSetImpl< BasicBlock * > &MergeBlocks, Loop *L=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)
 Merge block(s) sucessors, if possible.
 
bool llvm::RemoveRedundantDbgInstrs (BasicBlock *BB)
 Try to remove redundant dbg.value instructions from given basic block.
 
void llvm::ReplaceInstWithValue (BasicBlock::iterator &BI, Value *V)
 Replace all uses of an instruction (specified by BI) with a value, then remove and delete the original instruction.
 
void llvm::ReplaceInstWithInst (BasicBlock *BB, BasicBlock::iterator &BI, Instruction *I)
 Replace the instruction specified by BI with the instruction specified by I.
 
void llvm::ReplaceInstWithInst (Instruction *From, Instruction *To)
 Replace the instruction specified by From with the instruction specified by To.
 
bool llvm::IsBlockFollowedByDeoptOrUnreachable (const BasicBlock *BB)
 Check if we can prove that all paths starting from this block converge to a block that either has a @llvm.experimental.deoptimize call prior to its terminating return instruction or is terminated by unreachable.
 
void llvm::createPHIsForSplitLoopExit (ArrayRef< BasicBlock * > Preds, BasicBlock *SplitBB, BasicBlock *DestBB)
 When a loop exit edge is split, LCSSA form may require new PHIs in the new exit block.
 
BasicBlockllvm::SplitCriticalEdge (Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
 If this edge is a critical edge, insert a new node to split the critical edge.
 
BasicBlockllvm::SplitKnownCriticalEdge (Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
 If it is known that an edge is critical, SplitKnownCriticalEdge can be called directly, rather than calling SplitCriticalEdge first.
 
BasicBlock * llvm::SplitCriticalEdge (BasicBlock *Src, BasicBlock *Dst, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
 If an edge from Src to Dst is critical, split the edge and return true, otherwise return false.
 
unsigned llvm::SplitAllCriticalEdges (Function &F, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
 Loop over all of the edges in the CFG, breaking critical edges as they are found.
 
BasicBlockllvm::SplitEdge (BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
 Split the edge connecting the specified blocks, and return the newly created basic block between From and To.
 
void llvm::setUnwindEdgeTo (Instruction *TI, BasicBlock *Succ)
 Sets the unwind edge of an instruction to a particular successor.
 
void llvm::updatePhiNodes (BasicBlock *DestBB, BasicBlock *OldPred, BasicBlock *NewPred, PHINode *Until=nullptr)
 Replaces all uses of OldPred with the NewPred block in all PHINodes in a block.
 
BasicBlockllvm::ehAwareSplitEdge (BasicBlock *BB, BasicBlock *Succ, LandingPadInst *OriginalPad=nullptr, PHINode *LandingPadReplacement=nullptr, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
 Split the edge connect the specficed blocks in the case that Succ is an Exception Handling Block.
 
BasicBlockllvm::SplitBlock (BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
 Split the specified block at the specified instruction.
 
BasicBlock * llvm::SplitBlock (BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
 
BasicBlockllvm::SplitBlock (BasicBlock *Old, BasicBlock::iterator SplitPt, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
 Split the specified block at the specified instruction.
 
BasicBlock * llvm::SplitBlock (BasicBlock *Old, Instruction *SplitPt, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
 
BasicBlockllvm::splitBlockBefore (BasicBlock *Old, BasicBlock::iterator SplitPt, DomTreeUpdater *DTU, LoopInfo *LI, MemorySSAUpdater *MSSAU, const Twine &BBName="")
 Split the specified block at the specified instruction SplitPt.
 
BasicBlock * llvm::splitBlockBefore (BasicBlock *Old, Instruction *SplitPt, DomTreeUpdater *DTU, LoopInfo *LI, MemorySSAUpdater *MSSAU, const Twine &BBName="")
 
BasicBlockllvm::SplitBlockPredecessors (BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
 This method introduces at least one new basic block into the function and moves some of the predecessors of BB to be predecessors of the new block.
 
BasicBlockllvm::SplitBlockPredecessors (BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
 This method introduces at least one new basic block into the function and moves some of the predecessors of BB to be predecessors of the new block.
 
void llvm::SplitLandingPadPredecessors (BasicBlock *OrigBB, ArrayRef< BasicBlock * > Preds, const char *Suffix, const char *Suffix2, SmallVectorImpl< BasicBlock * > &NewBBs, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
 This method transforms the landing pad, OrigBB, by introducing two new basic blocks into the function.
 
ReturnInstllvm::FoldReturnIntoUncondBranch (ReturnInst *RI, BasicBlock *BB, BasicBlock *Pred, DomTreeUpdater *DTU=nullptr)
 This method duplicates the specified return instruction into a predecessor which ends in an unconditional branch.
 
Instructionllvm::SplitBlockAndInsertIfThen (Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
 Split the containing block at the specified instruction - everything before SplitBefore stays in the old basic block, and the rest of the instructions in the BB are moved to a new block.
 
Instruction * llvm::SplitBlockAndInsertIfThen (Value *Cond, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
 
Instructionllvm::SplitBlockAndInsertIfElse (Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ElseBlock=nullptr)
 Similar to SplitBlockAndInsertIfThen, but the inserted block is on the false path of the branch.
 
Instruction * llvm::SplitBlockAndInsertIfElse (Value *Cond, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ElseBlock=nullptr)
 
void llvm::SplitBlockAndInsertIfThenElse (Value *Cond, BasicBlock::iterator SplitBefore, Instruction **ThenTerm, Instruction **ElseTerm, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)
 SplitBlockAndInsertIfThenElse is similar to SplitBlockAndInsertIfThen, but also creates the ElseBlock.
 
void llvm::SplitBlockAndInsertIfThenElse (Value *Cond, Instruction *SplitBefore, Instruction **ThenTerm, Instruction **ElseTerm, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)
 
void llvm::SplitBlockAndInsertIfThenElse (Value *Cond, BasicBlock::iterator SplitBefore, BasicBlock **ThenBlock, BasicBlock **ElseBlock, bool UnreachableThen=false, bool UnreachableElse=false, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)
 Split the containing block at the specified instruction - everything before SplitBefore stays in the old basic block, and the rest of the instructions in the BB are moved to a new block.
 
void llvm::SplitBlockAndInsertIfThenElse (Value *Cond, Instruction *SplitBefore, BasicBlock **ThenBlock, BasicBlock **ElseBlock, bool UnreachableThen=false, bool UnreachableElse=false, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)
 
std::pair< Instruction *, Value * > llvm::SplitBlockAndInsertSimpleForLoop (Value *End, Instruction *SplitBefore)
 Insert a for (int i = 0; i < End; i++) loop structure (with the exception that End is assumed > 0, and thus not checked on entry) at SplitBefore.
 
void llvm::SplitBlockAndInsertForEachLane (ElementCount EC, Type *IndexTy, Instruction *InsertBefore, std::function< void(IRBuilderBase &, Value *)> Func)
 Utility function for performing a given action on each lane of a vector with EC elements.
 
void llvm::SplitBlockAndInsertForEachLane (Value *End, Instruction *InsertBefore, std::function< void(IRBuilderBase &, Value *)> Func)
 Utility function for performing a given action on each lane of a vector with EVL effective length.
 
BranchInstllvm::GetIfCondition (BasicBlock *BB, BasicBlock *&IfTrue, BasicBlock *&IfFalse)
 Check whether BB is the merge point of a if-region.
 
bool llvm::SplitIndirectBrCriticalEdges (Function &F, bool IgnoreBlocksWithoutPHI, BranchProbabilityInfo *BPI=nullptr, BlockFrequencyInfo *BFI=nullptr)
 
BasicBlock * llvm::CreateControlFlowHub (DomTreeUpdater *DTU, SmallVectorImpl< BasicBlock * > &GuardBlocks, const SetVector< BasicBlock * > &Predecessors, const SetVector< BasicBlock * > &Successors, const StringRef Prefix, std::optional< unsigned > MaxControlFlowBooleans=std::nullopt)
 Given a set of incoming and outgoing blocks, create a "hub" such that every edge from an incoming block InBB to an outgoing block OutBB is now split into two edges, one from InBB to the hub and another from the hub to OutBB.
 
void llvm::InvertBranch (BranchInst *PBI, IRBuilderBase &Builder)
 
bool llvm::hasOnlySimpleTerminator (const Function &F)
 
bool llvm::isPresplitCoroSuspendExitEdge (const BasicBlock &Src, const BasicBlock &Dest)