Fix a disconcerting bug in Value::isUsedInBasicBlock, which gave wrong answers for blocks larger than 3 instrs.

Also add a unit test. PR15727.

llvm-svn: 179370
This commit is contained in:
Benjamin Kramer
2013-04-12 08:33:11 +00:00
parent e48866969e
commit eee73f5fcf
3 changed files with 48 additions and 1 deletions

View File

@@ -118,7 +118,7 @@ bool Value::isUsedInBasicBlock(const BasicBlock *BB) const {
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
if (std::find(I->op_begin(), I->op_end(), this) != I->op_end())
return true;
if (MaxBlockSize-- == 0) // If the block is larger fall back to use_iterator
if (--MaxBlockSize == 0) // If the block is larger fall back to use_iterator
break;
}