| Submitter | Chung-Lin Tang |
|---|---|
| Date | Sept. 29, 2010, 5:21 p.m. |
| Message ID | <4CA3759B.3080208@codesourcery.com> |
| Download | mbox | patch |
| Permalink | /patch/66080/ |
| State | New |
| Headers | show |
Comments
Ping. Chung-Lin Tang wrote: > Hi, > this patch adds guard conditions to the DATA/LOCAL_ALIGNMENT macros, to > turn off the BITS_PER_WORD enlarging of data alignment when optimizing > for size/conserving stack space. > > This corresponds to Linaro bug #640544 > https://bugs.launchpad.net/gcc-linaro/+bug/640544 > > Okay for trunk? > > Thanks, > Chung-Lin > > * config/arm/arm.h (ARM_EXPAND_ALIGNMENT): Rename from > DATA_ALIGNMENT and add COND parameter. > (DATA_ALIGNMENT): Use ARM_EXPAND_ALIGNMENT, with !optimize_size. > (LOCAL_ALIGNMENT): Use ARM_EXPAND_ALIGNMENT, with > !flag_conserve_stack.
> * config/arm/arm.h (ARM_EXPAND_ALIGNMENT): Rename from > DATA_ALIGNMENT and add COND parameter. > (DATA_ALIGNMENT): Use ARM_EXPAND_ALIGNMENT, with !optimize_size. > (LOCAL_ALIGNMENT): Use ARM_EXPAND_ALIGNMENT, with > !flag_conserve_stack. ... > initializations and copies can be made more efficient. This is not > ABI-changing, so it only affects places where we can see the > definition. */ I think this comment needs updating. i.e. increasing the alignment tends to introduce padding, so don't do this when optimizing for size. Other than that, ok. In theory we could try and be smarter. e.g. still align multiple-of-4 sized objects, treating readonly/initialized data differently (i.e. where it doesn't effect runtime init code). In practice I doubt it's worth the hassle, and you still won't please everyone. Paul
Patch
Index: arm.h =================================================================== --- arm.h (revision 300183) +++ arm.h (working copy) @@ -635,14 +635,19 @@ initializations and copies can be made more efficient. This is not ABI-changing, so it only affects places where we can see the definition. */ -#define DATA_ALIGNMENT(EXP, ALIGN) \ - ((((ALIGN) < BITS_PER_WORD) \ +#define ARM_EXPAND_ALIGNMENT(COND, EXP, ALIGN) \ + (((COND) && ((ALIGN) < BITS_PER_WORD) \ && (TREE_CODE (EXP) == ARRAY_TYPE \ || TREE_CODE (EXP) == UNION_TYPE \ || TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN)) +/* Align global data. */ +#define DATA_ALIGNMENT(EXP, ALIGN) \ + ARM_EXPAND_ALIGNMENT(!optimize_size, EXP, ALIGN) + /* Similarly, make sure that objects on the stack are sensibly aligned. */ -#define LOCAL_ALIGNMENT(EXP, ALIGN) DATA_ALIGNMENT(EXP, ALIGN) +#define LOCAL_ALIGNMENT(EXP, ALIGN) \ + ARM_EXPAND_ALIGNMENT(!flag_conserve_stack, EXP, ALIGN) /* Setting STRUCTURE_SIZE_BOUNDARY to 32 produces more efficient code, but the value set in previous versions of this toolchain was 8, which produces more
Hi, this patch adds guard conditions to the DATA/LOCAL_ALIGNMENT macros, to turn off the BITS_PER_WORD enlarging of data alignment when optimizing for size/conserving stack space. This corresponds to Linaro bug #640544 https://bugs.launchpad.net/gcc-linaro/+bug/640544 Okay for trunk? Thanks, Chung-Lin * config/arm/arm.h (ARM_EXPAND_ALIGNMENT): Rename from DATA_ALIGNMENT and add COND parameter. (DATA_ALIGNMENT): Use ARM_EXPAND_ALIGNMENT, with !optimize_size. (LOCAL_ALIGNMENT): Use ARM_EXPAND_ALIGNMENT, with !flag_conserve_stack.