[LLVMdev] Regions according to LLVM

Tobias Grosser tobias at grosser.es
Thu Jul 16 22:08:11 PDT 2015


On 07/16/2015 08:01 PM, Félix Cloutier wrote:
> 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
>>
>> loop:
>>   br i1 false, label %loop, label %end
>>
>> 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?

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.

Tobias




More information about the llvm-dev mailing list