LLVM API Documentation

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 ArgumentListType::iterator arg_iterator
typedef ArgumentListType::const_iterator const_arg_iterator

Public Member Functions

 Function (const FunctionType *Ty, LinkageTypes Linkage, const std::string &N="", Module *M=0)
 ~Function ()
const TypegetReturnType () const
const FunctionTypegetFunctionType () const
bool isVarArg () const
virtual bool isExternal () const
unsigned getIntrinsicID () const
bool isIntrinsic () const
unsigned getCallingConv () const
void setCallingConv (unsigned CC)
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
size_t size () const
bool empty () const
const BasicBlockfront () const
BasicBlockfront ()
const BasicBlockback () const
BasicBlockback ()
arg_iterator arg_begin ()
const_arg_iterator arg_begin () const
arg_iterator arg_end ()
const_arg_iterator arg_end () const
size_t arg_size () const
bool arg_empty () const
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 49 of file Function.h.


Member Typedef Documentation

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

Definition at line 51 of file Function.h.

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

Definition at line 52 of file Function.h.

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

Definition at line 55 of file Function.h.

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

Definition at line 56 of file Function.h.

typedef ArgumentListType::iterator llvm::Function::arg_iterator

Definition at line 58 of file Function.h.

typedef ArgumentListType::const_iterator llvm::Function::const_arg_iterator

Definition at line 59 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 77 of file Function.cpp.

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

Function::~Function (  ) 

Definition at line 104 of file Function.cpp.

References dropAllReferences().


Member Function Documentation

const Type * Function::getReturnType (  )  const

Definition at line 129 of file Function.cpp.

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

Referenced by Function(), InsertCodeToShowFunctionExit(), and llvm::UpgradeIntrinsicCall().

const FunctionType * Function::getFunctionType (  )  const

Definition at line 121 of file Function.cpp.

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

Referenced by EvaluateFunction(), getArgumentPermutation(), getReturnType(), isVarArg(), ReplaceCallWith(), ResolveFunctions(), llvm::ExecutionEngine::runFunctionAsMain(), and llvm::UpgradeIntrinsicCall().

bool Function::isVarArg (  )  const

isVarArg - Return true if this function takes a variable number of arguments.

Definition at line 125 of file Function.cpp.

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

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 96 of file Function.h.

Referenced by EvaluateFunction(), GetAllUndefinedSymbols(), isResolvableFunc(), removeIdenticalCalls(), llvm::EquivClassGraphs::runOnModule(), and llvm::CompleteBUDataStructures::runOnModule().

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 202 of file Function.cpp.

References llvm::Value::getName(), and Name.

Referenced by llvm::IntrinsicInst::getIntrinsicID(), HandleInlinedInvoke(), isIntrinsic(), and llvm::DefaultIntrinsicLowering::LowerIntrinsicCall().

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

Definition at line 106 of file Function.h.

References getIntrinsicID().

unsigned llvm::Function::getCallingConv (  )  const [inline]

getCallingConv()/setCallingConv(uint) - These method get and set the calling convention of this function. The enum values for the known calling conventions are defined in CallingConv.h.

Definition at line 111 of file Function.h.

void llvm::Function::setCallingConv ( unsigned  CC  )  [inline]

Definition at line 112 of file Function.h.

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 146 of file Function.cpp.

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

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

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

Definition at line 124 of file Function.h.

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

void Function::removeFromParent (  ) 

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

Definition at line 133 of file Function.cpp.

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

void Function::eraseFromParent (  ) 

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

Definition at line 137 of file Function.cpp.

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

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

Definition at line 144 of file Function.h.

References Next.

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

Definition at line 145 of file Function.h.

References Next.

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

Definition at line 146 of file Function.h.

References Prev.

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

Definition at line 147 of file Function.h.

References Prev.

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 152 of file Function.h.

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

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

Definition at line 153 of file Function.h.

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

Definition at line 155 of file Function.h.

Referenced by llvm::BasicBlock::BasicBlock(), llvm::BasicBlock::eraseFromParent(), getBBVal(), llvm::InlineFunction(), llvm::BasicBlock::moveBefore(), and llvm::BasicBlock::removeFromParent().

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

Definition at line 156 of file Function.h.

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

Definition at line 158 of file Function.h.

References front().

Referenced by llvm::CloneAndPruneFunctionInto().

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

Definition at line 159 of file Function.h.

References front().

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

getSymbolTable() - Return the symbol table...

Definition at line 166 of file Function.h.

Referenced by lookupInSymbolTable(), renameLocalSymbols(), and setValueName().

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

Definition at line 167 of file Function.h.

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

Definition at line 173 of file Function.h.

Referenced by llvm::CloneAndPruneFunctionInto(), llvm::CloneFunctionInto(), dropAllReferences(), llvm::FunctionLoweringInfo::FunctionLoweringInfo(), llvm::InlineFunction(), llvm::InsertProfilingInitCall(), and llvm::SelectionDAGISel::runOnFunction().

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

Definition at line 174 of file Function.h.

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

Definition at line 175 of file Function.h.

Referenced by llvm::CloneAndPruneFunctionInto(), llvm::CloneFunctionInto(), llvm::CloneTraceInto(), dropAllReferences(), llvm::FunctionLoweringInfo::FunctionLoweringInfo(), HandleInlinedInvoke(), llvm::InlineFunction(), ReplaceUsesOfBlockWith(), and llvm::SelectionDAGISel::runOnFunction().

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

Definition at line 176 of file Function.h.

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

Definition at line 178 of file Function.h.

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

Definition at line 179 of file Function.h.

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

Definition at line 180 of file Function.h.

Referenced by CheckForEscapingAllocas(), llvm::CloneBasicBlock(), getEntryBlock(), llvm::ProfileInfo::getExecutionCount(), llvm::InlineFunction(), llvm::SimplifyCFG(), and TryToSinkInstruction().

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

Definition at line 181 of file Function.h.

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

Definition at line 182 of file Function.h.

Referenced by llvm::InlineFunction().

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

Definition at line 183 of file Function.h.

arg_iterator llvm::Function::arg_begin (  )  [inline]

Definition at line 188 of file Function.h.

Referenced by AllCalleesPassInValidPointerForArgument(), llvm::CloneAndPruneFunctionInto(), llvm::CloneFunctionInto(), llvm::FunctionLoweringInfo::FunctionLoweringInfo(), and llvm::InsertProfilingInitCall().

const_arg_iterator llvm::Function::arg_begin (  )  const [inline]

Definition at line 189 of file Function.h.

arg_iterator llvm::Function::arg_end (  )  [inline]

Definition at line 190 of file Function.h.

Referenced by llvm::CloneAndPruneFunctionInto(), llvm::CloneFunctionInto(), and llvm::FunctionLoweringInfo::FunctionLoweringInfo().

const_arg_iterator llvm::Function::arg_end (  )  const [inline]

Definition at line 191 of file Function.h.

size_t llvm::Function::arg_size (  )  const [inline]

Definition at line 193 of file Function.h.

Referenced by llvm::InsertProfilingInitCall().

bool llvm::Function::arg_empty (  )  const [inline]

Definition at line 194 of file Function.h.

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

print - Implement operator<< on Value...

Reimplemented from llvm::Constant.

Definition at line 196 of file Function.h.

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

Definition at line 1288 of file AsmWriter.cpp.

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

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 140 of file CFGPrinter.cpp.

References llvm::Value::getName(), and llvm::ViewGraph().

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 149 of file CFGPrinter.cpp.

References CFGOnly, and viewCFG().

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

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

Definition at line 215 of file Function.h.

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

Reimplemented from llvm::GlobalValue.

Definition at line 216 of file Function.h.

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

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 189 of file Function.cpp.

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

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


Friends And Related Function Documentation

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

Definition at line 69 of file Function.h.


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