summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2012-06-25 19:47:37 +0000
committerDan Gohman <gohman@apple.com>2012-06-25 19:47:37 +0000
commit5f725cd1968c88e05f1c5b13a8187db8fa821cd7 (patch)
tree964bf2bfd0df29f726fb446b2110b76972c68924 /llvm/lib/Transforms
parent49979f2e38ff97d1e90183f5cfa5d3effcd75c06 (diff)
downloadbcm5719-llvm-5f725cd1968c88e05f1c5b13a8187db8fa821cd7.tar.gz
bcm5719-llvm-5f725cd1968c88e05f1c5b13a8187db8fa821cd7.zip
Fix the objc_autoreleasedReturnValue optimization code to locate
the call correctly even in the case where it is an invoke. This fixes rdar://11714057. llvm-svn: 159157
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/ObjCARC.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/ObjCARC.cpp b/llvm/lib/Transforms/Scalar/ObjCARC.cpp
index d89996a1ff6..87e17c7f90a 100644
--- a/llvm/lib/Transforms/Scalar/ObjCARC.cpp
+++ b/llvm/lib/Transforms/Scalar/ObjCARC.cpp
@@ -4064,8 +4064,22 @@ bool ObjCARCContract::runOnFunction(Function &F) {
if (!RetainRVMarker)
break;
BasicBlock::iterator BBI = Inst;
- --BBI;
- while (isNoopInstruction(BBI)) --BBI;
+ BasicBlock *InstParent = Inst->getParent();
+
+ // Step up to see if the call immediately precedes the RetainRV call.
+ // If it's an invoke, we have to cross a block boundary. And we have
+ // to carefully dodge no-op instructions.
+ do {
+ if (&*BBI == InstParent->begin()) {
+ BasicBlock *Pred = InstParent->getSinglePredecessor();
+ if (!Pred)
+ goto decline_rv_optimization;
+ BBI = Pred->getTerminator();
+ break;
+ }
+ --BBI;
+ } while (isNoopInstruction(BBI));
+
if (&*BBI == GetObjCArg(Inst)) {
Changed = true;
InlineAsm *IA =
@@ -4075,6 +4089,7 @@ bool ObjCARCContract::runOnFunction(Function &F) {
/*Constraints=*/"", /*hasSideEffects=*/true);
CallInst::Create(IA, "", Inst);
}
+ decline_rv_optimization:
break;
}
case IC_InitWeak: {
OpenPOWER on IntegriCloud