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: Forced alignment of arrays


On 5/5/07, Mark Shinwell <shinwell@codesourcery.com> wrote:
I'd like to test the water on the patch below, which was developed
internally against a 4.2-based branch.  It introduces a new flag that
forces the minimum alignment of array variables to be the largest power
of two less than or equal to their total storage size, or the biggest
alignment used on the machine, whichever is smaller.

This patch was developed in response to a request from a customer who
has a large body of code using type punning in non-strictly-conforming
(in the sense of the C standard) ways such as this:

        char foo[4];
        *(int *) foo = 42;

Use of the new -falign-arrays option clearly does not guarantee that
all code using dubious type punning will work; it just provides
alignment guarantees about the start of arrays.

Note that this patch requires that callers of DATA_ALIGNMENT and
LOCAL_ALIGNMENT now go via calculate_data_alignment and
calculate_local_alignment respectively rather than using the macros
directly.

Is the consensus that this patch, suitably tested on mainline, is
acceptable -- or not?

I don't think we want such a thing. People will use it for things it was not designed for (like forcing alignment for vectorizing, trying to force alignment on stack locals, etc.).

Richard.


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