LLVM API Documentation
LLVM Basic Block Representation. More...
#include <BasicBlock.h>
Public Types | |
typedef iplist< Instruction > | InstListType |
typedef InstListType::iterator | iterator |
Instruction iterators... More... | |
typedef InstListType::const_iterator | const_iterator |
typedef InstListType::reverse_iterator | reverse_iterator |
typedef InstListType::const_reverse_iterator | const_reverse_iterator |
![]() | |
enum | ValueTy { ArgumentVal, BasicBlockVal, FunctionVal, GlobalAliasVal, GlobalVariableVal, UndefValueVal, BlockAddressVal, ConstantExprVal, ConstantAggregateZeroVal, ConstantDataArrayVal, ConstantDataVectorVal, ConstantIntVal, ConstantFPVal, ConstantArrayVal, ConstantStructVal, ConstantVectorVal, ConstantPointerNullVal, MDNodeVal, MDStringVal, InlineAsmVal, PseudoSourceValueVal, FixedStackPseudoSourceValueVal, InstructionVal, ConstantFirstVal = FunctionVal, ConstantLastVal = ConstantPointerNullVal } |
typedef value_use_iterator< User > | use_iterator |
typedef value_use_iterator < const User > | const_use_iterator |
Public Member Functions | |
LLVMContext & | getContext () const |
Get the context in which this basic block lives. More... | |
~BasicBlock () | |
const Function * | getParent () const |
Return the enclosing method, or null if none. More... | |
Function * | getParent () |
TerminatorInst * | getTerminator () |
Returns the terminator instruction if the block is well formed or null if the block is not well formed. More... | |
const TerminatorInst * | getTerminator () const |
Instruction * | getFirstNonPHI () |
Returns a pointer to the first instruction in this block that is not a PHINode instruction. More... | |
const Instruction * | getFirstNonPHI () const |
Instruction * | getFirstNonPHIOrDbg () |
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic. More... | |
const Instruction * | getFirstNonPHIOrDbg () const |
Instruction * | getFirstNonPHIOrDbgOrLifetime () |
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic, or a lifetime intrinsic. More... | |
const Instruction * | getFirstNonPHIOrDbgOrLifetime () const |
iterator | getFirstInsertionPt () |
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI instruction. More... | |
const_iterator | getFirstInsertionPt () const |
void | removeFromParent () |
Unlink 'this' from the containing function, but do not delete it. More... | |
void | eraseFromParent () |
Unlink 'this' from the containing function and delete it. More... | |
void | moveBefore (BasicBlock *MovePos) |
Unlink this basic block from its current function and insert it into the function that MovePos lives in, right before MovePos . More... | |
void | moveAfter (BasicBlock *MovePos) |
Unlink this basic block from its current function and insert it right after MovePos in the function MovePos lives in. More... | |
BasicBlock * | getSinglePredecessor () |
Return this block if it has a single predecessor block. Otherwise return a null pointer. More... | |
const BasicBlock * | getSinglePredecessor () const |
BasicBlock * | getUniquePredecessor () |
Return this block if it has a unique predecessor block. Otherwise return a null pointer. More... | |
const BasicBlock * | getUniquePredecessor () const |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
size_t | size () const |
bool | empty () const |
const Instruction & | front () const |
Instruction & | front () |
const Instruction & | back () const |
Instruction & | back () |
const InstListType & | getInstList () const |
Return the underlying instruction list container. More... | |
InstListType & | getInstList () |
ValueSymbolTable * | getValueSymbolTable () |
Returns a pointer to the symbol table if one exists. More... | |
void | dropAllReferences () |
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining. More... | |
void | removePredecessor (BasicBlock *Pred, bool DontDeleteUselessPHIs=false) |
Notify the BasicBlock that the predecessor Pred is no longer able to reach it. More... | |
BasicBlock * | splitBasicBlock (iterator I, const Twine &BBName="") |
Split the basic block into two basic blocks at the specified instruction. More... | |
bool | hasAddressTaken () const |
Returns true if there are any uses of this basic block other than direct branches, switches, etc. to it. More... | |
void | replaceSuccessorsPhiUsesWith (BasicBlock *New) |
Update all phi nodes in this basic block's successors to refer to basic block New instead of to it. More... | |
bool | isLandingPad () const |
Return true if this basic block is a landing pad. More... | |
LandingPadInst * | getLandingPadInst () |
Return the landingpad instruction associated with the landing pad. More... | |
const LandingPadInst * | getLandingPadInst () const |
![]() | |
virtual | ~Value () |
void | dump () const |
dump - Support for debugging, callable in GDB: V->dump() More... | |
void | print (raw_ostream &O, AssemblyAnnotationWriter *AAW=0) const |
Type * | getType () const |
LLVMContext & | getContext () const |
All values hold a context through their type. More... | |
bool | hasName () const |
ValueName * | getValueName () const |
void | setValueName (ValueName *VN) |
StringRef | getName () const |
void | setName (const Twine &Name) |
void | takeName (Value *V) |
void | replaceAllUsesWith (Value *V) |
bool | use_empty () const |
use_iterator | use_begin () |
const_use_iterator | use_begin () const |
use_iterator | use_end () |
const_use_iterator | use_end () const |
User * | use_back () |
const User * | use_back () const |
bool | hasOneUse () const |
bool | hasNUses (unsigned N) const |
bool | hasNUsesOrMore (unsigned N) const |
bool | isUsedInBasicBlock (const BasicBlock *BB) const |
unsigned | getNumUses () const |
void | addUse (Use &U) |
unsigned | getValueID () const |
unsigned | getRawSubclassOptionalData () const |
void | clearSubclassOptionalData () |
bool | hasSameSubclassOptionalData (const Value *V) const |
void | intersectOptionalDataWith (const Value *V) |
bool | hasValueHandle () const |
Value * | stripPointerCasts () |
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value, returning the original uncasted value. More... | |
const Value * | stripPointerCasts () const |
Value * | stripPointerCastsNoFollowAliases () |
Strips off any unneeded pointer casts and all-zero GEPs from the specified value, returning the original uncasted value. More... | |
const Value * | stripPointerCastsNoFollowAliases () const |
Value * | stripInBoundsConstantOffsets () |
Strips off unneeded pointer casts and all-constant GEPs from the specified value, returning the original pointer value. More... | |
const Value * | stripInBoundsConstantOffsets () const |
Value * | stripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) |
Strips like stripInBoundsConstantOffsets but also accumulates the constant offset stripped. More... | |
const Value * | stripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const |
Value * | stripInBoundsOffsets () |
Strips off unneeded pointer casts and any in-bounds offsets from the specified value, returning the original pointer value. More... | |
const Value * | stripInBoundsOffsets () const |
bool | isDereferenceablePointer () const |
Value * | DoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) |
const Value * | DoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const |
void | mutateType (Type *Ty) |
![]() | |
BasicBlock * | getPrevNode () |
Get the previous node, or 0 for the list head. More... | |
const BasicBlock * | getPrevNode () const |
Get the previous node, or 0 for the list head. More... | |
BasicBlock * | getNextNode () |
Get the next node, or 0 for the list tail. More... | |
const BasicBlock * | getNextNode () const |
Get the next node, or 0 for the list tail. More... | |
Static Public Member Functions | |
static BasicBlock * | Create (LLVMContext &Context, const Twine &Name="", Function *Parent=0, BasicBlock *InsertBefore=0) |
Creates a new BasicBlock. More... | |
static iplist< Instruction > BasicBlock::* | getSublistAccess (Instruction *) |
Returns a pointer to a member of the instruction list. More... | |
static bool | classof (const Value *V) |
Methods for support type inquiry through isa, cast, and dyn_cast. More... | |
Friends | |
class | BlockAddress |
class | SymbolTableListTraits< BasicBlock, Function > |
Additional Inherited Members | |
![]() | |
static const unsigned | MaximumAlignment = 1u << 29 |
![]() | |
virtual void | printCustom (raw_ostream &O) const |
Value (Type *Ty, unsigned scid) | |
unsigned short | getSubclassDataFromValue () const |
void | setValueSubclassData (unsigned short D) |
![]() | |
ilist_node () | |
![]() | |
unsigned char | SubclassOptionalData: 7 |
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 72 of file BasicBlock.h.
Definition at line 100 of file BasicBlock.h.
Definition at line 102 of file BasicBlock.h.
Definition at line 76 of file BasicBlock.h.
Instruction iterators...
Definition at line 99 of file BasicBlock.h.
Definition at line 101 of file BasicBlock.h.
BasicBlock::~BasicBlock | ( | ) |
Definition at line 61 of file BasicBlock.cpp.
References llvm::iplist< NodeTy, Traits >::clear(), llvm::BlockAddress::destroyConstant(), dropAllReferences(), llvm::ConstantInt::get(), getContext(), llvm::Type::getInt32Ty(), llvm::ConstantExpr::getIntToPtr(), getParent(), llvm::Value::getType(), hasAddressTaken(), llvm::Value::replaceAllUsesWith(), llvm::Value::use_back(), and llvm::Value::use_empty().
|
inline |
Definition at line 207 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::back().
Referenced by AddBlockAndPredsToSet(), llvm::AliasAnalysis::canBasicBlockModify(), llvm::CloneAndPruneFunctionInto(), ComputePostOrders(), llvm::DeleteDeadBlock(), and llvm::objcarc::FindDependencies().
|
inline |
Definition at line 208 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::back().
|
inline |
Instruction iterator methods
Definition at line 193 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(), checkCSEInPredecessor(), llvm::CloneAndPruneFunctionInto(), llvm::CloneBasicBlock(), CloneLoopBlocks(), createPHIsForSplitLoopExit(), cse(), cxxDtorIsEmpty(), llvm::DeleteDeadPHIs(), DeleteInstructionInBlock(), llvm::DemotePHIToStack(), llvm::DemoteRegToStack(), llvm::DominatorTree::dominates(), dropAllReferences(), llvm::EliminateDuplicatePHINodes(), llvm::CodeExtractor::extractCodeRegion(), llvm::FindAvailableLoadedValue(), llvm::objcarc::FindDependencies(), FindInitTrampolineFromBB(), llvm::CodeExtractor::findInputsOutputs(), FindPHIForConditionForwarding(), llvm::SSAUpdaterTraits< SSAUpdater >::FindPredecessorBlocks(), fixupFPReturnAndCall(), llvm::FoldBranchToCommonDest(), FoldCondBranchOnPHI(), llvm::FoldSingleEntryPHINodes(), FoldTwoEntryPHINode(), generateUnsignedDivisionCode(), llvm::Loop::getCanonicalInductionVariable(), GetCaseResults(), llvm::MemoryDependenceAnalysis::getDependency(), getFirstNonPHI(), getFirstNonPHIOrDbg(), getFirstNonPHIOrDbgOrLifetime(), llvm::GetIfCondition(), llvm::MemoryDependenceAnalysis::getNonLocalCallDependency(), llvm::MemoryDependenceAnalysis::getPointerDependencyFrom(), llvm::SSAUpdater::GetValueInMiddleOfBlock(), HandleCallsInBlockInlinedThroughInvoke(), HasNoDuplicateCall(), HoistThenElseCodeToIf(), llvm::InlineFunction(), insertFastDiv(), isBlockValidForExtraction(), llvm::Loop::isLCSSAForm(), llvm::isSafeToLoadUnconditionally(), isTrivialLoopExitBlockHelper(), llvm::Value::isUsedInBasicBlock(), LLVMGetFirstInstruction(), LLVMGetLastInstruction(), LLVMGetPreviousInstruction(), markAliveBlocks(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), mergeEmptyReturnBlocks(), NegateValue(), llvm::SparseSolver::Print(), llvm::AssemblyWriter::printBasicBlock(), PushLoopPHIs(), removePredecessor(), llvm::RemovePredecessorAndSimplify(), removeUndefIntroducingPredecessor(), replaceSuccessorsPhiUsesWith(), RewriteUsesOfClonedInstructions(), llvm::LoadAndStorePromoter::run(), SimplifyBranchOnICmpChain(), SimplifyCondBranchToCondBranch(), llvm::InstCombiner::SimplifyDivRemOfSelect(), llvm::SimplifyInstructionsInBlock(), SinkThenElseCodeToEnd(), llvm::SparseSolver::Solve(), SpeculativelyExecuteBB(), splitBasicBlock(), llvm::SplitBlockPredecessors(), llvm::SplitCriticalEdge(), llvm::SplitEdge(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), TryToSimplifyUncondBranchWithICmpInIt(), TurnSwitchRangeIntoICmp(), llvm::UnrollLoop(), UpdatePHINodes(), llvm::InstVisitor< ObjectSizeOffsetVisitor, SizeOffsetType >::visit(), llvm::InstCombiner::visitPHINode(), and llvm::InstCombiner::visitStoreInst().
|
inline |
Definition at line 194 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::begin().
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition at line 226 of file BasicBlock.h.
References llvm::Value::BasicBlockVal, and llvm::Value::getValueID().
|
inlinestatic |
Creates a new BasicBlock.
If the Parent parameter is specified, the basic block is automatically inserted at either the end of the function (if InsertBefore is 0), or before the specified basic block.
Definition at line 109 of file BasicBlock.h.
References llvm::ISD::BasicBlock.
Referenced by llvm::CloneBasicBlock(), convertMemSetToLoop(), convertTransferToLoop(), llvm::CodeExtractor::extractCodeRegion(), FoldCondBranchOnPHI(), generateUnsignedDivisionCode(), INITIALIZE_PASS(), insertFastDiv(), LLVMAppendBasicBlockInContext(), LLVMInsertBasicBlockInContext(), PerformHeapAllocSRoA(), llvm::JIT::runFunction(), llvm::UnifyFunctionExitNodes::runOnFunction(), SimplifyCondBranchToCondBranch(), splitBasicBlock(), llvm::SplitBlockAndInsertIfThen(), llvm::SplitBlockPredecessors(), llvm::SplitCriticalEdge(), llvm::SplitLandingPadPredecessors(), TryToSimplifyUncondBranchWithICmpInIt(), and llvm::UnrollRuntimeLoopProlog().
void BasicBlock::dropAllReferences | ( | ) |
Cause all subinstructions to "let go" of all the references that said subinstructions 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 I.
Referenced by ~BasicBlock().
|
inline |
Definition at line 204 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::empty().
Referenced by llvm::DeleteDeadBlock().
|
inline |
Definition at line 195 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::end().
Referenced by llvm::AliasSetTracker::add(), AddReachableCodeToWorklist(), llvm::CodeMetrics::analyzeBasicBlock(), changeToUnreachable(), checkCSEInPredecessor(), llvm::CloneBasicBlock(), cse(), cxxDtorIsEmpty(), dropAllReferences(), llvm::objcarc::FindDependencies(), llvm::CodeExtractor::findInputsOutputs(), fixupFPReturnAndCall(), FoldBlockIntoPredecessor(), llvm::FoldBranchToCommonDest(), GenerateARCBBTerminatorAnnotation(), GetCaseResults(), llvm::MemoryDependenceAnalysis::getNonLocalCallDependency(), HandleCallsInBlockInlinedThroughInvoke(), HasNoDuplicateCall(), insertFastDiv(), isBlockValidForExtraction(), llvm::isInTailCallPosition(), llvm::Loop::isLCSSAForm(), llvm::isPotentiallyReachable(), isSafeAndProfitableToSinkLoad(), isTrivialLoopExitBlockHelper(), llvm::Value::isUsedInBasicBlock(), LLVMGetFirstInstruction(), LLVMGetLastInstruction(), LLVMGetNextInstruction(), LLVMPositionBuilder(), markAliveBlocks(), llvm::MergeBlockIntoPredecessor(), passingValueIsAlwaysUndefined(), llvm::SparseSolver::Print(), llvm::AssemblyWriter::printBasicBlock(), replaceSuccessorsPhiUsesWith(), RewriteUsesOfClonedInstructions(), llvm::LoadAndStorePromoter::run(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SimplifyInstructionsInBlock(), SinkThenElseCodeToEnd(), llvm::SparseSolver::Solve(), SpeculativelyExecuteBB(), splitBasicBlock(), TryToSinkInstruction(), and llvm::InstVisitor< ObjectSizeOffsetVisitor, SizeOffsetType >::visit().
|
inline |
Definition at line 196 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::end().
void BasicBlock::eraseFromParent | ( | ) |
Unlink 'this' from the containing function and delete it.
Definition at line 100 of file BasicBlock.cpp.
References llvm::iplist< NodeTy, Traits >::erase(), llvm::Function::getBasicBlockList(), and getParent().
Referenced by llvm::CloneAndPruneFunctionInto(), llvm::DeleteDeadBlock(), FoldBlockIntoPredecessor(), llvm::InlineFunction(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), mergeEmptyReturnBlocks(), and llvm::TryToSimplifyUncondBranchFromEmptyBlock().
|
inline |
Definition at line 205 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::front().
Referenced by llvm::AliasAnalysis::canBasicBlockModify(), llvm::SSAUpdaterTraits< SSAUpdater >::CreateEmptyPHI(), CreatePrologue(), llvm::FoldBranchToCommonDest(), llvm::SSAUpdater::GetValueInMiddleOfBlock(), llvm::MergeBlockIntoPredecessor(), mergeEmptyReturnBlocks(), removePredecessor(), llvm::RemovePredecessorAndSimplify(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), and TryToSimplifyUncondBranchWithICmpInIt().
|
inline |
Definition at line 206 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::front().
LLVMContext & BasicBlock::getContext | ( | ) | const |
Get the context in which this basic block lives.
Definition at line 33 of file BasicBlock.cpp.
References llvm::Type::getContext(), and llvm::Value::getType().
Referenced by llvm::CloneBasicBlock(), llvm::ConstantFoldTerminator(), EliminateDeadSwitchCases(), llvm::EmitFWrite(), llvm::EmitMemChr(), llvm::EmitMemCmp(), llvm::EmitMemCpyChk(), llvm::EmitStrLen(), llvm::EmitStrNCmp(), llvm::EmitStrNLen(), llvm::CodeExtractor::extractCodeRegion(), llvm::SimplifyFortifiedLibCalls::fold(), FoldCondBranchOnPHI(), PerformHeapAllocSRoA(), splitBasicBlock(), llvm::SplitBlockAndInsertIfThen(), llvm::SplitBlockPredecessors(), llvm::SplitLandingPadPredecessors(), TryToSimplifyUncondBranchWithICmpInIt(), llvm::UnrollRuntimeLoopProlog(), and ~BasicBlock().
BasicBlock::iterator BasicBlock::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::DemoteRegToStack(), llvm::InstCombiner::DoOneIteration(), GenerateARCBBEntranceAnnotation(), getFirstInsertionPt(), OptimizeCmpExpression(), OptimizeNoopCopyExpression(), llvm::SplitLandingPadPredecessors(), TryToSinkInstruction(), and llvm::ObjectSizeOffsetEvaluator::visitPHINode().
|
inline |
Definition at line 154 of file BasicBlock.h.
References getFirstInsertionPt().
Instruction * BasicBlock::getFirstNonPHI | ( | ) |
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
When adding instructions 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(), getFirstInsertionPt(), getFirstNonPHI(), getJumpThreadDuplicationCost(), getLandingPadInst(), llvm::InvokeInst::getLandingPadInst(), llvm::SSAUpdater::GetValueInMiddleOfBlock(), llvm::InsertPreheaderForLoop(), and isLandingPad().
|
inline |
Definition at line 131 of file BasicBlock.h.
References getFirstNonPHI().
Instruction * BasicBlock::getFirstNonPHIOrDbg | ( | ) |
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic.
Definition at line 140 of file BasicBlock.cpp.
References begin().
Referenced by FindPHIForConditionForwarding(), getFirstNonPHIOrDbg(), SimplifyCondBranchToTwoReturns(), SwitchToLookupTable(), and llvm::InstCombiner::visitAllocaInst().
|
inline |
Definition at line 138 of file BasicBlock.h.
References getFirstNonPHIOrDbg().
Instruction * BasicBlock::getFirstNonPHIOrDbgOrLifetime | ( | ) |
Returns a pointer to the first instruction in this block that is not a PHINode, a debug intrinsic, or a lifetime intrinsic.
Definition at line 150 of file BasicBlock.cpp.
References begin(), llvm::dyn_cast(), llvm::IntrinsicInst::getIntrinsicID(), llvm::Intrinsic::lifetime_end, and llvm::Intrinsic::lifetime_start.
Referenced by getFirstNonPHIOrDbgOrLifetime().
|
inline |
Definition at line 145 of file BasicBlock.h.
References getFirstNonPHIOrDbgOrLifetime().
|
inline |
Return the underlying instruction list container.
Currently you need to access the underlying instruction list container directly if you want to modify it.
Definition at line 214 of file BasicBlock.h.
Referenced by changeToUnreachable(), llvm::CloneAndPruneFunctionInto(), llvm::CloneBasicBlock(), CloneLoopBlocks(), llvm::BinaryOperator::Create(), createCallHelper(), createMalloc(), llvm::DeleteDeadBlock(), DeleteInstructionInBlock(), llvm::InstCombiner::DoOneIteration(), llvm::Instruction::eraseFromParent(), llvm::CodeExtractor::extractCodeRegion(), FoldBlockIntoPredecessor(), llvm::FoldBranchToCommonDest(), FoldCondBranchOnPHI(), llvm::FoldReturnIntoUncondBranch(), FoldTwoEntryPHINode(), HandleCallsInBlockInlinedThroughInvoke(), HoistThenElseCodeToIf(), llvm::InlineFunction(), llvm::Instruction::insertAfter(), llvm::Instruction::insertBefore(), insertFastDiv(), llvm::IRBuilderDefaultInserter< true >::InsertHelper(), llvm::InstCombiner::InsertNewInstBefore(), llvm::Instruction::Instruction(), LdStHasDebugValue(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), llvm::Instruction::moveBefore(), llvm::Instruction::removeFromParent(), removePredecessor(), llvm::ReplaceInstWithInst(), llvm::UnifyFunctionExitNodes::runOnFunction(), SinkThenElseCodeToEnd(), SpeculativelyExecuteBB(), splitBasicBlock(), llvm::SplitLandingPadPredecessors(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), and llvm::UnrollLoop().
|
inline |
Definition at line 215 of file BasicBlock.h.
LandingPadInst * BasicBlock::getLandingPadInst | ( | ) |
Return the landingpad instruction associated with the landing pad.
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().
|
inline |
Return the enclosing method, or null if none.
Definition at line 116 of file BasicBlock.h.
Referenced by llvm::CodeMetrics::analyzeBasicBlock(), CanTRE(), changeToUnreachable(), 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::DominatorTree::dominates(), 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::EmitStrNLen(), llvm::EmitUnaryFloatFnCall(), eraseFromParent(), llvm::CodeExtractor::extractCodeRegion(), FindPotentialTailCall(), FoldCondBranchOnPHI(), GenerateARCBBEntranceAnnotation(), GenerateARCBBTerminatorAnnotation(), generateUnsignedDivisionCode(), llvm::BlockAddress::get(), llvm::MMIAddrLabelMap::getAddrLabelSymbol(), getCommonReturnValue(), llvm::IRBuilderBase::getCurrentFunctionReturnType(), llvm::MemoryDependenceAnalysis::getDependency(), 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(), insertFastDiv(), isDynamicConstant(), llvm::SelectionDAGBuilder::isExportableFromCurrentBlock(), llvm::isInTailCallPosition(), llvm::isPotentiallyReachable(), llvm::AllocaInst::isStaticAlloca(), LLVMGetNextBasicBlock(), LLVMGetPreviousBasicBlock(), LLVMInsertBasicBlockInContext(), llvm::IntrinsicLowering::LowerToByteSwap(), moveAfter(), moveBefore(), NegateValue(), PerformHeapAllocSRoA(), PlaceSplitBlockCarefully(), llvm::AssemblyWriter::printBasicBlock(), PrintOps(), ProcessUAddIdiom(), ProcessUGT_ADDCST_ADD(), promoteSingleBlockAlloca(), removeFromParent(), ReplaceCallWith(), replaceConstantExprOp(), rewriteSingleStoreAlloca(), SimplifyCondBranchToCondBranch(), splitBasicBlock(), llvm::SplitBlockAndInsertIfThen(), llvm::SplitBlockPredecessors(), llvm::SplitCriticalEdge(), llvm::SplitLandingPadPredecessors(), SwitchToLookupTable(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), TryToSimplifyUncondBranchWithICmpInIt(), TryToSinkInstruction(), llvm::UnrollLoop(), llvm::UnrollRuntimeLoopProlog(), UpdateCallGraphAfterInlining(), llvm::MMIAddrLabelMap::UpdateForDeletedBlock(), useFuncSeen(), ValueDominatesPHI(), llvm::DominatorTree::verifyAnalysis(), llvm::InstCombiner::visitAllocaInst(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitFPTrunc(), and ~BasicBlock().
|
inline |
Definition at line 117 of file BasicBlock.h.
BasicBlock * BasicBlock::getSinglePredecessor | ( | ) |
Return this block if it has a single predecessor block. Otherwise return a null pointer.
getSinglePredecessor - If this basic block has a single predecessor block, return the block, otherwise return a null pointer.
Definition at line 183 of file BasicBlock.cpp.
References llvm::pred_begin(), and llvm::pred_end().
Referenced by CanPropagatePredecessorsForPHIs(), llvm::CloneAndPruneFunctionInto(), llvm::DeleteDeadBlock(), llvm::DemoteRegToStack(), llvm::DominatorTree::dominates(), FindPHIForConditionForwarding(), FoldBlockIntoPredecessor(), llvm::FoldBranchToCommonDest(), llvm::GetIfCondition(), getSinglePredecessor(), isOnlyReachableViaThisEdge(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::SplitEdge(), tryToMoveFreeBeforeNullTest(), and TryToSimplifyUncondBranchWithICmpInIt().
|
inline |
Definition at line 176 of file BasicBlock.h.
References getSinglePredecessor().
|
inlinestatic |
Returns a pointer to a member of the instruction list.
Definition at line 218 of file BasicBlock.h.
TerminatorInst * BasicBlock::getTerminator | ( | ) |
Returns the terminator instruction if the block is well formed or null if the block is not well formed.
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(), llvm::CloneAndPruneFunctionInto(), llvm::CloneFunctionInto(), CloneLoopBlocks(), ConnectProlog(), llvm::ConstantFoldTerminator(), convertMemSetToLoop(), convertTransferToLoop(), createPHIsForSplitLoopExit(), llvm::DeleteDeadBlock(), DeleteInstructionInBlock(), llvm::DemotePHIToStack(), DominatesMergePoint(), FindMostPopularDest(), FindPHIForConditionForwarding(), FindUnconditionalPreds(), FoldBlockIntoPredecessor(), llvm::FoldBranchToCommonDest(), FoldCondBranchOnPHI(), llvm::FoldReturnIntoUncondBranch(), FoldTwoEntryPHINode(), generateUnsignedDivisionCode(), GetBestDestForJumpOnUndef(), llvm::DOTGraphTraits< const Function * >::getEdgeSourceLabel(), getEdgeValueLocal(), llvm::Region::getExpandedRegion(), llvm::GetIfCondition(), getInsertPointForUses(), llvm::GetSuccessorNumber(), llvm::InlineFunction(), llvm::DIBuilder::insertDeclare(), llvm::InsertPreheaderForLoop(), llvm::SparseSolver::isEdgeFeasible(), llvm::isInTailCallPosition(), llvm::ScalarEvolution::isLoopBackedgeGuardedByCond(), isSafePHIToSpeculate(), llvm::BasicBlockEdge::isSingleEdge(), llvm::Loop::makeLoopInvariant(), markAliveBlocks(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), mergeEmptyReturnBlocks(), PerformHeapAllocSRoA(), removeUndefIntroducingPredecessor(), replaceConstantExprOp(), replaceSuccessorsPhiUsesWith(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::IRBuilderBase::SetInsertPoint(), SimplifyBranchOnICmpChain(), SimplifyCondBranchToCondBranch(), SimplifyCondBranchToTwoReturns(), SinkThenElseCodeToEnd(), llvm::InstCombiner::SliceUpIllegalIntegerPHI(), speculatePHINodeLoads(), SpeculativelyExecuteBB(), splitBasicBlock(), llvm::SplitBlockAndInsertIfThen(), llvm::SplitCriticalEdge(), SplitCriticalSideEffectEdges(), llvm::SplitEdge(), llvm::SplitLandingPadPredecessors(), llvm::succ_begin(), llvm::succ_end(), tryToMakeAllocaBePromotable(), tryToMoveFreeBeforeNullTest(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), TryToSimplifyUncondBranchWithICmpInIt(), llvm::UnrollLoop(), llvm::UnrollRuntimeLoopProlog(), and llvm::InstCombiner::visitCallInst().
const TerminatorInst * BasicBlock::getTerminator | ( | ) | const |
Definition at line 125 of file BasicBlock.cpp.
References llvm::iplist< NodeTy, Traits >::back(), llvm::dyn_cast(), and llvm::iplist< NodeTy, Traits >::empty().
BasicBlock * BasicBlock::getUniquePredecessor | ( | ) |
Return this block if it has a unique predecessor 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).
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().
|
inline |
Definition at line 186 of file BasicBlock.h.
References getUniquePredecessor().
ValueSymbolTable * BasicBlock::getValueSymbolTable | ( | ) |
Returns a pointer to the symbol table if one exists.
Definition at line 27 of file BasicBlock.cpp.
References F(), and getParent().
|
inline |
Returns true if there are any uses of this basic block other than direct branches, switches, etc. to it.
Definition at line 268 of file BasicBlock.h.
References llvm::Value::getSubclassDataFromValue().
Referenced by llvm::CloneFunctionInto(), llvm::AsmPrinter::EmitFunctionBody(), llvm::MMIAddrLabelMap::getAddrLabelSymbol(), llvm::MMIAddrLabelMap::getAddrLabelSymbolToEmit(), hasAddressTakenAndUsed(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), llvm::UnrollLoop(), and ~BasicBlock().
bool BasicBlock::isLandingPad | ( | ) | const |
Return true if this basic block is a landing pad.
Being a ``landing pad'' means that the basic block is the destination of the 'unwind' edge of an invoke instruction.
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(), llvm::InsertPreheaderForLoop(), isBlockValidForExtraction(), llvm::SplitCriticalEdge(), and llvm::SplitLandingPadPredecessors().
void BasicBlock::moveAfter | ( | BasicBlock * | MovePos | ) |
Unlink this basic block from its current function and insert it right after MovePos
in the function MovePos
lives in.
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(), I, and llvm::iplist< NodeTy, Traits >::splice().
Referenced by PlaceSplitBlockCarefully().
void BasicBlock::moveBefore | ( | BasicBlock * | MovePos | ) |
Unlink this basic block from its current function and insert it into the function that MovePos
lives in, right before 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(), getParent(), and llvm::iplist< NodeTy, Traits >::splice().
Referenced by insertFastDiv().
|
inline |
Definition at line 198 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::rbegin().
Referenced by FindPotentialTailCall(), and isSafeToSpeculateStore().
|
inline |
Definition at line 199 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::rbegin().
void BasicBlock::removeFromParent | ( | ) |
Unlink 'this' from the containing function, but do not delete it.
Definition at line 96 of file BasicBlock.cpp.
References llvm::Function::getBasicBlockList(), getParent(), and llvm::iplist< NodeTy, Traits >::remove().
void BasicBlock::removePredecessor | ( | BasicBlock * | Pred, |
bool | DontDeleteUselessPHIs = false |
||
) |
Notify the BasicBlock that the predecessor Pred
is no longer able to reach it.
This is actually not used to update the Predecessor list, but is actually used to update the PHI nodes that reside in the block. Note that this should be called while the predecessor still refers to this block.
removePredecessor - This method is used to notify a BasicBlock that the specified Predecessor of the block is no longer able to reach it. This is actually not used to update the Predecessor list, but is actually used to update the PHI nodes that reside in the block. Note that this should be called while the predecessor still refers to this block.
Definition at line 216 of file BasicBlock.cpp.
References begin(), llvm::dyn_cast(), llvm::iplist< NodeTy, Traits >::empty(), llvm::Instruction::eraseFromParent(), front(), llvm::UndefValue::get(), llvm::PHINode::getIncomingBlock(), getInstList(), llvm::PHINode::getNumIncomingValues(), llvm::PHINode::hasConstantValue(), llvm::Value::hasNUsesOrMore(), llvm::iplist< NodeTy, Traits >::pop_front(), llvm::pred_begin(), llvm::pred_end(), llvm::PHINode::removeIncomingValue(), and llvm::Value::replaceAllUsesWith().
Referenced by changeToCall(), changeToUnreachable(), llvm::ConstantFoldTerminator(), llvm::DeleteDeadBlock(), EliminateDeadSwitchCases(), FoldCondBranchOnPHI(), llvm::FoldReturnIntoUncondBranch(), HandleInlinedInvoke(), llvm::RemovePredecessorAndSimplify(), removeUndefIntroducingPredecessor(), SimplifyCondBranchToTwoReturns(), SimplifyTerminatorOnSelect(), llvm::SplitCriticalEdge(), and SwitchToLookupTable().
|
inline |
Definition at line 200 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::rend().
Referenced by FindPotentialTailCall(), and isSafeToSpeculateStore().
|
inline |
Definition at line 201 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::rend().
void BasicBlock::replaceSuccessorsPhiUsesWith | ( | BasicBlock * | New | ) |
Update all phi nodes in this basic block's successors to refer to basic block New
instead of to it.
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().
|
inline |
Definition at line 203 of file BasicBlock.h.
References llvm::iplist< NodeTy, Traits >::size().
Referenced by llvm::FastISel::FastEmitBranch(), SimplifyBranchOnICmpChain(), and tryToMoveFreeBeforeNullTest().
BasicBlock * BasicBlock::splitBasicBlock | ( | iterator | I, |
const Twine & | BBName = "" |
||
) |
Split the basic block into two basic blocks 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::BranchInst::Create(), llvm::dyn_cast(), end(), llvm::iplist< NodeTy, Traits >::end(), llvm::PHINode::getBasicBlockIndex(), getContext(), getInstList(), getParent(), getTerminator(), I, llvm::next(), llvm::PHINode::setIncomingBlock(), llvm::iplist< NodeTy, Traits >::splice(), llvm::succ_begin(), and llvm::succ_end().
Referenced by convertMemSetToLoop(), convertTransferToLoop(), generateUnsignedDivisionCode(), HandleCallsInBlockInlinedThroughInvoke(), llvm::InlineFunction(), PerformHeapAllocSRoA(), llvm::NVPTXSplitBBatBar::runOnFunction(), SimplifyBranchOnICmpChain(), llvm::SplitBlock(), and llvm::SplitBlockAndInsertIfThen().
|
friend |
Definition at line 74 of file BasicBlock.h.
|
friend |
Definition at line 82 of file BasicBlock.h.