<div dir="ltr">Hi,<div><br></div><div style>maybe you can have a look at the CReduce project: <a href="http://embed.cs.utah.edu/creduce/">http://embed.cs.utah.edu/creduce/</a></div><div style><br></div><div style>This project implements many source-to-source transformations of C programs, e.g. removing functions, changing variable names, deleting branches in if-statements, etc. Some of these are purely based on the source code, other use the Clang frontend.</div>

<div style><br></div><div style>Hope this helps,</div><div style>Jonas</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Mar 17, 2013 at 7:25 PM, Mingliang LIU <span dir="ltr"><<a href="mailto:liuml07@gmail.com" target="_blank">liuml07@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 dir="ltr">Hi all,<div><br></div><div>I'm doing the program slicing [1] in LLVM. Now I implemented the Weiser's algorithm [2] in a simple way by writing a plugin to analyze the IR. My final goal is to slice the source code, thus I recorded all the lines of source code to be sliced. The last step is to delete the lines which are not in the program slice. However, I met a problem when deleting the source code directly:</div>




<div><br></div><div>To make it clear, I gave an example following, in which the following lines (underline decoration) can be deleted. We can see that the line 4 should also be deleted, but it's not.</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">




<font face="courier new, monospace"><font color="#0000ff">1</font>   <u>for (int i = 0; i < BUFSIZE; i++) {</u><br></font><font face="courier new, monospace"><font color="#0000ff">2</font>      <u>for (int j = 0; j < np; j++)<br>



</u></font><font face="courier new, monospace"><font color="#0000ff">3</font>         <u>buf[i] = ((rank + j) % np);<br>
</u></font><font face="courier new, monospace"><font color="#0000ff">4</font>  }</font></blockquote><div><br></div><div>I got the LoC info from meta-data of the IR which can be deleted. However, there is no according IR in the first place, which represents the line 4 (whose functionality is to end a block). I'm not familiar with clang and its AST. A friend told me to parse the code using python to find the matching "}" (or END in Fortran) and delete them. I'd like to know if there is an LLVM way to do this.</div>




<div><br></div><div>Any idea?</div><div><br></div><div>Thank you!</div><div><br></div><div><font face="arial, helvetica, sans-serif">[1] </font><a href="http://en.wikipedia.org/wiki/Program_slicing" target="_blank">http://en.wikipedia.org/wiki/Program_slicing</a></div>



<div><font face="arial, helvetica, sans-serif">[2] </font><a href="http://dl.acm.org/citation.cfm?id=802557" target="_blank">http://dl.acm.org/citation.cfm?id=802557</a><span class="HOEnZb"><font color="#888888"><span style="line-height:21px;font-size:14px"><br>


</span>-- </font></span></div><span class="HOEnZb"><font color="#888888">
<font face="arial, helvetica, sans-serif" color="#666666">Mingliang LIU (刘明亮 in Chinese)<br>
<br>PACMAN Group,  Dept. of Computer Science & Technology<br>Tsinghua University, Beijing 100084, China<br>Email: <a href="mailto:liuml07@mails.tsinghua.edu.cn" target="_blank">liuml07@mails.tsinghua.edu.cn</a></font><div>




<font face="arial, helvetica, sans-serif" color="#666666">Homepage: <a href="http://pacman.cs.tsinghua.edu.cn/~liuml07" style="line-height:19px;text-align:center" target="_blank">http://pacman.cs.tsinghua.edu.cn/~liuml07/</a></font></div>





</font></span></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>