LLVM API Documentation

Classes | Enumerations | Functions | Variables
llvm::objcarc Namespace Reference

Classes

class  ARCRuntimeEntryPoints
class  ObjCARCAliasAnalysis
 This is a simple alias analysis implementation that uses knowledge of ARC constructs to answer queries. More...
class  ProvenanceAnalysis
 This is similar to BasicAliasAnalysis, and it uses many of the same techniques, except it uses special ObjC-specific reasoning about pointer relationships. More...

Enumerations

enum  DependenceKind {
  NeedsPositiveRetainCount, AutoreleasePoolBoundary, CanChangeRetainCount, RetainAutoreleaseDep,
  RetainAutoreleaseRVDep, RetainRVDep
}
 Defines different dependence kinds among various ARC constructs. More...
enum  InstructionClass {
  IC_Retain, IC_RetainRV, IC_RetainBlock, IC_Release,
  IC_Autorelease, IC_AutoreleaseRV, IC_AutoreleasepoolPush, IC_AutoreleasepoolPop,
  IC_NoopCast, IC_FusedRetainAutorelease, IC_FusedRetainAutoreleaseRV, IC_LoadWeakRetained,
  IC_StoreWeak, IC_InitWeak, IC_LoadWeak, IC_MoveWeak,
  IC_CopyWeak, IC_DestroyWeak, IC_StoreStrong, IC_IntrinsicUser,
  IC_CallOrUser, IC_Call, IC_User, IC_None
}
 A simple classification for instructions. More...

Functions

void FindDependencies (DependenceKind Flavor, const Value *Arg, BasicBlock *StartBB, Instruction *StartInst, SmallPtrSetImpl< Instruction * > &DependingInstructions, SmallPtrSetImpl< const BasicBlock * > &Visited, ProvenanceAnalysis &PA)
bool Depends (DependenceKind Flavor, Instruction *Inst, const Value *Arg, ProvenanceAnalysis &PA)
bool CanUse (const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, InstructionClass Class)
bool CanAlterRefCount (const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, InstructionClass Class)
static bool ModuleHasARC (const Module &M)
 Test if the given module looks interesting to run ARC optimization on.
raw_ostreamoperator<< (raw_ostream &OS, const InstructionClass Class)
static bool IsUser (InstructionClass Class)
 Test if the given class is a kind of user.
static bool IsRetain (InstructionClass Class)
 Test if the given class is objc_retain or equivalent.
static bool IsAutorelease (InstructionClass Class)
 Test if the given class is objc_autorelease or equivalent.
static bool IsForwarding (InstructionClass Class)
 Test if the given class represents instructions which return their argument verbatim.
static bool IsNoopOnNull (InstructionClass Class)
 Test if the given class represents instructions which do nothing if passed a null pointer.
static bool IsAlwaysTail (InstructionClass Class)
 Test if the given class represents instructions which are always safe to mark with the "tail" keyword.
static bool IsNeverTail (InstructionClass Class)
 Test if the given class represents instructions which are never safe to mark with the "tail" keyword.
static bool IsNoThrow (InstructionClass Class)
 Test if the given class represents instructions which are always safe to mark with the nounwind attribute.
static bool CanInterruptRV (InstructionClass Class)
InstructionClass GetFunctionClass (const Function *F)
 Determine if F is one of the special known Functions. If it isn't, return IC_CallOrUser.
static InstructionClass GetBasicInstructionClass (const Value *V)
 Determine which objc runtime call instruction class V belongs to.
InstructionClass GetInstructionClass (const Value *V)
 Determine what kind of construct V is.
static const ValueGetUnderlyingObjCPtr (const Value *V)
 This is a wrapper around getUnderlyingObject which also knows how to look through objc_retain and objc_autorelease calls, which we know to return their argument verbatim.
static const ValueStripPointerCastsAndObjCCalls (const Value *V)
 This is a wrapper around Value::stripPointerCasts which also knows how to look through objc_retain and objc_autorelease calls, which we know to return their argument verbatim.
static ValueStripPointerCastsAndObjCCalls (Value *V)
 This is a wrapper around Value::stripPointerCasts which also knows how to look through objc_retain and objc_autorelease calls, which we know to return their argument verbatim.
static ValueGetObjCArg (Value *Inst)
 Assuming the given instruction is one of the special calls such as objc_retain or objc_release, return the argument value, stripped of no-op casts and forwarding calls.
static bool IsNullOrUndef (const Value *V)
static bool IsNoopInstruction (const Instruction *I)
static void EraseInstruction (Instruction *CI)
 Erase the given instruction.
static bool IsPotentialRetainableObjPtr (const Value *Op)
 Test whether the given value is possible a retainable object pointer.
static bool IsPotentialRetainableObjPtr (const Value *Op, AliasAnalysis &AA)
static InstructionClass GetCallSiteClass (ImmutableCallSite CS)
 Helper for GetInstructionClass. Determines what kind of construct CS is.
static bool IsObjCIdentifiedObject (const Value *V)
 Return true if this value refers to a distinct and identifiable object.

Variables

bool EnableARCOpts
 A handy option to enable/disable all ARC Optimizations.

Enumeration Type Documentation

Defines different dependence kinds among various ARC constructs.

There are several kinds of dependence-like concepts in use here.

Enumerator:
NeedsPositiveRetainCount 
AutoreleasePoolBoundary 
CanChangeRetainCount 
RetainAutoreleaseDep 

Blocks objc_retainAutorelease.

RetainAutoreleaseRVDep 

Blocks objc_retainAutoreleaseReturnValue.

RetainRVDep 

Blocks objc_retainAutoreleasedReturnValue.

Definition at line 44 of file DependencyAnalysis.h.

A simple classification for instructions.

Enumerator:
IC_Retain 

objc_retain

IC_RetainRV 

objc_retainAutoreleasedReturnValue

IC_RetainBlock 

objc_retainBlock

IC_Release 

objc_release

IC_Autorelease 

objc_autorelease

IC_AutoreleaseRV 

objc_autoreleaseReturnValue

IC_AutoreleasepoolPush 

objc_autoreleasePoolPush

IC_AutoreleasepoolPop 

objc_autoreleasePoolPop

IC_NoopCast 

objc_retainedObject, etc.

IC_FusedRetainAutorelease 

objc_retainAutorelease

IC_FusedRetainAutoreleaseRV 

objc_retainAutoreleaseReturnValue

IC_LoadWeakRetained 

objc_loadWeakRetained (primitive)

IC_StoreWeak 

objc_storeWeak (primitive)

IC_InitWeak 

objc_initWeak (derived)

IC_LoadWeak 

objc_loadWeak (derived)

IC_MoveWeak 

objc_moveWeak (derived)

IC_CopyWeak 

objc_copyWeak (derived)

IC_DestroyWeak 

objc_destroyWeak (derived)

IC_StoreStrong 

objc_storeStrong (derived)

IC_IntrinsicUser 

clang.arc.use

IC_CallOrUser 

could call objc_release and/or "use" pointers

IC_Call 

could call objc_release

IC_User 

could "use" a pointer

IC_None 

anything else

Definition at line 73 of file lib/Transforms/ObjCARC/ObjCARC.h.


Function Documentation

static bool llvm::objcarc::CanInterruptRV ( InstructionClass  Class) [inline, static]

Test whether the given instruction can autorelease any pointer or cause an autoreleasepool pop.

Definition at line 179 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_Autorelease, IC_AutoreleasepoolPop, IC_AutoreleaseRV, IC_Call, IC_CallOrUser, IC_FusedRetainAutorelease, and IC_FusedRetainAutoreleaseRV.

Referenced by Depends().

Test whether the given instruction can "use" the given pointer's object in a way that requires the reference count to be positive.

Definition at line 73 of file DependencyAnalysis.cpp.

References llvm::objcarc::ProvenanceAnalysis::getAA(), GetUnderlyingObjCPtr(), IC_Call, IsPotentialRetainableObjPtr(), llvm::User::op_begin(), llvm::User::op_end(), and llvm::objcarc::ProvenanceAnalysis::related().

Referenced by Depends().

static void llvm::objcarc::EraseInstruction ( Instruction *  CI) [inline, static]

Erase the given instruction.

Many ObjC calls return their argument verbatim, so if it's such a call and the return value has users, replace them with the argument value.

Definition at line 282 of file lib/Transforms/ObjCARC/ObjCARC.h.

References llvm::Instruction::eraseFromParent(), GetBasicInstructionClass(), IsForwarding(), IsNoopOnNull(), llvm::RecursivelyDeleteTriviallyDeadInstructions(), llvm::Value::replaceAllUsesWith(), and llvm::Value::use_empty().

void llvm::objcarc::FindDependencies ( DependenceKind  Flavor,
const Value Arg,
BasicBlock StartBB,
Instruction StartInst,
SmallPtrSetImpl< Instruction * > &  DependingInsts,
SmallPtrSetImpl< const BasicBlock * > &  Visited,
ProvenanceAnalysis PA 
)

Walk up the CFG from StartPos (which is in StartBB) and find local and non-local dependencies on Arg.

TODO: Cache results?

Definition at line 206 of file DependencyAnalysis.cpp.

References llvm::BasicBlock::begin(), Depends(), llvm::SmallVectorBase::empty(), llvm::BasicBlock::end(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

static InstructionClass llvm::objcarc::GetBasicInstructionClass ( const Value *  V) [inline, static]

Determine which objc runtime call instruction class V belongs to.

This is similar to GetInstructionClass except that it only detects objc runtime calls. This allows it to be faster.

Definition at line 203 of file lib/Transforms/ObjCARC/ObjCARC.h.

References F(), GetFunctionClass(), IC_CallOrUser, and IC_User.

Referenced by Depends(), EraseInstruction(), FindSingleUseIdentifiedObject(), GetUnderlyingObjCPtr(), and StripPointerCastsAndObjCCalls().

static InstructionClass llvm::objcarc::GetCallSiteClass ( ImmutableCallSite  CS) [inline, static]
static Value* llvm::objcarc::GetObjCArg ( Value *  Inst) [inline, static]

Assuming the given instruction is one of the special calls such as objc_retain or objc_release, return the argument value, stripped of no-op casts and forwarding calls.

Definition at line 261 of file lib/Transforms/ObjCARC/ObjCARC.h.

References StripPointerCastsAndObjCCalls().

Referenced by Depends().

static const Value* llvm::objcarc::GetUnderlyingObjCPtr ( const Value *  V) [inline, static]

This is a wrapper around getUnderlyingObject which also knows how to look through objc_retain and objc_autorelease calls, which we know to return their argument verbatim.

Definition at line 221 of file lib/Transforms/ObjCARC/ObjCARC.h.

References GetBasicInstructionClass(), llvm::GetUnderlyingObject(), and IsForwarding().

Referenced by AreAnyUnderlyingObjectsAnAlloca(), and CanUse().

static bool llvm::objcarc::IsAlwaysTail ( InstructionClass  Class) [inline, static]

Test if the given class represents instructions which are always safe to mark with the "tail" keyword.

Definition at line 144 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_AutoreleaseRV, IC_Retain, and IC_RetainRV.

static bool llvm::objcarc::IsAutorelease ( InstructionClass  Class) [inline, static]

Test if the given class is objc_autorelease or equivalent.

Definition at line 116 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_Autorelease, and IC_AutoreleaseRV.

static bool llvm::objcarc::IsForwarding ( InstructionClass  Class) [inline, static]

Test if the given class represents instructions which return their argument verbatim.

Definition at line 123 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_Autorelease, IC_AutoreleaseRV, IC_NoopCast, IC_Retain, and IC_RetainRV.

Referenced by EraseInstruction(), FindSingleUseIdentifiedObject(), GetUnderlyingObjCPtr(), and StripPointerCastsAndObjCCalls().

static bool llvm::objcarc::IsNeverTail ( InstructionClass  Class) [inline, static]

Test if the given class represents instructions which are never safe to mark with the "tail" keyword.

It is never safe to tail call objc_autorelease since by tail calling objc_autorelease, we also tail call -[NSObject autorelease] which supports fast autoreleasing causing our object to be potentially reclaimed from the autorelease pool which violates the semantics of __autoreleasing types in ARC.

Definition at line 153 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_Autorelease.

static bool llvm::objcarc::IsNoopInstruction ( const Instruction *  I) [inline, static]

Definition at line 269 of file lib/Transforms/ObjCARC/ObjCARC.h.

References I.

static bool llvm::objcarc::IsNoopOnNull ( InstructionClass  Class) [inline, static]

Test if the given class represents instructions which do nothing if passed a null pointer.

Definition at line 133 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_Autorelease, IC_AutoreleaseRV, IC_Release, IC_Retain, IC_RetainBlock, and IC_RetainRV.

Referenced by EraseInstruction().

static bool llvm::objcarc::IsNoThrow ( InstructionClass  Class) [inline, static]

Test if the given class represents instructions which are always safe to mark with the nounwind attribute.

Definition at line 164 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_Autorelease, IC_AutoreleasepoolPop, IC_AutoreleasepoolPush, IC_AutoreleaseRV, IC_Release, IC_Retain, and IC_RetainRV.

static bool llvm::objcarc::IsNullOrUndef ( const Value *  V) [inline, static]

Definition at line 265 of file lib/Transforms/ObjCARC/ObjCARC.h.

static bool llvm::objcarc::IsObjCIdentifiedObject ( const Value *  V) [inline, static]

Return true if this value refers to a distinct and identifiable object.

This is similar to AliasAnalysis's isIdentifiedObject, except that it uses special knowledge of ObjC conventions.

Definition at line 363 of file lib/Transforms/ObjCARC/ObjCARC.h.

References LI, Name, llvm::StringRef::startswith(), and StripPointerCastsAndObjCCalls().

Referenced by FindSingleUseIdentifiedObject().

static bool llvm::objcarc::IsPotentialRetainableObjPtr ( const Value *  Op) [inline, static]

Test whether the given value is possible a retainable object pointer.

Definition at line 303 of file lib/Transforms/ObjCARC/ObjCARC.h.

References llvm::dyn_cast(), and llvm::Value::getType().

Referenced by CanAlterRefCount(), CanUse(), GetCallSiteClass(), GetInstructionClass(), and IsPotentialRetainableObjPtr().

static bool llvm::objcarc::IsPotentialRetainableObjPtr ( const Value *  Op,
AliasAnalysis AA 
) [inline, static]
static bool llvm::objcarc::IsRetain ( InstructionClass  Class) [inline, static]

Test if the given class is objc_retain or equivalent.

Definition at line 110 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_Retain, and IC_RetainRV.

static bool llvm::objcarc::IsUser ( InstructionClass  Class) [inline, static]

Test if the given class is a kind of user.

Definition at line 103 of file lib/Transforms/ObjCARC/ObjCARC.h.

References IC_CallOrUser, IC_IntrinsicUser, and IC_User.

static bool llvm::objcarc::ModuleHasARC ( const Module &  M) [inline, static]

Test if the given module looks interesting to run ARC optimization on.

Definition at line 49 of file lib/Transforms/ObjCARC/ObjCARC.h.

References llvm::Module::getNamedValue().

raw_ostream & llvm::objcarc::operator<< ( raw_ostream OS,
const InstructionClass  Class 
)
static const Value* llvm::objcarc::StripPointerCastsAndObjCCalls ( const Value *  V) [inline, static]

This is a wrapper around Value::stripPointerCasts which also knows how to look through objc_retain and objc_autorelease calls, which we know to return their argument verbatim.

Definition at line 235 of file lib/Transforms/ObjCARC/ObjCARC.h.

References GetBasicInstructionClass(), IsForwarding(), and llvm::Value::stripPointerCasts().

Referenced by FindSingleUseIdentifiedObject(), GetObjCArg(), and IsObjCIdentifiedObject().

static Value* llvm::objcarc::StripPointerCastsAndObjCCalls ( Value *  V) [inline, static]

This is a wrapper around Value::stripPointerCasts which also knows how to look through objc_retain and objc_autorelease calls, which we know to return their argument verbatim.

Definition at line 248 of file lib/Transforms/ObjCARC/ObjCARC.h.

References GetBasicInstructionClass(), IsForwarding(), and llvm::Value::stripPointerCasts().


Variable Documentation

A handy option to enable/disable all ARC Optimizations.

Definition at line 30 of file ObjCARC.cpp.