diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-06 17:44:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-06 17:44:17 +0000 |
commit | a9e7781b3b8e457946491529816feab73c66d774 (patch) | |
tree | acf07b39de747ac557a1307fe5171f458d7c1e1c /lib/VMCore/BasicBlock.cpp | |
parent | ebeebecad264d9d6f2429ceff596fad08747ae35 (diff) |
Find bugs sooner rather than later. In this case, don't allow the creation
of instructions that don't have a first-class or void type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14646 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/BasicBlock.cpp')
-rw-r--r-- | lib/VMCore/BasicBlock.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 587abf60aa..d3df1d1d71 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -130,17 +130,11 @@ void BasicBlock::dropAllReferences() { void BasicBlock::removePredecessor(BasicBlock *Pred) { assert(find(pred_begin(this), pred_end(this), Pred) != pred_end(this) && "removePredecessor: BB is not a predecessor!"); - if (!isa<PHINode>(front())) return; // Quick exit. - - pred_iterator PI(pred_begin(this)), EI(pred_end(this)); - unsigned max_idx; - - // Loop over the rest of the predecessors until we run out, or until we find - // out that there are more than 2 predecessors. - for (max_idx = 0; PI != EI && max_idx < 3; ++PI, ++max_idx) /*empty*/; + PHINode *APN = dyn_cast<PHINode>(&front()); + if (!APN) return; // Quick exit. // If there are exactly two predecessors, then we want to nuke the PHI nodes - // altogether. We cannot do this, however if this in this case however: + // altogether. However, we cannot do this, if this in this case: // // Loop: // %x = phi [X, Loop] @@ -151,10 +145,10 @@ void BasicBlock::removePredecessor(BasicBlock *Pred) { // basic block. The only case this can happen is with a self loop, so we // check for this case explicitly now. // + unsigned max_idx = APN->getNumIncomingValues(); assert(max_idx != 0 && "PHI Node in block with 0 predecessors!?!?!"); if (max_idx == 2) { - PI = pred_begin(this); - BasicBlock *Other = *PI == Pred ? *++PI : *PI; + BasicBlock *Other = APN->getIncomingBlock(APN->getIncomingBlock(0) == Pred); // Disable PHI elimination! if (this == Other) max_idx = 3; |