LLVM API Documentation
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_ostream & | operator<< (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 Value * | GetUnderlyingObjCPtr (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 Value * | StripPointerCastsAndObjCCalls (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 Value * | StripPointerCastsAndObjCCalls (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 Value * | GetObjCArg (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. |
Defines different dependence kinds among various ARC constructs.
There are several kinds of dependence-like concepts in use here.
Definition at line 44 of file DependencyAnalysis.h.
A simple classification for instructions.
Definition at line 73 of file lib/Transforms/ObjCARC/ObjCARC.h.
bool llvm::objcarc::CanAlterRefCount | ( | const Instruction * | Inst, |
const Value * | Ptr, | ||
ProvenanceAnalysis & | PA, | ||
InstructionClass | Class | ||
) |
Test whether the given instruction can result in a reference count modification (positive or negative) for the pointer's object.
Definition at line 36 of file DependencyAnalysis.cpp.
References llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_end(), llvm::objcarc::ProvenanceAnalysis::getAA(), llvm::AliasAnalysis::getModRefBehavior(), I, IC_Autorelease, IC_AutoreleaseRV, IC_IntrinsicUser, IC_User, IsPotentialRetainableObjPtr(), llvm::AliasAnalysis::onlyAccessesArgPointees(), llvm::AliasAnalysis::onlyReadsMemory(), and llvm::objcarc::ProvenanceAnalysis::related().
Referenced by Depends().
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().
bool llvm::objcarc::CanUse | ( | const Instruction * | Inst, |
const Value * | Ptr, | ||
ProvenanceAnalysis & | PA, | ||
InstructionClass | Class | ||
) |
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().
bool llvm::objcarc::Depends | ( | DependenceKind | Flavor, |
Instruction * | Inst, | ||
const Value * | Arg, | ||
ProvenanceAnalysis & | PA | ||
) |
Test if there can be dependencies on Inst through Arg. This function only tests dependencies relevant for removing pairs of calls.
Definition at line 118 of file DependencyAnalysis.cpp.
References AutoreleasePoolBoundary, CanAlterRefCount(), CanChangeRetainCount, CanInterruptRV(), CanUse(), llvm::tgtok::Class, GetBasicInstructionClass(), GetInstructionClass(), GetObjCArg(), IC_AutoreleasepoolPop, IC_AutoreleasepoolPush, IC_None, IC_Retain, IC_RetainRV, llvm_unreachable, NeedsPositiveRetainCount, RetainAutoreleaseDep, RetainAutoreleaseRVDep, and RetainRVDep.
Referenced by FindDependencies().
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] |
Helper for GetInstructionClass. Determines what kind of construct CS is.
Definition at line 349 of file lib/Transforms/ObjCARC/ObjCARC.h.
References llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_end(), I, IC_Call, IC_CallOrUser, IC_None, IC_User, IsPotentialRetainableObjPtr(), and llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::onlyReadsMemory().
Referenced by GetInstructionClass().
Determine if F is one of the special known Functions. If it isn't, return IC_CallOrUser.
Definition at line 83 of file ObjCARCUtil.cpp.
References llvm::Function::arg_begin(), llvm::Function::arg_end(), llvm::StringSwitch< T, R >::Case(), llvm::StringSwitch< T, R >::Default(), llvm::Value::getName(), llvm::Value::getType(), IC_Autorelease, IC_AutoreleasepoolPop, IC_AutoreleasepoolPush, IC_AutoreleaseRV, IC_CallOrUser, IC_CopyWeak, IC_DestroyWeak, IC_FusedRetainAutorelease, IC_FusedRetainAutoreleaseRV, IC_InitWeak, IC_IntrinsicUser, IC_LoadWeak, IC_LoadWeakRetained, IC_MoveWeak, IC_None, IC_NoopCast, IC_Release, IC_Retain, IC_RetainBlock, IC_RetainRV, IC_StoreStrong, IC_StoreWeak, IC_User, and llvm::Type::isIntegerTy().
Referenced by GetBasicInstructionClass(), and GetInstructionClass().
Determine what kind of construct V is.
Definition at line 167 of file ObjCARCUtil.cpp.
References llvm::Alloca, llvm::APIntOps::And(), llvm::Call, llvm::tgtok::Class, ExtractElement(), llvm::ExtractValue, F(), llvm::FCmp, llvm::FPExt, llvm::FPToSI, llvm::CallInst::getCalledFunction(), GetCallSiteClass(), GetFunctionClass(), I, IC_CallOrUser, IC_None, IC_User, llvm::InsertElement, llvm::IntToPtr, IsPotentialRetainableObjPtr(), llvm::LShr, llvm::APIntOps::Or(), llvm::TargetOpcode::PHI, llvm::MipsISD::Ret, llvm::MCID::Select, llvm::SExt, llvm::SIToFP, llvm::Trunc, llvm::VAArg, and llvm::APIntOps::Xor().
Referenced by Depends().
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] |
Definition at line 328 of file lib/Transforms/ObjCARC/ObjCARC.h.
References IsPotentialRetainableObjPtr(), LI, and llvm::AliasAnalysis::pointsToConstantMemory().
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 | ||
) |
Definition at line 28 of file ObjCARCUtil.cpp.
References IC_Autorelease, IC_AutoreleasepoolPop, IC_AutoreleasepoolPush, IC_AutoreleaseRV, IC_Call, IC_CallOrUser, IC_CopyWeak, IC_DestroyWeak, IC_FusedRetainAutorelease, IC_FusedRetainAutoreleaseRV, IC_InitWeak, IC_IntrinsicUser, IC_LoadWeak, IC_LoadWeakRetained, IC_MoveWeak, IC_None, IC_NoopCast, IC_Release, IC_Retain, IC_RetainBlock, IC_RetainRV, IC_StoreStrong, IC_StoreWeak, IC_User, and llvm_unreachable.
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().
A handy option to enable/disable all ARC Optimizations.
Definition at line 30 of file ObjCARC.cpp.