[LLVMdev] An unexpected behavior in RegionInfo's block_iterator

Paul Vario paul.paul.mit at gmail.com
Fri May 2 14:26:49 PDT 2014


Hi Fellows,

   I notice an unexpected behavior in RegionInfo's block_iterator. Consider
the following situation: a user creates her own region containing just a
single basic block TheBB, then tries to have the block_iterator to print a
DFS traversal of the region. The expected behavior should be that only the
single basic block TheBB will be printed, but the real behavior is that
block_iterator prints out all the basic blocks of the CFG starting from
TheBB to the end.

    It looks like the issue originates from setting the end iterator to
(BasicBlock *) 0. I understand that the "region" detected by RegionInfo
should never contain a single basic block or even a sequence of basic
blocks. So maybe the above degenerated case is considered "will never
happen"?

    ... ...

    BasicBlock *BB = Func.getARandomBasicBlock;

    Region *R = new Region(BB, BB, RI, DT);
    for (Region::block_iterator i = R->block_begin(),
           e = R->block_end(); i != e; ++i) {
         errs() << (*i)->getName() << "\n";
      }

      ... ...



Best Regards,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140502/aaf19ef1/attachment.html>


More information about the llvm-dev mailing list