[llvm] r312266 - [ObjCARC] Pass the correct BasicBlock to fix assertion failure.
Akira Hatanaka via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 31 11:27:47 PDT 2017
Author: ahatanak
Date: Thu Aug 31 11:27:47 2017
New Revision: 312266
URL: http://llvm.org/viewvc/llvm-project?rev=312266&view=rev
Log:
[ObjCARC] Pass the correct BasicBlock to fix assertion failure.
The BasicBlock passed to FindPredecessorRetainWithSafePath should be the
parent block of Autorelease. This fixes a crash that occurs in
FindDependencies when StartInst is not in StartBB.
rdar://problem/33866381
Modified:
llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/trunk/test/Transforms/ObjCARC/rv.ll
Modified: llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp?rev=312266&r1=312265&r2=312266&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (original)
+++ llvm/trunk/lib/Transforms/ObjCARC/ObjCARCOpts.cpp Thu Aug 31 11:27:47 2017
@@ -2027,7 +2027,8 @@ void ObjCARCOpt::OptimizeReturns(Functio
continue;
CallInst *Retain = FindPredecessorRetainWithSafePath(
- Arg, &BB, Autorelease, DependingInstructions, Visited, PA);
+ Arg, Autorelease->getParent(), Autorelease, DependingInstructions,
+ Visited, PA);
DependingInstructions.clear();
Visited.clear();
Modified: llvm/trunk/test/Transforms/ObjCARC/rv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ObjCARC/rv.ll?rev=312266&r1=312265&r2=312266&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ObjCARC/rv.ll (original)
+++ llvm/trunk/test/Transforms/ObjCARC/rv.ll Thu Aug 31 11:27:47 2017
@@ -314,6 +314,25 @@ define void @test25() {
ret void
}
+; Check that ObjCARCOpt::OptimizeReturns removes the redundant calls even when
+; they are not in the same basic block. This code used to cause an assertion
+; failure.
+
+; CHECK-LABEL: define i8* @test26()
+; CHECK: call i8* @returner()
+; CHECK-NOT: call
+define i8* @test26() {
+bb0:
+ %v0 = call i8* @returner()
+ %v1 = tail call i8* @objc_retain(i8* %v0)
+ br label %bb1
+bb1:
+ %v2 = tail call i8* @objc_autoreleaseReturnValue(i8* %v1)
+ br label %bb2
+bb2:
+ ret i8* %v2
+}
+
!0 = !{}
; CHECK: attributes [[NUW]] = { nounwind }
More information about the llvm-commits
mailing list