LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Enumerations | Functions | Variables
ObjCARCOpts.cpp File Reference
#include "ObjCARC.h"
#include "ARCRuntimeEntryPoints.h"
#include "DependencyAnalysis.h"
#include "ObjCARCAliasAnalysis.h"
#include "ProvenanceAnalysis.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/CommandLine.h"
Include dependency graph for ObjCARCOpts.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "objc-arc-opts"
 
#define ARC_ANNOTATIONS
 
#define ANNOTATE_BOTTOMUP(inst, ptr, old, new)
 
#define ANNOTATE_TOPDOWN(inst, ptr, old, new)
 
#define ANNOTATE_BB(_states, _bb, _name, _type, _direction)
 
#define ANNOTATE_BOTTOMUP_BBSTART(_states, _basicblock)
 
#define ANNOTATE_BOTTOMUP_BBEND(_states, _basicblock)
 
#define ANNOTATE_TOPDOWN_BBSTART(_states, _basicblock)
 
#define ANNOTATE_TOPDOWN_BBEND(_states, _basicblock)
 

Enumerations

enum  Sequence
 A sequence of states that a pointer may go through in which an objc_retain and objc_release are actually needed. More...
 

Functions

static const ValueFindSingleUseIdentifiedObject (const Value *Arg)
 This is similar to StripPointerCastsAndObjCCalls but it stops as soon as it finds a value with multiple uses. More...
 
static bool AreAnyUnderlyingObjectsAnAlloca (const Value *V)
 
 STATISTIC (NumNoops,"Number of no-op objc calls eliminated")
 
 STATISTIC (NumPartialNoops,"Number of partially no-op objc calls eliminated")
 
 STATISTIC (NumAutoreleases,"Number of autoreleases converted to releases")
 
 STATISTIC (NumRets,"Number of return value forwarding ""retain+autoreleases eliminated")
 
 STATISTIC (NumRRs,"Number of retain+release paths eliminated")
 
 STATISTIC (NumPeeps,"Number of calls peephole-optimized")
 
 STATISTIC (NumRetainsBeforeOpt,"Number of retains before optimization")
 
 STATISTIC (NumReleasesBeforeOpt,"Number of releases before optimization")
 
 STATISTIC (NumRetainsAfterOpt,"Number of retains after optimization")
 
 STATISTIC (NumReleasesAfterOpt,"Number of releases after optimization")
 
static Sequence MergeSeqs (Sequence A, Sequence B, bool TopDown)
 
static MDStringAppendMDNodeToSourcePtr (unsigned NodeId, Value *Ptr)
 
static std::string SequenceToString (Sequence A)
 
static MDStringSequenceToMDString (LLVMContext &Context, Sequence A)
 
static void AppendMDNodeToInstForPtr (unsigned NodeId, Instruction *Inst, Value *Ptr, MDString *PtrSourceMDNodeID, Sequence OldSeq, Sequence NewSeq)
 
static void GenerateARCBBEntranceAnnotation (const char *Name, BasicBlock *BB, Value *Ptr, Sequence Seq)
 
static void GenerateARCBBTerminatorAnnotation (const char *Name, BasicBlock *BB, Value *Ptr, Sequence Seq)
 
static void GenerateARCAnnotation (unsigned InstMDId, unsigned PtrMDId, Instruction *Inst, Value *Ptr, Sequence OldSeq, Sequence NewSeq)
 
 INITIALIZE_PASS_BEGIN (ObjCARCOpt,"objc-arc","ObjC ARC optimization", false, false) INITIALIZE_PASS_END(ObjCARCOpt
 
static void CheckForUseCFGHazard (const Sequence SuccSSeq, const bool SuccSRRIKnownSafe, PtrState &S, bool &SomeSuccHasSame, bool &AllSuccsHaveSame, bool &NotAllSeqEqualButKnownSafe, bool &ShouldContinue)
 
static void CheckForCanReleaseCFGHazard (const Sequence SuccSSeq, const bool SuccSRRIKnownSafe, PtrState &S, bool &SomeSuccHasSame, bool &AllSuccsHaveSame, bool &NotAllSeqEqualButKnownSafe)
 
static void ComputePostOrders (Function &F, SmallVectorImpl< BasicBlock * > &PostOrder, SmallVectorImpl< BasicBlock * > &ReverseCFGPostOrder, unsigned NoObjCARCExceptionsMDKind, DenseMap< const BasicBlock *, BBState > &BBStates)
 
static bool HasSafePathToPredecessorCall (const Value *Arg, Instruction *Retain, SmallPtrSet< Instruction *, 4 > &DepInsts, SmallPtrSet< const BasicBlock *, 4 > &Visited, ProvenanceAnalysis &PA)
 
static CallInstFindPredecessorRetainWithSafePath (const Value *Arg, BasicBlock *BB, Instruction *Autorelease, SmallPtrSet< Instruction *, 4 > &DepInsts, SmallPtrSet< const BasicBlock *, 4 > &Visited, ProvenanceAnalysis &PA)
 
static CallInstFindPredecessorAutoreleaseWithSafePath (const Value *Arg, BasicBlock *BB, ReturnInst *Ret, SmallPtrSet< Instruction *, 4 > &DepInsts, SmallPtrSet< const BasicBlock *, 4 > &V, ProvenanceAnalysis &PA)
 

Variables

static cl::opt< boolEnableARCAnnotations ("enable-objc-arc-annotations", cl::init(false), cl::desc("Enable emission of arc data flow analysis ""annotations"))
 Enable/disable ARC sequence annotations. More...
 
static cl::opt< boolDisableCheckForCFGHazards ("disable-objc-arc-checkforcfghazards", cl::init(false), cl::desc("Disable check for cfg hazards when ""annotating"))
 
static cl::opt< std::string > ARCAnnotationTargetIdentifier ("objc-arc-annotation-target-identifier", cl::init(""), cl::desc("filter out all data flow annotations ""but those that apply to the given ""target llvm identifier."))
 
objc arc
 
objc ObjC ARC optimization
 
objc ObjC ARC false
 

Detailed Description

This file defines ObjC ARC optimizations. ARC stands for Automatic Reference Counting and is a system for managing reference counts for objects in Objective C.

The optimizations performed include elimination of redundant, partially redundant, and inconsequential reference count operations, elimination of redundant weak pointer operations, and numerous minor simplifications.

WARNING: This file knows about certain library functions. It recognizes them by name, and hardwires knowledge of their semantics.

WARNING: This file knows about how certain Objective-C library functions are used. Naive LLVM IR transformations which would otherwise be behavior-preserving may break these assumptions.

Definition in file ObjCARCOpts.cpp.

Macro Definition Documentation

#define DEBUG_TYPE   "objc-arc-opts"

Definition at line 27 of file ObjCARCOpts.cpp.

Enumeration Type Documentation

enum Sequence

A sequence of states that a pointer may go through in which an objc_retain and objc_release are actually needed.

Definition at line 279 of file ObjCARCOpts.cpp.