From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Henderson To: Zack Weinberg , Alexandre Oliva Cc: egcs@egcs.cygnus.com, egcs-patches@egcs.cygnus.com Subject: Re: making aliases into the middle of a structure Date: Fri, 23 Apr 1999 15:24:00 -0000 Message-id: <19990423152359.F16695@cygnus.com> References: <199904222131.RAA09537@blastula.phys.columbia.edu> <199904222131.RAA09537@blastula.phys.columbia.edu> X-SW-Source: 1999-04/msg00824.html 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~ From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Henderson To: Zack Weinberg , Alexandre Oliva Cc: egcs@egcs.cygnus.com, egcs-patches@egcs.cygnus.com Subject: Re: making aliases into the middle of a structure Date: Fri, 30 Apr 1999 23:15:00 -0000 Message-ID: <19990423152359.F16695@cygnus.com> References: <199904222131.RAA09537@blastula.phys.columbia.edu> X-SW-Source: 1999-04n/msg00830.html Message-ID: <19990430231500.LZhaIWuvAY7226dA0f4F2vOwgeAu6U39fgeQGpQJpWA@z> 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~