dg icon indicating copy to clipboard operation
dg copied to clipboard

`ret` and Line number as a slicing criteria isn't working

Open aagontuk opened this issue 2 years ago • 1 comments

I am trying to slice following example (Adding line number for convenience):

     1  #include <stdio.h>
     2
     3  int main(int argc, char *argv[]) {
     4      int x = 10, y = 20, z = 30;
     5
     6      z = x + 10;
     7      z = z + 1;
     8
     9      y = 50;
    10
    11      return z;
    12  }

I am trying to slice on return statement in following way:

$ clang -g -c -emit-llvm example.c
$ ./llvm-slicer -c ret example.bc

llvm-slicer is giving following output:

No reachable slicing criteria: '' 'ret'
[llvm-slicer] saving sliced module to: example.sliced

I am getting same output when I try to slice using line numbers. If I give -c 7:z I am getting following output:

No reachable slicing criteria: '' '7:z'
[llvm-slicer] saving sliced module to: example.sliced

But if I use a function call site as a slicing criteria it is generating correct slice. Both -c foo and -c 7:z is working, given that foo is called in line 7 passing z as parameter.

aagontuk avatar Nov 14 '21 03:11 aagontuk

This looks like a bug, thaks for reporting it.

For both -c 7:z and -sc 7#z the criteria get parsed correctly, so the problem will be in their matching:

$ tools/llvm-slicer -c '7:z' t.bc -dbg
[39710][llvm - slicer] Searching for slicing criteria values
[39883][llvm - slicer] Criterion file # fun # line # obj ==>  #  # 7 # z
[39907][llvm - slicer] Checking global variables for slicing criteria
[39925][llvm - slicer] Checking all instructions for slicing criteria
No reachable slicing criteria: '' '7:z'
[llvm-slicer] saving sliced module to: t.sliced

mchalupa avatar Nov 16 '21 15:11 mchalupa