<div dir="ltr">Hi,<br><br>I have an experimental patch that implements an algorithm to detect control
structures in the CFG, such as If-Then, If-Then-Else, Self-Loop etc.
This analysis is kind of an extension of interval/region analysis to
detect more than just loops. The algorithm and data structures used in
this implementation are based on the description given in "Advanced
Compiler Design and Implementation" -- Steven. S. Muchnik (Section 7.7
"Structural Analysis"). The result of the analysis is a tree called the
control-structure-tree of the control flow graph of the function begin
analysis.<br>
<br>
Typical uses for this analysis are:<br>
1. Perform control flow transformations based on the control structure
tree. Some control transformations are easier to reason about using this
tree.<br>
2. IR to source transformations. Detecting source level constructs in
the CFG is usually useful in generating high level code from an already
reduced IR.<br>
3. Similar to the uses of interval/region analysis, control structure analysis also can be used to speed up data flow analyses.<br>
<br>
The code, although tested and used internally, needs further work:<br>
1. Make it an actual LLVM analysis.<br>
2. Provide a richer set of APIs for updates.<br>
3. Improve analysis time.<br>
<br>
I'm not sure how useful such an analysis would be to the community. If
people find it to be useful, I'm open to working on it further and
submitting it. Any feedback will be appreciated.<br>
<br>
<a href="http://reviews.llvm.org/D17031" rel="noreferrer" target="_blank">http://reviews.llvm.org/D17031</a><br><br>
<div><div class="gmail_signature"><div dir="ltr"> - Vaivaswatha<br></div></div></div>
</div>