-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dose this tool can do parameter slice #391
Comments
You should be able to get which parameters are relevant from the dependence graph, so yes, you can use DG to find that out. |
Sorry , maybe my question is too obscure . Find relevant parameters from dependence graph need to read output file and find it out manually . llvm-dda-dump --entry C_bincount --forward --dot --pta=fs -c=x test.bc > out.dot the .bc file is generated from test.c Because the png is too large to display and github not support svg , I can just put link here . |
By getting the information from the dependence graph I meant to use the API of
You probably do not want to use
|
I am sure I want to get the variables affected by # 1 "tmp1.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 341 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "tmp1.c" 2
#include <R_ext/Arith.h>
#include <R_ext/Error.h>
#include <R_ext/Print.h>
#include <R_ext/Utils.h>
#include <Rinternals.h>
#include <Rmath.h>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
# 23 "tmp1.c"
#include <string.h>
static void C_bincount(double *x, R_xlen_t n, double *breaks, R_xlen_t nb, int *count, int right, int include_border) {
R_xlen_t i, lo, hi, nb1 = nb - 1, new;
memset(count, 0, nb1 * sizeof(int));
for (i = 0; i < n; i++) {
lo = 0;
hi = nb1;
if (breaks[lo] <= x[i] && (x[i] < breaks[hi] || (x[i] == breaks[hi] && include_border))) {
while (hi - lo >= 2) {
new = (hi + lo) / 2;
if (x[i] > breaks[new] || (!right && x[i] == breaks[new])) {
lo = new;
} else {
hi = new;
}
}
count[lo]++;
}
}
}
SEXP C_BinCount(SEXP x, SEXP breaks, SEXP right, SEXP lowest) {
x = PROTECT(coerceVector(x, REALSXP));
breaks = PROTECT(coerceVector(breaks, REALSXP));
R_xlen_t n = XLENGTH(x), nB = XLENGTH(breaks);
int sr = asLogical(right), sl = asLogical(lowest);
if (sr == NA_INTEGER) {
error(("invalid '%s' argument"), "right");
}
if (sl == NA_INTEGER) {
error(("invalid '%s' argument"), "include.lowest");
}
SEXP counts = PROTECT(allocVector(INTSXP, nB - 1));
C_bincount(REAL(x), n, REAL(breaks), nB, INTEGER(counts), sr, sl);
UNPROTECT(3);
return counts;
} The sliced result static void C_bincount(double *x, R_xlen_t n, double *breaks, R_xlen_t nb, int *count, int right, int include_border) {
for (i = 0; i < n; i++) {
lo = 0;
if (breaks[lo] <= x[i] && (x[i] < breaks[hi] || (x[i] == breaks[hi] && include_border))) {
while (hi - lo >= 2) {
new = (hi + lo) / 2;
if (x[i] > breaks[new] || (!right && x[i] == breaks[new])) {
lo = new;
} else {
hi = new;
}
}
count[lo]++;
}
}
}
SEXP C_BinCount(SEXP x, SEXP breaks, SEXP right, SEXP lowest) {
x = PROTECT(coerceVector(x, REALSXP));
breaks = PROTECT(coerceVector(breaks, REALSXP));
R_xlen_t n = XLENGTH(x), nB = XLENGTH(breaks);
int sr = asLogical(right), sl = asLogical(lowest);
if (sr == NA_INTEGER) {
error(("invalid '%s' argument"), "right");
}
if (sl == NA_INTEGER) {
error(("invalid '%s' argument"), "include.lowest");
}
C_bincount(REAL(x), n, REAL(breaks), nB, INTEGER(counts), sr, sl);
UNPROTECT(3);
} The declaration is missing , is this normal to get the sliced one with no declaration ? |
And is the declaration present if you skip slicing? That is, just compile the code to LLVM and then (without slicing) use your tool to generate the source code? |
The forward slice in DG does backward slicing to make the slice executable, is that what you want? |
Yes , I use |
Oh, I thought that the output was from your clang-based tool. If the output is from the |
If I want to slice only parameter with criterion , like below
And I want to only get "breaks,hi,lo......" parameters which relate to variable x
Because the llvm-slicer can get "code" relate to x , I think there may be a way to find only related parameters
The text was updated successfully, but these errors were encountered: