[LLVMbugs] [Bug 15727] New: Value::isUsedInBasicBlock is buggy.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 11 13:56:04 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15727

            Bug ID: 15727
           Summary: Value::isUsedInBasicBlock is buggy.
           Product: libraries
           Version: 3.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Core LLVM classes
          Assignee: unassignedbugs at nondot.org
          Reporter: fjia at cs.ucsd.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I happened to use Value::isUsedInBasicBlock(const BasicBlock *BB) const.

I noticed that the function always returns false when the basic block size is
larger than 3. So I checked the source of Value.c and found there is a bug
there.

113   unsigned MaxBlockSize = 3;                                                
114   for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E;
++I) {    
115     if (std::find(I->op_begin(), I->op_end(), this) != I->op_end())         
116       return true;                                                          
117     if (MaxBlockSize-- == 0) // If the block is larger fall back to
use_iterator    
118       break;                                                                
119   }                                                                         
120                                                                             
121   if (MaxBlockSize != 0) // We scanned the entire block and found no use.   
122     return false;  

If block size is larger than 3, in line 117, the loop is breaked out, and
MaxBlockSize = -1. In line 121, MaxBlockSize != 0 is true, and false is
returned. This explains why the function always returns false when the block
size is larger than 3.

The potential bug fix is

117   if (--MaxBlockSize == 0) // If ...

Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130411/b96f41ce/attachment.html>


More information about the llvm-bugs mailing list