LLVM API Documentation
#include <BasicBlock.h>


Public Types | |
| typedef iplist< Instruction > | InstListType |
| typedef InstListType::iterator | iterator |
| Instruction iterators... | |
| typedef InstListType::const_iterator | const_iterator |
Public Member Functions | |
| ~BasicBlock () | |
| const Function * | getParent () const |
| Function * | getParent () |
| Instruction * | use_back () |
| const Instruction * | use_back () const |
| TerminatorInst * | getTerminator () |
| const TerminatorInst * | getTerminator () const |
| Instruction * | getFirstNonPHI () |
| const Instruction * | getFirstNonPHI () const |
| void | removeFromParent () |
| void | eraseFromParent () |
| void | moveBefore (BasicBlock *MovePos) |
| void | moveAfter (BasicBlock *MovePos) |
| BasicBlock * | getSinglePredecessor () |
| const BasicBlock * | getSinglePredecessor () const |
| iterator | begin () |
| const_iterator | begin () const |
| iterator | end () |
| const_iterator | end () const |
| size_t | size () const |
| bool | empty () const |
| const Instruction & | front () const |
| Instruction & | front () |
| const Instruction & | back () const |
| Instruction & | back () |
| const InstListType & | getInstList () const |
| InstListType & | getInstList () |
| void | dropAllReferences () |
| void | removePredecessor (BasicBlock *Pred, bool DontDeleteUselessPHIs=false) |
| BasicBlock * | splitBasicBlock (iterator I, const std::string &BBName="") |
Static Public Member Functions | |
| static BasicBlock * | Create (const std::string &Name="", Function *Parent=0, BasicBlock *InsertBefore=0) |
| static bool | classof (const BasicBlock *) |
| Methods for support type inquiry through isa, cast, and dyn_cast:. | |
| static bool | classof (const Value *V) |
| static unsigned | getInstListOffset () |
Friends | |
| class | SymbolTableListTraits< BasicBlock, Function > |
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 52 of file BasicBlock.h.
Definition at line 55 of file BasicBlock.h.
| typedef InstListType::iterator llvm::BasicBlock::iterator |
| typedef InstListType::const_iterator llvm::BasicBlock::const_iterator |
Definition at line 75 of file BasicBlock.h.
| BasicBlock::~BasicBlock | ( | ) |
| static BasicBlock* llvm::BasicBlock::Create | ( | const std::string & | Name = "", |
|
| Function * | Parent = 0, |
|||
| BasicBlock * | InsertBefore = 0 | |||
| ) | [inline, static] |
Create - 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 80 of file BasicBlock.h.
References llvm::ISD::BasicBlock, and Name.
Referenced by llvm::CloneBasicBlock(), LowerPartSelect(), LowerPartSet(), PerformHeapAllocSRoA(), llvm::JIT::runFunction(), llvm::UnifyFunctionExitNodes::runOnFunction(), splitBasicBlock(), llvm::SplitBlockPredecessors(), and llvm::SplitCriticalEdge().
| const Function* llvm::BasicBlock::getParent | ( | ) | const [inline] |
getParent - Return the enclosing method, or null if none
Definition at line 88 of file BasicBlock.h.
Referenced by CheckForEscapingAllocas(), llvm::CloneBasicBlock(), llvm::CloneLoop(), llvm::ConstantFoldTerminator(), llvm::IRBuilder< preserveNames, T >::CreateAggregateRet(), llvm::IRBuilder< preserveNames, T >::CreateGlobalString(), llvm::DemotePHIToStack(), llvm::DemoteRegToStack(), eraseFromParent(), FoldCondBranchOnPHI(), FoldValueComparisonIntoPredecessors(), llvm::CallSite::getCaller(), getCommonReturnValue(), llvm::ProfileInfo::getExecutionCount(), llvm::Trace::getFunction(), llvm::InlineCostAnalyzer::getInlineCost(), HandleInlinedInvoke(), llvm::InlineFunction(), llvm::BasicInlinerImpl::inlineFunctions(), isDynamicConstant(), llvm::SelectionDAGLowering::isExportableFromCurrentBlock(), LLVMGetNextBasicBlock(), LLVMGetPreviousBasicBlock(), LLVMInsertBasicBlock(), LowerPartSelect(), moveAfter(), moveBefore(), PerformHeapAllocSRoA(), llvm::Value::print(), PrintOps(), removeFromParent(), llvm::RemoveSuccessor(), ReplaceCallWith(), llvm::SimplifyCFG(), SimplifyCondBranchToCondBranch(), splitBasicBlock(), llvm::DominanceFrontier::splitBlock(), llvm::SplitBlockPredecessors(), llvm::SplitCriticalEdge(), SplitEdgeNicely(), TryToSinkInstruction(), UpdateCallGraphAfterInlining(), and ~BasicBlock().
| Function* llvm::BasicBlock::getParent | ( | ) | [inline] |
Definition at line 89 of file BasicBlock.h.
| Instruction* llvm::BasicBlock::use_back | ( | ) | [inline] |
use_back - Specialize the methods defined in Value, as we know that an BasicBlock can only be used by Instructions (specifically PHI and terms).
Reimplemented from llvm::Value.
Definition at line 93 of file BasicBlock.h.
References llvm::Value::use_begin().
| const Instruction* llvm::BasicBlock::use_back | ( | ) | const [inline] |
Reimplemented from llvm::Value.
Definition at line 94 of file BasicBlock.h.
References llvm::Value::use_begin().
| 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 137 of file BasicBlock.cpp.
References llvm::dyn_cast().
Referenced by AddReachableCodeToWorklist(), ApproximateLoopSize(), BlockIsSimpleEnoughToThreadThrough(), llvm::CloneBasicBlock(), llvm::CloneFunctionInto(), llvm::ConstantFoldTerminator(), llvm::DemotePHIToStack(), DominatesMergePoint(), FoldBlockIntoPredecessor(), FoldBranchToCommonDest(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), FoldValueComparisonIntoPredecessors(), llvm::ProfileInfoLoader::getBlockCounts(), llvm::DOTGraphTraits< const Function * >::getEdgeSourceLabel(), GetIfCondition(), llvm::InlineFunction(), llvm::SparseSolver::isEdgeFeasible(), MarkAliveBlocks(), llvm::MergeBlockIntoPredecessor(), PerformHeapAllocSRoA(), recBackEdge(), RewriteHeapSROALoadUser(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::SimplifyCFG(), SimplifyCondBranchToTwoReturns(), SimplifyEqualityComparisonWithOnlyPredecessor(), splitBasicBlock(), llvm::DominanceFrontier::splitBlock(), llvm::SplitCriticalEdge(), llvm::SplitEdge(), SplitEdgeNicely(), llvm::succ_begin(), llvm::succ_end(), llvm::UnrollLoop(), and llvm::SCEVExpander::visitAddRecExpr().
| const TerminatorInst * BasicBlock::getTerminator | ( | ) | const |
| 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 147 of file BasicBlock.cpp.
References begin().
Referenced by getFirstNonPHI(), getJumpThreadDuplicationCost(), llvm::RSProfilers_std::IncrementCounterInBlock(), llvm::IncrementCounterInBlock(), OptimizeCmpExpression(), OptimizeNoopCopyExpression(), llvm::SimplifyCFG(), and TryToSinkInstruction().
| const Instruction* llvm::BasicBlock::getFirstNonPHI | ( | ) | const [inline] |
| void BasicBlock::removeFromParent | ( | ) |
removeFromParent - This method unlinks 'this' from the containing function, but does not delete it.
Definition at line 113 of file BasicBlock.cpp.
References llvm::Function::getBasicBlockList(), and getParent().
| void BasicBlock::eraseFromParent | ( | ) |
eraseFromParent - This method unlinks 'this' from the containing function and deletes it.
Definition at line 117 of file BasicBlock.cpp.
References llvm::Function::getBasicBlockList(), and getParent().
Referenced by llvm::CloneAndPruneFunctionInto(), FoldBlockIntoPredecessor(), llvm::InlineFunction(), and llvm::MergeBlockIntoPredecessor().
| 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.
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 123 of file BasicBlock.cpp.
References llvm::Function::getBasicBlockList(), and getParent().
| 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.
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 130 of file BasicBlock.cpp.
References llvm::Function::getBasicBlockList(), getParent(), and I.
| BasicBlock * BasicBlock::getSinglePredecessor | ( | ) |
getSinglePredecessor - If this basic block has a single predecessor block, return the 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 164 of file BasicBlock.cpp.
References E, PI, llvm::pred_begin(), and llvm::pred_end().
Referenced by CanPropagatePredecessorsForPHIs(), llvm::CloneAndPruneFunctionInto(), llvm::DemoteRegToStack(), FoldBlockIntoPredecessor(), getSinglePredecessor(), llvm::SimplifyCFG(), and llvm::SplitEdge().
| const BasicBlock* llvm::BasicBlock::getSinglePredecessor | ( | ) | const [inline] |
| iterator llvm::BasicBlock::begin | ( | ) | [inline] |
Instruction iterator methods
Definition at line 142 of file BasicBlock.h.
Referenced by llvm::AliasSetTracker::add(), AddPredecessorToBlock(), AddReachableCodeToWorklist(), ApproximateLoopSize(), BlockIsSimpleEnoughToThreadThrough(), llvm::Interpreter::callFunction(), CanPropagatePredecessorsForPHIs(), CheckForEscapingAllocas(), llvm::CloneAndPruneFunctionInto(), llvm::CloneBasicBlock(), llvm::CloneLoop(), llvm::CloneTrace(), CollapsePhi(), copyCatchInfo(), llvm::DemotePHIToStack(), llvm::DemoteRegToStack(), llvm::DominatorTree::dominates(), DominatesMergePoint(), dropAllReferences(), EvaluateFunction(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), llvm::MemoryDependenceAnalysis::getDependency(), getFirstNonPHI(), HandleInlinedInvoke(), HoistThenElseCodeToIf(), llvm::InlineFunction(), llvm::SCEVExpander::InsertBinop(), llvm::InsertProfilingInitCall(), isSafeToLoadUnconditionally(), isTrivialLoopExitBlockHelper(), LLVMGetFirstInstruction(), LLVMGetLastInstruction(), LLVMGetPreviousInstruction(), MarkAliveBlocks(), llvm::MergeBlockIntoPredecessor(), llvm::SparseSolver::Print(), removePredecessor(), ReplacePhiPred(), llvm::SimplifyCFG(), SimplifyCondBranchToCondBranch(), SimplifyCondBranchToTwoReturns(), SpeculativelyExecuteBB(), splitBasicBlock(), llvm::SplitBlockPredecessors(), llvm::SplitCriticalEdge(), llvm::SplitEdge(), SplitEdgeNicely(), TryToSimplifyUncondBranchFromEmptyBlock(), and llvm::SCEVExpander::visitAddRecExpr().
| const_iterator llvm::BasicBlock::begin | ( | ) | const [inline] |
Definition at line 143 of file BasicBlock.h.
| iterator llvm::BasicBlock::end | ( | ) | [inline] |
Definition at line 144 of file BasicBlock.h.
Referenced by llvm::AliasSetTracker::add(), AddReachableCodeToWorklist(), ApproximateLoopSize(), ChangeToUnreachable(), CheckForEscapingAllocas(), llvm::CloneAndPruneFunctionInto(), llvm::CloneBasicBlock(), llvm::CloneLoop(), CollapsePhi(), copyCatchInfo(), dropAllReferences(), llvm::MemoryDependenceAnalysis::getDependency(), isSafeToSinkLoad(), isTrivialLoopExitBlockHelper(), LLVMGetFirstInstruction(), LLVMGetLastInstruction(), LLVMGetNextInstruction(), LLVMPositionBuilder(), MarkAliveBlocks(), llvm::MergeBlockIntoPredecessor(), llvm::SparseSolver::Print(), ReplacePhiPred(), llvm::IRBuilder< preserveNames, T >::SetInsertPoint(), SpeculativelyExecuteBB(), splitBasicBlock(), and TryToSinkInstruction().
| const_iterator llvm::BasicBlock::end | ( | ) | const [inline] |
Definition at line 145 of file BasicBlock.h.
| size_t llvm::BasicBlock::size | ( | ) | const [inline] |
Definition at line 147 of file BasicBlock.h.
Referenced by FoldValueComparisonIntoPredecessors(), and llvm::SimplifyCFG().
| bool llvm::BasicBlock::empty | ( | ) | const [inline] |
Definition at line 148 of file BasicBlock.h.
| const Instruction& llvm::BasicBlock::front | ( | ) | const [inline] |
Definition at line 149 of file BasicBlock.h.
Referenced by llvm::AliasAnalysis::canBasicBlockModify(), FoldBlockIntoPredecessor(), FoldBranchToCommonDest(), llvm::MergeBlockIntoPredecessor(), removePredecessor(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::SimplifyCFG(), and SplitEdgeNicely().
| Instruction& llvm::BasicBlock::front | ( | ) | [inline] |
Definition at line 150 of file BasicBlock.h.
| const Instruction& llvm::BasicBlock::back | ( | ) | const [inline] |
Definition at line 151 of file BasicBlock.h.
Referenced by llvm::AliasAnalysis::canBasicBlockModify(), llvm::CloneAndPruneFunctionInto(), and llvm::LiveVariables::MarkVirtRegAliveInBlock().
| Instruction& llvm::BasicBlock::back | ( | ) | [inline] |
Definition at line 152 of file BasicBlock.h.
| const InstListType& llvm::BasicBlock::getInstList | ( | ) | const [inline] |
getInstList() - Return the underlying instruction list container. You need to access it directly if you want to modify it currently.
Definition at line 157 of file BasicBlock.h.
Referenced by ChangeToCall(), ChangeToUnreachable(), llvm::CloneAndPruneFunctionInto(), llvm::CloneBasicBlock(), llvm::CloneTrace(), llvm::ConstantFoldTerminator(), llvm::BinaryOperator::Create(), llvm::Instruction::eraseFromParent(), FoldBlockIntoPredecessor(), FoldBranchToCommonDest(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), FoldValueComparisonIntoPredecessors(), HandleInlinedInvoke(), HoistThenElseCodeToIf(), llvm::InlineFunction(), llvm::Instruction::insertBefore(), llvm::IRBuilder< preserveNames, T >::InsertHelper(), llvm::Instruction::Instruction(), llvm::MergeBlockIntoPredecessor(), llvm::Instruction::moveBefore(), llvm::Instruction::removeFromParent(), removePredecessor(), llvm::ReplaceInstWithInst(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::SimplifyCFG(), SpeculativelyExecuteBB(), splitBasicBlock(), TryToSimplifyUncondBranchFromEmptyBlock(), and llvm::UnrollLoop().
| InstListType& llvm::BasicBlock::getInstList | ( | ) | [inline] |
Definition at line 158 of file BasicBlock.h.
| static bool llvm::BasicBlock::classof | ( | const BasicBlock * | ) | [inline, static] |
Methods for support type inquiry through isa, cast, and dyn_cast:.
Definition at line 161 of file BasicBlock.h.
| static bool llvm::BasicBlock::classof | ( | const Value * | V | ) | [inline, static] |
Reimplemented from llvm::Value.
Definition at line 162 of file BasicBlock.h.
References llvm::Value::BasicBlockVal, and llvm::Value::getValueID().
| 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 157 of file BasicBlock.cpp.
References begin(), E, end(), and I.
Referenced by ~BasicBlock().
| void BasicBlock::removePredecessor | ( | BasicBlock * | Pred, | |
| bool | DontDeleteUselessPHIs = false | |||
| ) |
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.
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 178 of file BasicBlock.cpp.
References begin(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), front(), llvm::UndefValue::get(), llvm::PHINode::getIncomingBlock(), getInstList(), llvm::PHINode::getNumIncomingValues(), llvm::PHINode::hasConstantValue(), llvm::Value::hasNUsesOrMore(), II, llvm::pred_begin(), llvm::pred_end(), llvm::PHINode::removeIncomingValue(), and llvm::Value::replaceAllUsesWith().
Referenced by ChangeToCall(), ChangeToUnreachable(), llvm::ConstantFoldTerminator(), FoldCondBranchOnPHI(), FoldValueComparisonIntoPredecessors(), HandleInlinedInvoke(), llvm::RemoveSuccessor(), llvm::SimplifyCFG(), SimplifyCondBranchToTwoReturns(), SimplifyEqualityComparisonWithOnlyPredecessor(), llvm::SplitCriticalEdge(), and SplitEdgeNicely().
| BasicBlock * BasicBlock::splitBasicBlock | ( | iterator | I, | |
| const std::string & | 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).
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 259 of file BasicBlock.cpp.
References begin(), llvm::BranchInst::Create(), Create(), llvm::dyn_cast(), E, end(), llvm::PHINode::getBasicBlockIndex(), getInstList(), getParent(), getTerminator(), II, llvm::next(), llvm::PHINode::setIncomingBlock(), llvm::succ_begin(), and llvm::succ_end().
Referenced by llvm::InlineFunction(), PerformHeapAllocSRoA(), and llvm::SplitBlock().
| static unsigned llvm::BasicBlock::getInstListOffset | ( | ) | [inline, static] |
Definition at line 199 of file BasicBlock.h.
References InstList.
Referenced by llvm::ilist_traits< Instruction >::getListOffset().
friend class SymbolTableListTraits< BasicBlock, Function > [friend] |
Definition at line 61 of file BasicBlock.h.