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) {
112 }
else if (
const StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
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.
Value * GetArgRCIdentityRoot(Value *Inst)
Assuming the given instruction is one of the special calls such as objc_retain or objc_release...
bool onlyReadsMemory(ImmutableCallSite CS)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
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
A Use represents the edge between a Value definition and its users.
LLVM_NODISCARD bool empty() const
objc_retainAutoreleasedReturnValue
bool IsPotentialRetainableObjPtr(const Value *Op)
Test whether the given value is possible a retainable object pointer.
FunctionModRefBehavior
Summary of how a function affects memory in the program.
An instruction for storing to memory.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
Return the behavior of the given call site.
This instruction compares its operands according to the predicate given to the constructor.
self_iterator getIterator()
anything that is inert from an ARC perspective.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ARCInstKind GetBasicARCInstKind(const Value *V)
Determine which objc runtime call instruction class V belongs to.
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.
Iterator for intrusive lists based on ilist_node.
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.
LLVM_NODISCARD T pop_back_val()
bool related(const Value *A, const Value *B, const DataLayout &DL)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from objects poin...
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...
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
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.