1//===- Transform/Utils/BasicBlockUtils.h - BasicBlock Utils -----*- C++ -*-===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 9// This family of functions perform manipulations on basic blocks, and 10// instructions contained within basic blocks. 12//===----------------------------------------------------------------------===// 14#ifndef LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H 15#define LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H 17// FIXME: Move to this file: BasicBlock::removePredecessor, BB::splitBasicBlock 30template <
typename PtrType>
classSmallPtrSetImpl;
31classBlockFrequencyInfo;
32classBranchProbabilityInfo;
38classMemoryDependenceResults;
40classPostDominatorTree;
42classTargetLibraryInfo;
45/// Replace contents of every block in \p BBs with single unreachable 46/// instruction. If \p Updates is specified, collect all necessary DT updates 47/// into this vector. If \p KeepOneInputPHIs is true, one-input Phis in 48/// successors of blocks being deleted will be preserved. 50 SmallVectorImpl<DominatorTree::UpdateType> *Updates,
51bool KeepOneInputPHIs =
false);
53/// Delete the specified block, which must have no predecessors. 55bool KeepOneInputPHIs =
false);
57/// Delete the specified blocks from \p BB. The set of deleted blocks must have 58/// no predecessors that are not being deleted themselves. \p BBs must have no 59/// duplicating blocks. If there are loops among this set of blocks, all 60/// relevant loop info updates should be done before this function is called. 61/// If \p KeepOneInputPHIs is true, one-input Phis in successors of blocks 62/// being deleted will be preserved. 64 DomTreeUpdater *DTU =
nullptr,
65bool KeepOneInputPHIs =
false);
67/// Delete all basic blocks from \p F that are not reachable from its entry 68/// node. If \p KeepOneInputPHIs is true, one-input Phis in successors of 69/// blocks being deleted will be preserved. 71bool KeepOneInputPHIs =
false);
73/// We know that BB has one predecessor. If there are any single-entry PHI nodes 74/// in it, fold them away. This handles the case when all entries to the PHI 75/// nodes in a block are guaranteed equal, such as when the block has exactly 78 MemoryDependenceResults *MemDep =
nullptr);
80/// Examine each PHI in the given block and delete it if it is dead. Also 81/// recursively delete any operands that become dead as a result. This includes 82/// tracing the def-use list from the PHI to see if it is ultimately unused or 83/// if it reaches an unused cycle. Return true if any PHIs were deleted. 84boolDeleteDeadPHIs(BasicBlock *BB,
const TargetLibraryInfo *TLI =
nullptr,
85 MemorySSAUpdater *MSSAU =
nullptr);
87/// Attempts to merge a block into its predecessor, if possible. The return 88/// value indicates success or failure. 89/// By default do not merge blocks if BB's predecessor has multiple successors. 90/// If PredecessorWithTwoSuccessors = true, the blocks can only be merged 91/// if BB's Pred has a branch to BB and to AnotherBB, and BB has a single 92/// successor Sing. In this case the branch will be updated with Sing instead of 93/// BB, and BB will still be merged into its predecessor and removed. 94/// If \p DT is not nullptr, update it directly; in that case, DTU must be 97 LoopInfo *LI =
nullptr,
98 MemorySSAUpdater *MSSAU =
nullptr,
99 MemoryDependenceResults *MemDep =
nullptr,
100bool PredecessorWithTwoSuccessors =
false,
101 DominatorTree *DT =
nullptr);
103/// Merge block(s) sucessors, if possible. Return true if at least two 104/// of the blocks were merged together. 105/// In order to merge, each block must be terminated by an unconditional 106/// branch. If L is provided, then the blocks merged into their predecessors 107/// must be in L. In addition, This utility calls on another utility: 108/// MergeBlockIntoPredecessor. Blocks are successfully merged when the call to 109/// MergeBlockIntoPredecessor returns true. 111 SmallPtrSetImpl<BasicBlock *> &MergeBlocks, Loop *L =
nullptr,
112 DomTreeUpdater *DTU =
nullptr, LoopInfo *LI =
nullptr);
114/// Try to remove redundant dbg.value instructions from given basic block. 115/// Returns true if at least one instruction was removed. Remove redundant 116/// pseudo ops when RemovePseudoOp is true. 119/// Replace all uses of an instruction (specified by BI) with a value, then 120/// remove and delete the original instruction. 123/// Replace the instruction specified by BI with the instruction specified by I. 124/// Copies DebugLoc from BI to I, if I doesn't already have a DebugLoc. The 125/// original instruction is deleted and BI is updated to point to the new 130/// Replace the instruction specified by From with the instruction specified by 131/// To. Copies DebugLoc from BI to I, if I doesn't already have a DebugLoc. 134/// Check if we can prove that all paths starting from this block converge 135/// to a block that either has a @llvm.experimental.deoptimize call 136/// prior to its terminating return instruction or is terminated by unreachable. 137/// All blocks in the traversed sequence must have an unique successor, maybe 138/// except for the last one. 141/// Option class for critical edge splitting. 143/// This provides a builder interface for overriding the default options used 144/// during critical edge splitting. 154 /// SplitCriticalEdge is guaranteed to preserve loop-simplify form if LI is 155 /// provided. If it cannot be preserved, no splitting will take place. If it 156 /// is not set, preserve loop-simplify form if possible. 191/// When a loop exit edge is split, LCSSA form may require new PHIs in the new 192/// exit block. This function inserts the new PHIs, as needed. Preds is a list 193/// of preds inside the loop, SplitBB is the new loop exit block, and DestBB is 194/// the old loop exit, now the successor of SplitBB. 196 BasicBlock *SplitBB, BasicBlock *DestBB);
198/// If this edge is a critical edge, insert a new node to split the critical 199/// edge. This will update the analyses passed in through the option struct. 200/// This returns the new block if the edge was split, null otherwise. 202/// If MergeIdenticalEdges in the options struct is true (not the default), 203/// *all* edges from TI to the specified successor will be merged into the same 204/// critical edge block. This is most commonly interesting with switch 205/// instructions, which may have many edges to any one destination. This 206/// ensures that all edges to that dest go to one block instead of each going 207/// to a different block, but isn't the standard definition of a "critical 210/// It is invalid to call this function on a critical edge that starts at an 211/// IndirectBrInst. Splitting these edges will almost always create an invalid 212/// program because the address of the new block won't be the one that is jumped 215const CriticalEdgeSplittingOptions &
Options =
216 CriticalEdgeSplittingOptions(),
217const Twine &BBName =
"");
219/// If it is known that an edge is critical, SplitKnownCriticalEdge can be 220/// called directly, rather than calling SplitCriticalEdge first. 222const CriticalEdgeSplittingOptions &
Options =
223 CriticalEdgeSplittingOptions(),
224const Twine &BBName =
"");
226/// If an edge from Src to Dst is critical, split the edge and return true, 227/// otherwise return false. This method requires that there be an edge between 228/// the two blocks. It updates the analyses passed in the options struct 243/// Loop over all of the edges in the CFG, breaking critical edges as they are 244/// found. Returns the number of broken edges. 246const CriticalEdgeSplittingOptions &
Options =
247 CriticalEdgeSplittingOptions());
249/// Split the edge connecting the specified blocks, and return the newly created 250/// basic block between \p From and \p To. 252 DominatorTree *DT =
nullptr, LoopInfo *LI =
nullptr,
253 MemorySSAUpdater *MSSAU =
nullptr,
254const Twine &BBName =
"");
256/// Sets the unwind edge of an instruction to a particular successor. 259/// Replaces all uses of OldPred with the NewPred block in all PHINodes in a 262 BasicBlock *NewPred, PHINode *Until =
nullptr);
264/// Split the edge connect the specficed blocks in the case that \p Succ is an 265/// Exception Handling Block 267 LandingPadInst *OriginalPad =
nullptr,
268 PHINode *LandingPadReplacement =
nullptr,
269const CriticalEdgeSplittingOptions &
Options =
270 CriticalEdgeSplittingOptions(),
271const Twine &BBName =
"");
273/// Split the specified block at the specified instruction. 275/// If \p Before is true, splitBlockBefore handles the block 276/// splitting. Otherwise, execution proceeds as described below. 278/// Everything before \p SplitPt stays in \p Old and everything starting with \p 279/// SplitPt moves to a new block. The two blocks are joined by an unconditional 280/// branch. The new block with name \p BBName is returned. 282/// FIXME: deprecated, switch to the DomTreeUpdater-based one. 284 LoopInfo *LI =
nullptr,
285 MemorySSAUpdater *MSSAU =
nullptr,
286const Twine &BBName =
"",
boolBefore =
false);
294/// Split the specified block at the specified instruction. 296/// If \p Before is true, splitBlockBefore handles the block 297/// splitting. Otherwise, execution proceeds as described below. 299/// Everything before \p SplitPt stays in \p Old and everything starting with \p 300/// SplitPt moves to a new block. The two blocks are joined by an unconditional 301/// branch. The new block with name \p BBName is returned. 303 DomTreeUpdater *DTU =
nullptr, LoopInfo *LI =
nullptr,
304 MemorySSAUpdater *MSSAU =
nullptr,
305const Twine &BBName =
"",
boolBefore =
false);
313/// Split the specified block at the specified instruction \p SplitPt. 314/// All instructions before \p SplitPt are moved to a new block and all 315/// instructions after \p SplitPt stay in the old block. The new block and the 316/// old block are joined by inserting an unconditional branch to the end of the 317/// new block. The new block with name \p BBName is returned. 319 DomTreeUpdater *DTU, LoopInfo *LI,
320 MemorySSAUpdater *MSSAU,
const Twine &BBName =
"");
327/// This method introduces at least one new basic block into the function and 328/// moves some of the predecessors of BB to be predecessors of the new block. 329/// The new predecessors are indicated by the Preds array. The new block is 330/// given a suffix of 'Suffix'. Returns new basic block to which predecessors 331/// from Preds are now pointing. 333/// If BB is a landingpad block then additional basicblock might be introduced. 334/// It will have Suffix+".split_lp". See SplitLandingPadPredecessors for more 335/// details on this case. 337/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but 338/// no other analyses. In particular, it does not preserve LoopSimplify 339/// (because it's complicated to handle the case where one of the edges being 340/// split is an exit of a loop with other exits). 342/// FIXME: deprecated, switch to the DomTreeUpdater-based one. 344constchar *Suffix, DominatorTree *DT,
345 LoopInfo *LI =
nullptr,
346 MemorySSAUpdater *MSSAU =
nullptr,
347bool PreserveLCSSA =
false);
349/// This method introduces at least one new basic block into the function and 350/// moves some of the predecessors of BB to be predecessors of the new block. 351/// The new predecessors are indicated by the Preds array. The new block is 352/// given a suffix of 'Suffix'. Returns new basic block to which predecessors 353/// from Preds are now pointing. 355/// If BB is a landingpad block then additional basicblock might be introduced. 356/// It will have Suffix+".split_lp". See SplitLandingPadPredecessors for more 357/// details on this case. 359/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but 360/// no other analyses. In particular, it does not preserve LoopSimplify 361/// (because it's complicated to handle the case where one of the edges being 362/// split is an exit of a loop with other exits). 365 DomTreeUpdater *DTU =
nullptr,
366 LoopInfo *LI =
nullptr,
367 MemorySSAUpdater *MSSAU =
nullptr,
368bool PreserveLCSSA =
false);
370/// This method transforms the landing pad, OrigBB, by introducing two new basic 371/// blocks into the function. One of those new basic blocks gets the 372/// predecessors listed in Preds. The other basic block gets the remaining 373/// predecessors of OrigBB. The landingpad instruction OrigBB is clone into both 374/// of the new basic blocks. The new blocks are given the suffixes 'Suffix1' and 375/// 'Suffix2', and are returned in the NewBBs vector. 377/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but 378/// no other analyses. In particular, it does not preserve LoopSimplify 379/// (because it's complicated to handle the case where one of the edges being 380/// split is an exit of a loop with other exits). 382 BasicBlock *OrigBB, ArrayRef<BasicBlock *> Preds,
constchar *Suffix,
383constchar *Suffix2, SmallVectorImpl<BasicBlock *> &NewBBs,
384 DomTreeUpdater *DTU =
nullptr, LoopInfo *LI =
nullptr,
385 MemorySSAUpdater *MSSAU =
nullptr,
bool PreserveLCSSA =
false);
387/// This method duplicates the specified return instruction into a predecessor 388/// which ends in an unconditional branch. If the return instruction returns a 389/// value defined by a PHI, propagate the right value into the return. It 390/// returns the new return instruction in the predecessor. 393 DomTreeUpdater *DTU =
nullptr);
395/// Split the containing block at the specified instruction - everything before 396/// SplitBefore stays in the old basic block, and the rest of the instructions 397/// in the BB are moved to a new block. The two blocks are connected by a 398/// conditional branch (with value of Cmp being the condition). 410/// If \p ThenBlock is not specified, a new block will be created for it. 411/// If \p Unreachable is true, the newly created block will end with 412/// UnreachableInst, otherwise it branches to Tail. 413/// Returns the NewBasicBlock's terminator. 415/// Updates DTU and LI if given. 418 MDNode *BranchWeights =
nullptr,
419 DomTreeUpdater *DTU =
nullptr,
420 LoopInfo *LI =
nullptr,
421 BasicBlock *ThenBlock =
nullptr);
425MDNode *BranchWeights =
nullptr,
430 Unreachable, BranchWeights, DTU, LI,
434/// Similar to SplitBlockAndInsertIfThen, but the inserted block is on the false 435/// path of the branch. 438 MDNode *BranchWeights =
nullptr,
439 DomTreeUpdater *DTU =
nullptr,
440 LoopInfo *LI =
nullptr,
441 BasicBlock *ElseBlock =
nullptr);
445MDNode *BranchWeights =
nullptr,
450 Unreachable, BranchWeights, DTU, LI,
454/// SplitBlockAndInsertIfThenElse is similar to SplitBlockAndInsertIfThen, 455/// but also creates the ElseBlock. 469/// Updates DT if given. 472 Instruction **ThenTerm,
473 Instruction **ElseTerm,
474 MDNode *BranchWeights =
nullptr,
475 DomTreeUpdater *DTU =
nullptr,
476 LoopInfo *LI =
nullptr);
481MDNode *BranchWeights =
nullptr,
486 ElseTerm, BranchWeights, DTU, LI);
489/// Split the containing block at the specified instruction - everything before 490/// SplitBefore stays in the old basic block, and the rest of the instructions 491/// in the BB are moved to a new block. The two blocks are connected by a 492/// conditional branch (with value of Cmp being the condition). 506/// If \p ThenBlock is null, the resulting CFG won't contain the TrueBlock. If 507/// \p ThenBlock is non-null and points to non-null BasicBlock pointer, that 508/// block will be inserted as the TrueBlock. Otherwise a new block will be 509/// created. Likewise for the \p ElseBlock parameter. 510/// If \p UnreachableThen or \p UnreachableElse is true, the corresponding newly 511/// created blocks will end with UnreachableInst, otherwise with branches to 512/// Tail. The function will not modify existing basic blocks passed to it. The 513/// caller must ensure that Tail is reachable from Head. 514/// Returns the newly created blocks in \p ThenBlock and \p ElseBlock. 515/// Updates DTU and LI if given. 518 BasicBlock **ThenBlock,
519 BasicBlock **ElseBlock,
520bool UnreachableThen =
false,
521bool UnreachableElse =
false,
522 MDNode *BranchWeights =
nullptr,
523 DomTreeUpdater *DTU =
nullptr,
524 LoopInfo *LI =
nullptr);
529bool UnreachableThen =
false,
530bool UnreachableElse =
false,
531MDNode *BranchWeights =
nullptr,
535 ElseBlock, UnreachableThen, UnreachableElse, BranchWeights, DTU, LI);
538/// Insert a for (int i = 0; i < End; i++) loop structure (with the exception 539/// that \p End is assumed > 0, and thus not checked on entry) at \p 540/// SplitBefore. Returns the first insert point in the loop body, and the 541/// PHINode for the induction variable (i.e. "i" above). 542std::pair<Instruction*, Value*>
545/// Utility function for performing a given action on each lane of a vector 546/// with \p EC elements. To simplify porting legacy code, this defaults to 547/// unrolling the implied loop for non-scalable element counts, but this is 548/// not considered to be part of the contract of this routine, and is 549/// expected to change in the future. The callback takes as arguments an 550/// IRBuilder whose insert point is correctly set for instantiating the 551/// given index, and a value which is (at runtime) the index to access. 552/// This index *may* be a constant. 555 std::function<
void(IRBuilderBase &, Value *)> Func);
557/// Utility function for performing a given action on each lane of a vector 558/// with \p EVL effective length. EVL is assumed > 0. To simplify porting legacy 559/// code, this defaults to unrolling the implied loop for non-scalable element 560/// counts, but this is not considered to be part of the contract of this 561/// routine, and is expected to change in the future. The callback takes as 562/// arguments an IRBuilder whose insert point is correctly set for instantiating 563/// the given index, and a value which is (at runtime) the index to access. This 564/// index *may* be a constant. 567 std::function<
void(IRBuilderBase &, Value *)> Func);
569/// Check whether BB is the merge point of a if-region. 570/// If so, return the branch instruction that determines which entry into 571/// BB will be taken. Also, return by references the block that will be 572/// entered from if the condition is true, and the block that will be 573/// entered if the condition is false. 575/// This does no checking to see if the true/false blocks have large or unsavory 576/// instructions in them. 578 BasicBlock *&IfFalse);
580// Split critical edges where the source of the edge is an indirectbr 581// instruction. This isn't always possible, but we can handle some easy cases. 582// This is useful because MI is unable to split such critical edges, 583// which means it will not be able to sink instructions along those edges. 584// This is especially painful for indirect branches with many successors, where 585// we end up having to prepare all outgoing values in the origin block. 587// Our normal algorithm for splitting critical edges requires us to update 588// the outgoing edges of the edge origin block, but for an indirectbr this 589// is hard, since it would require finding and updating the block addresses 590// the indirect branch uses. But if a block only has a single indirectbr 591// predecessor, with the others being regular branches, we can do it in a 593// Say we have A -> D, B -> D, I -> D where only I -> D is an indirectbr. 594// We can split D into D0 and D1, where D0 contains only the PHIs from D, 595// and D1 is the D block body. We can then duplicate D0 as D0A and D0B, and 596// create the following structure: 597// A -> D0A, B -> D0A, I -> D0B, D0A -> D1, D0B -> D1 598// If BPI and BFI aren't non-null, BPI/BFI will be updated accordingly. 599// When `IgnoreBlocksWithoutPHI` is set to `true` critical edges leading to a 600// block without phi-instructions will not be split. 602 BranchProbabilityInfo *BPI =
nullptr,
603 BlockFrequencyInfo *BFI =
nullptr);
605// Utility function for inverting branch condition and for swapping its 607voidInvertBranch(BranchInst *PBI, IRBuilderBase &Builder);
609// Check whether the function only has simple terminator: 610// br/brcond/unreachable/ret 613// Returns true if these basic blocks belong to a presplit coroutine and the 614// edge corresponds to the 'default' case in the switch statement in the 617// %0 = call i8 @llvm.coro.suspend(token none, i1 false) 618// switch i8 %0, label %suspend [i8 0, label %resume 619// i8 1, label %cleanup] 621// i.e. the edge to the `%suspend` BB. This edge is special in that it will 622// be elided by coroutine lowering (coro-split), and the `%suspend` BB needs 623// to be kept as-is. It's not a real CFG edge - post-lowering, it will end 624// up being a `ret`, and it must be thus lowerable to support symmetric 625// transfer. For example: 626// - this edge is not a loop exit edge if encountered in a loop (and should 628// - must not be split for PGO instrumentation, for example. 630const BasicBlock &Dest);
631}
// end namespace llvm 633#endif// LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H BlockVerifier::State From
static cl::opt< bool > SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), cl::Hidden, cl::desc("Split all critical edges during " "PHI elimination"))
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
self_iterator getIterator()
This is an optimization pass for GlobalISel generic memory operations.
void ReplaceInstWithInst(BasicBlock *BB, BasicBlock::iterator &BI, Instruction *I)
Replace the instruction specified by BI with the instruction specified by I.
bool RemoveRedundantDbgInstrs(BasicBlock *BB)
Try to remove redundant dbg.value instructions from given basic block.
bool IsBlockFollowedByDeoptOrUnreachable(const BasicBlock *BB)
Check if we can prove that all paths starting from this block converge to a block that either has a @...
BranchInst * GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue, BasicBlock *&IfFalse)
Check whether BB is the merge point of a if-region.
void detachDeadBlocks(ArrayRef< BasicBlock * > BBs, SmallVectorImpl< DominatorTree::UpdateType > *Updates, bool KeepOneInputPHIs=false)
Replace contents of every block in BBs with single unreachable instruction.
bool hasOnlySimpleTerminator(const Function &F)
ReturnInst * FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB, BasicBlock *Pred, DomTreeUpdater *DTU=nullptr)
This method duplicates the specified return instruction into a predecessor which ends in an unconditi...
std::pair< Instruction *, Value * > SplitBlockAndInsertSimpleForLoop(Value *End, BasicBlock::iterator SplitBefore)
Insert a for (int i = 0; i < End; i++) loop structure (with the exception that End is assumed > 0,...
BasicBlock * splitBlockBefore(BasicBlock *Old, BasicBlock::iterator SplitPt, DomTreeUpdater *DTU, LoopInfo *LI, MemorySSAUpdater *MSSAU, const Twine &BBName="")
Split the specified block at the specified instruction SplitPt.
Instruction * 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.
void DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
Delete the specified block, which must have no predecessors.
void ReplaceInstWithValue(BasicBlock::iterator &BI, Value *V)
Replace all uses of an instruction (specified by BI) with a value, then remove and delete the origina...
BasicBlock * 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,...
bool SplitIndirectBrCriticalEdges(Function &F, bool IgnoreBlocksWithoutPHI, BranchProbabilityInfo *BPI=nullptr, BlockFrequencyInfo *BFI=nullptr)
bool DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Examine each PHI in the given block and delete it if it is dead.
void InvertBranch(BranchInst *PBI, IRBuilderBase &Builder)
bool EliminateUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
Delete all basic blocks from F that are not reachable from its entry node.
bool MergeBlockSuccessorsIntoGivenBlocks(SmallPtrSetImpl< BasicBlock * > &MergeBlocks, Loop *L=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr)
Merge block(s) sucessors, if possible.
void 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...
BasicBlock * 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.
void 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...
BasicBlock * 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 predecess...
void 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.
bool 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.
BasicBlock * 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.
bool FoldSingleEntryPHINodes(BasicBlock *BB, MemoryDependenceResults *MemDep=nullptr)
We know that BB has one predecessor.
void 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.
bool isPresplitCoroSuspendExitEdge(const BasicBlock &Src, const BasicBlock &Dest)
BasicBlock * 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.
Instruction * 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 ...
void DeleteDeadBlocks(ArrayRef< BasicBlock * > BBs, DomTreeUpdater *DTU=nullptr, bool KeepOneInputPHIs=false)
Delete the specified blocks from BB.
BasicBlock * 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...
void setUnwindEdgeTo(Instruction *TI, BasicBlock *Succ)
Sets the unwind edge of an instruction to a particular successor.
void SplitBlockAndInsertForEachLane(ElementCount EC, Type *IndexTy, BasicBlock::iterator InsertBefore, std::function< void(IRBuilderBase &, Value *)> Func)
Utility function for performing a given action on each lane of a vector with EC elements.
Option class for critical edge splitting.
CriticalEdgeSplittingOptions(DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, PostDominatorTree *PDT=nullptr)
CriticalEdgeSplittingOptions & setMergeIdenticalEdges()
bool IgnoreUnreachableDests
CriticalEdgeSplittingOptions & setKeepOneInputPHIs()
bool PreserveLoopSimplify
SplitCriticalEdge is guaranteed to preserve loop-simplify form if LI is provided.
CriticalEdgeSplittingOptions & unsetPreserveLoopSimplify()
CriticalEdgeSplittingOptions & setPreserveLCSSA()
CriticalEdgeSplittingOptions & setIgnoreUnreachableDests()