summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-01-29 21:00:52 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-01-29 21:00:52 +0000
commit774d2c014eea60f833e63560f95b823a0df20dc5 (patch)
tree9aaba3378b947c8b7d135a467d5dc0e5c153d179 /llvm/lib/Transforms
parent03eefb3a3887a706efeffc8752057ae1a6b76c71 (diff)
downloadbcm5719-llvm-774d2c014eea60f833e63560f95b823a0df20dc5.tar.gz
bcm5719-llvm-774d2c014eea60f833e63560f95b823a0df20dc5.zip
Changed DoesObjCBlockEscape => DoesRetainableObjPtrEscape so I can use it to perform escape analysis of other retainable object pointers in other locations.
llvm-svn: 173829
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index e968c8b22ce..727b4f7c96c 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud