diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-01-29 21:00:52 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-01-29 21:00:52 +0000 |
commit | 82b83011a1e330e41147dbad97e44939840ba755 (patch) | |
tree | a4d7c005cc4225d863b4427a106664b85205e0a8 /lib/Transforms/ObjCARC | |
parent | 6dc3781d44e56f0addf28b06232a50f3f9e6b1af (diff) |
Changed DoesObjCBlockEscape => DoesRetainableObjPtrEscape so I can use it to perform escape analysis of other retainable object pointers in other locations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/ObjCARC')
-rw-r--r-- | lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index e968c8b22c..727b4f7c96 100644 --- a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -171,33 +171,36 @@ static const Value *FindSingleUseIdentifiedObject(const Value *Arg) { return 0; } -/// \brief Test whether the given pointer, which is an Objective C block -/// pointer, does not "escape". +/// \brief Test whether the given retainable object pointer escapes. /// /// This differs from regular escape analysis in that a use as an /// argument to a call is not considered an escape. /// -static bool DoesObjCBlockEscape(const Value *BlockPtr) { +static bool DoesRetainableObjPtrEscape(const User *Ptr) { - DEBUG(dbgs() << "DoesObjCBlockEscape: Target: " << *BlockPtr << "\n"); + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: Target: " << *Ptr << "\n"); // Walk the def-use chains. SmallVector<const Value *, 4> Worklist; - Worklist.push_back(BlockPtr); + Worklist.push_back(Ptr); + // If Ptr has any operands add them as well. + for (User::const_op_iterator I = Ptr->op_begin(), E = Ptr->op_end(); I != E; ++I) { + Worklist.push_back(*I); + } // Ensure we do not visit any value twice. - SmallPtrSet<const Value *, 4> VisitedSet; + SmallPtrSet<const Value *, 8> VisitedSet; do { const Value *V = Worklist.pop_back_val(); - DEBUG(dbgs() << "DoesObjCBlockEscape: Visiting: " << *V << "\n"); + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: Visiting: " << *V << "\n"); for (Value::const_use_iterator UI = V->use_begin(), UE = V->use_end(); UI != UE; ++UI) { const User *UUser = *UI; - DEBUG(dbgs() << "DoesObjCBlockEscape: User: " << *UUser << "\n"); + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: User: " << *UUser << "\n"); // Special - Use by a call (callee or argument) is not considered // to be an escape. @@ -207,7 +210,7 @@ static bool DoesObjCBlockEscape(const Value *BlockPtr) { case IC_StoreStrong: case IC_Autorelease: case IC_AutoreleaseRV: { - DEBUG(dbgs() << "DoesObjCBlockEscape: User copies pointer arguments. " + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: User copies pointer arguments. " "Block Escapes!\n"); // These special functions make copies of their pointer arguments. return true; @@ -220,11 +223,11 @@ static bool DoesObjCBlockEscape(const Value *BlockPtr) { isa<PHINode>(UUser) || isa<SelectInst>(UUser)) { if (!VisitedSet.insert(UUser)) { - DEBUG(dbgs() << "DoesObjCBlockEscape: User copies value. Escapes " + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: User copies value. Escapes " "if result escapes. Adding to list.\n"); Worklist.push_back(UUser); } else { - DEBUG(dbgs() << "DoesObjCBlockEscape: Already visited node.\n"); + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: Already visited node.\n"); } continue; } @@ -241,13 +244,13 @@ static bool DoesObjCBlockEscape(const Value *BlockPtr) { continue; } // Otherwise, conservatively assume an escape. - DEBUG(dbgs() << "DoesObjCBlockEscape: Assuming block escapes.\n"); + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: Assuming block escapes.\n"); return true; } } while (!Worklist.empty()); // No escapes found. - DEBUG(dbgs() << "DoesObjCBlockEscape: Block does not escape.\n"); + DEBUG(dbgs() << "DoesRetainableObjPtrEscape: Block does not escape.\n"); return false; } @@ -822,7 +825,7 @@ bool ObjCARCOpt::IsRetainBlockOptimizable(const Instruction *Inst) { // If the pointer "escapes" (not including being used in a call), // the copy may be needed. - if (DoesObjCBlockEscape(Inst)) + if (DoesRetainableObjPtrEscape(Inst)) return false; // Otherwise, it's not needed. |