[llvm] 86eb2c3 - Revert "[ObjC][ARC] Don't remove autoreleaseRV/retainRV pairs if the call isn't"
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 13 07:16:27 PDT 2020
Author: Nico Weber
Date: 2020-03-13T10:16:02-04:00
New Revision: 86eb2c3991c5b5ed40eaecdb7181cbbde7048d70
URL: https://github.com/llvm/llvm-project/commit/86eb2c3991c5b5ed40eaecdb7181cbbde7048d70
DIFF: https://github.com/llvm/llvm-project/commit/86eb2c3991c5b5ed40eaecdb7181cbbde7048d70.diff
LOG: Revert "[ObjC][ARC] Don't remove autoreleaseRV/retainRV pairs if the call isn't"
This reverts commit 1f5b471b8bf4c6d22fb13d8e24bc31c75245b0d0.
Causes asserts when building code with arc. See
https://bugs.chromium.org/p/chromium/issues/detail?id=1061289#c2
for a full repro. Will post a creduced repro once creduce is done
running.
Added:
Modified:
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/test/Transforms/ObjCARC/rv.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 9a029cc74834..577a744f3062 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -2296,7 +2296,7 @@ FindPredecessorAutoreleaseWithSafePath(const Value *Arg, BasicBlock *BB,
/// Look for this pattern:
/// \code
-/// %call = tail call i8* @something(...)
+/// %call = call i8* @something(...)
/// %2 = call i8* @objc_retain(i8* %call)
/// %3 = call i8* @objc_autorelease(i8* %2)
/// ret i8* %3
@@ -2344,13 +2344,6 @@ void ObjCARCOpt::OptimizeReturns(Function &F) {
bool HasSafePathToCall = HasSafePathToPredecessorCall(Arg, Retain,
DependingInstructions,
Visited, PA);
-
- // Don't remove retainRV/autoreleaseRV pairs if the call isn't a tail call.
- if (GetBasicARCInstKind(Retain) == ARCInstKind::RetainRV &&
- GetBasicARCInstKind(Autorelease) == ARCInstKind::AutoreleaseRV &&
- !cast<CallInst>(*DependingInstructions.begin())->isTailCall())
- continue;
-
DependingInstructions.clear();
Visited.clear();
diff --git a/llvm/test/Transforms/ObjCARC/rv.ll b/llvm/test/Transforms/ObjCARC/rv.ll
index ea06b38aa9b4..3d0d56ca0e53 100644
--- a/llvm/test/Transforms/ObjCARC/rv.ll
+++ b/llvm/test/Transforms/ObjCARC/rv.ll
@@ -77,7 +77,7 @@ define void @test2() {
; CHECK-NEXT: ret i8* %call
define i8* @test3() {
entry:
- %call = tail call i8* @returner()
+ %call = call i8* @returner()
%0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call) nounwind
%1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %0) nounwind
ret i8* %1
@@ -387,20 +387,6 @@ bb3:
ret i32* %retval
}
-; Don't eliminate the retainRV/autoreleaseRV pair if the call isn't a tail call.
-
-; CHECK-LABEL: define i8* @test28(
-; CHECK: call i8* @returner()
-; CHECK: call i8* @llvm.objc.retainAutoreleasedReturnValue(
-; CHECK: call i8* @llvm.objc.autoreleaseReturnValue(
-define i8* @test28() {
-entry:
- %call = call i8* @returner()
- %0 = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %call) nounwind
- %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %0) nounwind
- ret i8* %1
-}
-
!0 = !{}
; CHECK: attributes [[NUW]] = { nounwind }
More information about the llvm-commits
mailing list