Program Slicing using LLVM?

Hi all...
    I am developing a program slicing framework using LLVM. The idea
is to remove the computation parts from the program and only keep the
parts relevant for the control flow.
For example, in the following C loop.

for (i=0;i<=VAL;)

printf("In the loop");


after slicing...

for (i=0;i<=VAL;)


so basically, all the lines of the program which do not correspond to
the computation are removed or sliced out.

Has someone already worked on this, or are there similar components i
can reuse in my work?

I am planning to create a IntraProcedure Dependence Graph (PDG) and
then traverse along it to identify the relevant parts of the program.
Any ideas?


LLVM has analysis passes that compute post-dominator information, on
which a PDG construction algorithm could be built. I know of two specific
things to be aware of in this area. First, if the program has any
infinite loops using unconditional branches, they won't be post-dominated
by any exit node. If this is a problem for you, you may have to do some
extra work to handle it. Second, programs with multiple return statements
aren't handled correctly; see PR1098. This can be worked around by
using the mergereturn pass.