how to get the field_id for member of structure in gcc front end

2006-03-28 Thread Tianwei Sheng
Hi all:
   for the following statement, how can I get the field_id info for
the structure member
  struct{
  int a;
  int b;
} pair;
int main()
{
  int * p = &pair.a;
}

It seems that we can't get the field_id info because of address taken
operator. it treats the "&pair.a" as "&pair + ofset of a".
I am not familiar with the gcc tree. any one know this?

thanks.

tianwei


Re: how to get the field_id for member of structure in gcc front end

2006-03-28 Thread Tianwei Sheng
I need the field_info to help in alias analysis. for example:
int *p = &pair.a;
int *q = &pair.b;

then if I can set length of "*p" to 4,ofset is '0' . for "*q" to
"8,4". also I know that p definitly points to pair.a and q points to
pair.b, then i can say "*p" and "*q" are not aliased with each other.

thanks.

tianwei

On 3/29/06, Tianwei Sheng <[EMAIL PROTECTED]> wrote:
> Hi all:
>for the following statement, how can I get the field_id info for
> the structure member
>   struct{
>   int a;
>   int b;
> } pair;
> int main()
> {
>   int * p = &pair.a;
> }
>
> It seems that we can't get the field_id info because of address taken
> operator. it treats the "&pair.a" as "&pair + ofset of a".
> I am not familiar with the gcc tree. any one know this?
>
> thanks.
>
> tianwei
>


--
Sheng, Tianwei
Inst. of High Performance Computing
Dept. of Computer Sci. & Tech.
Tsinghua Univ.


Re: how to get the field_id for member of structure in gcc front end

2006-03-29 Thread Tianwei Sheng
but it's my be too aggressive. as you said, you mean "base,ofst" rule is enough,
a more safe method is "base,ofst, lenght" rule. p still can point to
pair.b if p is update by
assignment or other ways.

we should ensure *p will never exceed the length, otherwilse it will 
fail to do alias analysis. our compiler will use "base,ofst,lenght"
rule for every indirect memop
to do alias analysis. now we can only set the lenght to the size of structure.
for example,
int *p = &pair.a
int *q = &pair.a;;
p = p+1;
*p = 1;
*q = 2;

(*p) and (*q) are not aliased because of p = p +1; now p points to pair.b.

any way, I  will think over your "base,ofst" rule.

tianwei
On 3/29/06, Mike Stump <[EMAIL PROTECTED]> wrote:
> On Mar 28, 2006, at 11:03 PM, Tianwei Sheng wrote:
> > I need the field_info to help in alias analysis. for example:
> > int *p = &pair.a;
> > int *q = &pair.b;
> >
> > then if I can set length of "*p" to 4,ofset is '0' . for "*q" to
> > "8,4". also I know that p definitly points to pair.a and q points to
> > pair.b, then i can say "*p" and "*q" are not aliased with each other.
>
> My take, a + 0 != a + 8, so they point to different areas.  Since you
> already have the offset information, you already have the information
> you need.
>
> Kinda like &a[4] != &a[5], even though the type is the same.
>