aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Scalar/ObjCARC.cpp2
-rw-r--r--test/Transforms/ObjCARC/pr12270.ll6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp
index 80c1dd166e..56e6c4c957 100644
--- a/lib/Transforms/Scalar/ObjCARC.cpp
+++ b/lib/Transforms/Scalar/ObjCARC.cpp
@@ -4073,7 +4073,7 @@ bool ObjCARCContract::runOnFunction(Function &F) {
if (!UserInst)
continue;
// FIXME: dominates should return true for unreachable UserInst.
- if (!DT->isReachableFromEntry(UserInst->getParent()) ||
+ if (DT->isReachableFromEntry(UserInst->getParent()) &&
DT->dominates(Inst, UserInst)) {
Changed = true;
Instruction *Replacement = Inst;
diff --git a/test/Transforms/ObjCARC/pr12270.ll b/test/Transforms/ObjCARC/pr12270.ll
index 30610f8694..1faae5f687 100644
--- a/test/Transforms/ObjCARC/pr12270.ll
+++ b/test/Transforms/ObjCARC/pr12270.ll
@@ -9,7 +9,13 @@ entry:
return: ; No predecessors!
%bar = bitcast %2* %x to i8*
%foo = call i8* @objc_autoreleaseReturnValue(i8* %bar) nounwind
+ call void @callee()
+ call void @use_pointer(i8* %foo)
+ call void @objc_release(i8* %foo) nounwind
ret void
}
declare i8* @objc_autoreleaseReturnValue(i8*)
+declare void @objc_release(i8*)
+declare void @callee()
+declare void @use_pointer(i8*)