LLVM API Documentation

llvm::BasicBlock Class Reference

#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

 BasicBlock (const std::string &Name="", Function *Parent=0, BasicBlock *InsertBefore=0)
 ~BasicBlock ()
const FunctiongetParent () const
FunctiongetParent ()
BasicBlockgetNext ()
const BasicBlockgetNext () const
BasicBlockgetPrev ()
const BasicBlockgetPrev () const
TerminatorInstgetTerminator ()
const TerminatorInst *const getTerminator () const
void removeFromParent ()
void eraseFromParent ()
void moveBefore (BasicBlock *MovePos)
BasicBlockgetSinglePredecessor ()
const BasicBlockgetSinglePredecessor () 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 ()
virtual void print (std::ostream &OS) const
void print (std::ostream &OS, AssemblyAnnotationWriter *AAW) const
void dropAllReferences ()
void removePredecessor (BasicBlock *Pred, bool DontDeleteUselessPHIs=false)
BasicBlocksplitBasicBlock (iterator I, const std::string &BBName="")

Static Public Member Functions

static bool classof (const BasicBlock *)
 Methods for support type inquiry through isa, cast, and dyn_cast:.
static bool classof (const Value *V)

Friends

class SymbolTableListTraits< BasicBlock, Function, Function >

Detailed Description

Definition at line 49 of file BasicBlock.h.


Member Typedef Documentation

typedef InstListType::const_iterator llvm::BasicBlock::const_iterator

Definition at line 67 of file BasicBlock.h.

typedef iplist<Instruction> llvm::BasicBlock::InstListType

Definition at line 51 of file BasicBlock.h.

typedef InstListType::iterator llvm::BasicBlock::iterator

Instruction iterators...

Definition at line 66 of file BasicBlock.h.


Constructor & Destructor Documentation

BasicBlock::BasicBlock ( const std::string &  Name = "",
Function Parent = 0,
BasicBlock InsertBefore = 0 
)

BasicBlock ctor - If the function parameter is specified, the basic block is automatically inserted at either the end of the function (if InsertBefore is null), or before the specified basic block.

Definition at line 62 of file BasicBlock.cpp.

References llvm::LeakDetector::addGarbageObject(), llvm::Function::getBasicBlockList(), and llvm::InsertBefore().

BasicBlock::~BasicBlock (  ) 

Definition at line 81 of file BasicBlock.cpp.

References dropAllReferences(), and getParent().


Member Function Documentation

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

Definition at line 130 of file BasicBlock.h.

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

Definition at line 129 of file BasicBlock.h.

Referenced by llvm::AliasAnalysis::canBasicBlockModify(), llvm::SimplifyCFG(), and llvm::SelectionDAGLowering::visitSwitch().

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

Definition at line 121 of file BasicBlock.h.

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

Instruction iterator methods

Definition at line 120 of file BasicBlock.h.

Referenced by llvm::AliasSetTracker::add(), AddPredecessorToBlock(), ApproximateLoopSize(), BlockIsSimpleEnoughToThreadThrough(), llvm::Interpreter::callFunction(), CanPropagatePredecessorsForPHIs(), CheckForEscapingAllocas(), llvm::CloneBasicBlock(), llvm::CloneFunctionInto(), llvm::CloneTrace(), llvm::CloneTraceInto(), CollapsePhi(), ComputeMaxOptionalArgsSize(), DominatesMergePoint(), dropAllReferences(), EvaluateFunction(), FindPHIToPartitionLoops(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), HandleInlinedInvoke(), HoistThenElseCodeToIf(), llvm::SlotCalculator::incorporateFunction(), llvm::RSProfilers_std::IncrementCounterInBlock(), llvm::IncrementCounterInBlock(), llvm::InlineFunction(), InsertCodeToShowFunctionEntry(), InsertGEPComputeCode(), InsertInstrumentationCall(), llvm::InsertProfilingInitCall(), llvm::InstrForest::InstrForest(), isBlockSimpleEnough(), isSafeToLoadUnconditionally(), isTrivialLoopExitBlockHelper(), IsTrivialUnswitchCondition(), LinkFunctionBody(), ReleasePtrSeqNumbers(), removePredecessor(), ReplacePhiPred(), ReplaceUsesOfBlockWith(), llvm::Inliner::runOnSCC(), llvm::SimplifyCFG(), llvm::SplitCriticalEdge(), TraceValuesAtBBExit(), TryToSimplifyUncondBranchFromEmptyBlock(), TryToSinkInstruction(), and llvm::Interpreter::visitCallSite().

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

Reimplemented from llvm::Value.

Definition at line 143 of file BasicBlock.h.

References llvm::Value::BasicBlockVal, and V.

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

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

Definition at line 142 of file BasicBlock.h.

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 124 of file BasicBlock.cpp.

References begin(), E, end(), and I.

Referenced by ~BasicBlock().

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

Definition at line 126 of file BasicBlock.h.

Referenced by llvm::SimplifyCFG().

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

Definition at line 123 of file BasicBlock.h.

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

Definition at line 122 of file BasicBlock.h.

Referenced by llvm::AliasSetTracker::add(), ApproximateLoopSize(), llvm::BuildMI(), CheckForEscapingAllocas(), llvm::CloneBasicBlock(), llvm::CloneFunctionInto(), llvm::CloneTraceInto(), CollapsePhi(), ComputeMaxOptionalArgsSize(), dropAllReferences(), HandleInlinedInvoke(), llvm::SlotCalculator::incorporateFunction(), llvm::InlineFunction(), llvm::InstrForest::InstrForest(), isTrivialLoopExitBlockHelper(), IsTrivialUnswitchCondition(), LinkFunctionBody(), ReleasePtrSeqNumbers(), ReplacePhiPred(), ReplaceUsesOfBlockWith(), llvm::Inliner::runOnSCC(), llvm::SimplifyCFG(), and splitBasicBlock().

void BasicBlock::eraseFromParent (  ) 

eraseFromParent - This method unlinks 'this' from the containing function and deletes it.

Definition at line 101 of file BasicBlock.cpp.

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

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

Instruction& llvm::BasicBlock::front (  )  [inline]

Definition at line 128 of file BasicBlock.h.

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

Definition at line 127 of file BasicBlock.h.

Referenced by llvm::AliasAnalysis::canBasicBlockModify(), CanPropagatePredecessorsForPHIs(), isBlockSimpleEnough(), removePredecessor(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::SimplifyCFG(), and TryToSimplifyUncondBranchFromEmptyBlock().

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

Definition at line 136 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 135 of file BasicBlock.h.

Referenced by AssociativeOpt(), llvm::CloneBasicBlock(), llvm::ConstantFoldTerminator(), llvm::ConvertExpressionToType(), llvm::BinaryOperator::create(), llvm::DecomposeArrayRef(), llvm::Instruction::eraseFromParent(), ErasePossiblyDeadInstructionTree(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), HandleInlinedInvoke(), HoistThenElseCodeToIf(), llvm::InlineFunction(), llvm::Instruction::Instruction(), llvm::Instruction::moveBefore(), llvm::BytecodeReader::ParseInstruction(), RecursiveDelete(), llvm::Instruction::removeFromParent(), removePredecessor(), llvm::ReplaceInstWithInst(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::SimplifyCFG(), splitBasicBlock(), and TryToSimplifyUncondBranchFromEmptyBlock().

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

Definition at line 84 of file BasicBlock.h.

References Next.

BasicBlock* llvm::BasicBlock::getNext (  )  [inline]

Definition at line 83 of file BasicBlock.h.

References Next.

Referenced by ReleasePtrSeqNumbers(), splitBasicBlock(), and llvm::SplitCriticalEdge().

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

Definition at line 80 of file BasicBlock.h.

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

getParent - Return the enclosing method, or null if none

Definition at line 79 of file BasicBlock.h.

Referenced by CheckForEscapingAllocas(), llvm::CloneBasicBlock(), llvm::ConstantFoldTerminator(), createSlotMachine(), llvm::DemoteRegToStack(), llvm::MachineCodeForInstruction::destroy(), eraseFromParent(), FoldCondBranchOnPHI(), FoldValueComparisonIntoPredecessors(), llvm::MachineCodeForInstruction::get(), llvm::DSCallSite::getCaller(), llvm::CallSite::getCaller(), getCommonReturnValue(), getConstantEvolvingPHI(), llvm::ProfileInfo::getExecutionCount(), getFnForValue(), llvm::Trace::getFunction(), getModuleFromVal(), HandleInlinedInvoke(), IdenticalComplexInst(), InlineCallIfPossible(), llvm::InlineFunction(), llvm::X86TargetLowering::InsertAtEndOfBasicBlock(), llvm::PPCTargetLowering::InsertAtEndOfBasicBlock(), InsertCodeToShowFunctionExit(), InsertInstrumentationCall(), InsertPrintInst(), isDynamicConstant(), isIdenticalBinaryInst(), isIdenticalSelectInst(), isUsedOutsideOfDefiningBlock(), moveBefore(), llvm::Instruction::print(), print(), PrintOps(), removeFromParent(), ReplaceCallWith(), ReplaceUsesOfBlockWith(), llvm::PeepholeOpts::runOnBasicBlock(), llvm::Inliner::runOnSCC(), llvm::BasicBlockPass::runPass(), llvm::Value::setName(), llvm::SimplifyCFG(), splitBasicBlock(), llvm::SplitCriticalEdge(), TryToSinkInstruction(), and ~BasicBlock().

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

Definition at line 86 of file BasicBlock.h.

References Prev.

BasicBlock* llvm::BasicBlock::getPrev (  )  [inline]

Definition at line 85 of file BasicBlock.h.

References Prev.

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

Definition at line 113 of file BasicBlock.h.

References getSinglePredecessor().

BasicBlock * BasicBlock::getSinglePredecessor (  ) 

getSinglePredecessor - If this basic block has a single predecessor block, return the block, otherwise return a null pointer.

Definition at line 131 of file BasicBlock.cpp.

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

Referenced by CanPropagatePredecessorsForPHIs(), getSinglePredecessor(), and llvm::SimplifyCFG().

const TerminatorInst *const BasicBlock::getTerminator (  )  const

Definition at line 119 of file BasicBlock.cpp.

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 114 of file BasicBlock.cpp.

Referenced by ApproximateLoopSize(), BlockIsSimpleEnoughToThreadThrough(), llvm::ChooseInstructionsForDelaySlots(), llvm::CloneBasicBlock(), llvm::CloneFunctionInto(), llvm::ConstantFoldTerminator(), DominatesMergePoint(), FoldCondBranchOnPHI(), FoldTwoEntryPHINode(), llvm::ProfileInfoLoader::getBlockCounts(), llvm::ProfileInfoLoader::getEdgeCounts(), GetIfCondition(), HandleInlinedInvoke(), llvm::InlineFunction(), InsertCodeToShowFunctionExit(), isBlockSimpleEnough(), IsTrivialUnswitchCondition(), llvm::MSchedGraphSB::MSchedGraphSB(), llvm::BytecodeReader::ParseInstructionList(), recBackEdge(), llvm::ReplaceNopsWithUsefulInstr(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::SimplifyCFG(), SimplifyEqualityComparisonWithOnlyPredecessor(), splitBasicBlock(), llvm::SplitCriticalEdge(), llvm::succ_begin(), llvm::succ_end(), TraceValuesAtBBExit(), and llvm::SCEVExpander::visitAddRecExpr().

void BasicBlock::moveBefore ( BasicBlock MovePos  ) 

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

Definition at line 108 of file BasicBlock.cpp.

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

void BasicBlock::print ( std::ostream &  OS,
AssemblyAnnotationWriter AAW 
) const

Definition at line 1296 of file AsmWriter.cpp.

References getParent(), and llvm::AssemblyWriter::write().

virtual void llvm::BasicBlock::print ( std::ostream &  OS  )  const [inline, virtual]

print - Implement operator<< on Value...

Implements llvm::Value.

Definition at line 138 of file BasicBlock.h.

Referenced by llvm::MachineFunction::print().

void BasicBlock::removeFromParent (  ) 

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

Definition at line 97 of file BasicBlock.cpp.

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

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.

Definition at line 145 of file BasicBlock.cpp.

References begin(), llvm::Instruction::eraseFromParent(), front(), llvm::UndefValue::get(), llvm::PHINode::getIncomingBlock(), getInstList(), llvm::PHINode::getNumIncomingValues(), llvm::PHINode::hasConstantValue(), llvm::Value::hasNUsesOrMore(), II, llvm::MVT::Other, llvm::pred_begin(), llvm::pred_end(), llvm::PHINode::removeIncomingValue(), and llvm::Value::replaceAllUsesWith().

Referenced by llvm::ConstantFoldTerminator(), FoldCondBranchOnPHI(), FoldValueComparisonIntoPredecessors(), HandleInlinedInvoke(), llvm::RemoveSuccessor(), llvm::SimplifyCFG(), and SimplifyEqualityComparisonWithOnlyPredecessor().

size_t llvm::BasicBlock::size (  )  const [inline]

Definition at line 125 of file BasicBlock.h.

Referenced by FoldValueComparisonIntoPredecessors(), isBlockSimpleEnough(), and llvm::BytecodeReader::ParseInstruction().

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).

Definition at line 225 of file BasicBlock.cpp.

References E, end(), llvm::PHINode::getBasicBlockIndex(), getInstList(), getNext(), getParent(), getTerminator(), II, llvm::PHINode::setIncomingBlock(), llvm::succ_begin(), and llvm::succ_end().

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


Friends And Related Function Documentation

friend class SymbolTableListTraits< BasicBlock, Function, Function > [friend]

Definition at line 59 of file BasicBlock.h.


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