Type based alias analysis
John Milford
jwm@CSUA.Berkeley.EDU
Sun Jun 13 18:01:00 GMT 1999
"Martin v. Loewis" <martin@mira.isdn.cs.tu-berlin.de> wrote:
> > With all the recent posts I have been trying to think of
> > a good way to make the transition easier. It sounds like adding
> > in warnings for non-conforming accesses would be very difficult,
> > but could the compiler document all of the assumptions it makes based
> > on this analysis by inserting code very much like an assert?
>
> I don't think it could. At run-time, you would have to keep track of
> what type is supposed to hide behind a certain memory location. That
> would radically change the layout of structures and array, and break a
> lot of programs.
>
> Regards,
> Martin
I was thinking of something a little different. For instance
with the following function:
int foo(int *ip, float *fp) {
*ip = 10;
*fp = 3.4;
return(*ip);
}
type based alias analysis will assume that ip and fp don't point
to the same location, so the compiler would turn this into something
equivalent to:
int foo(int *ip, float *fp) {
assert(ip != fp);
*ip = 10;
*fp = 3.4;
return(*ip);
}
Basically, ever time the compiler makes the assumption that
two pointers don't alias the same memory it would insert a check
that would verify the assumption is correct at runtime. This would
require no type information at runtime to be inserted, only extra
code space, and as far as I can tell it would be link compatable
with code generated without the checks.
--John
More information about the Gcc
mailing list