mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-09 22:13:07 +00:00
[objc-arc] Refactored OptimizeReturns so that it uses continue instead of a large multi-level nested if statement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179964 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7e48a92829
commit
9f2b618ac5
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user