Fixed bug in ObjCARC where we were changing a call from objc_autoreleaseRV => objc_autorelease but were not updating the InstructionClass to IC_Autorelease.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172288 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Gottesman 2013-01-12 01:25:19 +00:00
parent e8c161a924
commit 0e385450fc
2 changed files with 7 additions and 4 deletions

View File

@ -1716,7 +1716,8 @@ namespace {
void OptimizeRetainCall(Function &F, Instruction *Retain);
bool OptimizeRetainRVCall(Function &F, Instruction *RetainRV);
void OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV);
void OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV,
InstructionClass &Class);
void OptimizeIndividualCalls(Function &F);
void CheckForCFGHazards(const BasicBlock *BB,
@ -2289,7 +2290,8 @@ ObjCARCOpt::OptimizeRetainRVCall(Function &F, Instruction *RetainRV) {
/// OptimizeAutoreleaseRVCall - Turn objc_autoreleaseReturnValue into
/// objc_autorelease if the result is not used as a return value.
void
ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV) {
ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV,
InstructionClass &Class) {
// Check for a return of the pointer value.
const Value *Ptr = GetObjCArg(AutoreleaseRV);
SmallVector<const Value *, 2> Users;
@ -2320,6 +2322,7 @@ ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F, Instruction *AutoreleaseRV) {
AutoreleaseRVCI->
setCalledFunction(getAutoreleaseCallee(F.getParent()));
AutoreleaseRVCI->setTailCall(false); // Never tail call objc_autorelease.
Class = IC_Autorelease;
DEBUG(dbgs() << " New: "
<< *AutoreleaseRV << "\n");
@ -2417,7 +2420,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
continue;
break;
case IC_AutoreleaseRV:
OptimizeAutoreleaseRVCall(F, Inst);
OptimizeAutoreleaseRVCall(F, Inst, Class);
break;
}

View File

@ -67,7 +67,7 @@ entry:
; @objc_autorelease, ensure that the tail call is removed.
define i8* @test5(i8* %x) {
entry:
; TMP: %tmp0 = call i8* @objc_autorelease(i8* %x)
; CHECK: %tmp0 = call i8* @objc_autorelease(i8* %x)
%tmp0 = tail call i8* @objc_autoreleaseReturnValue(i8* %x)
ret i8* %tmp0
}