1 //===- ProvenanceAnalysis.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 a special form of Alias Analysis called ``Provenance
12 /// Analysis''. The word ``provenance'' refers to the history of the ownership
13 /// of an object. Thus ``Provenance Analysis'' is an analysis which attempts to
14 /// use various techniques to determine if locally
16 /// WARNING: This file knows about certain library functions. It recognizes them
17 /// by name, and hardwires knowledge of their semantics.
19 /// WARNING: This file knows about how certain Objective-C library functions are
20 /// used. Naive LLVM IR transformations which would otherwise be
21 /// behavior-preserving may break these assumptions.
23 //===----------------------------------------------------------------------===//
25 #ifndef LLVM_TRANSFORMS_OBJCARC_PROVENANCEANALYSIS_H
26 #define LLVM_TRANSFORMS_OBJCARC_PROVENANCEANALYSIS_H
28 #include "llvm/ADT/DenseMap.h"
39 /// \brief This is similar to BasicAliasAnalysis, and it uses many of the same
40 /// techniques, except it uses special ObjC-specific reasoning about pointer
43 /// In this context ``Provenance'' is defined as the history of an object's
44 /// ownership. Thus ``Provenance Analysis'' is defined by using the notion of
45 /// an ``independent provenance source'' of a pointer to determine whether or
46 /// not two pointers have the same provenance source and thus could
47 /// potentially be related.
48 class ProvenanceAnalysis {
51 typedef std::pair<const Value *, const Value *> ValuePairTy;
52 typedef DenseMap<ValuePairTy, bool> CachedResultsTy;
53 CachedResultsTy CachedResults;
55 bool relatedCheck(const Value *A, const Value *B);
56 bool relatedSelect(const SelectInst *A, const Value *B);
57 bool relatedPHI(const PHINode *A, const Value *B);
59 void operator=(const ProvenanceAnalysis &) LLVM_DELETED_FUNCTION;
60 ProvenanceAnalysis(const ProvenanceAnalysis &) LLVM_DELETED_FUNCTION;
63 ProvenanceAnalysis() {}
65 void setAA(AliasAnalysis *aa) { AA = aa; }
67 AliasAnalysis *getAA() const { return AA; }
69 bool related(const Value *A, const Value *B);
72 CachedResults.clear();
76 } // end namespace objcarc
77 } // end namespace llvm
79 #endif // LLVM_TRANSFORMS_OBJCARC_PROVENANCEANALYSIS_H