LLVM  8.0.1
DependencyAnalysis.h
Go to the documentation of this file.
1 //===- DependencyAnalysis.h - ObjC ARC Optimization ---*- C++ -*-----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// This file declares special dependency analysis routines used in Objective C
12 /// ARC Optimizations.
13 ///
14 /// WARNING: This file knows about certain library functions. It recognizes them
15 /// by name, and hardwires knowledge of their semantics.
16 ///
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.
20 ///
21 //===----------------------------------------------------------------------===//
22 
23 #ifndef LLVM_LIB_TRANSFORMS_OBJCARC_DEPENDENCYANALYSIS_H
24 #define LLVM_LIB_TRANSFORMS_OBJCARC_DEPENDENCYANALYSIS_H
25 
26 #include "llvm/ADT/SmallPtrSet.h"
28 
29 namespace llvm {
30  class BasicBlock;
31  class Instruction;
32  class Value;
33 }
34 
35 namespace llvm {
36 namespace objcarc {
37 
38 class ProvenanceAnalysis;
39 
40 /// \enum DependenceKind
41 /// Defines different dependence kinds among various ARC constructs.
42 ///
43 /// There are several kinds of dependence-like concepts in use here.
44 ///
49  RetainAutoreleaseDep, ///< Blocks objc_retainAutorelease.
50  RetainAutoreleaseRVDep, ///< Blocks objc_retainAutoreleaseReturnValue.
51  RetainRVDep ///< Blocks objc_retainAutoreleasedReturnValue.
52 };
53 
55  const Value *Arg,
56  BasicBlock *StartBB, Instruction *StartInst,
57  SmallPtrSetImpl<Instruction *> &DependingInstructions,
59  ProvenanceAnalysis &PA);
60 
61 bool
62 Depends(DependenceKind Flavor, Instruction *Inst, const Value *Arg,
63  ProvenanceAnalysis &PA);
64 
65 /// Test whether the given instruction can "use" the given pointer's object in a
66 /// way that requires the reference count to be positive.
67 bool CanUse(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA,
69 
70 /// Test whether the given instruction can result in a reference count
71 /// modification (positive or negative) for the pointer's object.
72 bool CanAlterRefCount(const Instruction *Inst, const Value *Ptr,
74 
75 /// Returns true if we can not conservatively prove that Inst can not decrement
76 /// the reference count of Ptr. Returns false if we can.
77 bool CanDecrementRefCount(const Instruction *Inst, const Value *Ptr,
79 
80 static inline bool CanDecrementRefCount(const Instruction *Inst,
81  const Value *Ptr,
82  ProvenanceAnalysis &PA) {
83  return CanDecrementRefCount(Inst, Ptr, PA, GetARCInstKind(Inst));
84 }
85 
86 } // namespace objcarc
87 } // namespace llvm
88 
89 #endif
ARCInstKind GetARCInstKind(const Value *V)
Map V to its ARCInstKind equivalence class.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
bool CanUse(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class)
Test whether the given instruction can "use" the given pointer&#39;s object in a way that requires the re...
Blocks objc_retainAutorelease.
bool Depends(DependenceKind Flavor, Instruction *Inst, const Value *Arg, ProvenanceAnalysis &PA)
Test if there can be dependencies on Inst through Arg.
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
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.
ARCInstKind
Equivalence classes of instructions in the ARC Model.
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...
amdgpu Simplify well known AMD library false Value Value * Arg
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.
Definition: Value.h:73
This is similar to BasicAliasAnalysis, and it uses many of the same techniques, except it uses specia...
Blocks objc_retainAutoreleasedReturnValue.