31 using namespace llvm::objcarc;
33 bool ProvenanceAnalysis::relatedSelect(
const SelectInst *
A,
38 if (
const SelectInst *SB = dyn_cast<SelectInst>(B))
48 bool ProvenanceAnalysis::relatedPHI(
const PHINode *A,
54 if (
const PHINode *PNB = dyn_cast<PHINode>(B))
83 for (
const Use &U : P->
uses()) {
84 const User *Ur = U.getUser();
85 if (isa<StoreInst>(Ur)) {
86 if (U.getOperandNo() == 0)
92 if (isa<CallInst>(Ur))
95 if (isa<PtrToIntInst>(P))
98 if (Visited.
insert(Ur).second)
101 }
while (!Worklist.
empty());
107 bool ProvenanceAnalysis::relatedCheck(
const Value *A,
const Value *B,
118 switch (AA->
alias(A, B)) {
134 if (isa<LoadInst>(B))
138 if (isa<LoadInst>(A))
143 }
else if (BIsIdentified) {
145 if (isa<LoadInst>(A))
150 if (
const PHINode *PN = dyn_cast<PHINode>(A))
151 return relatedPHI(PN, B);
152 if (
const PHINode *PN = dyn_cast<PHINode>(B))
153 return relatedPHI(PN, A);
154 if (
const SelectInst *S = dyn_cast<SelectInst>(A))
155 return relatedSelect(S, B);
156 if (
const SelectInst *S = dyn_cast<SelectInst>(B))
157 return relatedSelect(S, A);
169 std::pair<CachedResultsTy::iterator, bool> Pair =
170 CachedResults.
insert(std::make_pair(ValuePairTy(A, B),
true));
172 return Pair.first->second;
174 bool Result = relatedCheck(A, B, DL);
175 CachedResults[ValuePairTy(A, B)] = Result;
The two locations precisely alias each other.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
iterator_range< use_iterator > uses()
The two locations alias, but only due to a partial overlap.
The two locations do not alias at all.
The two locations may or may not alias. This is the least precise result.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
SelectInst - This class represents the LLVM 'select' instruction.
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
A Use represents the edge between a Value definition and its users.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
unsigned getNumIncomingValues() const
getNumIncomingValues - Return the number of incoming edges
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...
const Value * getCondition() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
BasicBlock * getIncomingBlock(unsigned i) const
getIncomingBlock - Return incoming basic block number i.
static bool IsObjCIdentifiedObject(const Value *V)
Return true if this value refers to a distinct and identifiable object.
static const Value * GetUnderlyingObjCPtr(const Value *V, const DataLayout &DL)
This is a wrapper around getUnderlyingObject which also knows how to look through objc_retain and obj...
const Value * getTrueValue() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Value * getIncomingValue(unsigned i) const
getIncomingValue - Return incoming value number x
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Alias Queries...
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
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...
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 DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
LLVM Value Representation.
const Value * getFalseValue() const
op_range incoming_values()
const BasicBlock * getParent() const