[llvm] r173829 - Changed DoesObjCBlockEscape => DoesRetainableObjPtrEscape so I can use it to perform escape analysis of other retainable object pointers in other locations.
Michael Gottesman
mgottesman at apple.com
Tue Jan 29 13:00:52 PST 2013
Author: mgottesman
Date: Tue Jan 29 15:00:52 2013
New Revision: 173829
URL: http://llvm.org/viewvc/llvm-project?rev=173829&view=rev
Log:
Changed DoesObjCBlockEscape => DoesRetainableObjPtrEscape so I can use it to perform escape analysis of other retainable object pointers in other locations.
Modified:
llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp?rev=173829&r1=173828&r2=173829&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp Tue Jan 29 15:00:52 2013
@@ -171,33 +171,36 @@ static const Value *FindSingleUseIdentif
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 Va
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 Va
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 Va
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::IsRetainBlockOptimizabl
// 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.
More information about the llvm-commits
mailing list