Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ inline const Value *GetUnderlyingObjCPtr(const Value *V) {
}

/// A wrapper for GetUnderlyingObjCPtr used for results memoization.
inline const Value *
GetUnderlyingObjCPtrCached(const Value *V,
DenseMap<const Value *, WeakTrackingVH> &Cache) {
if (auto InCache = Cache.lookup(V))
return InCache;
inline const Value *GetUnderlyingObjCPtrCached(
const Value *V,
DenseMap<const Value *, std::pair<WeakVH, WeakTrackingVH>> &Cache) {
// The entry is invalid if either value handle is null.
auto InCache = Cache.lookup(V);
if (InCache.first && InCache.second)
return InCache.second;

const Value *Computed = GetUnderlyingObjCPtr(V);
Cache[V] = const_cast<Value *>(Computed);
Cache[V] =
std::make_pair(const_cast<Value *>(V), const_cast<Value *>(Computed));
return Computed;
}

Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class ProvenanceAnalysis {

CachedResultsTy CachedResults;

DenseMap<const Value *, WeakTrackingVH> UnderlyingObjCPtrCache;
DenseMap<const Value *, std::pair<WeakVH, WeakTrackingVH>>
UnderlyingObjCPtrCache;

bool relatedCheck(const Value *A, const Value *B);
bool relatedSelect(const SelectInst *A, const Value *B);
Expand Down