------- Comment #34 from mikulas at artax dot karlin dot mff dot cuni dot cz  
2009-09-13 14:07 -------
So I posted these two examples that show that the patch is insufficient:

1) if the array is embedded in a structure and that structure is on the stack,
the stack is not aligned. (if the array were out of structure, it would be)

2) gcc sometimes spills xmm registers over function calls (spilling zero this
way is suboptimal, but that's only a performance issue) and the stack is not
aligned in this case.

Note, in align-counterexample2.c, there is another bug! Gcc shouldn't assume
that arrays "x" and "y" are 16-byte aligned. Arrays "x" and "y" are in common
section, that means that they can be declared in any other module and the
linker joins these declarations. So, for example, if in another module someone
declared int x[100] = { 1, 2, 3, 4 } and the module were compiled with
different compiler that doesn't align the array (the ABI allows it) , the
linker is forced to use the declaration with the initialization and the array
would be misaligned.

We can only assume alignment on the variables that are not in common section,
i.e. with -fno-common or explicitly initialized.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838

Reply via email to