diff options
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h')
-rw-r--r-- | contrib/llvm-project/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/contrib/llvm-project/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h index cad1c52f7f87..16c5f6701da0 100644 --- a/contrib/llvm-project/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h +++ b/contrib/llvm-project/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h @@ -23,7 +23,6 @@ #define LLVM_LIB_ANALYSIS_OBJCARCANALYSISUTILS_H #include "llvm/ADT/Optional.h" -#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/ObjCARCInstKind.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/Constants.h" @@ -31,6 +30,9 @@ #include "llvm/IR/ValueHandle.h" namespace llvm { + +class AAResults; + namespace objcarc { /// A handy option to enable/disable all ARC Optimizations. @@ -64,10 +66,9 @@ inline bool ModuleHasARC(const Module &M) { /// This is a wrapper around getUnderlyingObject which also knows how to /// look through objc_retain and objc_autorelease calls, which we know to return /// their argument verbatim. -inline const Value *GetUnderlyingObjCPtr(const Value *V, - const DataLayout &DL) { +inline const Value *GetUnderlyingObjCPtr(const Value *V) { for (;;) { - V = GetUnderlyingObject(V, DL); + V = getUnderlyingObject(V); if (!IsForwarding(GetBasicARCInstKind(V))) break; V = cast<CallInst>(V)->getArgOperand(0); @@ -78,12 +79,12 @@ inline const Value *GetUnderlyingObjCPtr(const Value *V, /// A wrapper for GetUnderlyingObjCPtr used for results memoization. inline const Value * -GetUnderlyingObjCPtrCached(const Value *V, const DataLayout &DL, +GetUnderlyingObjCPtrCached(const Value *V, DenseMap<const Value *, WeakTrackingVH> &Cache) { if (auto InCache = Cache.lookup(V)) return InCache; - const Value *Computed = GetUnderlyingObjCPtr(V, DL); + const Value *Computed = GetUnderlyingObjCPtr(V); Cache[V] = const_cast<Value *>(Computed); return Computed; } @@ -146,7 +147,7 @@ inline bool IsPotentialRetainableObjPtr(const Value *Op) { return false; // Special arguments can not be a valid retainable object pointer. if (const Argument *Arg = dyn_cast<Argument>(Op)) - if (Arg->hasPassPointeeByValueAttr() || Arg->hasNestAttr() || + if (Arg->hasPassPointeeByValueCopyAttr() || Arg->hasNestAttr() || Arg->hasStructRetAttr()) return false; // Only consider values with pointer types. @@ -162,24 +163,7 @@ inline bool IsPotentialRetainableObjPtr(const Value *Op) { return true; } -inline bool IsPotentialRetainableObjPtr(const Value *Op, - AliasAnalysis &AA) { - // First make the rudimentary check. - if (!IsPotentialRetainableObjPtr(Op)) - return false; - - // Objects in constant memory are not reference-counted. - if (AA.pointsToConstantMemory(Op)) - return false; - - // Pointers in constant memory are not pointing to reference-counted objects. - if (const LoadInst *LI = dyn_cast<LoadInst>(Op)) - if (AA.pointsToConstantMemory(LI->getPointerOperand())) - return false; - - // Otherwise assume the worst. - return true; -} +bool IsPotentialRetainableObjPtr(const Value *Op, AAResults &AA); /// Helper for GetARCInstKind. Determines what kind of construct CS /// is. |