#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 {
/// 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
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/IR/ValueHandle.h"
#include <utility>
namespace llvm {
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);