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]

Re: Type-based aliasing



These are the interesting bugs which have come up in the alias code.


1.  The alias code inherited from gcc2 looks at the form of an address
to determine whether it is a fixed or variable address, and does
optimizations based on this determination (the "struct/varying" test,
a struct at a variable address can not alias a scalar at a fixed
address).  CSE can change a variable address to a fixed address,
causing the alias check to falsely report that aliasing is not
possible.

This is a bug and I posted a test case; due to the lack of bug reports
from real code the egcs project leader wanted the optimization retained.

2. The stdarg/varargs implementation plays type games which are not
permitted by ANSI C (stdarg can't be implemented in conforming ANSI C).

The stdarg code was changed to work around this problem.  These
changes are fragile and depend on the precise implementation of the
alias code.  It is possible that more bugs remain.

3. Register spills lose the struct flag of the original memory
reference and so can confuse the struct/varying optimization.

I prototyped but did not finish a change to set the MEM_IN_STRUCT_P
flag properly for spills.

I don't know if this is still a bug.

4. ANSI C generally prohibits storing one type and reading a different
type from the same location.  The mode test I put in to take advantage
of this rule was incorrect for two reasons.

4a. gcc internally changes conforming ANSI C code to rtl which
represents a non-conforming program, for example converting a 32 bit
load followed by a 16->32 bit sign extend to a 16 bit load.  ANSI C
does not define the result of

	*(short *)&integer

but gcc interally assumes a meaning for that expression.


4b. I wrote code to account for the ANSI-undefined cases which are
generated internally by gcc, but there is a gcc extension which says,
in effect, that any type can alias any other type.  On learning this I
gave up.

The only mode tests remaining are the original ones: QImode (char) and
BLKmode memory references can alias even if the struct/varying test
would say otherwise.



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