LLVM 19.0.0git
Namespaces | Functions | Variables
ARC Optimization.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Functions

 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 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 CallInstHasSafePathToPredecessorCall (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 CallInstFindPredecessorRetainWithSafePath (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 CallInstFindPredecessorAutoreleaseWithSafePath (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.
 
raw_ostreamllvm::operator<< (raw_ostream &OS, BBState &BBState) LLVM_ATTRIBUTE_UNUSED
 

Variables

static const unsigned BBState::OverflowOccurredValue = 0xffffffff
 

Detailed Description

Function Documentation

◆ CheckForCanReleaseCFGHazard()

static void CheckForCanReleaseCFGHazard ( const Sequence  SuccSSeq,
const bool  SuccSRRIKnownSafe,
TopDownPtrState S,
bool SomeSuccHasSame,
bool AllSuccsHaveSame,
bool NotAllSeqEqualButKnownSafe 
)
static

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.

Definition at line 1210 of file ObjCARCOpts.cpp.

References llvm::objcarc::PtrState::IsKnownSafe(), llvm_unreachable, llvm::objcarc::S_CanRelease, llvm::objcarc::S_MovableRelease, llvm::objcarc::S_None, llvm::objcarc::S_Retain, llvm::objcarc::S_Stop, and llvm::objcarc::S_Use.

◆ CheckForUseCFGHazard()

static void CheckForUseCFGHazard ( const Sequence  SuccSSeq,
const bool  SuccSRRIKnownSafe,
TopDownPtrState S,
bool SomeSuccHasSame,
bool AllSuccsHaveSame,
bool NotAllSeqEqualButKnownSafe,
bool ShouldContinue 
)
static

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.

Definition at line 1173 of file ObjCARCOpts.cpp.

References llvm::objcarc::PtrState::ClearSequenceProgress(), llvm::objcarc::PtrState::IsKnownSafe(), llvm_unreachable, llvm::objcarc::S_CanRelease, llvm::objcarc::S_MovableRelease, llvm::objcarc::S_None, llvm::objcarc::S_Retain, llvm::objcarc::S_Stop, llvm::objcarc::S_Use, and llvm::objcarc::PtrState::SetCFGHazardAfflicted().

◆ collectReleaseInsertPts()

static void collectReleaseInsertPts ( const BlotMapVector< Value *, RRInfo > &  Retains,
DenseMap< const Instruction *, SmallPtrSet< const Value *, 2 > > &  ReleaseInsertPtToRCIdentityRoots 
)
static

Definition at line 1463 of file ObjCARCOpts.cpp.

References llvm::objcarc::GetRCIdentityRoot(), P, and llvm::objcarc::Retain.

◆ ComputePostOrders()

static void ComputePostOrders ( Function F,
SmallVectorImpl< BasicBlock * > &  PostOrder,
SmallVectorImpl< BasicBlock * > &  ReverseCFGPostOrder,
unsigned  NoObjCARCExceptionsMDKind,
DenseMap< const BasicBlock *, BBState > &  BBStates 
)
static

◆ FindPredecessorAutoreleaseWithSafePath()

static CallInst * FindPredecessorAutoreleaseWithSafePath ( const Value Arg,
BasicBlock BB,
ReturnInst Ret,
ProvenanceAnalysis PA 
)
static

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.

Definition at line 2314 of file ObjCARCOpts.cpp.

References llvm::objcarc::Autorelease, llvm::objcarc::findSingleDependency(), llvm::objcarc::GetArgRCIdentityRoot(), llvm::objcarc::GetBasicARCInstKind(), llvm::objcarc::IsAutorelease(), and llvm::objcarc::NeedsPositiveRetainCount.

◆ FindPredecessorRetainWithSafePath()

static CallInst * FindPredecessorRetainWithSafePath ( const Value Arg,
BasicBlock BB,
Instruction Autorelease,
ProvenanceAnalysis PA 
)
static

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.

Definition at line 2295 of file ObjCARCOpts.cpp.

References llvm::objcarc::Autorelease, llvm::objcarc::CanChangeRetainCount, llvm::objcarc::findSingleDependency(), llvm::objcarc::GetArgRCIdentityRoot(), llvm::objcarc::GetBasicARCInstKind(), llvm::objcarc::IsRetain(), and llvm::objcarc::Retain.

◆ getRCIdentityRootsFromReleaseInsertPt()

static const SmallPtrSet< const Value *, 2 > * getRCIdentityRootsFromReleaseInsertPt ( const Instruction InsertPt,
const DenseMap< const Instruction *, SmallPtrSet< const Value *, 2 > > &  ReleaseInsertPtToRCIdentityRoots 
)
static

Definition at line 1482 of file ObjCARCOpts.cpp.

References I.

◆ HasSafePathToPredecessorCall()

static CallInst * HasSafePathToPredecessorCall ( const Value Arg,
Instruction Retain,
ProvenanceAnalysis PA 
)
static

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.

Note that Retain need not be in BB.

Definition at line 2274 of file ObjCARCOpts.cpp.

References llvm::objcarc::Call, llvm::objcarc::CanChangeRetainCount, llvm::objcarc::findSingleDependency(), llvm::objcarc::GetBasicARCInstKind(), and llvm::objcarc::Retain.

◆ isInertARCValue()

static bool isInertARCValue ( Value V,
SmallPtrSet< Value *, 1 > &  VisitedPhis 
)
static

This function returns true if the value is inert.

An ObjC ARC runtime call taking an inert operand can be safely deleted.

Definition at line 861 of file ObjCARCOpts.cpp.

References llvm::PHINode::incoming_values(), llvm::SmallPtrSetImpl< PtrType >::insert(), isInertARCValue(), and llvm::objcarc::IsNullOrUndef().

Referenced by isInertARCValue().

◆ operator<<()

raw_ostream & llvm::operator<< ( raw_ostream OS,
BBState &  BBState 
)

Definition at line 434 of file ObjCARCOpts.cpp.

References llvm::dbgs(), E, I, LLVM_DEBUG, OS, and P.

◆ STATISTIC() [1/10]

STATISTIC ( NumAutoreleases  ,
"Number of autoreleases converted to releases"   
)

◆ STATISTIC() [2/10]

STATISTIC ( NumNoops  ,
"Number of no-op objc calls eliminated"   
)

◆ STATISTIC() [3/10]

STATISTIC ( NumPartialNoops  ,
"Number of partially no-op objc calls eliminated"   
)

◆ STATISTIC() [4/10]

STATISTIC ( NumPeeps  ,
"Number of calls peephole-optimized"   
)

◆ STATISTIC() [5/10]

STATISTIC ( NumReleasesAfterOpt  ,
"Number of releases after optimization"   
)

◆ STATISTIC() [6/10]

STATISTIC ( NumReleasesBeforeOpt  ,
"Number of releases before optimization"   
)

◆ STATISTIC() [7/10]

STATISTIC ( NumRetainsAfterOpt  ,
"Number of retains after optimization"   
)

◆ STATISTIC() [8/10]

STATISTIC ( NumRetainsBeforeOpt  ,
"Number of retains before optimization"   
)

◆ STATISTIC() [9/10]

STATISTIC ( NumRets  ,
"Number of return value forwarding " "retain+autoreleases eliminated"   
)

◆ STATISTIC() [10/10]

STATISTIC ( NumRRs  ,
"Number of retain+release paths eliminated"   
)

Variable Documentation

◆ OverflowOccurredValue

const unsigned BBState::OverflowOccurredValue = 0xffffffff
static

Definition at line 208 of file ObjCARCOpts.cpp.