LLVM  mainline
Classes | Namespaces | Defines | Enumerations | Functions | Variables
FunctionAttrs.cpp File Reference

This file implements interprocedural passes which walk the call-graph deducing and/or propagating function attributes. More...

#include "llvm/Transforms/IPO.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Include dependency graph for FunctionAttrs.cpp:

Go to the source code of this file.

Classes

struct  llvm::GraphTraits< ArgumentGraphNode * >
struct  llvm::GraphTraits< ArgumentGraph * >

Namespaces

namespace  llvm
 

Compute iterated dominance frontiers using a linear time algorithm.


Defines

#define DEBUG_TYPE   "functionattrs"

Enumerations

enum  MemoryAccessKind
 The three kinds of memory access relevant to 'readonly' and 'readnone' attributes. More...

Functions

 STATISTIC (NumReadNone,"Number of functions marked readnone")
 STATISTIC (NumReadOnly,"Number of functions marked readonly")
 STATISTIC (NumNoCapture,"Number of arguments marked nocapture")
 STATISTIC (NumReadNoneArg,"Number of arguments marked readnone")
 STATISTIC (NumReadOnlyArg,"Number of arguments marked readonly")
 STATISTIC (NumNoAlias,"Number of function returns marked noalias")
 STATISTIC (NumNonNullReturn,"Number of function returns marked nonnull")
 STATISTIC (NumNoRecurse,"Number of functions marked as norecurse")
 INITIALIZE_PASS_BEGIN (PostOrderFunctionAttrs,"functionattrs","Deduce function attributes", false, false) INITIALIZE_PASS_END(PostOrderFunctionAttrs
static MemoryAccessKind checkFunctionMemoryAccess (Function &F, AAResults &AAR, const SCCNodeSet &SCCNodes)
template<typename AARGetterT >
static bool addReadAttrs (const SCCNodeSet &SCCNodes, AARGetterT AARGetter)
 Deduce readonly/readnone attributes for the SCC.
static Attribute::AttrKind determinePointerReadAttrs (Argument *A, const SmallPtrSet< Argument *, 8 > &SCCNodes)
 Returns Attribute::None, Attribute::ReadOnly or Attribute::ReadNone.
static bool addArgumentAttrs (const SCCNodeSet &SCCNodes)
 Deduce nocapture attributes for the SCC.
static bool isFunctionMallocLike (Function *F, const SCCNodeSet &SCCNodes)
 Tests whether a function is "malloc-like".
static bool addNoAliasAttrs (const SCCNodeSet &SCCNodes)
 Deduce noalias attributes for the SCC.
static bool isReturnNonNull (Function *F, const SCCNodeSet &SCCNodes, const TargetLibraryInfo &TLI, bool &Speculative)
 Tests whether this function is known to not return null.
static bool addNonNullAttrs (const SCCNodeSet &SCCNodes, const TargetLibraryInfo &TLI)
 Deduce nonnull attributes for the SCC.
static bool setDoesNotRecurse (Function &F)
static bool addNoRecurseAttrs (const CallGraphSCC &SCC)
 INITIALIZE_PASS_BEGIN (ReversePostOrderFunctionAttrs,"rpo-functionattrs","Deduce function attributes in RPO", false, false) INITIALIZE_PASS_END(ReversePostOrderFunctionAttrs
static bool addNoRecurseAttrsTopDown (Function &F)

Variables

 functionattrs
Deduce function attributes
Deduce function false
rpo Deduce function attributes in RPO

Detailed Description

This file implements interprocedural passes which walk the call-graph deducing and/or propagating function attributes.

Definition in file FunctionAttrs.cpp.


Define Documentation

#define DEBUG_TYPE   "functionattrs"

Definition at line 39 of file FunctionAttrs.cpp.


Enumeration Type Documentation

The three kinds of memory access relevant to 'readonly' and 'readnone' attributes.

Definition at line 89 of file FunctionAttrs.cpp.


Function Documentation

static bool addArgumentAttrs ( const SCCNodeSet &  SCCNodes) [static]
static bool addNoAliasAttrs ( const SCCNodeSet &  SCCNodes) [static]
static bool addNonNullAttrs ( const SCCNodeSet &  SCCNodes,
const TargetLibraryInfo TLI 
) [static]
static bool addNoRecurseAttrs ( const CallGraphSCC SCC) [static]
static bool addNoRecurseAttrsTopDown ( Function F) [static]
template<typename AARGetterT >
static bool addReadAttrs ( const SCCNodeSet &  SCCNodes,
AARGetterT  AARGetter 
) [static]

Deduce readonly/readnone attributes for the SCC.

Definition at line 202 of file FunctionAttrs.cpp.

References llvm::AttrBuilder::addAttribute(), B, checkFunctionMemoryAccess(), F, and llvm::AttributeSet::FunctionIndex.

static MemoryAccessKind checkFunctionMemoryAccess ( Function F,
AAResults AAR,
const SCCNodeSet &  SCCNodes 
) [static]
static Attribute::AttrKind determinePointerReadAttrs ( Argument A,
const SmallPtrSet< Argument *, 8 > &  SCCNodes 
) [static]

Returns Attribute::None, Attribute::ReadOnly or Attribute::ReadNone.

Definition at line 386 of file FunctionAttrs.cpp.

References llvm::AddrSpaceCast, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::Function::arg_begin(), llvm::Function::arg_size(), llvm::objcarc::Call, llvm::SmallPtrSetImpl< PtrType >::count(), llvm::CS, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::data_operands_size(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::doesNotAccessMemory(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::doesNotCapture(), llvm::SmallVectorBase::empty(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getNumArgOperands(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::Argument::hasInAllocaAttr(), I, llvm::SmallSet< T, N, C >::insert(), llvm::Function::isVarArg(), llvm::Type::isVoidTy(), llvm::SPII::Load, llvm::Attribute::None, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::onlyReadsMemory(), llvm::TargetOpcode::PHI, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::MipsISD::Ret, llvm::MCID::Select, and llvm::Value::uses().

Referenced by addArgumentAttrs().

INITIALIZE_PASS_BEGIN ( PostOrderFunctionAttrs  ,
"functionattrs"  ,
"Deduce function attributes ,
false  ,
false   
)
INITIALIZE_PASS_BEGIN ( ReversePostOrderFunctionAttrs  ,
"rpo-functionattrs ,
"Deduce function attributes in RPO ,
false  ,
false   
)
static bool isFunctionMallocLike ( Function F,
const SCCNodeSet &  SCCNodes 
) [static]
static bool isReturnNonNull ( Function F,
const SCCNodeSet &  SCCNodes,
const TargetLibraryInfo TLI,
bool Speculative 
) [static]
static bool setDoesNotRecurse ( Function F) [static]
STATISTIC ( NumReadNone  ,
"Number of functions marked readnone"   
)
STATISTIC ( NumReadOnly  ,
"Number of functions marked readonly"   
)
STATISTIC ( NumNoCapture  ,
"Number of arguments marked nocapture"   
)
STATISTIC ( NumReadNoneArg  ,
"Number of arguments marked readnone"   
)
STATISTIC ( NumReadOnlyArg  ,
"Number of arguments marked readonly"   
)
STATISTIC ( NumNoAlias  ,
"Number of function returns marked noalias  
)
STATISTIC ( NumNonNullReturn  ,
"Number of function returns marked nonnull"   
)
STATISTIC ( NumNoRecurse  ,
"Number of functions marked as norecurse"   
)

Variable Documentation

Definition at line 81 of file FunctionAttrs.cpp.

rpo Deduce function attributes in false

Definition at line 81 of file FunctionAttrs.cpp.

Definition at line 81 of file FunctionAttrs.cpp.

rpo Deduce function attributes in RPO

Definition at line 1045 of file FunctionAttrs.cpp.