Removal of useless null pointer checks
Jeffrey A Law
law@cygnus.com
Tue Sep 21 19:10:00 GMT 1999
In message < 37E76FD9.56F681E9@PaceMicro.com >you write:
> The machine might not have an MMU, or any other means of causing a fault.
But you've triggered undefined behavior in a hosted environment. Hmm, in
a non-hosted (aka freestanding) environment it may be reasonable to have things
at address zero.
> Some unfortunate machines require writeable memory or have I/O at
> or very near address zero.
Yes. Very near doesn't count :-) The only address that matters is zero.
This optimization will not consider (mem (plus (reg X) (const_int)) as
defining X to have a nonzero value.
However, I believe it is legitimate to reference address zero in a non-hosted
environment. So we'll need to make this optimization configurable by the
front-end. I was planning to do that anyway based on some conversations I
had with the Java folks a few months back.
> I guess this optimisation won't cause as much grief as the
> strict-aliasing stuff...
> Linux kernel traps null pointers, yes ?
You'll get an oops. Don't ask me how I know :-)
jeff
More information about the Gcc-patches
mailing list