29 using namespace llvm::objcarc;
31 #define DEBUG_TYPE "objc-arc-dependency"
49 assert(CS &&
"Only calls can alter reference counts!");
96 if (
const ICmpInst *ICI = dyn_cast<ICmpInst>(Inst)) {
105 OE =
CS.arg_end(); OI != OE; ++OI) {
106 const Value *Op = *OI;
112 }
else if (
const StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
125 const Value *Op = *OI;
150 return CanUse(Inst, Arg, PA, Class);
232 Worklist.
push_back(std::make_pair(StartBB, StartPos));
234 std::pair<BasicBlock *, BasicBlock::iterator> Pair =
240 if (LocalStartPos == StartBBBegin) {
244 DependingInsts.
insert(
nullptr);
249 if (Visited.
insert(PredBB).second)
250 Worklist.
push_back(std::make_pair(PredBB, PredBB->
end()));
251 }
while (++PI != PE);
256 if (
Depends(Flavor, Inst, Arg, PA)) {
257 DependingInsts.
insert(Inst);
261 }
while (!Worklist.
empty());
272 if (Succ != StartBB && !Visited.count(Succ)) {
273 DependingInsts.
insert(reinterpret_cast<Instruction *>(-1));
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
This file declares special dependency analysis routines used in Objective C ARC Optimizations.
ARCInstKind GetARCInstKind(const Value *V)
Map V to its ARCInstKind equivalence class.
bool CanUse(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class)
Test whether the given instruction can "use" the given pointer's object in a way that requires the ...
Blocks objc_retainAutorelease.
ModRefBehavior
ModRefBehavior - Summary of how a function affects memory in the program.
static ARCInstKind GetBasicARCInstKind(const Value *V)
Determine which objc runtime call instruction class V belongs to.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
iterator begin()
Instruction iterator methods.
objc_autoreleaseReturnValue
bool Depends(DependenceKind Flavor, Instruction *Inst, const Value *Arg, ProvenanceAnalysis &PA)
Test if there can be dependencies on Inst through Arg.
AliasAnalysis * getAA() const
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
A Use represents the edge between a Value definition and its users.
objc_retainAutoreleasedReturnValue
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
StoreInst - an instruction for storing to memory.
bool onlyReadsMemory(ImmutableCallSite CS)
onlyReadsMemory - If the specified call is known to only read from non-volatile memory (or not access...
Subclasses of this class are all able to terminate a basic block.
LLVM Basic Block Representation.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
This instruction compares its operands according to the predicate given to the constructor.
static const Value * GetUnderlyingObjCPtr(const Value *V, const DataLayout &DL)
This is a wrapper around getUnderlyingObject which also knows how to look through objc_retain and obj...
anything that is inert from an ARC perspective.
virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS)
getModRefBehavior - Return the behavior when calling the given call site.
bool CanDecrementRefCount(ARCInstKind Kind)
Returns false if conservatively we can prove that any instruction mapped to this kind can not decreme...
DependenceKind
Defines different dependence kinds among various ARC constructs.
static Value * GetArgRCIdentityRoot(Value *Inst)
Assuming the given instruction is one of the special calls such as objc_retain or objc_release...
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
This file declares a special form of Alias Analysis called ``Provenance Analysis''.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
ARCInstKind
Equivalence classes of instructions in the ARC Model.
bool related(const Value *A, const Value *B, const DataLayout &DL)
static bool IsPotentialRetainableObjPtr(const Value *Op)
Test whether the given value is possible a retainable object pointer.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
static bool onlyAccessesArgPointees(ModRefBehavior MRB)
onlyAccessesArgPointees - Return true if functions with the specified behavior are known to read and ...
ImmutableCallSite - establish a view to a call site for examination.
Blocks objc_retainAutoreleaseReturnValue.
bool CanAlterRefCount(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class)
Test whether the given instruction can result in a reference count modification (positive or negative...
LLVM Value Representation.
IterTy arg_begin() const
arg_begin/arg_end - Return iterators corresponding to the actual argument list for a call site...
This is similar to BasicAliasAnalysis, and it uses many of the same techniques, except it uses specia...
bool CanInterruptRV(ARCInstKind Class)
Test whether the given instruction can autorelease any pointer or cause an autoreleasepool pop...
void FindDependencies(DependenceKind Flavor, const Value *Arg, BasicBlock *StartBB, Instruction *StartInst, SmallPtrSetImpl< Instruction * > &DependingInstructions, 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...
Blocks objc_retainAutoreleasedReturnValue.