Skip over debug info when trying to merge two return BBs.
authorBill Wendling <isanbard@gmail.com>
Sun, 14 Mar 2010 10:40:55 +0000 (10:40 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 14 Mar 2010 10:40:55 +0000 (10:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98491 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SimplifyCFGPass.cpp

index 62f34a2ee06802b4bd17a8aa58186fe912815a1c..952d1a8ffb84ef18be2f08c353440f7af397af71 100644 (file)
@@ -26,6 +26,7 @@
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Module.h"
 #include "llvm/Attributes.h"
 #include "llvm/Support/CFG.h"
@@ -210,12 +211,16 @@ static bool MergeEmptyReturnBlocks(Function &F) {
       // Check for something else in the block.
       BasicBlock::iterator I = Ret;
       --I;
-      if (!isa<PHINode>(I) || I != BB.begin() ||
-          Ret->getNumOperands() == 0 ||
-          Ret->getOperand(0) != I)
+      // Skip over debug info.
+      while (isa<DbgInfoIntrinsic>(I) && I != BB.begin())
+        --I;
+      if (!isa<DbgInfoIntrinsic>(I) &&
+          (!isa<PHINode>(I) || I != BB.begin() ||
+           Ret->getNumOperands() == 0 ||
+           Ret->getOperand(0) != I))
         continue;
     }
-    
+
     // If this is the first returning block, remember it and keep going.
     if (RetBlock == 0) {
       RetBlock = &BB;