Fix bug: TailDup/2003-07-22-InfiniteLoop.ll
authorChris Lattner <sabre@nondot.org>
Wed, 23 Jul 2003 03:32:41 +0000 (03:32 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 23 Jul 2003 03:32:41 +0000 (03:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7243 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/TailDuplication.cpp

index 04736f07e144cf7bc4512e4c1dde55120f31e1f7..eea2096a9ef885f74977e352e022cdb4b9ceb23b 100644 (file)
@@ -76,6 +76,11 @@ bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI) {
   BasicBlock *Dest = BI->getSuccessor(0);
   if (Dest == BI->getParent()) return false;        // Do not loop infinitely!
 
+  // Do not inline a block if we will just get another branch to the same block!
+  if (BranchInst *DBI = dyn_cast<BranchInst>(Dest->getTerminator()))
+    if (DBI->isUnconditional() && DBI->getSuccessor(0) == Dest)
+      return false;                                 // Do not loop infinitely!
+
   // Do not bother working on dead blocks...
   pred_iterator PI = pred_begin(Dest), PE = pred_end(Dest);
   if (PI == PE && Dest != Dest->getParent()->begin())