[llvm-commits] [llvm] r122228 - /llvm/trunk/lib/CodeGen/MachineVerifier.cpp

Cameron Zwarich zwarich at apple.com
Sun Dec 19 20:19:48 PST 2010


Author: zwarich
Date: Sun Dec 19 22:19:48 2010
New Revision: 122228

URL: http://llvm.org/viewvc/llvm-project?rev=122228&view=rev
Log:
MachineVerifier should count landing pad successors as basic blocks rather than
out-edges. Fixes PR8824.

Modified:
    llvm/trunk/lib/CodeGen/MachineVerifier.cpp

Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=122228&r1=122227&r2=122228&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Sun Dec 19 22:19:48 2010
@@ -380,11 +380,13 @@
   const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
 
   // Count the number of landing pad successors.
-  unsigned LandingPadSuccs = 0;
+  SmallPtrSet<MachineBasicBlock*, 4> LandingPadSuccs;
   for (MachineBasicBlock::const_succ_iterator I = MBB->succ_begin(),
-       E = MBB->succ_end(); I != E; ++I)
-    LandingPadSuccs += (*I)->isLandingPad();
-  if (LandingPadSuccs > 1)
+       E = MBB->succ_end(); I != E; ++I) {
+    if ((*I)->isLandingPad())
+      LandingPadSuccs.insert(*I);
+  }
+  if (LandingPadSuccs.size() > 1)
     report("MBB has more than one landing pad successor", MBB);
 
   // Call AnalyzeBranch. If it succeeds, there several more conditions to check.
@@ -402,11 +404,11 @@
         // It's possible that the block legitimately ends with a noreturn
         // call or an unreachable, in which case it won't actually fall
         // out the bottom of the function.
-      } else if (MBB->succ_size() == LandingPadSuccs) {
+      } else if (MBB->succ_size() == LandingPadSuccs.size()) {
         // It's possible that the block legitimately ends with a noreturn
         // call or an unreachable, in which case it won't actuall fall
         // out of the block.
-      } else if (MBB->succ_size() != 1+LandingPadSuccs) {
+      } else if (MBB->succ_size() != 1+LandingPadSuccs.size()) {
         report("MBB exits via unconditional fall-through but doesn't have "
                "exactly one CFG successor!", MBB);
       } else if (!MBB->isSuccessor(MBBI)) {
@@ -424,7 +426,7 @@
       }
     } else if (TBB && !FBB && Cond.empty()) {
       // Block unconditionally branches somewhere.
-      if (MBB->succ_size() != 1+LandingPadSuccs) {
+      if (MBB->succ_size() != 1+LandingPadSuccs.size()) {
         report("MBB exits via unconditional branch but doesn't have "
                "exactly one CFG successor!", MBB);
       } else if (!MBB->isSuccessor(TBB)) {





More information about the llvm-commits mailing list