getExitBlocks returns duplicates in result vector

Hi,

LoopBase::getExitBlocks in LoopInfo.h returns all exit basic blocks by iterating over all blocks of a loop and storing all branch targets
that are outside the loop. This method allows for duplicates in the
result vector, e.g.:

Loop at depth 2 containing: %bb2<header><exit>,%bb1<latch>,%bb3<exit>

where both bb2 and bb3 have bb4 as their exit block.

This loop corresponds to the following common pattern found in C code:
while( c1 <bb2> && c2 <bb3> )
  bb1;
bb4;

In this case, bb4 occurs twice in the result vector. Is this behavior
intended, or should duplicates be avoided.

Harmen

Yes. Try LoopInfo::getUniqueExitBlocks() if you'd like to avoid duplicates.