SVF-tools / Test-Suite

PTABen: Micro-benchmark Suite for Pointer Analysis
72 stars 38 forks source link

The second assertion MAYALIAS(z, &obj1) of `cs_tests/cs8.c` should be NOALIAS? #30

Open taquangtrung opened 3 years ago

taquangtrung commented 3 years ago

Hi,

For this test case, I think the second assertion MAYALIAS(z, &obj1) should be NOALIAS?

This is because in the if-else branch, both a and b are equal to &z, and when calling foo(a,b), the *b will be updated to &obj2. Hence, z and &obj2 are MayAlias, but z and &obj1 are NoAlias.

// cs_tests/cs8.c

#include "aliascheck.h"
int obj1,obj2;
void foo(int **p, int **q){
    *p = &obj1;
    *q = &obj2;
}

int main(){
    int **a,**b,*x,*y,*z;
    if(a){
        a = &x;
        b = &y;
    }
    else{
        a = &z;
        b = &z;
    }
    foo(a,b);
    MAYALIAS(x,&obj1);
    MAYALIAS(z,&obj1);
    MAYALIAS(y,&obj2);
    MAYALIAS(z,&obj2);
    NOALIAS(x,&obj2);

}
yuleisui commented 3 years ago

Yes, you are correct. But the underlying analysis is calling-context-sensitive but not branch-insensitive.... Feel free to develop more precise analysis derived from this case:)