diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-06 21:00:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-06 21:00:31 +0000 |
commit | f6ffcb6b713c259992b68d6b328f1b806775b9fb (patch) | |
tree | dee0290224554486f5ac91da7c4b2f13e6173b2e | |
parent | 2a408f06b545a4815666f22a72f62dd38e7ebd10 (diff) |
PHI nodes are not allowed to exist with zero incoming values, check that
there aren't any like this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4044 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Verifier.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 51e0d2dddd..1663ddf6b7 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -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 @@ -258,6 +259,12 @@ void Verifier::visitPHINode(PHINode &PN) { "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())); // Loop over all of the incoming values, make sure that there are |