gcc/ChangeLog

        * cfgexpand.c (align_local_variable): Check DECL_USER_ALIGN.
---
 gcc/cfgexpand.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index a7ec77d5c85..19a020b4b97 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -369,13 +369,19 @@ align_local_variable (tree decl, bool really_expand)
     align = TYPE_ALIGN (TREE_TYPE (decl));
   else
     {
-      align = LOCAL_DECL_ALIGNMENT (decl);
-      /* Don't change DECL_ALIGN when called from estimated_stack_frame_size.
-        That is done before IPA and could bump alignment based on host
-        backend even for offloaded code which wants different
-        LOCAL_DECL_ALIGNMENT.  */
-      if (really_expand)
-       SET_DECL_ALIGN (decl, align);
+      if (DECL_USER_ALIGN (decl))
+       align = DECL_ALIGN (decl);
+      else
+       {
+         align = LOCAL_DECL_ALIGNMENT (decl);
+         /* Don't change DECL_ALIGN when called from
+            estimated_stack_frame_size.
+            That is done before IPA and could bump alignment based on host
+            backend even for offloaded code which wants different
+            LOCAL_DECL_ALIGNMENT.  */
+         if (really_expand)
+           SET_DECL_ALIGN (decl, align);
+       }
     }
   return align / BITS_PER_UNIT;
 }
-- 
2.25.2

Reply via email to