[llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 6 16:01:01 PDT 2002


Changes in directory llvm/lib/VMCore:

Verifier.cpp updated: 1.38 -> 1.39

---
Log message:

PHI nodes are not allowed to exist with zero incoming values, check that
there aren't any like this.


---
Diffs of the changes:

Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.38 llvm/lib/VMCore/Verifier.cpp:1.39
--- llvm/lib/VMCore/Verifier.cpp:1.38	Thu Sep 19 11:12:19 2002
+++ llvm/lib/VMCore/Verifier.cpp	Sun Oct  6 16:00:31 2002
@@ -17,6 +17,7 @@
 //  * Only phi nodes can be self referential: 'add int %0, %0 ; <int>:0' is bad
 //  * PHI nodes must have an entry for each predecessor, with no extras.
 //  * PHI nodes must be the first thing in a basic block, all grouped together
+//  * PHI nodes must have at least one entry
 //  * All basic blocks should only end with terminator insts, not contain them
 //  * The entry node to a function must not have predecessors
 //  * All Instructions must be embeded into a basic block
@@ -257,6 +258,12 @@
   Assert2(PN.getPrev() == 0 || isa<PHINode>(PN.getPrev()),
           "PHI nodes not grouped at top of basic block!",
           &PN, PN.getParent());
+
+  // Ensure that PHI nodes have at least one entry!
+  Assert1(PN.getNumIncomingValues() != 0,
+          "PHI nodes must have at least one entry.  If the block is dead, "
+          "the PHI should be removed!",
+          &PN);
 
   std::vector<BasicBlock*> Preds(pred_begin(PN.getParent()),
                                  pred_end(PN.getParent()));





More information about the llvm-commits mailing list