42 bool ProvenanceAnalysis::relatedSelect(
const SelectInst *A,
47 if (
const SelectInst *SB = dyn_cast<SelectInst>(B))
57 bool ProvenanceAnalysis::relatedPHI(
const PHINode *A,
63 if (
const PHINode *PNB = dyn_cast<PHINode>(B))
92 for (
const Use &U : P->
uses()) {
93 const User *Ur = U.getUser();
94 if (isa<StoreInst>(Ur)) {
95 if (U.getOperandNo() == 0)
101 if (isa<CallInst>(Ur))
104 if (isa<PtrToIntInst>(P))
107 if (Visited.
insert(Ur).second)
110 }
while (!Worklist.
empty());
116 bool ProvenanceAnalysis::relatedCheck(
const Value *A,
const Value *B,
119 switch (AA->
alias(A, B)) {
135 if (isa<LoadInst>(B))
139 if (isa<LoadInst>(A))
144 }
else if (BIsIdentified) {
146 if (isa<LoadInst>(A))
151 if (
const PHINode *PN = dyn_cast<PHINode>(A))
152 return relatedPHI(PN, B);
153 if (
const PHINode *PN = dyn_cast<PHINode>(B))
154 return relatedPHI(PN, A);
155 if (
const SelectInst *S = dyn_cast<SelectInst>(A))
156 return relatedSelect(S, B);
157 if (
const SelectInst *S = dyn_cast<SelectInst>(B))
158 return relatedSelect(S, A);
177 std::pair<CachedResultsTy::iterator, bool> Pair =
178 CachedResults.
insert(std::make_pair(ValuePairTy(A, B),
true));
180 return Pair.first->second;
182 bool Result = relatedCheck(A, B, DL);
183 CachedResults[ValuePairTy(A, B)] = Result;
A parsed version of the target data layout string in and methods for querying it. ...
iterator_range< use_iterator > uses()
This class represents lattice values for constants.
void push_back(const T &Elt)
const Value * getTrueValue() const
The two locations do not alias at all.
This defines the Use class.
bool IsObjCIdentifiedObject(const Value *V)
Return true if this value refers to a distinct and identifiable object.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
This class represents the LLVM 'select' instruction.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
A Use represents the edge between a Value definition and its users.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool IsStoredObjCPointer(const Value *P)
Test if the value of P, or any value covered by its provenance, is ever stored within the function (n...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
const Value * getCondition() const
This file defines common analysis utilities used by the ObjC ARC Optimizer.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
The two locations may or may not alias. This is the least precise result.
The two locations precisely alias each other.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This file declares a special form of Alias Analysis called ``Provenance Analysis''.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD T pop_back_val()
const Value * GetUnderlyingObjCPtrCached(const Value *V, const DataLayout &DL, DenseMap< const Value *, WeakTrackingVH > &Cache)
A wrapper for GetUnderlyingObjCPtr used for results memoization.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool related(const Value *A, const Value *B, const DataLayout &DL)
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
const Value * getFalseValue() const
LLVM_NODISCARD bool empty() const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
LLVM Value Representation.
The two locations alias, but only due to a partial overlap.
op_range incoming_values()
const BasicBlock * getParent() const