1 //===- DependencyAnalysis.h - ObjC ARC Optimization ---*- mode: c++ -*-----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file declares special dependency analysis routines used in Objective C
12 /// ARC Optimizations.
14 /// WARNING: This file knows about certain library functions. It recognizes them
15 /// by name, and hardwires knowledge of their semantics.
17 /// WARNING: This file knows about how certain Objective-C library functions are
18 /// used. Naive LLVM IR transformations which would otherwise be
19 /// behavior-preserving may break these assumptions.
21 //===----------------------------------------------------------------------===//
23 #ifndef LLVM_TRANSFORMS_OBJCARC_DEPEDENCYANALYSIS_H
24 #define LLVM_TRANSFORMS_OBJCARC_DEPEDENCYANALYSIS_H
26 #include "llvm/ADT/SmallPtrSet.h"
37 class ProvenanceAnalysis;
39 /// \enum DependenceKind
40 /// \brief Defines different dependence kinds among various ARC constructs.
42 /// There are several kinds of dependence-like concepts in use here.
45 NeedsPositiveRetainCount,
46 AutoreleasePoolBoundary,
48 RetainAutoreleaseDep, ///< Blocks objc_retainAutorelease.
49 RetainAutoreleaseRVDep, ///< Blocks objc_retainAutoreleaseReturnValue.
50 RetainRVDep ///< Blocks objc_retainAutoreleasedReturnValue.
53 void FindDependencies(DependenceKind Flavor,
55 BasicBlock *StartBB, Instruction *StartInst,
56 SmallPtrSet<Instruction *, 4> &DependingInstructions,
57 SmallPtrSet<const BasicBlock *, 4> &Visited,
58 ProvenanceAnalysis &PA);
61 Depends(DependenceKind Flavor, Instruction *Inst, const Value *Arg,
62 ProvenanceAnalysis &PA);
64 /// Test whether the given instruction can "use" the given pointer's object in a
65 /// way that requires the reference count to be positive.
67 CanUse(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA,
68 InstructionClass Class);
70 /// Test whether the given instruction can result in a reference count
71 /// modification (positive or negative) for the pointer's object.
73 CanAlterRefCount(const Instruction *Inst, const Value *Ptr,
74 ProvenanceAnalysis &PA, InstructionClass Class);
76 } // namespace objcarc
79 #endif // LLVM_TRANSFORMS_OBJCARC_DEPEDENCYANALYSIS_H