Hi,
I am working on an alias analysis using the points-to information
generated during IPA-PTA. If we look at the varmap varinfo_t array in
gcc/tree-ssa-struct.c, most of the constraint variable info structs
contain a non-null decl field which points to a valid tree in gimple
(which is an SSA variable and a pointer). I am trying to find out a way
to obtain points-to information for pointer expressions. By this, the
concrete example I have in mind is answering the following question:
What does `astruct->aptrfield` points to?
Here I have a concrete example:
#include <stdlib.h>
struct A { char *f1; struct A *f2;};
int __GIMPLE(startwith("ipa-pta"))
main (int argc, char * * argv)
{
struct A * p1;
char * pc;
int i;
int _27;
i_15 = 1;
pc = malloc(100); // HEAP(1)
p1 = malloc (16); // HEAP(2)
p1->f1 = pc;
p1->f2 = p1;
_27 = (int) 0;
return _27;
}
Will give the following correct points-to information:
HEAP(1) = { }
HEAP(2) = { HEAP(1) HEAP(2) }
pc_30 = { HEAP(1) }
p1_32 = { HEAP(2) }
However, there does not seem to be information printed for neither:
p1->f1
p1->f2
which I would expect (or like) something like:
p1_32->0 = { HEAP(1) }
p1_32->64 = { HEAP(2) }
Looking more closely at the problem, I found that some varinfo_t have a
non-null "complex" field. Which has an array of "complex" constraints
used to handle offsets and dereferences in gimple. For this same gimple
code, we have the following complex constraints for the variable p1_32:
main.clobber = p1_32 + 64
*p1_32 = pc_30
*p1_32 + 64 = p1_32
It seems to me that I can probably parse these complex constraints to
generate the answers which I want. Is this the way this is currently
being handled in GCC or is there some other standard mechanism for this?
Thanks!