diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-04-21 00:25:01 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-04-21 00:25:01 +0000 |
commit | fb9ece9a7c8afe02a8cd31b9d1fd89e4bbd332bd (patch) | |
tree | 701ee2e0fcb4ec782df217c20380660d01773f34 | |
parent | 01338a442a9d59f3dcca4d03f3aca4a4754fbece (diff) | |
download | bcm5719-llvm-fb9ece9a7c8afe02a8cd31b9d1fd89e4bbd332bd.tar.gz bcm5719-llvm-fb9ece9a7c8afe02a8cd31b9d1fd89e4bbd332bd.zip |
[objc-arc] Refactored OptimizeReturns so that it uses continue instead of a large multi-level nested if statement.
llvm-svn: 179964
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index 1516d854451..f2f82bad72e 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -2965,34 +2965,39 @@ void ObjCARCOpt::OptimizeReturns(Function &F) { FindPredecessorAutoreleaseWithSafePath(Arg, BB, Ret, DependingInstructions, Visited, PA); - if (Autorelease) { - DependingInstructions.clear(); - Visited.clear(); - - CallInst *Retain = - FindPredecessorRetainWithSafePath(Arg, BB, Autorelease, - DependingInstructions, Visited, PA); - if (Retain) { - DependingInstructions.clear(); - Visited.clear(); - - // Check that there is nothing that can affect the reference count - // between the retain and the call. Note that Retain need not be in BB. - if (HasSafePathToPredecessorCall(Arg, Retain, DependingInstructions, - Visited, PA)) { - // If so, we can zap the retain and autorelease. - Changed = true; - ++NumRets; - DEBUG(dbgs() << "Erasing: " << *Retain << "\nErasing: " - << *Autorelease << "\n"); - EraseInstruction(Retain); - EraseInstruction(Autorelease); - } - } - } + DependingInstructions.clear(); + Visited.clear(); + + if (!Autorelease) + continue; + CallInst *Retain = + FindPredecessorRetainWithSafePath(Arg, BB, Autorelease, + DependingInstructions, Visited, PA); DependingInstructions.clear(); Visited.clear(); + + if (!Retain) + continue; + + // Check that there is nothing that can affect the reference count + // between the retain and the call. Note that Retain need not be in BB. + bool HasSafePathToCall = HasSafePathToPredecessorCall(Arg, Retain, + DependingInstructions, + Visited, PA); + DependingInstructions.clear(); + Visited.clear(); + + if (!HasSafePathToCall) + continue; + + // If so, we can zap the retain and autorelease. + Changed = true; + ++NumRets; + DEBUG(dbgs() << "Erasing: " << *Retain << "\nErasing: " + << *Autorelease << "\n"); + EraseInstruction(Retain); + EraseInstruction(Autorelease); } } |