This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: PATCH to layout_decl for middle-end/27945


> I think a simpler change would be to just select between
>
>          DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT);
>
> and
>
>          if (known_align)
>            DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), known_align);
>
> for packing, based on a langhook.

I've changed my mind about this stuff and now think that the alignment 
promotion is best done in the Ada front-end, more precisely Gigi.

However a change is still needed in layout_decl, something like:


        * stor-layout.c (layout_decl): Do not bump the alignment of a
        bit-field to more than byte alignment if it is packed.


-- 
Eric Botcazou
Index: stor-layout.c
===================================================================
--- stor-layout.c	(revision 132377)
+++ stor-layout.c	(working copy)
@@ -388,13 +388,13 @@ layout_decl (tree decl, unsigned int kno
 	    {
 	      enum machine_mode xmode
 		= mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
+	      unsigned int xalign = GET_MODE_ALIGNMENT (xmode);
 
 	      if (xmode != BLKmode
-		  && (known_align == 0
-		      || known_align >= GET_MODE_ALIGNMENT (xmode)))
+		  && !(xalign > BITS_PER_UNIT && DECL_PACKED (decl))
+		  && (known_align == 0 || known_align >= xalign))
 		{
-		  DECL_ALIGN (decl) = MAX (GET_MODE_ALIGNMENT (xmode),
-					   DECL_ALIGN (decl));
+		  DECL_ALIGN (decl) = MAX (xalign, DECL_ALIGN (decl));
 		  DECL_MODE (decl) = xmode;
 		  DECL_BIT_FIELD (decl) = 0;
 		}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]