aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-01-12 01:25:19 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-01-12 01:25:19 +0000
commit0e385450fc62a69cf7c557173f2f5df132702379 (patch)
tree41fb7c88e6c1f7532eb0361415c5ddf26c203bab
parente8c161a92451ad38919525ea73ae3c6936c24bdf (diff)
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
-rw-r--r--lib/Transforms/Scalar/ObjCARC.cpp9
-rw-r--r--test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll2
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp
index 1607e8e80a..a982c35c74 100644
--- a/lib/Transforms/Scalar/ObjCARC.cpp
+++ b/lib/Transforms/Scalar/ObjCARC.cpp
@@ -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;
}
diff --git a/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll b/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll
index d9e2c0c6ea..74ac97c7b3 100644
--- a/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll
+++ b/test/Transforms/ObjCARC/tail-call-invariant-enforcement.ll
@@ -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
}