Regions according to LLVM

Hi all,

I'm working with regions, and I was surprised by the region set of this function:

define void @foo() {
  br i1 false, label %loop, label %end

br i1 false, label %loop, label %end

ret void

.dot file as generated by opt —view-regions attached. Essentially, there are 3 regions: one that has the whole function, one that has the entry block and the loop, and one that has the loop only.

The second one puzzles me. The definition of single-entry single-exit region that I know of uses edges instead of blocks but can rather easily be extended to blocks: edge A dominates edge B, edge B postdominates edge A, and any cycle containing edge A also contains edge B.

I'm confused because in the case of the second region, the loop block does not postdominate the entry, and I can't think of a pair of edges around these that work without being equivalent to the last region.

Am I missing something?

Félix (1.11 KB)

Hi Felix,

you may want to try the option -only-simple-regions when looking at the regions, which illustrates that there are two kind of regions, simple ones (which follow what you expect) and extended regions (which do not have a simple exit edge, but which can be transformed to a single region by inserting a single BB).

For details, have a look into the RegionInfo.h file, starting line 185 with: /// @brief A single entry single exit Region.


Thank you for your answer.