1263508Sdim//===- DependencyAnalysis.h - ObjC ARC Optimization ---*- C++ -*-----------===// 2249259Sdim// 3249259Sdim// The LLVM Compiler Infrastructure 4249259Sdim// 5249259Sdim// This file is distributed under the University of Illinois Open Source 6249259Sdim// License. See LICENSE.TXT for details. 7249259Sdim// 8249259Sdim//===----------------------------------------------------------------------===// 9249259Sdim/// \file 10249259Sdim/// 11249259Sdim/// This file declares special dependency analysis routines used in Objective C 12249259Sdim/// ARC Optimizations. 13249259Sdim/// 14249259Sdim/// WARNING: This file knows about certain library functions. It recognizes them 15249259Sdim/// by name, and hardwires knowledge of their semantics. 16249259Sdim/// 17249259Sdim/// WARNING: This file knows about how certain Objective-C library functions are 18249259Sdim/// used. Naive LLVM IR transformations which would otherwise be 19249259Sdim/// behavior-preserving may break these assumptions. 20249259Sdim/// 21249259Sdim//===----------------------------------------------------------------------===// 22249259Sdim 23249259Sdim#ifndef LLVM_TRANSFORMS_OBJCARC_DEPEDENCYANALYSIS_H 24249259Sdim#define LLVM_TRANSFORMS_OBJCARC_DEPEDENCYANALYSIS_H 25249259Sdim 26249259Sdim#include "llvm/ADT/SmallPtrSet.h" 27249259Sdim 28249259Sdimnamespace llvm { 29249259Sdim class BasicBlock; 30249259Sdim class Instruction; 31249259Sdim class Value; 32249259Sdim} 33249259Sdim 34249259Sdimnamespace llvm { 35249259Sdimnamespace objcarc { 36249259Sdim 37249259Sdimclass ProvenanceAnalysis; 38249259Sdim 39249259Sdim/// \enum DependenceKind 40249259Sdim/// \brief Defines different dependence kinds among various ARC constructs. 41249259Sdim/// 42249259Sdim/// There are several kinds of dependence-like concepts in use here. 43249259Sdim/// 44249259Sdimenum DependenceKind { 45249259Sdim NeedsPositiveRetainCount, 46249259Sdim AutoreleasePoolBoundary, 47249259Sdim CanChangeRetainCount, 48249259Sdim RetainAutoreleaseDep, ///< Blocks objc_retainAutorelease. 49249259Sdim RetainAutoreleaseRVDep, ///< Blocks objc_retainAutoreleaseReturnValue. 50249259Sdim RetainRVDep ///< Blocks objc_retainAutoreleasedReturnValue. 51249259Sdim}; 52249259Sdim 53249259Sdimvoid FindDependencies(DependenceKind Flavor, 54249259Sdim const Value *Arg, 55249259Sdim BasicBlock *StartBB, Instruction *StartInst, 56249259Sdim SmallPtrSet<Instruction *, 4> &DependingInstructions, 57249259Sdim SmallPtrSet<const BasicBlock *, 4> &Visited, 58249259Sdim ProvenanceAnalysis &PA); 59249259Sdim 60249259Sdimbool 61249259SdimDepends(DependenceKind Flavor, Instruction *Inst, const Value *Arg, 62249259Sdim ProvenanceAnalysis &PA); 63249259Sdim 64249259Sdim/// Test whether the given instruction can "use" the given pointer's object in a 65249259Sdim/// way that requires the reference count to be positive. 66249259Sdimbool 67249259SdimCanUse(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, 68249259Sdim InstructionClass Class); 69249259Sdim 70249259Sdim/// Test whether the given instruction can result in a reference count 71249259Sdim/// modification (positive or negative) for the pointer's object. 72249259Sdimbool 73249259SdimCanAlterRefCount(const Instruction *Inst, const Value *Ptr, 74249259Sdim ProvenanceAnalysis &PA, InstructionClass Class); 75249259Sdim 76249259Sdim} // namespace objcarc 77249259Sdim} // namespace llvm 78249259Sdim 79249259Sdim#endif // LLVM_TRANSFORMS_OBJCARC_DEPEDENCYANALYSIS_H 80