From 76c60c3241225cb5294e28e5211d0886207ce6e7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 24 Mar 2011 18:07:13 +0000 Subject: --- Merging r128212 into '.': U lib/Transforms/Scalar/CodeGenPrepare.cpp --- Merging r128217 into '.': G lib/Transforms/Scalar/CodeGenPrepare.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_29@128223 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/CodeGenPrepare.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index 237b0a7d48..15d8c20f14 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -602,7 +602,9 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) { if (&*BI != RI) return false; } else { - if (&*BB->begin() != RI) + BasicBlock::iterator BI = BB->begin(); + while (isa(BI)) ++BI; + if (&*BI != RI) return false; } @@ -626,10 +628,12 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) { BasicBlock::InstListType &InstList = (*PI)->getInstList(); BasicBlock::InstListType::reverse_iterator RI = InstList.rbegin(); BasicBlock::InstListType::reverse_iterator RE = InstList.rend(); - if (++RI == RE) + do { ++RI; } while (RI != RE && isa(&*RI)); + if (RI == RE) continue; + CallInst *CI = dyn_cast(&*RI); - if (CI && CI->getType()->isVoidTy() && TLI->mayBeEmittedAsTailCall(CI)) + if (CI && CI->use_empty() && TLI->mayBeEmittedAsTailCall(CI)) TailCalls.push_back(CI); } } -- cgit v1.2.3-18-g5258