diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-04-03 02:57:24 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-04-03 02:57:24 +0000 |
commit | a67a20c95f08b31b499d06d1fa47bdf14f9d40d0 (patch) | |
tree | f06bdd22f1809d7c7bc82828b878617814f359d8 /lib/Transforms/ObjCARC | |
parent | 003d5f946d3ad44cb42f7d25b0c40f04e9a5a0a2 (diff) |
Remove an optimization where we were changing an objc_autorelease into an objc_autoreleaseReturnValue.
The semantics of ARC implies that a pointer passed into an objc_autorelease
must live until some point (potentially down the stack) where an
autorelease pool is popped. On the other hand, an
objc_autoreleaseReturnValue just signifies that the object must live
until the end of the given function at least.
Thus objc_autorelease is stronger than objc_autoreleaseReturnValue in
terms of the semantics of ARC* implying that performing the given
strength reduction without any knowledge of how this relates to
the autorelease pool pop that is further up the stack violates the
semantics of ARC.
*Even though objc_autoreleaseReturnValue if you know that no RV
optimization will occur is more computationally expensive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/ObjCARC')
-rw-r--r-- | lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index a956caeffe..5ac8c8e6c2 100644 --- a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -1440,8 +1440,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) { break; } - // objc_autorelease(x), objc_autoreleaseRV -> objc_release(x) if x is - // otherwise unused. + // objc_autorelease(x) -> objc_release(x) if x is otherwise unused. if (IsAutorelease(Class) && Inst->use_empty()) { CallInst *Call = cast<CallInst>(Inst); const Value *Arg = Call->getArgOperand(0); @@ -2861,20 +2860,6 @@ void ObjCARCOpt::OptimizeReturns(Function &F) { DependingInstructions.clear(); Visited.clear(); - // Convert the autorelease to an autoreleaseRV, since it's - // returning the value. - if (AutoreleaseClass == IC_Autorelease) { - DEBUG(dbgs() << "ObjCARCOpt::OptimizeReturns: Converting autorelease " - "=> autoreleaseRV since it's returning a value.\n" - " In: " << *Autorelease - << "\n"); - Autorelease->setCalledFunction(getAutoreleaseRVCallee(F.getParent())); - DEBUG(dbgs() << " Out: " << *Autorelease - << "\n"); - Autorelease->setTailCall(); // Always tail call autoreleaseRV. - AutoreleaseClass = IC_AutoreleaseRV; - } - // 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. |