<div dir="ltr">Dear John,<div><br></div><div>Thanks for your reply! I understand. </div><div><br></div><div>My question is more subtle. Could I obtain the LLVM IR for a specific stmt ?</div><div><br></div><div>For example, </div><div><br></div><div>void foo()</div><div>{</div><div> ... // some stmts</div><div><br></div><div> for(...) {</div><div> ...</div><div> }</div><div><br></div><div> ... // some stmts</div><div>} </div><div><br></div><div>Once I built the Clang AST, there is a node to represent that for-loop, say nodeFor. </div><div><br></div><div>Then I could take nodeFor as parameter to call buildCFG() to generate the source code level CFG of that for-loop.</div><div><br></div><div>Could I use a similar method to get the LLVM IR for that for-loop? Again I do not want to generate LLVM IR for other stmts other than that for-loop.</div><div>Hope my question is clear.</div><div><br></div><div>Sincerely</div><div>xiaohui </div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 17, 2016 at 12:27 PM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><span class="">
<div>On 2/15/16 8:57 PM, xiaohui chen via
cfe-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Dear All:
<div><br>
</div>
<div><span>I am working on Clang/LLVM and interested to know if
there is a programmatic way to extract the CFG of a specific</span></div>
<div><span>node in AST like a for loop? </span></div>
<div><span><br>
</span></div>
<div><span> I am aware of </span><code>-emit-llvm</code><span>option,
but it will apply on the whole TU.</span><span><br>
</span></div>
<div><span><br>
</span></div>
<div><span>For example,</span></div>
<div><span>we could use </span><span>CFG</span><span>::</span><span>buildCFG to extract the
source level CFG of a specific node.</span></div>
<div><span>Is there a counterpart API to extract the
LLVM IR level CFG of a specific node?</span></div>
</div>
</blockquote>
<br></span>
The LLVM IR expresses each function as a set of basic blocks with an
explicit CFG. In other words, the LLVM IR encodes the CFG of each
function explicitly. If you have the LLVM IR of a function, you
already have the CFG.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div><span><br>
</span></div>
<div><span>Sincerely</span></div>
<div><span>xiaohui</span></div>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
cfe-dev mailing list
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
<pre cols="72">--
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
</font></span></div>
</blockquote></div><br></div>