LLVM API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Friends
llvm::BasicBlock Class Reference

LLVM Basic Block Representation. More...

#include <BasicBlock.h>

Inheritance diagram for llvm::BasicBlock:
Inheritance graph
[legend]
Collaboration diagram for llvm::BasicBlock:
Collaboration graph
[legend]

List of all members.

Public Types

typedef iplist< InstructionInstListType
typedef InstListType::iterator iterator
 Instruction iterators...
typedef
InstListType::const_iterator 
const_iterator

Public Member Functions

LLVMContextgetContext () const
 getContext - Get the context in which this basic block lives.
 ~BasicBlock ()
const FunctiongetParent () const
FunctiongetParent ()
TerminatorInstgetTerminator ()
const TerminatorInstgetTerminator () const
InstructiongetFirstNonPHI ()
const InstructiongetFirstNonPHI () const
InstructiongetFirstNonPHIOrDbg ()
const InstructiongetFirstNonPHIOrDbg () const
InstructiongetFirstNonPHIOrDbgOrLifetime ()
const InstructiongetFirstNonPHIOrDbgOrLifetime () const
iterator getFirstInsertionPt ()
const_iterator getFirstInsertionPt () const
void removeFromParent ()
void eraseFromParent ()
void moveBefore (BasicBlock *MovePos)
void moveAfter (BasicBlock *MovePos)
BasicBlockgetSinglePredecessor ()
const BasicBlockgetSinglePredecessor () const
BasicBlockgetUniquePredecessor ()
const BasicBlockgetUniquePredecessor () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
size_t size () const
bool empty () const
const Instructionfront () const
Instructionfront ()
const Instructionback () const
Instructionback ()
const InstListTypegetInstList () const
InstListTypegetInstList ()
ValueSymbolTablegetValueSymbolTable ()
 getValueSymbolTable() - returns pointer to symbol table (if any)
void dropAllReferences ()
void removePredecessor (BasicBlock *Pred, bool DontDeleteUselessPHIs=false)
BasicBlocksplitBasicBlock (iterator I, const Twine &BBName="")
bool hasAddressTaken () const
void replaceSuccessorsPhiUsesWith (BasicBlock *New)
bool isLandingPad () const
LandingPadInstgetLandingPadInst ()
const LandingPadInstgetLandingPadInst () const

Static Public Member Functions

static BasicBlockCreate (LLVMContext &Context, const Twine &Name="", Function *Parent=0, BasicBlock *InsertBefore=0)
static iplist< Instruction >
BasicBlock::* 
getSublistAccess (Instruction *)
 getSublistAccess() - returns pointer to member of instruction list
static bool classof (const BasicBlock *)
 Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof (const Value *V)

Friends

class BlockAddress
class SymbolTableListTraits< BasicBlock, Function >

Detailed Description

LLVM Basic Block Representation.

This represents a single basic block in LLVM. A basic block is simply a container of instructions that execute sequentially. Basic blocks are Values because they are referenced by instructions such as branches and switch tables. The type of a BasicBlock is "Type::LabelTy" because the basic block represents a label to which a branch can jump.

A well formed basic block is formed of a list of non-terminating instructions followed by a single TerminatorInst instruction. TerminatorInst's may not occur in the middle of basic blocks, and must terminate the blocks. The BasicBlock class allows malformed basic blocks to occur because it may be useful in the intermediate stage of constructing or modifying a program. However, the verifier will ensure that basic blocks are "well formed".

Definition at line 70 of file BasicBlock.h.


Member Typedef Documentation

Definition at line 97 of file BasicBlock.h.

Definition at line 74 of file BasicBlock.h.

Instruction iterators...

Definition at line 96 of file BasicBlock.h.


Constructor & Destructor Documentation

BasicBlock::~BasicBlock ( )

Member Function Documentation

const Instruction& llvm::BasicBlock::back ( ) const [inline]
Instruction& llvm::BasicBlock::back ( ) [inline]

Definition at line 199 of file BasicBlock.h.

References llvm::iplist< NodeTy, Traits >::back().

iterator llvm::BasicBlock::begin ( ) [inline]

Instruction iterator methods

Definition at line 189 of file BasicBlock.h.

References llvm::iplist< NodeTy, Traits >::begin().

Referenced by llvm::AliasSetTracker::add(), AddPHINodeEntriesForMappedBlock(), AddPredecessorToBlock(), AddReachableCodeToWorklist(), llvm::CodeMetrics::analyzeBasicBlock(), BlockIsSimpleEnoughToThreadThrough(), llvm::Interpreter::callFunction(), CanPropagatePredecessorsForPHIs(), CheckForEscapingAllocas(), llvm::CloneAndPruneFunctionInto(), llvm::CloneBasicBlock(), CloneLoopBlocks(), createPHIsForSplitLoopExit(), cxxDtorIsEmpty(), llvm::DeleteDeadPHIs(), DeleteInstructionInBlock(), llvm::DemotePHIToStack(), llvm::DemoteRegToStack(), llvm::DominatorTree::dominates(), dropAllReferences(), llvm::EliminateDuplicatePHINodes(), llvm::CodeExtractor::extractCodeRegion(), llvm::FindAvailableLoadedValue(), FindDependencies(), FindInitTrampolineFromBB(), llvm::CodeExtractor::findInputsOutputs(), FindLoopCounter(), FindPHIForConditionForwarding(), FindPHIToPartitionLoops(), llvm::SSAUpdaterTraits< SSAUpdater >::FindPredecessorBlocks(), llvm::FoldBranchToCommonDest(), FoldCondBranchOnPHI(), llvm::FoldSingleEntryPHINodes(), FoldTwoEntryPHINode(), llvm::Loop::getCanonicalInductionVariable(), llvm::MemoryDependenceAnalysis::getDependency(), getFirstNonPHI(), getFirstNonPHIOrDbg(), getFirstNonPHIOrDbgOrLifetime(), GetIfCondition(), llvm::MemoryDependenceAnalysis::getNonLocalCallDependency(), llvm::SCEVExpander::getOrInsertCanonicalInductionVariable(), llvm::MemoryDependenceAnalysis::getPointerDependencyFrom(), llvm::SSAUpdater::GetValueInMiddleOfBlock(), HandleCallsInBlockInlinedThroughInvoke(), HoistThenElseCodeToIf(), llvm::InlineFunction(), llvm::InsertProfilingInitCall(), isBlockValidForExtraction(), isExistingPhi(), llvm::Loop::isLCSSAForm(), llvm::isSafeToLoadUnconditionally(), isTrivialLoopExitBlockHelper(), llvm::Value::isUsedInBasicBlock(), LLVMGetFirstInstruction(), LLVMGetLastInstruction(), LLVMGetPreviousInstruction(), MarkAliveBlocks(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), MergeEmptyReturnBlocks(), NegateValue(), llvm::SparseSolver::Print(), PushLoopPHIs(), removePredecessor(), llvm::RemovePredecessorAndSimplify(), removeUndefIntroducingPredecessor(), llvm::ProfileInfoT< FType, BType >::repair(), llvm::SCEVExpander::replaceCongruentIVs(), replaceSuccessorsPhiUsesWith(), RewriteUsesOfClonedInstructions(), llvm::LoadAndStorePromoter::run(), SimplifyBranchOnICmpChain(), SimplifyCondBranchToCondBranch(), llvm::InstCombiner::SimplifyDivRemOfSelect(), llvm::SimplifyInstructionsInBlock(), llvm::simplifyLoopIVs(), llvm::SparseSolver::Solve(), SpeculativelyExecuteBB(), splitBasicBlock(), llvm::SplitBlockPredecessors(), llvm::SplitCriticalEdge(), llvm::SplitEdge(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), TryToSimplifyUncondBranchWithICmpInIt(), llvm::UnrollLoop(), UpdatePHINodes(), llvm::InstCombiner::visitPHINode(), and llvm::InstCombiner::visitStoreInst().

const_iterator llvm::BasicBlock::begin ( ) const [inline]

Definition at line 190 of file BasicBlock.h.

References llvm::iplist< NodeTy, Traits >::begin().

static bool llvm::BasicBlock::classof ( const BasicBlock ) [inline, static]

Methods for support type inquiry through isa, cast, and dyn_cast:

Definition at line 216 of file BasicBlock.h.

static bool llvm::BasicBlock::classof ( const Value V) [inline, static]

Reimplemented from llvm::Value.

Definition at line 217 of file BasicBlock.h.

References llvm::Value::BasicBlockVal, and llvm::Value::getValueID().

static BasicBlock* llvm::BasicBlock::Create ( LLVMContext Context,
const Twine Name = "",
Function Parent = 0,
BasicBlock InsertBefore = 0 
) [inline, static]
void BasicBlock::dropAllReferences ( )

dropAllReferences() - This function causes all the subinstructions to "let go" of all references that they are maintaining. This allows one to 'delete' a whole class at a time, even though there may be circular references... first all references are dropped, and all use counts go to zero. Then everything is delete'd for real. Note that no operations are valid on an object that has "dropped all references", except operator delete.

Definition at line 176 of file BasicBlock.cpp.

References begin(), end(), and llvm::ARM_PROC::I.

Referenced by ~BasicBlock().

bool llvm::BasicBlock::empty ( ) const [inline]

Definition at line 195 of file BasicBlock.h.

References llvm::iplist< NodeTy, Traits >::empty().

Referenced by llvm::DeleteDeadBlock().

iterator llvm::BasicBlock::end ( ) [inline]
const_iterator llvm::BasicBlock::end ( ) const [inline]

Definition at line 192 of file BasicBlock.h.

References llvm::iplist< NodeTy, Traits >::end().

void BasicBlock::eraseFromParent ( )
const Instruction& llvm::BasicBlock::front ( ) const [inline]
Instruction& llvm::BasicBlock::front ( ) [inline]

Definition at line 197 of file BasicBlock.h.

References llvm::iplist< NodeTy, Traits >::front().

LLVMContext & BasicBlock::getContext ( ) const
BasicBlock::iterator BasicBlock::getFirstInsertionPt ( )

getFirstInsertionPt - Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI instruction. In particular, it skips all PHIs and LandingPad instructions.

Definition at line 170 of file BasicBlock.cpp.

References getFirstNonPHI().

Referenced by llvm::InstCombiner::DoOneIteration(), getFirstInsertionPt(), llvm::IncrementCounterInBlock(), OptimizeCmpExpression(), OptimizeNoopCopyExpression(), llvm::SCEVExpander::replaceCongruentIVs(), llvm::SplitLandingPadPredecessors(), and TryToSinkInstruction().

const_iterator llvm::BasicBlock::getFirstInsertionPt ( ) const [inline]

Definition at line 146 of file BasicBlock.h.

References getFirstInsertionPt().

Instruction * BasicBlock::getFirstNonPHI ( )

Returns a pointer to the first instructon in this block that is not a PHINode instruction. When adding instruction to the beginning of the basic block, they should be added before the returned value, not before the first instruction, which might be PHI. Returns 0 is there's no non-PHI instruction.

Definition at line 130 of file BasicBlock.cpp.

References begin().

Referenced by createPHIsForSplitLoopExit(), llvm::GetFirstDebugLocInBasicBlock(), getFirstInsertionPt(), getFirstNonPHI(), getJumpThreadDuplicationCost(), getLandingPadInst(), llvm::InvokeInst::getLandingPadInst(), and isLandingPad().

const Instruction* llvm::BasicBlock::getFirstNonPHI ( ) const [inline]

Definition at line 126 of file BasicBlock.h.

References getFirstNonPHI().

Instruction * BasicBlock::getFirstNonPHIOrDbg ( )
const Instruction* llvm::BasicBlock::getFirstNonPHIOrDbg ( ) const [inline]

Definition at line 132 of file BasicBlock.h.

References getFirstNonPHIOrDbg().

Instruction * BasicBlock::getFirstNonPHIOrDbgOrLifetime ( )
const Instruction* llvm::BasicBlock::getFirstNonPHIOrDbgOrLifetime ( ) const [inline]

Definition at line 138 of file BasicBlock.h.

References getFirstNonPHIOrDbgOrLifetime().

const InstListType& llvm::BasicBlock::getInstList ( ) const [inline]
InstListType& llvm::BasicBlock::getInstList ( ) [inline]

Definition at line 205 of file BasicBlock.h.

LandingPadInst * BasicBlock::getLandingPadInst ( )

getLandingPadInst() - Return the landingpad instruction associated with the landing pad.

Definition at line 366 of file BasicBlock.cpp.

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

Referenced by llvm::InlineFunction(), and llvm::SplitLandingPadPredecessors().

const LandingPadInst * BasicBlock::getLandingPadInst ( ) const

Definition at line 369 of file BasicBlock.cpp.

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

const Function* llvm::BasicBlock::getParent ( ) const [inline]

getParent - Return the enclosing method, or null if none

Definition at line 110 of file BasicBlock.h.

Referenced by llvm::ProfileInfoT< FType, BType >::addExecutionCount(), llvm::CodeMetrics::analyzeBasicBlock(), llvm::ProfileInfoT< FType, BType >::CalculateMissingEdge(), ChangeToUnreachable(), CheckForEscapingAllocas(), llvm::CloneBasicBlock(), CloneLoopBlocks(), llvm::ConstantFoldTerminator(), llvm::IRBuilderBase::CreateGlobalString(), llvm::IRBuilderBase::CreateLifetimeEnd(), llvm::IRBuilderBase::CreateLifetimeStart(), llvm::IRBuilderBase::CreateMemCpy(), llvm::IRBuilderBase::CreateMemMove(), llvm::IRBuilderBase::CreateMemSet(), llvm::DemotePHIToStack(), llvm::DemoteRegToStack(), llvm::EmitFPutC(), llvm::EmitFPutS(), llvm::EmitFWrite(), llvm::EmitMemChr(), llvm::EmitMemCmp(), llvm::EmitMemCpyChk(), llvm::EmitPutChar(), llvm::EmitPutS(), llvm::EmitStrChr(), llvm::EmitStrCpy(), llvm::EmitStrLen(), llvm::EmitStrNCmp(), llvm::EmitStrNCpy(), llvm::EmitUnaryFloatFnCall(), eraseFromParent(), llvm::CodeExtractor::extractCodeRegion(), FoldCondBranchOnPHI(), llvm::BlockAddress::get(), llvm::MMIAddrLabelMap::getAddrLabelSymbol(), getCommonReturnValue(), llvm::IRBuilderBase::getCurrentFunctionReturnType(), llvm::MemoryDependenceAnalysis::getDependency(), llvm::ProfileInfoT< FType, BType >::getExecutionCount(), llvm::Trace::getFunction(), getFunctionForValue(), llvm::ValueEnumerator::getGlobalBasicBlockID(), llvm::MemoryDependenceAnalysis::getLoadLoadClobberFullWidthSize(), llvm::DOTGraphTraits< DomTreeNode * >::getNodeLabel(), llvm::DOTGraphTraits< RegionNode * >::getNodeLabel(), llvm::MemoryDependenceAnalysis::getNonLocalCallDependency(), llvm::MemoryDependenceAnalysis::getPointerDependencyFrom(), llvm::JIT::getPointerToBasicBlock(), getValueSymbolTable(), HandleByValArgument(), HandleInlinedInvoke(), llvm::InlineFunction(), isDynamicConstant(), llvm::SelectionDAGBuilder::isExportableFromCurrentBlock(), llvm::isInTailCallPosition(), llvm::AllocaInst::isStaticAlloca(), LLVMGetNextBasicBlock(), LLVMGetPreviousBasicBlock(), LLVMInsertBasicBlockInContext(), llvm::IntrinsicLowering::LowerToByteSwap(), moveAfter(), moveBefore(), NegateValue(), PerformHeapAllocSRoA(), llvm::Value::print(), PrintOps(), ProcessUAddIdiom(), ProcessUGT_ADDCST_ADD(), llvm::ProfileInfoT< FType, BType >::removeBlock(), removeFromParent(), llvm::ProfileInfoT< FType, BType >::replaceAllUses(), ReplaceCallWith(), llvm::ProfileInfoT< FType, BType >::setExecutionCount(), SimplifyCondBranchToCondBranch(), splitBasicBlock(), llvm::ProfileInfoT< FType, BType >::splitBlock(), llvm::SplitBlockPredecessors(), llvm::SplitCriticalEdge(), llvm::ProfileInfoT< FType, BType >::splitEdge(), llvm::SplitLandingPadPredecessors(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), TryToSimplifyUncondBranchWithICmpInIt(), TryToSinkInstruction(), llvm::UnrollLoop(), llvm::UnrollRuntimeLoopProlog(), UpdateCallGraphAfterInlining(), llvm::MMIAddrLabelMap::UpdateForDeletedBlock(), useFuncSeen(), ValueDominatesPHI(), llvm::DominatorTree::verifyAnalysis(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitFPTrunc(), and ~BasicBlock().

Function* llvm::BasicBlock::getParent ( ) [inline]

Definition at line 111 of file BasicBlock.h.

BasicBlock * BasicBlock::getSinglePredecessor ( )
const BasicBlock* llvm::BasicBlock::getSinglePredecessor ( ) const [inline]

Definition at line 172 of file BasicBlock.h.

References getSinglePredecessor().

static iplist<Instruction> BasicBlock::* llvm::BasicBlock::getSublistAccess ( Instruction ) [inline, static]

getSublistAccess() - returns pointer to member of instruction list

Definition at line 208 of file BasicBlock.h.

TerminatorInst * BasicBlock::getTerminator ( )

getTerminator() - If this is a well formed basic block, then this returns a pointer to the terminator instruction. If it is not, then you get a null pointer back.

Definition at line 120 of file BasicBlock.cpp.

References llvm::iplist< NodeTy, Traits >::back(), llvm::dyn_cast(), and llvm::iplist< NodeTy, Traits >::empty().

Referenced by AddReachableCodeToWorklist(), llvm::CodeMetrics::analyzeBasicBlock(), BlockIsSimpleEnoughToThreadThrough(), canExpandBackedgeTakenCount(), llvm::CloneAndPruneFunctionInto(), llvm::CloneFunctionInto(), CloneLoopBlocks(), ConnectProlog(), llvm::ConstantFoldTerminator(), convertMemSetToLoop(), convertTransferToLoop(), createPHIsForSplitLoopExit(), llvm::DeleteDeadBlock(), DeleteInstructionInBlock(), llvm::DemotePHIToStack(), DominatesMergePoint(), FindLoopCounter(), FindMostPopularDest(), FindPHIForConditionForwarding(), FindUnconditionalPreds(), FoldBlockIntoPredecessor(), llvm::FoldBranchToCommonDest(), FoldCondBranchOnPHI(), llvm::FoldReturnIntoUncondBranch(), FoldTwoEntryPHINode(), genLoopLimit(), GetBestDestForJumpOnUndef(), llvm::DOTGraphTraits< const Function * >::getEdgeSourceLabel(), llvm::Region::getExpandedRegion(), GetIfCondition(), getInsertPointForUses(), llvm::GetSuccessorNumber(), llvm::IncrementCounterInBlock(), llvm::InlineFunction(), llvm::DIBuilder::insertDeclare(), llvm::SparseSolver::isEdgeFeasible(), llvm::isInTailCallPosition(), llvm::ScalarEvolution::isLoopBackedgeGuardedByCond(), isSafePHIToSpeculate(), llvm::Loop::makeLoopInvariant(), MarkAliveBlocks(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), MergeEmptyReturnBlocks(), needsLFTR(), PerformHeapAllocSRoA(), removeUndefIntroducingPredecessor(), replaceSuccessorsPhiUsesWith(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::IRBuilderBase::SetInsertPoint(), SimplifyBranchOnICmpChain(), SimplifyCondBranchToCondBranch(), SimplifyCondBranchToTwoReturns(), llvm::InstCombiner::SliceUpIllegalIntegerPHI(), SpeculativelyExecuteBB(), splitBasicBlock(), llvm::SplitCriticalEdge(), SplitCriticalSideEffectEdges(), llvm::SplitEdge(), llvm::SplitLandingPadPredecessors(), llvm::succ_begin(), llvm::succ_end(), tryToMakeAllocaBePromotable(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), TryToSimplifyUncondBranchWithICmpInIt(), llvm::UnrollLoop(), llvm::UnrollRuntimeLoopProlog(), and llvm::InstCombiner::visitCallInst().

const TerminatorInst * BasicBlock::getTerminator ( ) const
BasicBlock * BasicBlock::getUniquePredecessor ( )

getUniquePredecessor - If this basic block has a unique predecessor block, return the block, otherwise return a null pointer. Note that unique predecessor doesn't mean single edge, there can be multiple edges from the unique predecessor to this block (for example a switch statement with multiple cases having the same destination).

Definition at line 196 of file BasicBlock.cpp.

References llvm::pred_begin(), and llvm::pred_end().

Referenced by getUniquePredecessor(), isDynamicConstant(), and llvm::MergeBlockIntoPredecessor().

const BasicBlock* llvm::BasicBlock::getUniquePredecessor ( ) const [inline]

Definition at line 182 of file BasicBlock.h.

References getUniquePredecessor().

ValueSymbolTable * BasicBlock::getValueSymbolTable ( )

getValueSymbolTable() - returns pointer to symbol table (if any)

Definition at line 27 of file BasicBlock.cpp.

References F(), and getParent().

bool llvm::BasicBlock::hasAddressTaken ( ) const [inline]
bool BasicBlock::isLandingPad ( ) const

isLandingPad - Return true if this basic block is a landing pad. I.e., it's the destination of the 'unwind' edge of an invoke instruction.

Definition at line 360 of file BasicBlock.cpp.

References getFirstNonPHI().

Referenced by ConnectProlog(), createPHIsForSplitLoopExit(), isBlockValidForExtraction(), llvm::SplitCriticalEdge(), and llvm::SplitLandingPadPredecessors().

void BasicBlock::moveAfter ( BasicBlock MovePos)

moveAfter - Unlink this basic block from its current function and insert it into the function that MovePos lives in, right after MovePos.

Definition at line 113 of file BasicBlock.cpp.

References llvm::Function::getBasicBlockList(), getParent(), and llvm::ARM_PROC::I.

void BasicBlock::moveBefore ( BasicBlock MovePos)

moveBefore - Unlink this basic block from its current function and insert it into the function that MovePos lives in, right before MovePos.

Definition at line 106 of file BasicBlock.cpp.

References llvm::Function::getBasicBlockList(), and getParent().

void BasicBlock::removeFromParent ( )

removeFromParent - This method unlinks 'this' from the containing function, but does not delete it.

Definition at line 96 of file BasicBlock.cpp.

References llvm::Function::getBasicBlockList(), and getParent().

void BasicBlock::removePredecessor ( BasicBlock Pred,
bool  DontDeleteUselessPHIs = false 
)
void BasicBlock::replaceSuccessorsPhiUsesWith ( BasicBlock New)

replaceSuccessorsPhiUsesWith - Update all phi nodes in all our successors to refer to basic block New instead of to us.

Definition at line 337 of file BasicBlock.cpp.

References begin(), llvm::dyn_cast(), end(), llvm::PHINode::getBasicBlockIndex(), llvm::TerminatorInst::getNumSuccessors(), llvm::TerminatorInst::getSuccessor(), getTerminator(), llvm::ARM_PROC::IE, and llvm::PHINode::setIncomingBlock().

size_t llvm::BasicBlock::size ( ) const [inline]
BasicBlock * BasicBlock::splitBasicBlock ( iterator  I,
const Twine BBName = "" 
)

splitBasicBlock - This splits a basic block into two at the specified instruction. Note that all instructions BEFORE the specified iterator stay as part of the original basic block, an unconditional branch is added to the original BB, and the rest of the instructions in the BB are moved to the new BB, including the old terminator. The newly formed BasicBlock is returned. This function invalidates the specified iterator.

Note that this only works on well formed basic blocks (must have a terminator), and 'I' must not be the end of instruction list (which would cause a degenerate basic block to be formed, having a terminator inside of the basic block).

Also note that this doesn't preserve any passes. To split blocks while keeping loop information consistent, use the SplitBlock utility function.

splitBasicBlock - This splits a basic block into two at the specified instruction. Note that all instructions BEFORE the specified iterator stay as part of the original basic block, an unconditional branch is added to the new BB, and the rest of the instructions in the BB are moved to the new BB, including the old terminator. This invalidates the iterator.

Note that this only works on well formed basic blocks (must have a terminator), and 'I' must not be the end of instruction list (which would cause a degenerate basic block to be formed, having a terminator inside of the basic block).

Definition at line 298 of file BasicBlock.cpp.

References begin(), Create(), llvm::dyn_cast(), end(), llvm::iplist< NodeTy, Traits >::end(), llvm::PHINode::getBasicBlockIndex(), getContext(), getInstList(), getParent(), getTerminator(), llvm::ARM_PROC::I, llvm::next(), llvm::PHINode::setIncomingBlock(), llvm::iplist< NodeTy, Traits >::splice(), llvm::succ_begin(), and llvm::succ_end().

Referenced by convertMemSetToLoop(), convertTransferToLoop(), HandleCallsInBlockInlinedThroughInvoke(), llvm::InlineFunction(), PerformHeapAllocSRoA(), llvm::NVPTXSplitBBatBar::runOnFunction(), SimplifyBranchOnICmpChain(), and llvm::SplitBlock().


Friends And Related Function Documentation

friend class BlockAddress [friend]

Definition at line 72 of file BasicBlock.h.

friend class SymbolTableListTraits< BasicBlock, Function > [friend]

Definition at line 80 of file BasicBlock.h.


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