[LLVMdev] How to slice the source code?

Mingliang LIU liuml07 at gmail.com
Fri Mar 29 03:44:15 PDT 2013


It will definitely help me a lot.

Thank you.


On Tue, Mar 26, 2013 at 3:43 PM, Jonas Wagner <jonas.wagner at epfl.ch> wrote:

> Hi,
>
> maybe you can have a look at the CReduce project:
> http://embed.cs.utah.edu/creduce/
>
> 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.
>
> Hope this helps,
> Jonas
>
>
> On Sun, Mar 17, 2013 at 7:25 PM, Mingliang LIU <liuml07 at gmail.com> wrote:
>
>> Hi all,
>>
>> 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:
>>
>> 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.
>>
>>> 1   *for (int i = 0; i < BUFSIZE; i++) {*
>>> 2      *for (int j = 0; j < np; j++)
>>> *3         *buf[i] = ((rank + j) % np);
>>> *4  }
>>
>>
>> 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.
>>
>> Any idea?
>>
>> Thank you!
>>
>> [1] http://en.wikipedia.org/wiki/Program_slicing
>> [2] http://dl.acm.org/citation.cfm?id=802557
>> --
>> Mingliang LIU (刘明亮 in Chinese)
>>
>> PACMAN Group,  Dept. of Computer Science & Technology
>> Tsinghua University, Beijing 100084, China
>> Email: liuml07 at mails.tsinghua.edu.cn
>> Homepage: http://pacman.cs.tsinghua.edu.cn/~liuml07/
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>


-- 
Mingliang LIU (刘明亮 in Chinese)

PACMAN Group,  Dept. of Computer Science & Technology
Tsinghua University, Beijing 100084, China
Email: liuml07 at mails.tsinghua.edu.cn
Homepage: http://pacman.cs.tsinghua.edu.cn/~liuml07/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130329/2920c71a/attachment.html>


More information about the llvm-dev mailing list