forked from OSchip/llvm-project
Use an early return instead of a long if block.
llvm-svn: 128196
This commit is contained in:
parent
dd84bcce8f
commit
0e331c05ae
|
|
@ -597,7 +597,10 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
|
|||
if (!V)
|
||||
return false;
|
||||
|
||||
if (PHINode *PN = dyn_cast<PHINode>(V)) {
|
||||
PHINode *PN = dyn_cast<PHINode>(V);
|
||||
if (!PN)
|
||||
return false;
|
||||
|
||||
BasicBlock *BB = RI->getParent();
|
||||
if (PN->getParent() != BB)
|
||||
return false;
|
||||
|
|
@ -615,8 +618,8 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
|
|||
if (&*BI != RI)
|
||||
return false;
|
||||
|
||||
/// Only dup the ReturnInst if the CallInst is likely to be emitted as a
|
||||
/// tail call.
|
||||
/// Only dup the ReturnInst if the CallInst is likely to be emitted as a tail
|
||||
/// call.
|
||||
SmallVector<CallInst*, 4> TailCalls;
|
||||
for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) {
|
||||
CallInst *CI = dyn_cast<CallInst>(PN->getIncomingValue(I));
|
||||
|
|
@ -631,14 +634,14 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
|
|||
CallInst *CI = TailCalls[i];
|
||||
CallSite CS(CI);
|
||||
|
||||
// Conservatively require the attributes of the call to match those of
|
||||
// the return. Ignore noalias because it doesn't affect the call sequence.
|
||||
// Conservatively require the attributes of the call to match those of the
|
||||
// return. Ignore noalias because it doesn't affect the call sequence.
|
||||
unsigned CalleeRetAttr = CS.getAttributes().getRetAttributes();
|
||||
if ((CalleeRetAttr ^ CallerRetAttr) & ~Attribute::NoAlias)
|
||||
continue;
|
||||
|
||||
// Make sure the call instruction is followed by an unconditional branch
|
||||
// to the return block.
|
||||
// Make sure the call instruction is followed by an unconditional branch to
|
||||
// the return block.
|
||||
BasicBlock *CallBB = CI->getParent();
|
||||
BranchInst *BI = dyn_cast<BranchInst>(CallBB->getTerminator());
|
||||
if (!BI || !BI->isUnconditional() || BI->getSuccessor(0) != BB)
|
||||
|
|
@ -655,9 +658,6 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) {
|
|||
BB->eraseFromParent();
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
|||
Loading…
Reference in New Issue