15 #ifndef LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H
16 #define LLVM_TRANSFORMS_UTILS_BASICBLOCKUTILS_H
26 class MemoryDependenceAnalysis;
32 class TargetLibraryInfo;
44 MemoryDependenceAnalysis *MemDep =
nullptr);
56 LoopInfo *LI =
nullptr,
58 MemoryDependenceAnalysis *MemDep =
nullptr);
143 const CriticalEdgeSplittingOptions &Options =
144 CriticalEdgeSplittingOptions());
162 bool MadeChange =
false;
192 const CriticalEdgeSplittingOptions &Options =
193 CriticalEdgeSplittingOptions());
197 DominatorTree *DT =
nullptr, LoopInfo *LI =
nullptr);
205 DominatorTree *DT =
nullptr, LoopInfo *LI =
nullptr);
226 DominatorTree *DT =
nullptr,
227 LoopInfo *LI =
nullptr,
228 bool PreserveLCSSA =
false);
244 ArrayRef<BasicBlock *> Preds,
245 const char *Suffix,
const char *Suffix2,
246 SmallVectorImpl<BasicBlock *> &NewBBs,
248 DominatorTree *DT =
nullptr,
249 LoopInfo *LI =
nullptr,
250 bool PreserveLCSSA =
false);
283 MDNode *BranchWeights =
nullptr,
284 DominatorTree *DT =
nullptr);
301 TerminatorInst **ThenTerm,
302 TerminatorInst **ElseTerm,
303 MDNode *BranchWeights =
nullptr);
void ReplaceInstWithInst(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Instruction *I)
ReplaceInstWithInst - Replace the instruction specified by BI with the instruction specified by I...
void SplitBlockAndInsertIfThenElse(Value *Cond, Instruction *SplitBefore, TerminatorInst **ThenTerm, TerminatorInst **ElseTerm, MDNode *BranchWeights=nullptr)
SplitBlockAndInsertIfThenElse is similar to SplitBlockAndInsertIfThen, but also creates the ElseBlock...
BasicBlock * SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
SplitBlock - Split the specified block at the specified instruction - every thing before SplitPt stay...
void DeleteDeadBlock(BasicBlock *BB)
DeleteDeadBlock - Delete the specified block, which must have no predecessors.
TerminatorInst * SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DominatorTree *DT=nullptr)
SplitBlockAndInsertIfThen - Split the containing block at the specified instruction - everything befo...
unsigned SplitAllCriticalEdges(Function &F, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
Option class for critical edge splitting.
CriticalEdgeSplittingOptions()
CriticalEdgeSplittingOptions(AliasAnalysis *AA, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
Basic case of setting up all the analysis.
bool MergeBlockIntoPredecessor(BasicBlock *BB, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, AliasAnalysis *AA=nullptr, MemoryDependenceAnalysis *MemDep=nullptr)
MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor, if possible.
bool DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr)
DeleteDeadPHIs - Examine each PHI in the given block and delete it if it is dead. ...
iplist< Instruction > InstListType
void ReplaceInstWithValue(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Value *V)
ReplaceInstWithValue - Replace all uses of an instruction (specified by BI) with a value...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
void FoldSingleEntryPHINodes(BasicBlock *BB, AliasAnalysis *AA=nullptr, MemoryDependenceAnalysis *MemDep=nullptr)
FoldSingleEntryPHINodes - We know that BB has one predecessor.
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
BasicBlock * SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
SplitCriticalEdge - If this edge is a critical edge, insert a new node to split the critical edge...
CriticalEdgeSplittingOptions & setMergeIdenticalEdges()
Subclasses of this class are all able to terminate a basic block.
LLVM Basic Block Representation.
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
Value * GetIfCondition(BasicBlock *BB, BasicBlock *&IfTrue, BasicBlock *&IfFalse)
GetIfCondition - Check whether BB is the merge point of a if-region.
unsigned getSuccessorIndex() const
getSuccessorIndex - This is used to interface between code that wants to operate on terminator instru...
CriticalEdgeSplittingOptions & setPreserveLCSSA()
void SplitLandingPadPredecessors(BasicBlock *OrigBB, ArrayRef< BasicBlock * > Preds, const char *Suffix, const char *Suffix2, SmallVectorImpl< BasicBlock * > &NewBBs, AliasAnalysis *AA=nullptr, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, bool PreserveLCSSA=false)
SplitLandingPadPredecessors - This method transforms the landing pad, OrigBB, by introducing two new ...
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
ReturnInst * FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB, BasicBlock *Pred)
FoldReturnIntoUncondBranch - This method duplicates the specified return instruction into a predecess...
CriticalEdgeSplittingOptions & setDontDeleteUselessPHIs()
CriticalEdgeSplittingOptions(DominatorTree *DT, LoopInfo *LI)
A common pattern is to preserve the dominator tree and loop info but not care about AA...
BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
SplitEdge - Split the edge connecting specified block.
BasicBlock * SplitBlockPredecessors(BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, AliasAnalysis *AA=nullptr, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, bool PreserveLCSSA=false)
SplitBlockPredecessors - This method introduces at least one new basic block into the function and mo...
bool DontDeleteUselessPHIs
InstListType::iterator iterator
Instruction iterators...