Don't block basic block with only SwitchInst to fold into predecessors.
[oota-llvm.git] / lib / Transforms / Utils / SimplifyCFG.cpp
index 6c14a643e8153f32bedf8ec3a82732420246bc64..08c8a3f65e5183acea80021958d5cd67d293c43a 100644 (file)
@@ -1887,7 +1887,11 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
 
       // If the block only contains the switch, see if we can fold the block
       // away into any preds.
-      if (SI == &BB->front())
+      BasicBlock::iterator BBI = BB->begin();
+      // Ignore dbg intrinsics.
+      while (isa<DbgInfoIntrinsic>(BBI))
+        ++BBI;
+      if (SI == &*BBI)
         if (FoldValueComparisonIntoPredecessors(SI))
           return SimplifyCFG(BB) || 1;
     }