Skip to content

Commit 76c60c3

Browse files
committed
--- 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
1 parent 5bc870c commit 76c60c3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/Transforms/Scalar/CodeGenPrepare.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
602602
if (&*BI != RI)
603603
return false;
604604
} else {
605-
if (&*BB->begin() != RI)
605+
BasicBlock::iterator BI = BB->begin();
606+
while (isa<DbgInfoIntrinsic>(BI)) ++BI;
607+
if (&*BI != RI)
606608
return false;
607609
}
608610

@@ -626,10 +628,12 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
626628
BasicBlock::InstListType &InstList = (*PI)->getInstList();
627629
BasicBlock::InstListType::reverse_iterator RI = InstList.rbegin();
628630
BasicBlock::InstListType::reverse_iterator RE = InstList.rend();
629-
if (++RI == RE)
631+
do { ++RI; } while (RI != RE && isa<DbgInfoIntrinsic>(&*RI));
632+
if (RI == RE)
630633
continue;
634+
631635
CallInst *CI = dyn_cast<CallInst>(&*RI);
632-
if (CI && CI->getType()->isVoidTy() && TLI->mayBeEmittedAsTailCall(CI))
636+
if (CI && CI->use_empty() && TLI->mayBeEmittedAsTailCall(CI))
633637
TailCalls.push_back(CI);
634638
}
635639
}

0 commit comments

Comments
 (0)