diff options
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 1ac459d..052316f 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -2102,6 +2102,7 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB, bool &ModifiedDT return false; PHINode *PN = nullptr; + ExtractValueInst *EVI = nullptr; BitCastInst *BCI = nullptr; Value *V = RetI->getReturnValue(); if (V) { @@ -2109,6 +2110,14 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB, bool &ModifiedDT if (BCI) V = BCI->getOperand(0); + EVI = dyn_cast<ExtractValueInst>(V); + if (EVI) { + V = EVI->getOperand(0); + if (!std::all_of(EVI->idx_begin(), EVI->idx_end(), + [](unsigned idx) { return idx == 0; })) + return false; + } + PN = dyn_cast<PHINode>(V); if (!PN) return false; @@ -2122,7 +2131,9 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB, bool &ModifiedDT if (PN) { BasicBlock::iterator BI = BB->begin(); // Skip over debug and the bitcast. - do { ++BI; } while (isa<DbgInfoIntrinsic>(BI) || &*BI == BCI); + do { + ++BI; + } while (isa<DbgInfoIntrinsic>(BI) || &*BI == BCI || &*BI == EVI); if (&*BI != RetI) return false; } else { |