Removal of useless null pointer checks

John Vickers John.Vickers@PaceMicro.com
Wed Sep 22 08:52:00 GMT 1999


Jeffrey A Law wrote:
> 
>   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.

I was under the impression that the standards didn't distinguish in this matter
between free-standing & hosted, so from that point of view, the compiler could
do what it liked anyway.

I was thinking of embedded stuff, like having ROM or tables of exception vectors
at address zero, but some of it seems to apply to the Vax compat & RS6000 weirdness
which Kenner mentioned.  In embedded world, external symbols could happily
resolve to 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.

Yeah, that's what I was asking with "very near".

> 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.

Great.

> I was planning to do that anyway based on some conversations I
> had with the Java folks a few months back.

Eeek!  I don't think I want to know.

Regards,

John.


More information about the Gcc-patches mailing list