This is the mail archive of the gcc-bugs@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]

[Bug middle-end/88085] User alignments on var decls not respected if smaller than type alignment


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88085

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
ISTR you have to use packed to decrease alignment.  OTOH

  /* We can set the alignment from the type if we are making an object or if
     this is an INDIRECT_REF.  */
  if (objectp || TREE_CODE (t) == INDIRECT_REF)
    attrs.align = MAX (attrs.align, TYPE_ALIGN (type));

is fishy but so is the preceeding

  /* Otherwise, default values from the mode of the MEM reference.  */
  else
    {
...
      /* Respect mode alignment for STRICT_ALIGNMENT targets if T is a type;
         if T is an object, always compute the object alignment below.  */
      if (TYPE_P (t))
        attrs.align = defattrs->align;
      else
        attrs.align = BITS_PER_UNIT;

IMHO alignment setting should be left to the callers and it should be
conservative here (the objectp == true case can probably be preserved).

Note we already set the alignment later in a correct way if ! TYPE_P
but likewise using

      attrs.align = MAX (attrs.align, obj_align);

which is bogus again unless the caller already had pre-existing attrs
on the MEM.  I guess using

      attrs.align = refattrs ? MAX (refattrs.align, obj_align) : obj_align;

fixes your issue?  Or are you objectp == true?  I think an INDIRECT_REF never
happens today.

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