Skip to content

[ObjC][ARC] Invalidate an entry of UnderlyingObjCPtrCache when the instruction the key points to is deleted #3516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2021
Merged
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