git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148419
91177308-0d34-0410-b5e6-
96231b3b80d8
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
virtual bool runOnModule(Module &M);
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
virtual bool runOnModule(Module &M);
- bool MayAutorelease(CallSite CS);
+ bool MayAutorelease(CallSite CS, unsigned Depth = 0);
bool OptimizeBB(BasicBlock *BB);
public:
bool OptimizeBB(BasicBlock *BB);
public:
/// MayAutorelease - Interprocedurally determine if calls made by the
/// given call site can possibly produce autoreleases.
/// MayAutorelease - Interprocedurally determine if calls made by the
/// given call site can possibly produce autoreleases.
-bool ObjCARCAPElim::MayAutorelease(CallSite CS) {
+bool ObjCARCAPElim::MayAutorelease(CallSite CS, unsigned Depth) {
if (Function *Callee = CS.getCalledFunction()) {
if (Callee->isDeclaration() || Callee->mayBeOverridden())
return true;
if (Function *Callee = CS.getCalledFunction()) {
if (Callee->isDeclaration() || Callee->mayBeOverridden())
return true;
BasicBlock *BB = I;
for (BasicBlock::iterator J = BB->begin(), F = BB->end(); J != F; ++J)
if (CallSite JCS = CallSite(J))
BasicBlock *BB = I;
for (BasicBlock::iterator J = BB->begin(), F = BB->end(); J != F; ++J)
if (CallSite JCS = CallSite(J))
- if (!JCS.onlyReadsMemory() && MayAutorelease(JCS))
+ // This recursion depth limit is arbitrary. It's just great
+ // enough to cover known interesting testcases.
+ if (Depth < 3 &&
+ !JCS.onlyReadsMemory() &&
+ MayAutorelease(JCS, Depth + 1))
return true;
}
return false;
return true;
}
return false;