Linux and aliasing?
Richard Henderson
rth@cygnus.com
Fri Jun 4 15:02:00 GMT 1999
This thread is huge, and there is obviously a bit of bile swilling about,
so I probably won't read it all. However, I will point out one thing --
On Thu, Jun 03, 1999 at 11:02:35PM -0700, Linus Torvalds wrote:
> The extremely straightforward rule that at least I would advocate is _so_
> straightforward as to be almost scary:
> - if there is a pointer cast, that pointer cast invalidates all
> type-based alias information.
Doing what you want is actually very hard for GCC right now. Consider
int i;
short s, *ps = (short *)&i;
i = 0;
s = *ps;
Due to a long-ago quirk of history, GCC processes the abstract syntax
tree one statement at a time, so the fact of the cast is long gone by
the time we do the dereference. Mark got around this problem by
annotating the memories as we create them, which is good enough to pass
legal muster, but not good enough for what you want.
To do what you want, we'd have to annotate pointers instead of memories
and then do global data flow analysis to find out what addresses have
been "infected" by the cast. Doing anything on a local scale wouldn't
be good enough, I don't think, to handle code coming in from inlines.
Now, we do want to do some of this, since if you can do global data
flow analysis, you can propogate points-to data that gets you even
better alias info than what we have now. We'd just fall back on type
information for lack of interprocedural alias info.
But something like that is a long way off.
r~
More information about the Gcc
mailing list