[llvm-commits] [llvm] r148419 - /llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
Dan Gohman
gohman at apple.com
Wed Jan 18 13:24:45 PST 2012
Author: djg
Date: Wed Jan 18 15:24:45 2012
New Revision: 148419
URL: http://llvm.org/viewvc/llvm-project?rev=148419&view=rev
Log:
Add a depth limit to avoid runaway recursion.
Modified:
llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=148419&r1=148418&r2=148419&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Wed Jan 18 15:24:45 2012
@@ -895,7 +895,7 @@
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:
@@ -922,7 +922,7 @@
/// 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;
@@ -931,7 +931,11 @@
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;
More information about the llvm-commits
mailing list