aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRamana Radhakrishnan <ramana.radhakrishnan@arm.com>2017-06-28 22:09:50 +0000
committerRamana Radhakrishnan <ramana@gcc.gnu.org>2017-06-28 22:09:50 +0000
commit9850348784435131aa3d78feab4c93dd34481dde (patch)
treec91935c2c3cdffd5f92f33b925a84e7a8e2bba5d /gcc
parentcffc4a68d759fdca588cdf9ece998862b76141e6 (diff)
downloadgcc-9850348784435131aa3d78feab4c93dd34481dde.zip
gcc-9850348784435131aa3d78feab4c93dd34481dde.tar.gz
gcc-9850348784435131aa3d78feab4c93dd34481dde.tar.bz2
[AArch64] Do not increase data alignment at -Os and with -fconserve-stack.
We unnecessarily align data to 8 byte alignments even when -Os is specified. This brings the logic in the AArch64 backend more in line with the ARM backend and helps gain some image size in a few places. Caught by an internal report on the size of rodata sections being high with aarch64 gcc. * config/aarch64/aarch64.h (AARCH64_EXPAND_ALIGNMENT): New. (DATA_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT. (LOCAL_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT. Bootstrapped and regression tested on aarch64-none-linux-gnu with no regressions. From-SVN: r249764
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/aarch64/aarch64.h26
2 files changed, 24 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c752375..5211806 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-28 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
+
+ * config/aarch64/aarch64.h (AARCH64_EXPAND_ALIGNMENT): New.
+ (DATA_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
+ (LOCAL_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
+
2017-06-28 Sebastian Peryt <sebastian.peryt@intel.com>
* config/i386/avx512vlintrin.h (_mm256_permutexvar_epi64)
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 3b3f27e..106cf3a 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -98,14 +98,24 @@
&& (ALIGN) < BITS_PER_WORD) \
? BITS_PER_WORD : ALIGN)
-#define DATA_ALIGNMENT(EXP, ALIGN) \
- ((((ALIGN) < BITS_PER_WORD) \
- && (TREE_CODE (EXP) == ARRAY_TYPE \
- || TREE_CODE (EXP) == UNION_TYPE \
- || TREE_CODE (EXP) == RECORD_TYPE)) \
- ? BITS_PER_WORD : (ALIGN))
-
-#define LOCAL_ALIGNMENT(EXP, ALIGN) DATA_ALIGNMENT(EXP, ALIGN)
+/* Align definitions of arrays, unions and structures so that
+ initializations and copies can be made more efficient. This is not
+ ABI-changing, so it only affects places where we can see the
+ definition. Increasing the alignment tends to introduce padding,
+ so don't do this when optimizing for size/conserving stack space. */
+#define AARCH64_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) \
+ AARCH64_EXPAND_ALIGNMENT (!optimize_size, EXP, ALIGN)
+
+/* Similarly, make sure that objects on the stack are sensibly aligned. */
+#define LOCAL_ALIGNMENT(EXP, ALIGN) \
+ AARCH64_EXPAND_ALIGNMENT (!flag_conserve_stack, EXP, ALIGN)
#define STRUCTURE_SIZE_BOUNDARY 8