]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
xtensa: align data naturally when optimizing for size
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 23 Feb 2015 23:35:31 +0000 (23:35 +0000)
committerMax Filippov <jcmvbkbc@gcc.gnu.org>
Mon, 23 Feb 2015 23:35:31 +0000 (23:35 +0000)
gcc for xtensa always aligns data at least to a word boundary, even when
it has smaller natural alignment. This results in unexpectedly high data
section sizes and unreasonable amount of wasted space when linking
objects compiled with -fdata-sections flag.

Align data naturally when optimization for size is enabled.

2015-02-22  Max Filippov  <jcmvbkbc@gmail.com>

gcc/
* config/xtensa/xtensa.h (CONSTANT_ALIGNMENT, DATA_ALIGNMENT):
use natural alignment when optimizing for size.

From-SVN: r220923

gcc/ChangeLog
gcc/config/xtensa/xtensa.h

index 843716d5b4dffcd052fa5efb67326814395cae95..02e60b77dc209736e587ed456cabfd04a68e70d6 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-22  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * config/xtensa/xtensa.h (CONSTANT_ALIGNMENT, DATA_ALIGNMENT):
+       use natural alignment when optimizing for size.
+
 2015-02-23  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        PR target/65153
index 0de072b16c39493593d94fc45086863aac9a0f14..74ca240b4e6e78ea941fd460ad9399877643d438 100644 (file)
@@ -174,7 +174,8 @@ extern unsigned xtensa_current_frame_size;
    constants to be word aligned so that 'strcpy' calls that copy
    constants can be done inline.  */
 #define CONSTANT_ALIGNMENT(EXP, ALIGN)                                 \
-  ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR)   \
+  (!optimize_size &&                                                   \
+   (TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR)   \
    && (ALIGN) < BITS_PER_WORD                                          \
        ? BITS_PER_WORD                                                 \
        : (ALIGN))
@@ -186,7 +187,7 @@ extern unsigned xtensa_current_frame_size;
    that copy constants to character arrays can be done inline.  */
 #undef DATA_ALIGNMENT
 #define DATA_ALIGNMENT(TYPE, ALIGN)                                    \
-  ((((ALIGN) < BITS_PER_WORD)                                          \
+  (!optimize_size && (((ALIGN) < BITS_PER_WORD)                                \
     && (TREE_CODE (TYPE) == ARRAY_TYPE                                 \
        || TREE_CODE (TYPE) == UNION_TYPE                               \
        || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))