This is the mail archive of the gcc@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: strict aliasing warning


On Wed, Nov 29, 2006 at 11:02:51AM -0800, Silvius Rus wrote:
> 
> I wrote some code (not released yet) that improves the accuracy of 
> -Wstrict-aliasing using tree-ssa-alias information.  The primary idea 
> was to tell the programmer "go fix the types of variables x and y at 
> lines ..." when -fstrict-aliasing breaks their code.

Cool.

> It occurred to me that part of this code could be used as a 
> preconditioner to aggressive optimization that would normally require 
> -fstrict-aliasing, so this more aggressive optimization can then be 
> performed selectively on individual functions even with 
> -fno-strict-aliasing on the command line.  I fear a little though that 
> the functions which are provably free of cross-type aliasing might also 
> not benefit much from -fstrict-aliasing, but I have very little 
> experience with C compilers and GCC.  Is this something worth pursuing?

If you first prove that there is no cross-type aliasing, then turn on
-fstrict-aliasing, it seems to me that your alias sets won't change at
all.  The reason is that if there is a change, it means that you
eliminated an aliasing possibility based on the fact that it's not
allowed because of cross-type aliasing, which you said you proved there
is none of.

There have been concerns expressed in the past that if gcc checks for
strict aliasing violations, users will be upset when it misses some
violations but does optimization that breaks an ill-formed program.
I personally am not that worried about that; I think that it will help
train users if they see warning messages about blatant violations, to
the point where they will be less likely to create subtle, hard-to-detect
violations.


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