LLVM  6.0.0svn
ProvenanceAnalysis.h
Go to the documentation of this file.
1 //===- ProvenanceAnalysis.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 //
10 /// \file
11 ///
12 /// This file declares a special form of Alias Analysis called ``Provenance
13 /// Analysis''. The word ``provenance'' refers to the history of the ownership
14 /// of an object. Thus ``Provenance Analysis'' is an analysis which attempts to
15 /// use various techniques to determine if locally
16 ///
17 /// WARNING: This file knows about certain library functions. It recognizes them
18 /// by name, and hardwires knowledge of their semantics.
19 ///
20 /// WARNING: This file knows about how certain Objective-C library functions are
21 /// used. Naive LLVM IR transformations which would otherwise be
22 /// behavior-preserving may break these assumptions.
23 //
24 //===----------------------------------------------------------------------===//
25 
26 #ifndef LLVM_LIB_TRANSFORMS_OBJCARC_PROVENANCEANALYSIS_H
27 #define LLVM_LIB_TRANSFORMS_OBJCARC_PROVENANCEANALYSIS_H
28 
29 #include "llvm/ADT/DenseMap.h"
31 #include <utility>
32 
33 namespace llvm {
34 
35 class DataLayout;
36 class PHINode;
37 class SelectInst;
38 class Value;
39 
40 namespace objcarc {
41 
42 /// \brief This is similar to BasicAliasAnalysis, and it uses many of the same
43 /// techniques, except it uses special ObjC-specific reasoning about pointer
44 /// relationships.
45 ///
46 /// In this context ``Provenance'' is defined as the history of an object's
47 /// ownership. Thus ``Provenance Analysis'' is defined by using the notion of
48 /// an ``independent provenance source'' of a pointer to determine whether or
49 /// not two pointers have the same provenance source and thus could
50 /// potentially be related.
52  AliasAnalysis *AA;
53 
54  using ValuePairTy = std::pair<const Value *, const Value *>;
56 
57  CachedResultsTy CachedResults;
58 
59  bool relatedCheck(const Value *A, const Value *B, const DataLayout &DL);
60  bool relatedSelect(const SelectInst *A, const Value *B);
61  bool relatedPHI(const PHINode *A, const Value *B);
62 
63 public:
64  ProvenanceAnalysis() = default;
65  ProvenanceAnalysis(const ProvenanceAnalysis &) = delete;
67 
68  void setAA(AliasAnalysis *aa) { AA = aa; }
69 
70  AliasAnalysis *getAA() const { return AA; }
71 
72  bool related(const Value *A, const Value *B, const DataLayout &DL);
73 
74  void clear() {
75  CachedResults.clear();
76  }
77 };
78 
79 } // end namespace objcarc
80 
81 } // end namespace llvm
82 
83 #endif // LLVM_LIB_TRANSFORMS_OBJCARC_PROVENANCEANALYSIS_H
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This class represents the LLVM &#39;select&#39; instruction.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
bool related(const Value *A, const Value *B, const DataLayout &DL)
LLVM Value Representation.
Definition: Value.h:73
ProvenanceAnalysis & operator=(const ProvenanceAnalysis &)=delete
This is similar to BasicAliasAnalysis, and it uses many of the same techniques, except it uses specia...