LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

llvm::Function Class Reference

#include <Function.h>

Inheritance diagram for llvm::Function:

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

Collaboration graph
[legend]
List of all members.

Public Types

typedef iplist< ArgumentArgumentListType
typedef iplist< BasicBlockBasicBlockListType
typedef BasicBlockListType::iterator iterator
typedef BasicBlockListType::const_iterator const_iterator
typedef std::reverse_iterator<
const_iterator
const_reverse_iterator
typedef std::reverse_iterator<
iterator
reverse_iterator
typedef ArgumentListType::iterator aiterator
typedef ArgumentListType::const_iterator const_aiterator
typedef std::reverse_iterator<
const_aiterator
const_reverse_aiterator
typedef std::reverse_iterator<
aiterator
reverse_aiterator

Public Member Functions

 Function (const FunctionType *Ty, LinkageTypes Linkage, const std::string &N="", Module *M=0)
 ~Function ()
virtual void setName (const std::string &name, SymbolTable *ST=0)
const TypegetReturnType () const
const FunctionTypegetFunctionType () const
virtual bool isExternal () const
unsigned getIntrinsicID () const
bool isIntrinsic () const
void renameLocalSymbols ()
void deleteBody ()
void removeFromParent ()
void eraseFromParent ()
FunctiongetNext ()
const FunctiongetNext () const
FunctiongetPrev ()
const FunctiongetPrev () const
const ArgumentListTypegetArgumentList () const
ArgumentListTypegetArgumentList ()
const BasicBlockListTypegetBasicBlockList () const
BasicBlockListTypegetBasicBlockList ()
const BasicBlockgetEntryBlock () const
BasicBlockgetEntryBlock ()
SymbolTablegetSymbolTable ()
const SymbolTablegetSymbolTable () 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 BasicBlockfront () const
BasicBlockfront ()
const BasicBlockback () const
BasicBlockback ()
aiterator abegin ()
const_aiterator abegin () const
aiterator aend ()
const_aiterator aend () const
reverse_aiterator arbegin ()
const_reverse_aiterator arbegin () const
reverse_aiterator arend ()
const_reverse_aiterator arend () const
size_t asize () const
bool aempty () const
const Argumentafront () const
Argumentafront ()
const Argumentaback () const
Argumentaback ()
virtual void print (std::ostream &OS) const
void print (std::ostream &OS, AssemblyAnnotationWriter *AAW) const
void viewCFG () const
void viewCFGOnly () const
void dropAllReferences ()

Static Public Member Functions

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

Friends

class SymbolTableListTraits< Function, Module, Module >

Detailed Description

Definition at line 48 of file Function.h.


Member Typedef Documentation

typedef ArgumentListType::iterator llvm::Function::aiterator
 

Definition at line 59 of file Function.h.

typedef iplist<Argument> llvm::Function::ArgumentListType
 

Definition at line 50 of file Function.h.

typedef iplist<BasicBlock> llvm::Function::BasicBlockListType
 

Definition at line 51 of file Function.h.

typedef ArgumentListType::const_iterator llvm::Function::const_aiterator
 

Definition at line 60 of file Function.h.

typedef BasicBlockListType::const_iterator llvm::Function::const_iterator
 

Definition at line 55 of file Function.h.

typedef std::reverse_iterator<const_aiterator> llvm::Function::const_reverse_aiterator
 

Definition at line 61 of file Function.h.

typedef std::reverse_iterator<const_iterator> llvm::Function::const_reverse_iterator
 

Definition at line 56 of file Function.h.

typedef BasicBlockListType::iterator llvm::Function::iterator
 

Definition at line 54 of file Function.h.

typedef std::reverse_iterator<aiterator> llvm::Function::reverse_aiterator
 

Definition at line 62 of file Function.h.

typedef std::reverse_iterator<iterator> llvm::Function::reverse_iterator
 

Definition at line 57 of file Function.h.


Constructor & Destructor Documentation

Function::Function const FunctionType Ty,
LinkageTypes  Linkage,
const std::string &  N = "",
Module M = 0
 

Function ctor - If the (optional) Module argument is specified, the function is automatically inserted into the end of the function list for the module.

Definition at line 88 of file Function.cpp.

References llvm::LeakDetector::addGarbageObject(), llvm::Module::getFunctionList(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), getReturnType(), and llvm::Type::VoidTy.

Function::~Function  ) 
 

Definition at line 114 of file Function.cpp.

References dropAllReferences().


Member Function Documentation

Argument& llvm::Function::aback  )  [inline]
 

Definition at line 203 of file Function.h.

const Argument& llvm::Function::aback  )  const [inline]
 

Definition at line 202 of file Function.h.

const_aiterator llvm::Function::abegin  )  const [inline]
 

Definition at line 189 of file Function.h.

aiterator llvm::Function::abegin  )  [inline]
 

Definition at line 188 of file Function.h.

Referenced by AllCalleesPassInValidPointerForArgument(), llvm::DSGraph::AssertGraphOK(), llvm::Interpreter::callFunction(), llvm::CloneFunction(), llvm::CloneFunctionInto(), llvm::CloneModule(), llvm::SparcV9RegInfo::colorMethodArgs(), llvm::LiveRangeInfo::constructLiveRanges(), llvm::DSGraph::getCallSiteForArguments(), llvm::InlineFunction(), InsertCodeToShowFunctionEntry(), llvm::InsertProfilingInitCall(), isDynamicConstant(), LinkFunctionBody(), llvm::DSGraph::markIncompleteNodes(), llvm::DSGraph::mergeInGraph(), and llvm::SparcV9RegInfo::suggestRegs4MethodArgs().

bool llvm::Function::aempty  )  const [inline]
 

Definition at line 199 of file Function.h.

const_aiterator llvm::Function::aend  )  const [inline]
 

Definition at line 191 of file Function.h.

aiterator llvm::Function::aend  )  [inline]
 

Definition at line 190 of file Function.h.

Referenced by llvm::DSGraph::AssertGraphOK(), llvm::Interpreter::callFunction(), llvm::CloneFunction(), llvm::CloneFunctionInto(), llvm::SparcV9RegInfo::colorMethodArgs(), llvm::LiveRangeInfo::constructLiveRanges(), llvm::DSGraph::getCallSiteForArguments(), llvm::InlineFunction(), InsertCodeToShowFunctionEntry(), LinkFunctionBody(), llvm::DSGraph::markIncompleteNodes(), llvm::DSGraph::mergeInGraph(), and llvm::SparcV9RegInfo::suggestRegs4MethodArgs().

Argument& llvm::Function::afront  )  [inline]
 

Definition at line 201 of file Function.h.

const Argument& llvm::Function::afront  )  const [inline]
 

Definition at line 200 of file Function.h.

const_reverse_aiterator llvm::Function::arbegin  )  const [inline]
 

Definition at line 194 of file Function.h.

reverse_aiterator llvm::Function::arbegin  )  [inline]
 

Definition at line 193 of file Function.h.

const_reverse_aiterator llvm::Function::arend  )  const [inline]
 

Definition at line 196 of file Function.h.

reverse_aiterator llvm::Function::arend  )  [inline]
 

Definition at line 195 of file Function.h.

size_t llvm::Function::asize  )  const [inline]
 

Definition at line 198 of file Function.h.

Referenced by llvm::Interpreter::callFunction(), CheckVarargs(), and llvm::InsertProfilingInitCall().

BasicBlock& llvm::Function::back  )  [inline]
 

Definition at line 183 of file Function.h.

const BasicBlock& llvm::Function::back  )  const [inline]
 

Definition at line 182 of file Function.h.

Referenced by llvm::InlineFunction().

const_iterator llvm::Function::begin  )  const [inline]
 

Definition at line 169 of file Function.h.

iterator llvm::Function::begin  )  [inline]
 

Definition at line 168 of file Function.h.

Referenced by llvm::Interpreter::callFunction(), llvm::CloneFunctionInto(), llvm::StableBasicBlockNumbering::compute(), ComputeMaxOptionalArgsSize(), dropAllReferences(), llvm::getBBtrace(), getCommonReturnValue(), llvm::hasBackEdge(), llvm::InlineFunction(), llvm::InsertProfilingInitCall(), llvm::InstrForest::InstrForest(), LinkFunctionBody(), llvm::GraphTraits< const Function * >::nodes_begin(), llvm::GraphTraits< Function * >::nodes_begin(), llvm::PgmDependenceGraph::print(), llvm::ImmediateDominatorsBase::print(), llvm::DependenceGraph::print(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::ProfilePaths::runOnFunction(), llvm::PostDominatorSet::runOnFunction(), llvm::BasicBlockPass::runOnFunction(), llvm::DominatorSet::runOnFunction(), and llvm::SelectionDAG::SelectionDAG().

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

Reimplemented from llvm::GlobalValue.

Definition at line 225 of file Function.h.

References llvm::Value::FunctionVal, and llvm::Value::getValueType().

static bool llvm::Function::classof const Function  )  [inline, static]
 

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

Definition at line 224 of file Function.h.

void llvm::Function::deleteBody  )  [inline]
 

deleteBody - This method deletes the body of the function, and converts the linkage to external.

Definition at line 119 of file Function.h.

References dropAllReferences(), llvm::GlobalValue::ExternalLinkage, and llvm::GlobalValue::setLinkage().

void Function::dropAllReferences  ) 
 

dropAllReferences() - This method causes all the subinstructions to "let go" of all references that they are maintaining. This allows one to 'delete' a whole module 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 deleted for real. Note that no operations are valid on an object that has "dropped all references", except operator delete.

Since no other object in the module can have references into the body of a function, dropping all references deletes the entire body of the function, including any contained basic blocks.

Reimplemented from llvm::User.

Definition at line 205 of file Function.cpp.

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

Referenced by deleteBody(), and ~Function().

bool llvm::Function::empty  )  const [inline]
 

Definition at line 179 of file Function.h.

const_iterator llvm::Function::end  )  const [inline]
 

Definition at line 171 of file Function.h.

iterator llvm::Function::end  )  [inline]
 

Definition at line 170 of file Function.h.

Referenced by llvm::CloneFunctionInto(), llvm::CloneTraceInto(), llvm::StableBasicBlockNumbering::compute(), ComputeMaxOptionalArgsSize(), dropAllReferences(), llvm::getBBtrace(), getBlockAfter(), getCommonReturnValue(), llvm::InlineFunction(), llvm::InstrForest::InstrForest(), LinkFunctionBody(), llvm::GraphTraits< const Function * >::nodes_end(), llvm::GraphTraits< Function * >::nodes_end(), llvm::PgmDependenceGraph::print(), llvm::ImmediateDominatorsBase::print(), llvm::DependenceGraph::print(), llvm::UnifyFunctionExitNodes::runOnFunction(), llvm::ProfilePaths::runOnFunction(), llvm::PostDominatorSet::runOnFunction(), llvm::BasicBlockPass::runOnFunction(), llvm::DominatorSet::runOnFunction(), and llvm::SelectionDAG::SelectionDAG().

void Function::eraseFromParent  ) 
 

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

Definition at line 153 of file Function.cpp.

References llvm::Module::getFunctionList(), and llvm::GlobalValue::getParent().

BasicBlock& llvm::Function::front  )  [inline]
 

Definition at line 181 of file Function.h.

const BasicBlock& llvm::Function::front  )  const [inline]
 

Definition at line 180 of file Function.h.

Referenced by dyn_castFixedAlloca(), llvm::getBBtrace(), getEntryBlock(), llvm::ProfileInfo::getExecutionCount(), llvm::InlineFunction(), llvm::IntervalIterator< NodeTy, OrigContainer_t, GT, IGT >::IntervalIterator(), llvm::ProfilePaths::runOnFunction(), and llvm::SimplifyCFG().

ArgumentListType& llvm::Function::getArgumentList  )  [inline]
 

Definition at line 148 of file Function.h.

const ArgumentListType& llvm::Function::getArgumentList  )  const [inline]
 

Get the underlying elements of the Function... the basic block list is empty for external functions.

Definition at line 147 of file Function.h.

Referenced by llvm::Argument::Argument().

BasicBlockListType& llvm::Function::getBasicBlockList  )  [inline]
 

Definition at line 151 of file Function.h.

const BasicBlockListType& llvm::Function::getBasicBlockList  )  const [inline]
 

Definition at line 150 of file Function.h.

Referenced by llvm::BasicBlock::BasicBlock(), llvm::BasicBlock::eraseFromParent(), getBBVal(), llvm::InlineFunction(), LinkFunctionBody(), llvm::BytecodeReader::ParseInstructionList(), llvm::BasicBlock::removeFromParent(), llvm::SimplifyCFG(), and llvm::SplitCriticalEdge().

BasicBlock& llvm::Function::getEntryBlock  )  [inline]
 

Definition at line 154 of file Function.h.

References front().

const BasicBlock& llvm::Function::getEntryBlock  )  const [inline]
 

Definition at line 153 of file Function.h.

References front().

Referenced by llvm::DemoteRegToStack(), llvm::GraphTraits< Inverse< const Function * > >::getEntryNode(), llvm::GraphTraits< Inverse< Function * > >::getEntryNode(), llvm::GraphTraits< const Function * >::getEntryNode(), llvm::GraphTraits< Function * >::getEntryNode(), InsertCodeToShowFunctionEntry(), llvm::ProfilePaths::runOnFunction(), llvm::DominatorSet::runOnFunction(), and llvm::ImmediateDominators::runOnFunction().

const FunctionType * Function::getFunctionType  )  const
 

Definition at line 141 of file Function.cpp.

References llvm::SequentialType::getElementType(), and llvm::GlobalValue::getType().

Referenced by llvm::Interpreter::callExternalFunction(), llvm::Interpreter::callFunction(), CheckVarargs(), llvm::CloneFunction(), getReturnType(), llvm::InlineFunction(), LinkFunctionProtos(), lookupFunction(), llvm::DSGraph::mergeInGraph(), ProcessGlobalsWithSameName(), ReplaceCallWith(), ResolveFunctions(), llvm::JIT::runFunction(), llvm::Interpreter::runFunction(), and llvm::ExecutionEngine::runFunctionAsMain().

unsigned Function::getIntrinsicID  )  const
 

getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intrinsic if the function is not an instrinsic, or if the pointer is null. This value is always defined to be zero to allow easy checking for whether a function is intrinsic or not. The particular intrinsic functions which correspond to this value are defined in llvm/Intrinsics.h.

Definition at line 218 of file Function.cpp.

References llvm::Intrinsic::dbg_declare, llvm::Intrinsic::dbg_func_start, llvm::Intrinsic::dbg_region_end, llvm::Intrinsic::dbg_region_start, llvm::Intrinsic::dbg_stoppoint, llvm::Intrinsic::frameaddress, llvm::Intrinsic::gcread, llvm::Intrinsic::gcroot, llvm::Intrinsic::gcwrite, llvm::Value::getName(), llvm::Intrinsic::isunordered, llvm::Intrinsic::longjmp, llvm::Intrinsic::memcpy, llvm::Intrinsic::memmove, llvm::Intrinsic::memset, llvm::Intrinsic::readio, llvm::Intrinsic::readport, llvm::Intrinsic::returnaddress, llvm::Intrinsic::setjmp, llvm::Intrinsic::siglongjmp, llvm::Intrinsic::sigsetjmp, size(), llvm::Intrinsic::vacopy, llvm::Intrinsic::vaend, llvm::Intrinsic::vastart, llvm::Intrinsic::writeio, and llvm::Intrinsic::writeport.

Referenced by llvm::canConstantFoldCallTo(), llvm::MemSetInst::classof(), llvm::MemMoveInst::classof(), llvm::MemCpyInst::classof(), dyncastIsNan(), isIntrinsic(), and llvm::DefaultIntrinsicLowering::LowerIntrinsicCall().

const Function* llvm::Function::getNext  )  const [inline]
 

Definition at line 140 of file Function.h.

References Next().

Function* llvm::Function::getNext  )  [inline]
 

Definition at line 139 of file Function.h.

References Next().

const Function* llvm::Function::getPrev  )  const [inline]
 

Definition at line 142 of file Function.h.

Function* llvm::Function::getPrev  )  [inline]
 

Definition at line 141 of file Function.h.

const Type * Function::getReturnType  )  const
 

Definition at line 145 of file Function.cpp.

References getFunctionType(), and llvm::FunctionType::getReturnType().

Referenced by CallersAllIgnoreReturnValue(), llvm::Interpreter::callFunction(), llvm::ConstantFoldCall(), Function(), llvm::InlineFunction(), InsertCodeToShowFunctionExit(), and llvm::UnifyFunctionExitNodes::runOnFunction().

const SymbolTable& llvm::Function::getSymbolTable  )  const [inline]
 

Definition at line 162 of file Function.h.

SymbolTable& llvm::Function::getSymbolTable  )  [inline]
 

getSymbolTable() - Return the symbol table...

Definition at line 161 of file Function.h.

Referenced by lookupInSymbolTable(), renameLocalSymbols(), llvm::Instruction::setName(), setName(), llvm::Argument::setName(), llvm::BasicBlock::setName(), and setValueName().

virtual bool llvm::Function::isExternal  )  const [inline, virtual]
 

isExternal - Is the body of this function unknown? (The basic block list is empty if so.) This is true for external functions, defined as forward "declare"ations

Implements llvm::GlobalValue.

Definition at line 97 of file Function.h.

Referenced by llvm::Interpreter::callFunction(), llvm::JIT::getPointerToFunction(), llvm::InlineFunction(), llvm::DSCallSiteIterator::isUnresolvableFunc(), LinkFunctionBodies(), LinkFunctionBody(), LinkFunctionProtos(), ProcessGlobalsWithSameName(), removeIdenticalCalls(), llvm::FunctionPass::run(), llvm::ProfilePaths::runOnFunction(), llvm::MemoryDepAnalysis::runOnFunction(), llvm::Inliner::runOnSCC(), and llvm::verifyFunction().

bool llvm::Function::isIntrinsic  )  const [inline]
 

Definition at line 107 of file Function.h.

References getIntrinsicID().

void Function::print std::ostream &  OS,
AssemblyAnnotationWriter AAW
const
 

Definition at line 1200 of file AsmWriter.cpp.

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

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

print - Implement operator<< on Value...

Reimplemented from llvm::Constant.

Definition at line 205 of file Function.h.

const_reverse_iterator llvm::Function::rbegin  )  const [inline]
 

Definition at line 174 of file Function.h.

reverse_iterator llvm::Function::rbegin  )  [inline]
 

Definition at line 173 of file Function.h.

void Function::removeFromParent  ) 
 

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

Definition at line 149 of file Function.cpp.

References llvm::Module::getFunctionList(), and llvm::GlobalValue::getParent().

void Function::renameLocalSymbols  ) 
 

renameLocalSymbols - This method goes through the Function's symbol table and renames any symbols that conflict with symbols at global scope. This is required before printing out to a textual form, to ensure that there is no ambiguity when parsing.

Definition at line 162 of file Function.cpp.

References E, llvm::SymbolTable::find(), llvm::GlobalValue::getParent(), llvm::Module::getSymbolTable(), getSymbolTable(), llvm::SymbolTable::plane_begin(), llvm::SymbolTable::plane_end(), llvm::Value::setName(), llvm::utostr(), and V.

const_reverse_iterator llvm::Function::rend  )  const [inline]
 

Definition at line 176 of file Function.h.

reverse_iterator llvm::Function::rend  )  [inline]
 

Definition at line 175 of file Function.h.

void Function::setName const std::string &  name,
SymbolTable ST = 0
[virtual]
 

Reimplemented from llvm::Constant.

Definition at line 124 of file Function.cpp.

References llvm::GlobalValue::getParent(), llvm::Module::getSymbolTable(), getSymbolTable(), llvm::Value::hasName(), llvm::SymbolTable::insert(), llvm::SymbolTable::remove(), and llvm::Value::setName().

Referenced by CheckVarargs(), and Cilkifier::TransformFunc().

size_t llvm::Function::size  )  const [inline]
 

Definition at line 178 of file Function.h.

Referenced by llvm::getBBtrace(), and getIntrinsicID().

void Function::viewCFG  )  const
 

viewCFG - This function is meant for use from the debugger. You can just say 'call F->viewCFG()' and a ghostview window should pop up from the program, displaying the CFG of the current function with the code for each basic block inside. This depends on there being a 'dot' and 'gv' program in your path.

Definition at line 139 of file CFGPrinter.cpp.

References F, llvm::Value::getName(), and llvm::WriteGraph().

Referenced by viewCFGOnly().

void Function::viewCFGOnly  )  const
 

viewCFGOnly - This function is meant for use from the debugger. It works just like viewCFG, but it does not include the contents of basic blocks into the nodes, just the label. If you are only interested in the CFG this can make the graph smaller.

Definition at line 169 of file CFGPrinter.cpp.

References CFGOnly, and viewCFG().


Friends And Related Function Documentation

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

Definition at line 71 of file Function.h.


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