forked from OSchip/llvm-project
[ObjC][ARC] Invalidate an entry of UnderlyingObjCPtrCache when the
instruction the key points to is deleted Use weak value handles for both the key and the value. The entry is invalid if either value handle is null. This fixes an assertion failure in BasicAAResult::alias that is caused by UnderlyingObjCPtrCache returning a wrong value. I don't have a test case for this patch that fails reliably. rdar://83984790
This commit is contained in:
parent
443820179a
commit
f2c7c3c7c7
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue