This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: making aliases into the middle of a structure


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.

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

If you like to emit `y' as a global symbol too, that's fine. 

BTW, you don't need the ifdef in varasm.c if you have a version
in defaults.h.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]