[LLVMdev] Make LoopBase inherit from "RegionBase"?

ether etherzhhb at gmail.com
Fri Jan 8 18:43:02 PST 2010


hi Tobi

On 2010-1-9 3:27, Tobias Grosser wrote:
> On 01/08/10 14:20, ether wrote:
>> sorry that i forgot to change the subjuect
>
> Hi ether,
>
> sounds interesting. Actually is/may be some kind of region. If you 
> want you can have a look at the analysis, that I wrote. It is not yet 
> finished, not completely documented and work in progress. However the 
> first big comment might be interesting for you. Or seeing the results of
> opt -regions -analyze
>
> The git repo to see it is here:
> http://repo.or.cz/w/llvm-complete/tobias-sandbox.git/shortlog/refs/heads/region 
>
that make sense to me,  and if you make your Region class a subclass of  
LoopBase, the codes like "addChildLoop" and "getLoopDepth()"  from 
LoopBase may help you a lot to manipulate regions in the later 
optimization passes (of course, we should give it a more meaningful name 
like "addChildRegion") :)

and i think if we ignore the "goto" statement and "return" statement (i 
remember theres a pass in llvm that will make a function only return in 
one basicblock) in loops, loops also will have only one exit block, so 
we can treat loop as a special region that have back edge, and we can 
say, a loop must be a region but a region not necessary a region.

we can read something about this in <<Compilers: Principles Techniques 
and Tools, Second Edition>>, 9.7 region-based analysis.

best regards
--ether
>
> I will think about this and maybe reply again.
>
> Tobi
>
>
>> hi all,
>>
>> On 2010-1-7 0:11, John Mosby wrote:
>>> In LLVM we could add support for generalized CFG regions and
>>> RegionPasses. A region is a part of the CFG. The only information we
>>> have is, that it has one entry and one exit, this it can be optimized
>>> separately.
>>> I think this is the best way to add region analysis. I must admit this
>>> approach
>>> helps me on another, similar project I'm working on in parallel (no
>>> pun intended).
>>> Tobias, is this how you are architecting your region analysis already?
>>>
>>> John
>>>
>>
>> i just implementing the skeleton of Region/RegionInfo like LoopBase and
>> LoopInfoBase[1] in the llvm existing codes, and found that theres lots
>> of common between "Region" and "Loop":
>>
>> 1. both of them are consist of several BasicBlocks
>> 2. both of them have some kind of nested structures, so both a loop and
>> a region could have parent or childrens
>> 3. both of them have a BasicBlocks(header of a loop and "entry" of a
>> region) that dominates all others
>>
>> and the Region class will have the most stuffs very similar in LoopBase,
>> like: ParentRegion, SubRegions, Blocks, getRegionDepth(),
>> getExitBlock(), getExitingBlock() ......
>>
>> so, could us just treat "Loop" as some kind of general "Region" of
>> BasicBlocks, and make Loop and Region inherit from "RegionBase"?
>>
>>
>> [1] http://llvm.org/doxygen/LoopInfo_8h-source.html
>>
>> best regards
>> --ether
>
>



More information about the llvm-dev mailing list