@@ -1,4 +1,4 @@
-From bd36042fd82e29204d2f10c180b9e7c27281eef2 Mon Sep 17 00:00:00 2001
+From faae30210f584bba92ab96aac479ae8f253e59b7 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Fri, 28 Oct 2016 12:59:55 +0100
Subject: [PATCH 1/2] PR77359: Properly align local variables in functions
@@ -7,16 +7,16 @@
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77359 for a discussion of the
problem and the fix.
---
- gcc/config/rs6000/aix.h | 27 +++++++++++++++++++++++++++
+ gcc/config/rs6000/aix.h | 35 +++++++++++++++++++++++++++++++++++
gcc/config/rs6000/rs6000.c | 9 +++++++--
- gcc/config/rs6000/rs6000.h | 14 ++++++++------
- 3 files changed, 42 insertions(+), 8 deletions(-)
+ gcc/config/rs6000/rs6000.h | 26 ++++++++++++++++++--------
+ 3 files changed, 60 insertions(+), 10 deletions(-)
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
-index b254236..7773517 100644
+index b254236..f6eb122 100644
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
-@@ -40,6 +40,33 @@
+@@ -40,6 +40,41 @@
#undef STACK_BOUNDARY
#define STACK_BOUNDARY 128
@@ -27,7 +27,12 @@
+
+ On the RS/6000, the frame pointer is the same as the stack pointer,
+ except for dynamic allocations. So we start after the fixed area and
-+ outgoing parameter area. */
++ outgoing parameter area.
++
++ If the function uses dynamic stack space (CALLS_ALLOCA is set), that
++ space needs to be aligned to STACK_BOUNDARY, i.e. the sum of the
++ sizes of the fixed area and the parameter area must be a multiple of
++ STACK_BOUNDARY. */
+
+#undef STARTING_FRAME_OFFSET
+#define STARTING_FRAME_OFFSET \
@@ -42,10 +47,13 @@
+
+ The default value for this macro is `STACK_POINTER_OFFSET' plus the
+ length of the outgoing arguments. The default is correct for most
-+ machines. See `function.c' for details. */
++ machines. See `function.c' for details.
++
++ This value must be a multiple of STACK_BOUNDARY (hard coded in
++ `emit-rtl.c'). */
+#undef STACK_DYNAMIC_OFFSET
+#define STACK_DYNAMIC_OFFSET(FUNDECL) \
-+ RS6000_ALIGN (crtl->outgoing_args_size + (STACK_POINTER_OFFSET), 16)
++ RS6000_ALIGN (crtl->outgoing_args_size + STACK_POINTER_OFFSET, 16)
+
#undef TARGET_IEEEQUAD
#define TARGET_IEEEQUAD 0
@@ -71,10 +79,21 @@
info->vars_size
+= RS6000_ALIGN (info->fixed_size + info->vars_size + info->parm_size,
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
-index 4b83abd..c11dc1b 100644
+index 4b83abd..afda416 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
-@@ -1728,9 +1728,12 @@ extern enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
+@@ -1723,25 +1723,35 @@ extern enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
+
+ On the RS/6000, the frame pointer is the same as the stack pointer,
+ except for dynamic allocations. So we start after the fixed area and
+- outgoing parameter area. */
++ outgoing parameter area.
++
++ If the function uses dynamic stack space (CALLS_ALLOCA is set), that
++ space needs to be aligned to STACK_BOUNDARY, i.e. the sum of the
++ sizes of the fixed area and the parameter area must be a multiple of
++ STACK_BOUNDARY. */
+
#define STARTING_FRAME_OFFSET \
(FRAME_GROWS_DOWNWARD \
? 0 \
@@ -90,14 +109,19 @@
/* Offset from the stack pointer register to an item dynamically
allocated on the stack, e.g., by `alloca'.
-@@ -1739,9 +1742,8 @@ extern enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
+
+ The default value for this macro is `STACK_POINTER_OFFSET' plus the
length of the outgoing arguments. The default is correct for most
- machines. See `function.c' for details. */
+- machines. See `function.c' for details. */
++ machines. See `function.c' for details.
++
++ This value must be a multiple of STACK_BOUNDARY (hard coded in
++ `emit-rtl.c'). */
#define STACK_DYNAMIC_OFFSET(FUNDECL) \
- (RS6000_ALIGN (crtl->outgoing_args_size, \
- (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8) \
- + (STACK_POINTER_OFFSET))
-+ RS6000_ALIGN (crtl->outgoing_args_size + (STACK_POINTER_OFFSET), \
++ RS6000_ALIGN (crtl->outgoing_args_size + STACK_POINTER_OFFSET, \
+ (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8)
/* If we generate an insn to push BYTES bytes,