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]
Other format: [Raw text]

Re: Aliasing brokenness (Was: Re: [patch RFC] SH: UseFRAME_GROWS_DOWNWARD)


On Tue, 2005-07-19 at 16:35 +0000, Joseph S. Myers wrote:
> On Tue, 19 Jul 2005, Daniel Berlin wrote:
> 
> > > Look at execute/20000603-1.c .  There is a union of struct s1 and struct s2,
> > > but nonoverlapping_component_refs_p still comes to the wrong conclusions.
> > >    
> > 
> > This case is questionable, and the current committee proposal seems to
> > be "this is not allowed".
> 
> There is no "current committee proposal". 

True enough, i'm sorry i used inaccurate language.

>  There are lots of individual 
> suggestions and nothing approaching consensus since the DR was submitted 
> five years ago. 
>  Furthermore, most of the discussions are looking at the 
> simple case of a union of int and double where the intent not to allow 
> aliasing when int and double pointers are used is clear - not the case of 
> common initial subsequences (which may serve as some sort of exception to 
> the type-based aliasing rules) where the best indication of committee 
> intent we have is the second example in example 3 in 6.5.2.3 saying "The 
> following is not a valid fragment (because the union type is not visible 
> within function f):" and thereby suggesting without explicitly saying that 
> if the type were visible in f the code would be valid.  No doubt if a 
> consensus is reached about the simple cases then the committee will work 
> out what should be done with common initial subsequences and whether that 
> example needs changing.

In this case, we actually changed alias.c to match what we actually
assume at the tree level, regardless of what the current intent is.

I'll note that there is no good place to draw a distinction, which is
probably why this DR has been open so long.

If you allow the case in 20000603-1.c, why not let the union be in some
other module?

And if you allow that, you can never know that two pieces of memory
incoming to a function don't point to the same thing, as long as you
have things you can't see that can call your function (library calls,
etc).

Such a limitation would be disastrous to optimization for no real
benefit to the user (since most *don't* actually do this).

Making rules about single modules isn't a bright line in the face of
most compilers anymore, and end up not being implementable in any sane
way.

If you want to come up with a rule somewhere in the middle to follow in
GCC that is a bright line that you think users want, than come up with
it, and i'll implement it.

Otherwise, i think the line drawn at "be consistent at the RTL and tree
level, and assume the user isn't toying with us when he hands us
pointers" is fine.

If we find somewhere we are breaking code and the user really needs to
be doing this, we should give them a flag to do it.

Or they could, you know, always just do what any sane person would do,
and pass a pointer to the union so we can see they are union accesses.

--Dan


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