aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2012-04-19 21:50:46 +0000
committerDan Gohman <gohman@apple.com>2012-04-19 21:50:46 +0000
commit8b74e5afda780d05a46c1a35f46ebfd625e41f1a (patch)
tree54e9ec49191f598bfad1b303089c891e6d431111
parentc8969fd2919ac99bfd2fa07a6885659d804101c6 (diff)
downloadexternal_llvm-8b74e5afda780d05a46c1a35f46ebfd625e41f1a.zip
external_llvm-8b74e5afda780d05a46c1a35f46ebfd625e41f1a.tar.gz
external_llvm-8b74e5afda780d05a46c1a35f46ebfd625e41f1a.tar.bz2
Avoid a bug in the path count computation, preventing an infinite
loop repeatedlt making the same change. This is for rdar://11256239. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155160 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/ObjCARC.cpp2
-rw-r--r--test/Transforms/ObjCARC/split-backedge.ll48
2 files changed, 49 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp
index 29234da..a5ccfec 100644
--- a/lib/Transforms/Scalar/ObjCARC.cpp
+++ b/lib/Transforms/Scalar/ObjCARC.cpp
@@ -3379,7 +3379,7 @@ ObjCARCOpt::PerformCodePlacement(DenseMap<const BasicBlock *, BBState>
// Ok, everything checks out and we're all set. Let's move some code!
Changed = true;
- AnyPairsCompletelyEliminated = NewCount == 0;
+ AnyPairsCompletelyEliminated = OldCount != 0 && NewCount == 0;
NumRRs += OldCount - NewCount;
MoveCalls(Arg, RetainsToMove, ReleasesToMove,
Retains, Releases, DeadInsts, M);
diff --git a/test/Transforms/ObjCARC/split-backedge.ll b/test/Transforms/ObjCARC/split-backedge.ll
new file mode 100644
index 0000000..08e2dce
--- /dev/null
+++ b/test/Transforms/ObjCARC/split-backedge.ll
@@ -0,0 +1,48 @@
+; RUN: opt -S -objc-arc < %s | FileCheck %s
+
+; Handle a retain+release pair entirely contained within a split loop backedge.
+; rdar://11256239
+
+; CHECK: define void @test0
+; CHECK: call i8* @objc_retain(i8* %call) nounwind
+; CHECK: call i8* @objc_retain(i8* %call) nounwind
+; CHECK: call i8* @objc_retain(i8* %cond) nounwind
+; CHECK: call void @objc_release(i8* %call) nounwind
+; CHECK: call void @objc_release(i8* %call) nounwind
+; CHECK: call void @objc_release(i8* %cond) nounwind
+define void @test0() {
+entry:
+ br label %while.body
+
+while.body: ; preds = %while.cond
+ %call = invoke i8* @returner()
+ to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !0
+
+invoke.cont: ; preds = %while.body
+ %t0 = call i8* @objc_retain(i8* %call) nounwind
+ %t1 = call i8* @objc_retain(i8* %call) nounwind
+ %call.i1 = invoke i8* @returner()
+ to label %invoke.cont1 unwind label %lpad
+
+invoke.cont1: ; preds = %invoke.cont
+ %cond = select i1 undef, i8* null, i8* %call
+ %t2 = call i8* @objc_retain(i8* %cond) nounwind
+ call void @objc_release(i8* %call) nounwind
+ call void @objc_release(i8* %call) nounwind
+ call void @use_pointer(i8* %cond)
+ call void @objc_release(i8* %cond) nounwind
+ br label %while.body
+
+lpad: ; preds = %invoke.cont, %while.body
+ %t4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*)
+ catch i8* null
+ ret void
+}
+
+declare i8* @returner()
+declare i32 @__objc_personality_v0(...)
+declare void @objc_release(i8*)
+declare i8* @objc_retain(i8*)
+declare void @use_pointer(i8*)
+
+!0 = metadata !{}