970125-0.f

Craig Burley burley@gnu.org
Wed Jun 3 10:45:00 GMT 1998


>  > Well, it's useful in that that's how it has worked for a very long
>  > time, and that's what various front ends expect.
>I meant from a code generation standpoint.  What do you expect to do with
>a pointer to a stack slot that holds the address of the object?

In g77's case, it passes the pointer as an argument to a procedure.
It doesn't care if the stack slot is destroyed upon return from
that procedure.

I don't know exactly what gcc has done about this, though; expand_expr's
ADDR_EXPR case doesn't make it clear to me, offhand, what scope/lifetime
it gives the stack slot.  Perhaps there's a separate way this is
handled for CALL_EXPR's subexpressions.  Or maybe the stack slot is
just "permanently" allocated to hold this value, which would be a
waste for g77.

In any case, just making it consistent with past gcc behavior should
be fine.

(Sorry if I'm not making sense, I'm cracking up watching this squirrel
try to figure out this new "squirrel-go-round" we just put up a couple
of feet outside my office window a couple of weeks back.  It has four
~foot-long rods with corn cobs dangling at the end of each one, connected
to a hub that spins freely, which is mounted so it is perpendicular to
the ground.  Now that one cob has been stripped clean, it's always the
lightest one, so another one won't "rest" at the top, where the squirrel
can easily reach it, so watching it try and figure out how to balance,
stretch, hold onto, slide to/from, a cob to get at the kernels is really
fun.  It's getting better at it, too.  No bi-squirrel raids yet, but
I've been told they sometimes will cooperate.  :)

>Regardless, I've tweaked the compiler to shove the pointer into a
>stack slot, then give you back the address of that stack slot.  I don't
>have any way to test whether or not the generated code is actually
>correct though.

I think I might.  I'm working on the same test case, for other
reasons I posted before, so between my Intel and Alpha boxes,
I should be able to determine whether the code is basically
working over the next week or so (allowing for a new snapshot
with your patch to come out).

Unfortunately, though I've wanted for years to really nail this down,
I haven't really looked into the handling, especially optimization,
of ADDR_EXPR vs. REFERENCE_EXPR or whatever.  Usually, when g77 wants
to pass a pointer to something, it is really passing it by reference;
there is no need to worry about that thing being referenced via
that pointer *after* the procedure returns, which can be important
for optimization.  Another case of my being generally too busy making
g77 work to make it work really well.

        tq vm, (burley)



More information about the Gcc-bugs mailing list