LLVM 20.0.0git
|
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/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/Analysis/ObjCARCUtil.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/EHPersonalities.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/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/ObjCARC.h"
#include <cassert>
#include <iterator>
#include <utility>
Go to the source code of this file.
Namespaces | |
namespace | llvm |
This is an optimization pass for GlobalISel generic memory operations. | |
Macros | |
#define | DEBUG_TYPE "objc-arc-opts" |
Functions | |
static const Value * | FindSingleUseIdentifiedObject (const Value *Arg) |
This is similar to GetRCIdentityRoot but it stops as soon as it finds a value with multiple uses. | |
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_ostream & | llvm::operator<< (raw_ostream &OS, BBState &BBState) LLVM_ATTRIBUTE_UNUSED |
static bool | isInertARCValue (Value *V, SmallPtrSet< Value *, 1 > &VisitedPhis) |
This function returns true if the value is inert. | |
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. | |
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. | |
static void | collectReleaseInsertPts (const BlotMapVector< Value *, RRInfo > &Retains, DenseMap< const Instruction *, SmallPtrSet< const Value *, 2 > > &ReleaseInsertPtToRCIdentityRoots) |
static const SmallPtrSet< const Value *, 2 > * | getRCIdentityRootsFromReleaseInsertPt (const Instruction *InsertPt, const DenseMap< const Instruction *, SmallPtrSet< const Value *, 2 > > &ReleaseInsertPtToRCIdentityRoots) |
static void | ComputePostOrders (Function &F, SmallVectorImpl< BasicBlock * > &PostOrder, SmallVectorImpl< BasicBlock * > &ReverseCFGPostOrder, unsigned NoObjCARCExceptionsMDKind, DenseMap< const BasicBlock *, BBState > &BBStates) |
static CallInst * | HasSafePathToPredecessorCall (const Value *Arg, Instruction *Retain, 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. | |
static CallInst * | FindPredecessorRetainWithSafePath (const Value *Arg, BasicBlock *BB, Instruction *Autorelease, 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. | |
static CallInst * | FindPredecessorAutoreleaseWithSafePath (const Value *Arg, BasicBlock *BB, ReturnInst *Ret, 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. | |
Variables | |
static cl::opt< unsigned > | MaxPtrStates ("arc-opt-max-ptr-states", cl::Hidden, cl::desc("Maximum number of ptr states the optimizer keeps track of"), cl::init(4095)) |
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.
#define DEBUG_TYPE "objc-arc-opts" |
Definition at line 74 of file ObjCARCOpts.cpp.