LLVM  6.0.0svn
Namespaces | Macros | Functions | Variables
ObjCARCOpts.cpp File Reference

This file defines ObjC ARC optimizations. More...

#include "ARCRuntimeEntryPoints.h"
#include "BlotMapVector.h"
#include "DependencyAnalysis.h"
#include "ObjCARC.h"
#include "ProvenanceAnalysis.h"
#include "PtrState.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/ObjCARCAliasAnalysis.h"
#include "llvm/Analysis/ObjCARCAnalysisUtils.h"
#include "llvm/Analysis/ObjCARCInstKind.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <iterator>
#include <utility>
Include dependency graph for ObjCARCOpts.cpp:

Go to the source code of this file.

Namespaces

 llvm
 Compute iterated dominance frontiers using a linear time algorithm.
 

Macros

#define DEBUG_TYPE   "objc-arc-opts"
 

Functions

static const ValueFindSingleUseIdentifiedObject (const Value *Arg)
 This is similar to GetRCIdentityRoot but it stops as soon as it finds a value with multiple uses. More...
 
 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")
 
raw_ostreamllvm::operator<< (raw_ostream &OS, BBState &BBState) LLVM_ATTRIBUTE_UNUSED
 
 INITIALIZE_PASS_BEGIN (ObjCARCOpt, "objc-arc", "ObjC ARC optimization", false, false) INITIALIZE_PASS_END(ObjCARCOpt
 
static void CheckForUseCFGHazard (const Sequence SuccSSeq, const bool SuccSRRIKnownSafe, TopDownPtrState &S, bool &SomeSuccHasSame, bool &AllSuccsHaveSame, bool &NotAllSeqEqualButKnownSafe, bool &ShouldContinue)
 If we have a top down pointer in the S_Use state, make sure that there are no CFG hazards by checking the states of various bottom up pointers. More...
 
static void CheckForCanReleaseCFGHazard (const Sequence SuccSSeq, const bool SuccSRRIKnownSafe, TopDownPtrState &S, bool &SomeSuccHasSame, bool &AllSuccsHaveSame, bool &NotAllSeqEqualButKnownSafe)
 If we have a Top Down pointer in the S_CanRelease state, make sure that there are no CFG hazards by checking the states of various bottom up pointers. More...
 
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, SmallPtrSetImpl< Instruction *> &DepInsts, SmallPtrSetImpl< const BasicBlock *> &Visited, ProvenanceAnalysis &PA)
 Check if there is a dependent call earlier that does not have anything in between the Retain and the call that can affect the reference count of their shared pointer argument. More...
 
static CallInstFindPredecessorRetainWithSafePath (const Value *Arg, BasicBlock *BB, Instruction *Autorelease, SmallPtrSetImpl< Instruction *> &DepInsts, SmallPtrSetImpl< const BasicBlock *> &Visited, ProvenanceAnalysis &PA)
 Find a dependent retain that precedes the given autorelease for which there is nothing in between the two instructions that can affect the ref count of Arg. More...
 
static CallInstFindPredecessorAutoreleaseWithSafePath (const Value *Arg, BasicBlock *BB, ReturnInst *Ret, SmallPtrSetImpl< Instruction *> &DepInsts, SmallPtrSetImpl< const BasicBlock *> &V, ProvenanceAnalysis &PA)
 Look for an ``autorelease'' instruction dependent on Arg such that there are no instructions dependent on Arg that need a positive ref count in between the autorelease and the ret. More...
 

Variables

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

◆ DEBUG_TYPE

#define DEBUG_TYPE   "objc-arc-opts"

Definition at line 74 of file ObjCARCOpts.cpp.