This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: making aliases into the middle of a structure
- To: Richard Henderson <rth at cygnus dot com>, Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: making aliases into the middle of a structure
- From: Zack Weinberg <zack at rabi dot columbia dot edu>
- Date: Fri, 23 Apr 1999 19:27:32 -0400
- cc: egcs at egcs dot cygnus dot com, egcs-patches at egcs dot cygnus dot com
On Fri, 23 Apr 1999 15:23:59 -0700, Richard Henderson wrote:
>On Thu, Apr 22, 1999 at 05:31:38PM -0400, Zack Weinberg wrote:
>> >That would probably be a good idea. alias could accept an arbitrary
>> >expression. If it's an lvalue within a global symbol, it will define
>> >an actual alias, otherwise it could just emit an error or ``construct
>> >a temporary and bind the reference to it'', to put it in C++ terms :-)
>>
>> It turns out to be relatively simple to implement, too (at least if
>> you don't try to construct temporaries). The appended patch is
>> a proof-of-concept; I don't expect it'll make it into 1.2. I had to
>> introduce a new MD macro, ASM_OUTPUT_OFFSET_DEF...
>
>This is a very bad way to implement this. You're hiding from the
>optimizers the fact that you've got two global symbols that alias.
Huh. Why isn't this a problem for the existing symbol-alias
mechanism? And what am I to do about references from another source
file? The intended use of this feature is isolated in a file that
does nothing but export `x' and `y'.
>The only way this will ever work is for you to adjust the DECL_RTL
>of `y' such that the aliasing is visible. You'd have something like
>
> (const (plus (symbol_ref "x") (const_int 42)))
>
>for a global; something obvious for stack-local objects.
Ok, if you don't mind my asking the dumb question, how do I do that?
The tree->rtl conversion isn't exactly documented.
>And of course this is only going to work without -fno-strict-aliasing
>if the programmer makes sure that the types correspond. But that, I
>think, is not your problem.
Maybe I should verify that the types correspond inside decl_attributes.
>If you like to emit `y' as a global symbol too, that's fine.
In this context, it's kinda necessary.
>BTW, you don't need the ifdef in varasm.c if you have a version
>in defaults.h.
The defaults.h version is only defined if SET_ASM_OP is available.
zw