]> granicus.if.org Git - llvm/commitdiff
[TRE] Add assertion for folding trivial return block
authorXin Tong <trent.xin.tong@gmail.com>
Sat, 17 Jun 2017 16:55:12 +0000 (16:55 +0000)
committerXin Tong <trent.xin.tong@gmail.com>
Sat, 17 Jun 2017 16:55:12 +0000 (16:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305637 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/TailRecursionElimination.cpp

index 93c4b57514cd5eeb4fc4dca0576d189b68bd764c..365566c07f4a4abeadf4e6aeaabbfaf0b20e6f72 100644 (file)
@@ -677,6 +677,10 @@ static bool foldReturnAndProcessPred(BasicBlock *BB, ReturnInst *Ret,
                                      const TargetTransformInfo *TTI) {
   bool Change = false;
 
+  // Make sure this block is a trivial return block.
+  assert(BB->getFirstNonPHIOrDbg() == Ret &&
+         "Trying to fold non-trivial return block");
+
   // If the return block contains nothing but the return and PHI's,
   // there might be an opportunity to duplicate the return in its
   // predecessors and perform TRE there. Look for predecessors that end