[PATCH] D48407: ProvenanceAnalysis: Store WeakTrackingVH instead of Value* in UnderlyingValue Cache.

Michael Zolotukhin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 20 22:18:40 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL335201: ProvenanceAnalysis: Store WeakTrackingVH instead of Value* in UnderlyingValue… (authored by mzolotukhin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48407?vs=152201&id=152223#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48407

Files:
  llvm/trunk/include/llvm/Analysis/ObjCARCAnalysisUtils.h
  llvm/trunk/lib/Transforms/ObjCARC/ProvenanceAnalysis.h


Index: llvm/trunk/include/llvm/Analysis/ObjCARCAnalysisUtils.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/ObjCARCAnalysisUtils.h
+++ llvm/trunk/include/llvm/Analysis/ObjCARCAnalysisUtils.h
@@ -34,6 +34,7 @@
 #include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/ValueHandle.h"
 #include "llvm/Pass.h"
 
 namespace llvm {
@@ -89,11 +90,13 @@
 /// A wrapper for GetUnderlyingObjCPtr used for results memoization.
 inline const Value *
 GetUnderlyingObjCPtrCached(const Value *V, const DataLayout &DL,
-                           DenseMap<const Value *, const Value *> &Cache) {
+                           DenseMap<const Value *, WeakTrackingVH> &Cache) {
   if (auto InCache = Cache.lookup(V))
     return InCache;
 
-  return Cache[V] = GetUnderlyingObjCPtr(V, DL);
+  const Value *Computed = GetUnderlyingObjCPtr(V, DL);
+  Cache[V] = const_cast<Value *>(Computed);
+  return Computed;
 }
 
 /// The RCIdentity root of a value \p V is a dominating value U for which
Index: llvm/trunk/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
===================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
+++ llvm/trunk/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
@@ -28,6 +28,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/IR/ValueHandle.h"
 #include <utility>
 
 namespace llvm {
@@ -56,7 +57,7 @@
 
   CachedResultsTy CachedResults;
 
-  DenseMap<const Value *, const Value *> UnderlyingObjCPtrCache;
+  DenseMap<const Value *, WeakTrackingVH> UnderlyingObjCPtrCache;
 
   bool relatedCheck(const Value *A, const Value *B, const DataLayout &DL);
   bool relatedSelect(const SelectInst *A, const Value *B);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48407.152223.patch
Type: text/x-patch
Size: 1834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180621/63530b00/attachment.bin>


More information about the llvm-commits mailing list